* * 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\AutoExpireFlashBag as FlashBag; /** * AutoExpireFlashBagTest. * * @author Drak */ class AutoExpireFlashBagTest extends TestCase { /** * @var \Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag */ private $bag; protected $array = array(); protected function setUp() { parent::setUp(); $this->bag = new FlashBag(); $this->array = array('new' => 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(); $array = array('new' => array('notice' => array('A previous flash message'))); $bag->initialize($array); $this->assertEquals(array('A previous flash message'), $bag->peek('notice')); $array = array('new' => array( 'notice' => array('Something else'), 'error' => array('a'), )); $bag->initialize($array); $this->assertEquals(array('Something else'), $bag->peek('notice')); $this->assertEquals(array('a'), $bag->peek('error')); } 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('non_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 testSet() { $this->bag->set('notice', 'Foo'); $this->assertEquals(array('A previous flash message'), $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() { $array = array( 'new' => array( 'notice' => 'Foo', 'error' => 'Bar', ), ); $this->bag->initialize($array); $this->assertEquals(array( 'notice' => 'Foo', 'error' => 'Bar', ), $this->bag->peekAll() ); $this->assertEquals(array( 'notice' => 'Foo', 'error' => 'Bar', ), $this->bag->peekAll() ); } public function testGet() { $this->assertEquals(array(), $this->bag->get('non_existing')); $this->assertEquals(array('default'), $this->bag->get('non_existing', array('default'))); $this->assertEquals(array('A previous flash message'), $this->bag->get('notice')); $this->assertEquals(array(), $this->bag->get('notice')); } public function testSetAll() { $this->bag->setAll(array('a' => 'first', 'b' => 'second')); $this->assertFalse($this->bag->has('a')); $this->assertFalse($this->bag->has('b')); } public function testAll() { $this->bag->set('notice', 'Foo'); $this->bag->set('error', 'Bar'); $this->assertEquals(array( 'notice' => array('A previous flash message'), ), $this->bag->all() ); $this->assertEquals(array(), $this->bag->all()); } public function testClear() { $this->assertEquals(array('notice' => array('A previous flash message')), $this->bag->clear()); } public function testDoNotRemoveTheNewFlashesWhenDisplayingTheExistingOnes() { $this->bag->add('success', 'Something'); $this->bag->all(); $this->assertEquals(array('new' => array('success' => array('Something')), 'display' => array()), $this->array); } } __halt_compiler();----SIGNATURE:----pri7ioX0EGUYAmY8gDD57u4/clHC7H9lYO3PmV8trDopyKZ8rhBKeisHCVQtKnouIzhTeNKmKNVQBQSUMnWfWRiPyGXL0dTVqzQlp1UlS4VmxE073RPcRM/O5jkyjhCw8QKox70FjmY7ZUH6Gh01GAf/sno7Fgjv+kqsNmKaawhZvOV6IoN5OniEiFYLs1PmnTuEHd978ldn/8UL4whMBEZZDuXB3ohlRUurX0mb2+ptzPtxqWRHyJTxnALKD0rIcm0Em1xPzsBdBTPkB18EQt6+RkP3yRS6YO0LofY9OaWh9KW4TAOwTR4KFlUcew4NRnIuG1JZ9nUHFw0M7WHTqI8CJb8wEIm98uswB+P9d3AXFN6u8SZ/3JZTXAiu+QE0/9MzSR3sRiL+ehinEYPrHzjqk37FDTM3whI468xgHJiNyICxmGq0jinL2HAvZGP+47n4VvtSpZLvvK2m7lYy3hGBUqAYJucdp31d67Vx48CjbIxduTPCASvUhxyG/s2jxoPAYx91MxfJp8s8oj+tzbaYZOZAh4LCI1Q9CD3RUfB2DqvFJziUFAutkRtJD2prCBeFqO+myLTw+aaLH9C80f4e/paRhYCFck0BMpg7TYmyQYsVeTJnJcyzyK1VHb66u80rGUNv+khIcuEjADUbb0oZqaLvXyY7Sq1XKe4eyxU=----ATTACHMENT:----MTQ1ODYxODYyNTcwNjQwIDEyNjYxNjAxNzQ1NjUxMzMgNDQ2MTc4NDgyNjIxNDQ2NQ==