Skip to content

Commit 1d450f7

Browse files
committed
Fixed tests
Signed-off-by: alexmerlin <alex.merlin.1985@gmail.com>
1 parent fb6d544 commit 1d450f7

File tree

5 files changed

+73
-12
lines changed

5 files changed

+73
-12
lines changed

test/Unit/Admin/RoutesDelegatorTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,39 @@
66

77
use Admin\Admin\RoutesDelegator;
88
use AdminTest\Unit\UnitTest;
9+
use Dot\Router\RouteCollectorInterface;
910
use Mezzio\Application;
1011
use PHPUnit\Framework\MockObject\Exception;
12+
use Psr\Container\ContainerExceptionInterface;
1113
use Psr\Container\ContainerInterface;
14+
use Psr\Container\NotFoundExceptionInterface;
1215

1316
class 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
}

test/Unit/App/RoutesDelegatorTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,39 @@
66

77
use Admin\Admin\RoutesDelegator;
88
use AdminTest\Unit\UnitTest;
9+
use Dot\Router\RouteCollectorInterface;
910
use Mezzio\Application;
1011
use PHPUnit\Framework\MockObject\Exception;
12+
use Psr\Container\ContainerExceptionInterface;
1113
use Psr\Container\ContainerInterface;
14+
use Psr\Container\NotFoundExceptionInterface;
1215

1316
class 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
}

test/Unit/Dashboard/RoutesDelegatorTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Admin\Dashboard\RoutesDelegator;
88
use AdminTest\Unit\UnitTest;
9+
use Dot\Router\RouteCollectorInterface;
910
use Mezzio\Application;
1011
use PHPUnit\Framework\MockObject\Exception;
1112
use Psr\Container\ContainerExceptionInterface;
@@ -15,20 +16,29 @@
1516
class 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
}

test/Unit/Page/RoutesDelegatorTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Admin\Page\RoutesDelegator;
88
use AdminTest\Unit\UnitTest;
9+
use Dot\Router\RouteCollectorInterface;
910
use Mezzio\Application;
1011
use PHPUnit\Framework\MockObject\Exception;
1112
use Psr\Container\ContainerExceptionInterface;
@@ -15,20 +16,28 @@
1516
class 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
}

test/Unit/Setting/RoutesDelegatorTest.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,39 @@
66

77
use Admin\App\RoutesDelegator;
88
use AdminTest\Unit\UnitTest;
9+
use Dot\Router\RouteCollectorInterface;
910
use Mezzio\Application;
1011
use PHPUnit\Framework\MockObject\Exception;
12+
use Psr\Container\ContainerExceptionInterface;
1113
use Psr\Container\ContainerInterface;
14+
use Psr\Container\NotFoundExceptionInterface;
1215

1316
class 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
}

0 commit comments

Comments
 (0)