/** * 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())); }
/** * Tests the NullHandler implementation, always returns itself, can't really be tested that it does nothing */ public function testPersistNullHandler() { $profile = Profile::create(); $persistenceHandler = $this->persistenceHandler->persist($profile); $this->assertSame($this->persistenceHandler, $persistenceHandler); }
public function testRetrieveObject() { $profile = Profile::create(); $resultInterface = new \ArrayIterator(array(array('identifier' => $profile->getIdentifier(), 'data' => serialize($profile->toArray())))); $this->statement->shouldReceive('execute')->once()->andReturn($resultInterface); $unserializedProfile = $this->handler->retrieve('foo'); $this->assertInstanceOf('Link0\\Profiler\\Profile', $unserializedProfile); $this->assertEquals($profile->getIdentifier(), $unserializedProfile->getIdentifier()); }
/** * @expectedException \Link0\Profiler\PersistenceHandler\Exception * @expectedExceptionMessage Unable to persist Profile[identifier=foo] */ public function testUnableToPersist() { $this->filesystem->shouldReceive('put')->andReturn(false); $profile = Profile::create('foo'); $this->persistenceHandler->persist($profile); }
public function testPersistWithRoundMicrotime() { $profile = Profile::create(); $profile->setServerData(array('REQUEST_TIME_FLOAT' => 1234)); $this->handler->persist($profile); }