本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Storage\MetadataBag::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP MetadataBag::initialize方法的具体用法?PHP MetadataBag::initialize怎么用?PHP MetadataBag::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Session\Storage\MetadataBag
的用法示例。
在下文中一共展示了MetadataBag::initialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLifetime
public function testGetLifetime()
{
$bag = new MetadataBag();
$array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 1000);
$bag->initialize($array);
$this->assertEquals(1000, $bag->getLifetime());
}
示例2: setUp
protected function setUp()
{
parent::setUp();
$this->bag = new MetadataBag();
$this->array = array(MetadataBag::CREATED => 1234567, MetadataBag::UPDATED => 12345678, MetadataBag::LIFETIME => 0);
$this->bag->initialize($this->array);
}
示例3: testInitialize
public function testInitialize()
{
$p = new \ReflectionProperty('Symfony\\Component\\HttpFoundation\\Session\\Storage\\MetadataBag', 'meta');
$p->setAccessible(true);
$bag1 = new MetadataBag();
$array = array();
$bag1->initialize($array);
$this->assertGreaterThanOrEqual(time(), $bag1->getCreated());
$this->assertEquals($bag1->getCreated(), $bag1->getLastUsed());
sleep(1);
$bag2 = new MetadataBag();
$array2 = $p->getValue($bag1);
$bag2->initialize($array2);
$this->assertEquals($bag1->getCreated(), $bag2->getCreated());
$this->assertEquals($bag1->getLastUsed(), $bag2->getLastUsed());
$this->assertEquals($bag2->getCreated(), $bag2->getLastUsed());
sleep(1);
$bag3 = new MetadataBag();
$array3 = $p->getValue($bag2);
$bag3->initialize($array3);
$this->assertEquals($bag1->getCreated(), $bag3->getCreated());
$this->assertGreaterThan($bag2->getLastUsed(), $bag3->getLastUsed());
$this->assertNotEquals($bag3->getCreated(), $bag3->getLastUsed());
}
示例4: testDoesNotSkipLastUsedUpdate
public function testDoesNotSkipLastUsedUpdate()
{
$bag = new MetadataBag('', 30);
$timeStamp = time();
$created = $timeStamp - 45;
$sessionMetadata = array(MetadataBag::CREATED => $created, MetadataBag::UPDATED => $created, MetadataBag::LIFETIME => 1000);
$bag->initialize($sessionMetadata);
$this->assertEquals($timeStamp, $sessionMetadata[MetadataBag::UPDATED]);
}