File tree Expand file tree Collapse file tree 5 files changed +73
-12
lines changed
Expand file tree Collapse file tree 5 files changed +73
-12
lines changed Original file line number Diff line number Diff line change 66
77use Admin \Admin \RoutesDelegator ;
88use AdminTest \Unit \UnitTest ;
9+ use Dot \Router \RouteCollectorInterface ;
910use Mezzio \Application ;
1011use PHPUnit \Framework \MockObject \Exception ;
12+ use Psr \Container \ContainerExceptionInterface ;
1113use Psr \Container \ContainerInterface ;
14+ use Psr \Container \NotFoundExceptionInterface ;
1215
1316class RoutesDelegatorTest extends UnitTest
1417{
1518 /**
19+ * @throws ContainerExceptionInterface
1620 * @throws Exception
21+ * @throws NotFoundExceptionInterface
1722 */
1823 public function testWillInvoke (): void
1924 {
25+ $ container = $ this ->createMock (ContainerInterface::class);
26+ $ container
27+ ->expects ($ this ->once ())
28+ ->method ('get ' )
29+ ->with (RouteCollectorInterface::class)
30+ ->willReturn (
31+ $ this ->createMock (RouteCollectorInterface::class)
32+ );
33+
2034 $ application = (new RoutesDelegator ())(
21- $ this -> createMock (ContainerInterface::class) ,
35+ $ container ,
2236 '' ,
2337 function () {
2438 return $ this ->createMock (Application::class);
2539 }
2640 );
2741
28- $ this ->assertInstanceOf (Application::class, $ application );
42+ $ this ->assertContainsOnlyInstancesOf (Application::class, [ $ application] );
2943 }
3044}
Original file line number Diff line number Diff line change 66
77use Admin \Admin \RoutesDelegator ;
88use AdminTest \Unit \UnitTest ;
9+ use Dot \Router \RouteCollectorInterface ;
910use Mezzio \Application ;
1011use PHPUnit \Framework \MockObject \Exception ;
12+ use Psr \Container \ContainerExceptionInterface ;
1113use Psr \Container \ContainerInterface ;
14+ use Psr \Container \NotFoundExceptionInterface ;
1215
1316class RoutesDelegatorTest extends UnitTest
1417{
1518 /**
19+ * @throws ContainerExceptionInterface
1620 * @throws Exception
21+ * @throws NotFoundExceptionInterface
1722 */
1823 public function testWillInvoke (): void
1924 {
25+ $ container = $ this ->createMock (ContainerInterface::class);
26+ $ container
27+ ->expects ($ this ->once ())
28+ ->method ('get ' )
29+ ->with (RouteCollectorInterface::class)
30+ ->willReturn (
31+ $ this ->createMock (RouteCollectorInterface::class)
32+ );
33+
2034 $ application = (new RoutesDelegator ())(
21- $ this -> createMock (ContainerInterface::class) ,
35+ $ container ,
2236 '' ,
2337 function () {
2438 return $ this ->createMock (Application::class);
2539 }
2640 );
2741
28- $ this ->assertInstanceOf (Application::class, $ application );
42+ $ this ->assertContainsOnlyInstancesOf (Application::class, [ $ application] );
2943 }
3044}
Original file line number Diff line number Diff line change 66
77use Admin \Dashboard \RoutesDelegator ;
88use AdminTest \Unit \UnitTest ;
9+ use Dot \Router \RouteCollectorInterface ;
910use Mezzio \Application ;
1011use PHPUnit \Framework \MockObject \Exception ;
1112use Psr \Container \ContainerExceptionInterface ;
1516class RoutesDelegatorTest extends UnitTest
1617{
1718 /**
18- * @throws Exception
1919 * @throws ContainerExceptionInterface
20+ * @throws Exception
2021 * @throws NotFoundExceptionInterface
2122 */
2223 public function testWillInvoke (): void
2324 {
25+ $ container = $ this ->createMock (ContainerInterface::class);
26+ $ container
27+ ->expects ($ this ->once ())
28+ ->method ('get ' )
29+ ->with (RouteCollectorInterface::class)
30+ ->willReturn (
31+ $ this ->createMock (RouteCollectorInterface::class)
32+ );
33+
2434 $ application = (new RoutesDelegator ())(
25- $ this -> createMock (ContainerInterface::class) ,
35+ $ container ,
2636 '' ,
2737 function () {
2838 return $ this ->createMock (Application::class);
2939 }
3040 );
3141
32- $ this ->assertInstanceOf (Application::class, $ application );
42+ $ this ->assertContainsOnlyInstancesOf (Application::class, [ $ application] );
3343 }
3444}
Original file line number Diff line number Diff line change 66
77use Admin \Page \RoutesDelegator ;
88use AdminTest \Unit \UnitTest ;
9+ use Dot \Router \RouteCollectorInterface ;
910use Mezzio \Application ;
1011use PHPUnit \Framework \MockObject \Exception ;
1112use Psr \Container \ContainerExceptionInterface ;
1516class RoutesDelegatorTest extends UnitTest
1617{
1718 /**
18- * @throws Exception
1919 * @throws ContainerExceptionInterface
20+ * @throws Exception
2021 * @throws NotFoundExceptionInterface
2122 */
2223 public function testWillInvoke (): void
2324 {
25+ $ container = $ this ->createMock (ContainerInterface::class);
26+ $ container
27+ ->method ('get ' )
28+ ->willReturnMap ([
29+ [RouteCollectorInterface::class, $ this ->createMock (RouteCollectorInterface::class)],
30+ ['config ' , []],
31+ ]);
32+
2433 $ application = (new RoutesDelegator ())(
25- $ this -> createMock (ContainerInterface::class) ,
34+ $ container ,
2635 '' ,
2736 function () {
2837 return $ this ->createMock (Application::class);
2938 }
3039 );
3140
32- $ this ->assertInstanceOf (Application::class, $ application );
41+ $ this ->assertContainsOnlyInstancesOf (Application::class, [ $ application] );
3342 }
3443}
Original file line number Diff line number Diff line change 66
77use Admin \App \RoutesDelegator ;
88use AdminTest \Unit \UnitTest ;
9+ use Dot \Router \RouteCollectorInterface ;
910use Mezzio \Application ;
1011use PHPUnit \Framework \MockObject \Exception ;
12+ use Psr \Container \ContainerExceptionInterface ;
1113use Psr \Container \ContainerInterface ;
14+ use Psr \Container \NotFoundExceptionInterface ;
1215
1316class RoutesDelegatorTest extends UnitTest
1417{
1518 /**
19+ * @throws ContainerExceptionInterface
1620 * @throws Exception
21+ * @throws NotFoundExceptionInterface
1722 */
1823 public function testWillInvoke (): void
1924 {
25+ $ container = $ this ->createMock (ContainerInterface::class);
26+ $ container
27+ ->expects ($ this ->once ())
28+ ->method ('get ' )
29+ ->with (RouteCollectorInterface::class)
30+ ->willReturn (
31+ $ this ->createMock (RouteCollectorInterface::class)
32+ );
33+
2034 $ application = (new RoutesDelegator ())(
21- $ this -> createMock (ContainerInterface::class) ,
35+ $ container ,
2236 '' ,
2337 function () {
2438 return $ this ->createMock (Application::class);
2539 }
2640 );
2741
28- $ this ->assertInstanceOf (Application::class, $ application );
42+ $ this ->assertContainsOnlyInstancesOf (Application::class, [ $ application] );
2943 }
3044}
You can’t perform that action at this time.
0 commit comments