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

Commit 44a2594

Browse files
author
Jefersson Nathan
committed
#44 — Added router tests for use of Di containers
1 parent d1ce0d9 commit 44a2594

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

tests/src/PHPRouterTest/RouteTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,14 @@
1818
namespace PHPRouterTest\Test;
1919

2020
use PHPRouter\Route;
21+
use PHPRouter\Test\SomeController;
2122
use PHPUnit_Framework_TestCase;
2223

2324
class RouteTest extends PHPUnit_Framework_TestCase
2425
{
26+
/**
27+
* @var Route
28+
*/
2529
private $routeWithParameters;
2630

2731
protected function setUp()
@@ -93,4 +97,24 @@ public function testGetAction()
9397
{
9498
self::assertEquals('page', $this->routeWithParameters->getAction());
9599
}
100+
101+
public function testShouldGetInstanceFromContainerIfContainerIsProvided()
102+
{
103+
/* @var $container \PHPUnit_Framework_MockObject_MockObject|\Interop\Container\ContainerInterface */
104+
$container = $this->getMock('Interop\Container\ContainerInterface');
105+
106+
$container->expects(self::once())
107+
->method('has')
108+
->with('PHPRouter\Test\SomeController')
109+
->willReturn(true);
110+
111+
$container->expects(self::once())
112+
->method('get')
113+
->with('PHPRouter\Test\SomeController')
114+
->willReturn(new SomeController());
115+
116+
$this->routeWithParameters->setContainer($container);
117+
118+
$this->routeWithParameters->dispatch();
119+
}
96120
}

0 commit comments

Comments
 (0)