Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Commit

Permalink
#44 — Added router tests for use of Di containers
Browse files Browse the repository at this point in the history
  • Loading branch information
Jefersson Nathan committed Apr 25, 2017
1 parent d1ce0d9 commit 44a2594
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/src/PHPRouterTest/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@
namespace PHPRouterTest\Test;

use PHPRouter\Route;
use PHPRouter\Test\SomeController;
use PHPUnit_Framework_TestCase;

class RouteTest extends PHPUnit_Framework_TestCase
{
/**
* @var Route
*/
private $routeWithParameters;

protected function setUp()
Expand Down Expand Up @@ -93,4 +97,24 @@ public function testGetAction()
{
self::assertEquals('page', $this->routeWithParameters->getAction());
}

public function testShouldGetInstanceFromContainerIfContainerIsProvided()
{
/* @var $container \PHPUnit_Framework_MockObject_MockObject|\Interop\Container\ContainerInterface */
$container = $this->getMock('Interop\Container\ContainerInterface');

$container->expects(self::once())
->method('has')
->with('PHPRouter\Test\SomeController')
->willReturn(true);

$container->expects(self::once())
->method('get')
->with('PHPRouter\Test\SomeController')
->willReturn(new SomeController());

$this->routeWithParameters->setContainer($container);

$this->routeWithParameters->dispatch();
}
}

0 comments on commit 44a2594

Please sign in to comment.