The Pharaoh was mummified and stored in a Sarcophagi inside and ancient Egyptian pyramid with his belongings so that he can safely journey to the Next World where they believed they would lead a new life.
Before the king would face his trials, he needs to "secure passage" in the form of a boat so that it can carry him down the river of the Underworld.
Once the Pharaoh set sail into the Underworld, he has to pass through the twelve gates of the Underworld. The twelve gates represent twelve hours of the night as the Pharaoh has twelve hours to be accepted into the afterlife.
When Egyptians are being mummified, all of their organs (except for the heart) are removed, mummified, and placed in canopic jars to be stored in the pyramid with the body and treasures. The heart remains in the body so that the weight of the heart can be compared to a feather during the journey to the Underworld. If it weighs more, than he/she cannot be accepted into the afterlife.
Osiris, god of the underworld, would make his final judgement as the very last step of the journey to the afterlife. Osiris ruled the heavenly kingdom where Egyptians wished to live after death. Many Egyptians believed that Osiris's kingdom was the perfect version of ancient Egypt.
The king would know if he passed the twelve gates of the Underworld as he went but he does not know if he passed the last test until dawn. If the sun rises at dawn, the Pharaoh knows he has been accepted, but if the sun Pharaoh fails the test, the sun will no longer appear and life as they knew it would be destroyed.