* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation\Tests\Session\Storage; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\HttpFoundation\Session\Attribute\AttributeBag; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; /** * Test class for MockArraySessionStorage. * * @author Drak */ class MockArraySessionStorageTest extends TestCase { /** * @var MockArraySessionStorage */ private $storage; /** * @var AttributeBag */ private $attributes; /** * @var FlashBag */ private $flashes; private $data; protected function setUp() { $this->attributes = new AttributeBag(); $this->flashes = new FlashBag(); $this->data = array( $this->attributes->getStorageKey() => array('foo' => 'bar'), $this->flashes->getStorageKey() => array('notice' => 'hello'), ); $this->storage = new MockArraySessionStorage(); $this->storage->registerBag($this->flashes); $this->storage->registerBag($this->attributes); $this->storage->setSessionData($this->data); } protected function tearDown() { $this->data = null; $this->flashes = null; $this->attributes = null; $this->storage = null; } public function testStart() { $this->assertEquals('', $this->storage->getId()); $this->storage->start(); $id = $this->storage->getId(); $this->assertNotEquals('', $id); $this->storage->start(); $this->assertEquals($id, $this->storage->getId()); } public function testRegenerate() { $this->storage->start(); $id = $this->storage->getId(); $this->storage->regenerate(); $this->assertNotEquals($id, $this->storage->getId()); $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); $id = $this->storage->getId(); $this->storage->regenerate(true); $this->assertNotEquals($id, $this->storage->getId()); $this->assertEquals(array('foo' => 'bar'), $this->storage->getBag('attributes')->all()); $this->assertEquals(array('notice' => 'hello'), $this->storage->getBag('flashes')->peekAll()); } public function testGetId() { $this->assertEquals('', $this->storage->getId()); $this->storage->start(); $this->assertNotEquals('', $this->storage->getId()); } public function testClearClearsBags() { $this->storage->clear(); $this->assertSame(array(), $this->storage->getBag('attributes')->all()); $this->assertSame(array(), $this->storage->getBag('flashes')->peekAll()); } public function testClearStartsSession() { $this->storage->clear(); $this->assertTrue($this->storage->isStarted()); } public function testClearWithNoBagsStartsSession() { $storage = new MockArraySessionStorage(); $storage->clear(); $this->assertTrue($storage->isStarted()); } /** * @expectedException \RuntimeException */ public function testUnstartedSave() { $this->storage->save(); } } __halt_compiler();----SIGNATURE:----UAabe71obepVjay/uTlBQ4nx8bPk31qg0uKR3CedF953YQ5nBK3SaWG7SAlj65fl7ZOl3pgYXKty9zYdMX1Foz+6h0ncpoI+QkbZ2N0+F/O8iP9H4j+RHQYkJeIJuYit+E2Z5V0i/BXa08QFSzOTJNhmBKzQeM3Pg2TshZjnELxcOhMxXBdJDHcSnus7mjgYicWEtOU9y9aBV88B9VIVulVDr6V7X5i3uPfb1nZGMQyEOE7AKiPo/Vy9fo7stB1cJvIF+rpiL4LW6dpsTczKpeDGYYYjR6ecCeIOlSX5vNFGofD4oTkilwaEhPQ7Uatri0+pR2kyYdvgfRRnyZ8lK2UnagXcpA2yxCAT1/NV/A5sffy1lT8A9Sz06JIAxR0+b8apluR0Azm0h+kCcbrx/mNSY1PV8Z3S//tbHFhRCiRc3gkWjPRSDJoTF+fd4v4U+Coshfyfah44pPNEhMWcw6F6hv4uUlNBnwoeEHHlA7hAI2GLxYuyxT54AaZWtSJ3YRNpeM/2YvO3tAk0n+/WEXv8n7eD77ci9jegJ0QczZaRzwRktP7FbTWJ2MG8OkEoaMkJi4wEgsaVAtr82nQNPS/2knE22tsJ/2fZ5JNxQm3QY5fkQUHxSUwdQoUUWH4R55Fv30ldcdfJkSvtxNWaF02izGLwlr0rSHU9dO/dygA=----ATTACHMENT:----MzQ1MTg4MjM1NTMxOTY0OCA2Nzg4NTIwMzM1MDI2MjgwIDYxODk3MTI4MzU4ODI1MzE=