create new method for testein ACtionMatcher

This commit is contained in:
Manuel Raynaud
2013-02-18 17:04:42 +01:00
parent 1fb530a3c8
commit 320047838d

View File

@@ -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]);
}
}