Navigation Menu

Skip to content

Commit

Permalink
Adding tests for FlashComponent::__call
Browse files Browse the repository at this point in the history
Refs #5825
  • Loading branch information
markstory committed Feb 4, 2015
1 parent d7c9ad7 commit d6b6e05
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/TestCase/Controller/Component/FlashComponentTest.php
Expand Up @@ -147,4 +147,36 @@ public function testSetWithComponentConfiguration()
$result = $this->Session->read('Flash.flash');
$this->assertEquals($expected, $result);
}

/**
* Test magic call method.
*
* @covers \Cake\Controller\Component\FlashComponent::__call
* @return void
*/
public function testCall()
{
$this->assertNull($this->Session->read('Flash.flash'));

$this->Flash->success('It worked');
$expected = [
'message' => 'It worked',
'key' => 'flash',
'element' => 'Flash/success',
'params' => []
];
$result = $this->Session->read('Flash.flash');
$this->assertEquals($expected, $result);

$this->Flash->error('It did not work', ['element' => 'error_thing']);

$expected = [
'message' => 'It did not work',
'key' => 'flash',
'element' => 'Flash/error',
'params' => []
];
$result = $this->Session->read('Flash.flash');
$this->assertEquals($expected, $result, 'Element is ignored in magic call.');
}
}

0 comments on commit d6b6e05

Please sign in to comment.