* * 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\Flash; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; /** * FlashBagTest. * * @author Drak */ class FlashBagTest extends TestCase { /** * @var \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface */ private $bag; protected $array = array(); protected function setUp() { parent::setUp(); $this->bag = new FlashBag(); $this->array = array('notice' => array('A previous flash message')); $this->bag->initialize($this->array); } protected function tearDown() { $this->bag = null; parent::tearDown(); } public function testInitialize() { $bag = new FlashBag(); $bag->initialize($this->array); $this->assertEquals($this->array, $bag->peekAll()); $array = array('should' => array('change')); $bag->initialize($array); $this->assertEquals($array, $bag->peekAll()); } public function testGetStorageKey() { $this->assertEquals('_symfony_flashes', $this->bag->getStorageKey()); $attributeBag = new FlashBag('test'); $this->assertEquals('test', $attributeBag->getStorageKey()); } public function testGetSetName() { $this->assertEquals('flashes', $this->bag->getName()); $this->bag->setName('foo'); $this->assertEquals('foo', $this->bag->getName()); } public function testPeek() { $this->assertEquals(array(), $this->bag->peek('non_existing')); $this->assertEquals(array('default'), $this->bag->peek('not_existing', array('default'))); $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); $this->assertEquals(array('A previous flash message'), $this->bag->peek('notice')); } public function testGet() { $this->assertEquals(array(), $this->bag->get('non_existing')); $this->assertEquals(array('default'), $this->bag->get('not_existing', array('default'))); $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); $this->assertEquals(array(), $this->bag->get('notice')); } public function testAll() { $this->bag->set('notice', 'Foo'); $this->bag->set('error', 'Bar'); $this->assertEquals(array( 'notice' => array('Foo'), 'error' => array('Bar'), ), $this->bag->all() ); $this->assertEquals(array(), $this->bag->all()); } public function testSet() { $this->bag->set('notice', 'Foo'); $this->bag->set('notice', 'Bar'); $this->assertEquals(array('Bar'), $this->bag->peek('notice')); } public function testHas() { $this->assertFalse($this->bag->has('nothing')); $this->assertTrue($this->bag->has('notice')); } public function testKeys() { $this->assertEquals(array('notice'), $this->bag->keys()); } public function testPeekAll() { $this->bag->set('notice', 'Foo'); $this->bag->set('error', 'Bar'); $this->assertEquals(array( 'notice' => array('Foo'), 'error' => array('Bar'), ), $this->bag->peekAll() ); $this->assertTrue($this->bag->has('notice')); $this->assertTrue($this->bag->has('error')); $this->assertEquals(array( 'notice' => array('Foo'), 'error' => array('Bar'), ), $this->bag->peekAll() ); } } __halt_compiler();----SIGNATURE:----DcyTB5xRm4GmT67pZtzhSalkDtQ9HhgpoLwWFNJnwTdpIkys3Of7HBScb6jfE9UvHLEZwapgbLLdI5CrQG0Gp6C/QMCV0xSeTDmyZLsYe42V4rOQovG1Jgi7ABWN34NezjKxbKYem62BwNlenCn7X4Jh/QtxA4UP7kSOz63tfVA3eNHTUZThGatxDcRDQwX9AflfY8zPRENo4Mftu+opvUwwL362c14WMRrg8Zi4DUv08OppVzNjpMm9prCx1l2ZDBTjBLZChtldHG0eAA8kCzWyGYHyCMtD1mxnNwhm5pMos3bvAh12L2GtCnTLddeS55bXmyhWu4WcrXsZeVbwyKYn+WUu4wVAbDTK8+zTM26eXjYUj7hxhAUjbJBiXGFQSU4B2Q0RfufhnQOSz3kySAeXJ2u3jLlS5TePAUtBQb/YYQFsX6DTQbfho9deIl21kYJUkbeO94xZpE9el92nxLUxcX2Vb8YZNVGd1qdgJ3mEkKm35izKQ/Z3atjWmtBaCwfRYEUTxHQd9lq13yYOv6nB6+cXJWecSZpWljiITa1dEtWuCbwoPHwt0eAJ/ZxVD6ktY9rmuv9WZyuN+A6c4erxH3+8LYQg4UqRUUWggF4fVOIPF1Brho4/cbhPirBpxJTvmWo1koQGvJWnY5CNlPRk2joI72xB8ZWk3tZrAhw=----ATTACHMENT:----MTUzMTc0NzgyNDc5OTI5MiA0NzMyNDQ4MDU3MDEwNzE1IDY1ODUwMTgzMjM1MjE5OTQ=