function loadDataFromStore() { if (file_exists($this->filename)) { $str = file_get_contents($this->filename); $rm = unserialize($str); } else { $rm = RegistrationManager::getInstance(); } return $rm; }
public function testPersistence() { //1.Create test data $rm = RegistrationManager::getInstance(); $participant = new Participant("Frank"); $rm->addParticipant($participant); // 2. Write all of the data $this->pm->writeDataToStore($rm); //3.Clear the data from memory $rm->delete(); //4. Load it back in $rm = $this->pm->loadDataFromStore(); //5. Check that we got it back $this->assertEquals(1, count($rm->getParticipants())); $myParticipant = $rm->getParticipant_index(0); $this->assertEquals("Frank", $myParticipant->getName()); }