diff options
author | Arnold Daniels <arnold@jasny.net> | 2016-11-17 16:17:55 +0100 |
---|---|---|
committer | Arnold Daniels <arnold@jasny.net> | 2016-11-17 16:17:55 +0100 |
commit | 7149ef62ca11d451dadd271f5cb63233a4ac0748 (patch) | |
tree | f141b8c05d75c5b86819edb63213ec8b93e281bd /tests/ControllerTest.php | |
parent | 14bc7de53fda2c44482c7cf46b896cfdd41aa68d (diff) | |
parent | b8540d92944123d15559f9033f523f9f6c5126ec (diff) | |
download | controller-7149ef62ca11d451dadd271f5cb63233a4ac0748.zip controller-7149ef62ca11d451dadd271f5cb63233a4ac0748.tar.gz controller-7149ef62ca11d451dadd271f5cb63233a4ac0748.tar.bz2 |
Merge branch 'Flash' of https://github.com/Minstel/controller into Minstel-Flash
Diffstat (limited to 'tests/ControllerTest.php')
-rw-r--r-- | tests/ControllerTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ControllerTest.php b/tests/ControllerTest.php index e0ebdc2..3c659b2 100644 --- a/tests/ControllerTest.php +++ b/tests/ControllerTest.php @@ -1,6 +1,7 @@ <?php use Jasny\Controller; +use Jasny\Flash; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -81,6 +82,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase } /** +<<<<<<< HEAD * Test functions that check request method * * @dataProvider requestMethodProvider @@ -313,6 +315,43 @@ class ControllerTest extends PHPUnit_Framework_TestCase ['forbidden', 409, false], ['badRequest', 400, true], ['badRequest', 403, false] + ]; + } + + /** + * Test setting flash + * + * @dataProvider flashProvider + * @param object $data + */ + public function testFlash($data) + { + $controller = $this->getMockBuilder(Controller::class)->disableOriginalConstructor()->getMockForAbstractClass(); + + $flash = $controller->flash(); + $this->assertInstanceOf(Flash::class, $flash, "Flash is not set"); + $this->assertEmpty($flash->get(), "Flash data should be empty"); + + $flash = $controller->flash($data->type, $data->message); + $this->assertInstanceOf(Flash::class, $flash, "Flash is not set"); + $this->assertEquals($data, $flash->get(), "Flash data is incorrect"); + + $flash = $controller->flash(); + $this->assertInstanceOf(Flash::class, $flash, "Flash is not set"); + $this->assertEquals($data, $flash->get(), "Flash data is incorrect"); + + $flash->clear(); + } + + /** + * Test setting flash + * + * @return array + */ + public function flashProvider() + { + return [ + [(object)['type' => 'test_type', 'message' => 'Test message']] ]; } |