14 use PHPUnit\Framework\TestCase;
32 protected $array = array();
34 protected function setUp()
38 $this->array = array(
'notice' => array(
'A previous flash message'));
39 $this->bag->initialize($this->array);
51 $bag->initialize($this->array);
52 $this->assertEquals($this->array, $bag->peekAll());
53 $array = array(
'should' => array(
'change'));
55 $this->assertEquals(
$array, $bag->peekAll());
60 $this->assertEquals(
'_sf2_flashes', $this->bag->getStorageKey());
61 $attributeBag =
new FlashBag(
'test');
62 $this->assertEquals(
'test', $attributeBag->getStorageKey());
67 $this->assertEquals(
'flashes', $this->bag->getName());
68 $this->bag->setName(
'foo');
69 $this->assertEquals(
'foo', $this->bag->getName());
74 $this->assertEquals(array(), $this->bag->peek(
'non_existing'));
75 $this->assertEquals(array(
'default'), $this->bag->peek(
'not_existing', array(
'default')));
76 $this->assertEquals(array(
'A previous flash message'), $this->bag->peek(
'notice'));
77 $this->assertEquals(array(
'A previous flash message'), $this->bag->peek(
'notice'));
82 $this->assertEquals(array(), $this->bag->get(
'non_existing'));
83 $this->assertEquals(array(
'default'), $this->bag->get(
'not_existing', array(
'default')));
84 $this->assertEquals(array(
'A previous flash message'), $this->bag->get(
'notice'));
85 $this->assertEquals(array(), $this->bag->get(
'notice'));
90 $this->bag->set(
'notice',
'Foo');
91 $this->bag->set(
'error',
'Bar');
92 $this->assertEquals(array(
93 'notice' => array(
'Foo'),
94 'error' => array(
'Bar'), ), $this->bag->all()
97 $this->assertEquals(array(), $this->bag->all());
102 $this->bag->set(
'notice',
'Foo');
103 $this->bag->set(
'notice',
'Bar');
104 $this->assertEquals(array(
'Bar'), $this->bag->peek(
'notice'));
109 $this->assertFalse($this->bag->has(
'nothing'));
110 $this->assertTrue($this->bag->has(
'notice'));
115 $this->assertEquals(array(
'notice'), $this->bag->keys());
120 $this->bag->set(
'notice',
'Foo');
121 $this->bag->set(
'error',
'Bar');
122 $this->assertEquals(array(
123 'notice' => array(
'Foo'),
124 'error' => array(
'Bar'),
125 ), $this->bag->peekAll()
127 $this->assertTrue($this->bag->has(
'notice'));
128 $this->assertTrue($this->bag->has(
'error'));
129 $this->assertEquals(array(
130 'notice' => array(
'Foo'),
131 'error' => array(
'Bar'),
132 ), $this->bag->peekAll()