summaryrefslogtreecommitdiff
path: root/tests/Unit/Routing/RoutingServiceProviderTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Unit/Routing/RoutingServiceProviderTest.php')
-rw-r--r--tests/Unit/Routing/RoutingServiceProviderTest.php49
1 files changed, 42 insertions, 7 deletions
diff --git a/tests/Unit/Routing/RoutingServiceProviderTest.php b/tests/Unit/Routing/RoutingServiceProviderTest.php
index dd9441eb..ce3d7290 100644
--- a/tests/Unit/Routing/RoutingServiceProviderTest.php
+++ b/tests/Unit/Routing/RoutingServiceProviderTest.php
@@ -2,10 +2,13 @@
namespace Engelsystem\Test\Unit\Routing;
+use Engelsystem\Config\Config;
+use Engelsystem\Routing\LegacyUrlGenerator;
use Engelsystem\Routing\RoutingServiceProvider;
use Engelsystem\Routing\UrlGenerator;
+use Engelsystem\Routing\UrlGeneratorInterface;
use Engelsystem\Test\Unit\ServiceProviderTest;
-use PHPUnit_Framework_MockObject_MockObject;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
class RoutingServiceProviderTest extends ServiceProviderTest
{
@@ -14,16 +17,48 @@ class RoutingServiceProviderTest extends ServiceProviderTest
*/
public function testRegister()
{
- /** @var PHPUnit_Framework_MockObject_MockObject|UrlGenerator $urlGenerator */
- $urlGenerator = $this->getMockBuilder(UrlGenerator::class)
- ->getMock();
+ $app = $this->getApp(['make', 'instance', 'bind', 'get']);
+ /** @var MockObject|Config $config */
+ $config = $this->getMockBuilder(Config::class)->getMock();
+ /** @var MockObject|UrlGeneratorInterface $urlGenerator */
+ $urlGenerator = $this->getMockForAbstractClass(UrlGeneratorInterface::class);
+ /** @var MockObject|UrlGeneratorInterface $legacyUrlGenerator */
+ $legacyUrlGenerator = $this->getMockForAbstractClass(UrlGeneratorInterface::class);
- $app = $this->getApp();
+ $config->expects($this->atLeastOnce())
+ ->method('get')
+ ->with('rewrite_urls')
+ ->willReturnOnConsecutiveCalls(
+ true,
+ false
+ );
- $this->setExpects($app, 'make', [UrlGenerator::class], $urlGenerator);
- $this->setExpects($app, 'instance', ['routing.urlGenerator', $urlGenerator]);
+ $this->setExpects($app, 'get', ['config'], $config, $this->atLeastOnce());
+
+ $app->expects($this->atLeastOnce())
+ ->method('make')
+ ->withConsecutive(
+ [UrlGenerator::class],
+ [LegacyUrlGenerator::class]
+ )
+ ->willReturnOnConsecutiveCalls(
+ $urlGenerator,
+ $legacyUrlGenerator
+ );
+ $app->expects($this->atLeastOnce())
+ ->method('instance')
+ ->withConsecutive(
+ ['routing.urlGenerator', $urlGenerator],
+ ['routing.urlGenerator', $legacyUrlGenerator]
+ );
+ $this->setExpects(
+ $app, 'bind',
+ [UrlGeneratorInterface::class, 'routing.urlGenerator'], null,
+ $this->atLeastOnce()
+ );
$serviceProvider = new RoutingServiceProvider($app);
$serviceProvider->register();
+ $serviceProvider->register();
}
}