14 use PHPUnit\Framework\TestCase;
32 protected $array = array();
34 protected function setUp()
38 $this->array = array(
'new' => array(
'notice' => array(
'A previous flash message')));
39 $this->bag->initialize($this->array);
51 $array = array(
'new' => array(
'notice' => array(
'A previous flash message')));
53 $this->assertEquals(array(
'A previous flash message'), $bag->peek(
'notice'));
55 'notice' => array(
'Something else'),
56 'error' => array(
'a'),
59 $this->assertEquals(array(
'Something else'), $bag->peek(
'notice'));
60 $this->assertEquals(array(
'a'), $bag->peek(
'error'));
65 $this->assertEquals(
'_sf2_flashes', $this->bag->getStorageKey());
66 $attributeBag =
new FlashBag(
'test');
67 $this->assertEquals(
'test', $attributeBag->getStorageKey());
72 $this->assertEquals(
'flashes', $this->bag->getName());
73 $this->bag->setName(
'foo');
74 $this->assertEquals(
'foo', $this->bag->getName());
79 $this->assertEquals(array(), $this->bag->peek(
'non_existing'));
80 $this->assertEquals(array(
'default'), $this->bag->peek(
'non_existing', array(
'default')));
81 $this->assertEquals(array(
'A previous flash message'), $this->bag->peek(
'notice'));
82 $this->assertEquals(array(
'A previous flash message'), $this->bag->peek(
'notice'));
87 $this->bag->set(
'notice',
'Foo');
88 $this->assertEquals(array(
'A previous flash message'), $this->bag->peek(
'notice'));
93 $this->assertFalse($this->bag->has(
'nothing'));
94 $this->assertTrue($this->bag->has(
'notice'));
99 $this->assertEquals(array(
'notice'), $this->bag->keys());
111 $this->bag->initialize(
$array);
112 $this->assertEquals(array(
115 ), $this->bag->peekAll()
118 $this->assertEquals(array(
121 ), $this->bag->peekAll()
127 $this->assertEquals(array(), $this->bag->get(
'non_existing'));
128 $this->assertEquals(array(
'default'), $this->bag->get(
'non_existing', array(
'default')));
129 $this->assertEquals(array(
'A previous flash message'), $this->bag->get(
'notice'));
130 $this->assertEquals(array(), $this->bag->get(
'notice'));
135 $this->bag->setAll(array(
'a' =>
'first',
'b' =>
'second'));
136 $this->assertFalse($this->bag->has(
'a'));
137 $this->assertFalse($this->bag->has(
'b'));
142 $this->bag->set(
'notice',
'Foo');
143 $this->bag->set(
'error',
'Bar');
144 $this->assertEquals(array(
145 'notice' => array(
'A previous flash message'),
149 $this->assertEquals(array(), $this->bag->all());
154 $this->assertEquals(array(
'notice' => array(
'A previous flash message')), $this->bag->clear());