public function testPersistAndRetrievePrimary() { $persistenceHandler = new PersistenceHandler\MemoryHandler(); $persistenceHandler->setProfileFactory(new ProfileFactory()); $profile = $persistenceHandler->getProfileFactory()->create(); $this->persistenceService->addPersistenceHandler($persistenceHandler); $this->persistenceService->persist($profile); $this->assertEquals($profile, $this->persistenceService->retrieve($profile->getIdentifier())); }
/** * Tests the MemoryHandler implementation */ public function testStorageAndRetrieval() { // Create an empty profile with self-generated identifier $profile = Profile::create(); $this->assertEmpty($this->persistenceHandler->getList()); // Default identifier is not yet persisted, assert null $this->assertNull($this->persistenceHandler->retrieve($profile->getIdentifier())); // Persist the profile $self = $this->persistenceHandler->persist($profile); $this->assertSame($self, $this->persistenceHandler); $this->assertEquals(1, sizeof($this->persistenceHandler->getList())); $this->assertSame($profile->getIdentifier(), $this->persistenceHandler->getList()[0]); // Assert retrieval back again $this->assertEquals($profile, $this->persistenceHandler->retrieve($profile->getIdentifier())); }