From 320047838dcb99c5de6a2ce7a050261d61886b55 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 18 Feb 2013 17:04:42 +0100 Subject: [PATCH] create new method for testein ACtionMatcher --- .../Routing/Matcher/ActionMatcherTest.php | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Tests/Routing/Matcher/ActionMatcherTest.php b/core/lib/Thelia/Tests/Routing/Matcher/ActionMatcherTest.php index 68e74f11c..043b47e6b 100644 --- a/core/lib/Thelia/Tests/Routing/Matcher/ActionMatcherTest.php +++ b/core/lib/Thelia/Tests/Routing/Matcher/ActionMatcherTest.php @@ -25,26 +25,43 @@ namespace Thelia\Tests\Routing\Matcher; use Symfony\Component\HttpFoundation\Request; use Thelia\Routing\Matcher\ActionMatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Thelia\Core\Event\ActionEvent; class ActionMatcherTest extends \PHPUnit_Framework_TestCase { /** + * + * if there is no action parameter and n + * * @expectedException Symfony\Component\Routing\Exception\ResourceNotFoundException + * @expectedExceptionMessage No action parameter found */ public function testDispatchActionWithoutAction() { $actionMatcher = new ActionMatcher(); - $request = new Request(); $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); $dispatcher->expects($this->any()) ->method("dispatch"); $actionMatcher->setDispatcher($dispatcher); - $actionMatcher->matchRequest($request); + $actionMatcher->matchRequest(new Request()); + } + + public function testDispatchActionWithAddProduct() + { + $request = new Request(array( + "action" => "addProduct" + )); + + $actionMatcher = new ActionMatcher(); + $actionMatcher->setDispatcher($this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface")); + $action = $actionMatcher->matchRequest($request); + + $this->assertArrayHasKey("_controller", $action); + $this->assertInstanceOf("Thelia\Action\Cart", $action["_controller"][0]); + } } \ No newline at end of file