Upon entering the test chamber, turn to face the entrance and place a portal directly opposite the transport beam generator. Now look to the right of the room (by the platform leading to the exit) and set your second portal here.
Now stand by the chasm and wait for the beam to kick in and transport you across the pit. Now step out and look up for where the Cube dispenser is located. There’s an L-shaped wall panel to your left, so place the transport beam portal here and hit the button. The Cube will drop down into the beam, so once it’s resting up against the wall, look for the white square panel just up and to your right (it’ll be facing you). Get the transport beam coming through here and it’ll catch the Cube and bring it right over to you.
Once you’ve got the Cube, set it down for a moment and fire your portal at the wall to the left of the light blue circles on the wall. This’ll create a beam that’ll carry you across the width of the chasm. Pick the Cube back up and stand on the jump plate to get flung into the beam.
Once you’re at the ceiling you need to place the final beam portal on the single square tile just below you (see screenshot above). This’ll carry both you and the Cube over to the switch and the exit.