Skip to content

Commit d6b6e05

Browse files
committed
Adding tests for FlashComponent::__call
Refs #5825
1 parent d7c9ad7 commit d6b6e05

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/TestCase/Controller/Component/FlashComponentTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,36 @@ public function testSetWithComponentConfiguration()
147147
$result = $this->Session->read('Flash.flash');
148148
$this->assertEquals($expected, $result);
149149
}
150+
151+
/**
152+
* Test magic call method.
153+
*
154+
* @covers \Cake\Controller\Component\FlashComponent::__call
155+
* @return void
156+
*/
157+
public function testCall()
158+
{
159+
$this->assertNull($this->Session->read('Flash.flash'));
160+
161+
$this->Flash->success('It worked');
162+
$expected = [
163+
'message' => 'It worked',
164+
'key' => 'flash',
165+
'element' => 'Flash/success',
166+
'params' => []
167+
];
168+
$result = $this->Session->read('Flash.flash');
169+
$this->assertEquals($expected, $result);
170+
171+
$this->Flash->error('It did not work', ['element' => 'error_thing']);
172+
173+
$expected = [
174+
'message' => 'It did not work',
175+
'key' => 'flash',
176+
'element' => 'Flash/error',
177+
'params' => []
178+
];
179+
$result = $this->Session->read('Flash.flash');
180+
$this->assertEquals($expected, $result, 'Element is ignored in magic call.');
181+
}
150182
}

0 commit comments

Comments
 (0)