From 0aa8838b01778dc6ca46e26e886e22422078fe0e Mon Sep 17 00:00:00 2001 From: WouterJ Date: Thu, 5 Jan 2017 21:47:28 +0100 Subject: [PATCH] Fixed tests after cleanup --- src/ChainRouter.php | 4 ++++ src/DynamicRouter.php | 4 ++++ tests/Unit/Candidates/CandidatesTest.php | 2 +- .../Compiler/RegisterRouteEnhancersPassTest.php | 2 +- .../Compiler/RegisterRoutersPassTest.php | 2 +- tests/Unit/Enhancer/ConditionalEnhancerTest.php | 2 +- .../Enhancer/ContentRepositoryEnhancerTest.php | 2 +- tests/Unit/Enhancer/FieldByClassEnhancerTest.php | 2 +- tests/Unit/Enhancer/FieldMapEnhancerTest.php | 2 +- tests/Unit/Enhancer/FieldPresenceEnhancerTest.php | 2 +- tests/Unit/Enhancer/RouteContentEnhancerTest.php | 4 ++-- tests/Unit/Enhancer/RouteObject.php | 2 +- tests/Unit/NestedMatcher/NestedMatcherTest.php | 2 +- tests/Unit/NestedMatcher/UrlMatcherTest.php | 7 ++----- tests/Unit/Routing/ChainRouterTest.php | 4 ---- tests/Unit/Routing/ContentAwareGeneratorTest.php | 15 ++++++++------- tests/Unit/Routing/DynamicRouterTest.php | 2 +- tests/Unit/Routing/RouteMock.php | 2 +- 18 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/ChainRouter.php b/src/ChainRouter.php index 5fcb6cd0..431ef6df 100644 --- a/src/ChainRouter.php +++ b/src/ChainRouter.php @@ -126,6 +126,10 @@ protected function sortRouters() { krsort($this->routers); + if (0 === count($this->routers)) { + return array(); + } + return call_user_func_array('array_merge', $this->routers); } diff --git a/src/DynamicRouter.php b/src/DynamicRouter.php index 2ae8f862..47614bdc 100644 --- a/src/DynamicRouter.php +++ b/src/DynamicRouter.php @@ -350,6 +350,10 @@ protected function sortRouteEnhancers() { krsort($this->enhancers); + if (0 === count($this->enhancers)) { + return array(); + } + return call_user_func_array('array_merge', $this->enhancers); } diff --git a/tests/Unit/Candidates/CandidatesTest.php b/tests/Unit/Candidates/CandidatesTest.php index 36b9de6d..2c215171 100644 --- a/tests/Unit/Candidates/CandidatesTest.php +++ b/tests/Unit/Candidates/CandidatesTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Candidates; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Candidates; use Symfony\Cmf\Component\Routing\Candidates\Candidates; use Symfony\Component\HttpFoundation\Request; diff --git a/tests/Unit/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php b/tests/Unit/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php index d0dc1e59..9279148b 100644 --- a/tests/Unit/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/RegisterRouteEnhancersPassTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\DependencyInjection\Compiler; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\DependencyInjection\Compiler; use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRouteEnhancersPass; use Symfony\Component\DependencyInjection\Definition; diff --git a/tests/Unit/DependencyInjection/Compiler/RegisterRoutersPassTest.php b/tests/Unit/DependencyInjection/Compiler/RegisterRoutersPassTest.php index 25e039a8..4898944c 100644 --- a/tests/Unit/DependencyInjection/Compiler/RegisterRoutersPassTest.php +++ b/tests/Unit/DependencyInjection/Compiler/RegisterRoutersPassTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Routing\Tests\DependencyInjection\Compiler; +namespace Symfony\Cmf\Routing\Tests\Unit\DependencyInjection\Compiler; use Symfony\Cmf\Component\Routing\DependencyInjection\Compiler\RegisterRoutersPass; use Symfony\Component\DependencyInjection\Reference; diff --git a/tests/Unit/Enhancer/ConditionalEnhancerTest.php b/tests/Unit/Enhancer/ConditionalEnhancerTest.php index 8889d900..a874169d 100644 --- a/tests/Unit/Enhancer/ConditionalEnhancerTest.php +++ b/tests/Unit/Enhancer/ConditionalEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Mapper; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Mapper; use Symfony\Cmf\Component\Routing\Enhancer\ConditionalEnhancer; use Symfony\Component\HttpFoundation\Request; diff --git a/tests/Unit/Enhancer/ContentRepositoryEnhancerTest.php b/tests/Unit/Enhancer/ContentRepositoryEnhancerTest.php index 974cdb66..4946bbae 100644 --- a/tests/Unit/Enhancer/ContentRepositoryEnhancerTest.php +++ b/tests/Unit/Enhancer/ContentRepositoryEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; use Symfony\Cmf\Component\Routing\Enhancer\ContentRepositoryEnhancer; use Symfony\Cmf\Component\Routing\RouteObjectInterface; diff --git a/tests/Unit/Enhancer/FieldByClassEnhancerTest.php b/tests/Unit/Enhancer/FieldByClassEnhancerTest.php index 6745b91d..24931375 100644 --- a/tests/Unit/Enhancer/FieldByClassEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldByClassEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; diff --git a/tests/Unit/Enhancer/FieldMapEnhancerTest.php b/tests/Unit/Enhancer/FieldMapEnhancerTest.php index 8351d32b..c1ac2ac5 100644 --- a/tests/Unit/Enhancer/FieldMapEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldMapEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Mapper; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Mapper; use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; diff --git a/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php b/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php index 84fc412d..44dd4072 100644 --- a/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php +++ b/tests/Unit/Enhancer/FieldPresenceEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\FieldPresenceEnhancer; diff --git a/tests/Unit/Enhancer/RouteContentEnhancerTest.php b/tests/Unit/Enhancer/RouteContentEnhancerTest.php index 24022e44..f0219f13 100644 --- a/tests/Unit/Enhancer/RouteContentEnhancerTest.php +++ b/tests/Unit/Enhancer/RouteContentEnhancerTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; use Symfony\Component\HttpFoundation\Request; use Symfony\Cmf\Component\Routing\Enhancer\RouteContentEnhancer; @@ -27,7 +27,7 @@ class RouteContentEnhancerTest extends CmfUnitTestCase public function setUp() { - $this->document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Enhancer\RouteObject', + $this->document = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer\RouteObject', array('getContent', 'getRouteDefaults', 'getUrl')); $this->mapper = new RouteContentEnhancer(RouteObjectInterface::ROUTE_OBJECT, '_content'); diff --git a/tests/Unit/Enhancer/RouteObject.php b/tests/Unit/Enhancer/RouteObject.php index 1d8d7eab..7ccc83a4 100644 --- a/tests/Unit/Enhancer/RouteObject.php +++ b/tests/Unit/Enhancer/RouteObject.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Enhancer; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Enhancer; use Symfony\Component\Routing\Route; use Symfony\Cmf\Component\Routing\RouteObjectInterface; diff --git a/tests/Unit/NestedMatcher/NestedMatcherTest.php b/tests/Unit/NestedMatcher/NestedMatcherTest.php index 7a2f1f8b..25214194 100644 --- a/tests/Unit/NestedMatcher/NestedMatcherTest.php +++ b/tests/Unit/NestedMatcher/NestedMatcherTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\NestedMatcher; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\NestedMatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouteCollection; diff --git a/tests/Unit/NestedMatcher/UrlMatcherTest.php b/tests/Unit/NestedMatcher/UrlMatcherTest.php index 4e27017c..ad282962 100644 --- a/tests/Unit/NestedMatcher/UrlMatcherTest.php +++ b/tests/Unit/NestedMatcher/UrlMatcherTest.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\NestedMatcher; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\NestedMatcher; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\RouteCollection; @@ -29,7 +29,7 @@ class UrlMatcherTest extends CmfUnitTestCase public function setUp() { - $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'getRouteKey', 'compile')); + $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Unit\Routing\RouteMock', array('getDefaults', 'getRouteKey', 'compile')); $this->routeCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); @@ -112,9 +112,6 @@ public function testMatchNoRouteObject() ->method('compile') ->will($this->returnValue($this->routeCompiled)) ; - $this->routeDocument->expects($this->never()) - ->method('getRouteKey') - ; $this->routeDocument->expects($this->atLeastOnce()) ->method('getDefaults') ->will($this->returnValue(array('foo' => 'bar'))) diff --git a/tests/Unit/Routing/ChainRouterTest.php b/tests/Unit/Routing/ChainRouterTest.php index e3cec84d..9844db4b 100644 --- a/tests/Unit/Routing/ChainRouterTest.php +++ b/tests/Unit/Routing/ChainRouterTest.php @@ -698,10 +698,6 @@ public function testWarmup() $dir = 'test_dir'; list($low) = $this->createRouterMocks(); - $low - ->expects($this->never()) - ->method('warmUp') - ; $high = $this->getMock('Symfony\Cmf\Component\Routing\Tests\Routing\WarmableRouterMock'); $high ->expects($this->once()) diff --git a/tests/Unit/Routing/ContentAwareGeneratorTest.php b/tests/Unit/Routing/ContentAwareGeneratorTest.php index ca09a69a..4ddc36e6 100644 --- a/tests/Unit/Routing/ContentAwareGeneratorTest.php +++ b/tests/Unit/Routing/ContentAwareGeneratorTest.php @@ -14,6 +14,7 @@ use Symfony\Cmf\Component\Routing\RouteReferrersReadInterface; use Symfony\Cmf\Component\Routing\ContentAwareGenerator; use Symfony\Cmf\Component\Routing\Test\CmfUnitTestCase; +use Symfony\Cmf\Component\Routing\Tests\Unit\Routing\RouteMock; class ContentAwareGeneratorTest extends CmfUnitTestCase { @@ -31,7 +32,7 @@ class ContentAwareGeneratorTest extends CmfUnitTestCase public function setUp() { $this->contentDocument = $this->buildMock('Symfony\Cmf\Component\Routing\RouteReferrersReadInterface'); - $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); + $this->routeDocument = $this->buildMock(RouteMock::class, array('getDefaults', 'compile')); $this->routeCompiled = $this->buildMock('Symfony\Component\Routing\CompiledRoute'); $this->provider = $this->buildMock('Symfony\Cmf\Component\Routing\RouteProviderInterface'); $this->context = $this->buildMock('Symfony\Component\Routing\RequestContext'); @@ -104,7 +105,7 @@ public function testGenerateEmptyRouteString() public function testGenerateRouteMultilang() { - $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); + $route_en = $this->buildMock(RouteMock::class, array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -130,7 +131,7 @@ public function testGenerateRouteMultilang() public function testGenerateRouteMultilangDefaultLocale() { - $route = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock'); + $route = $this->buildMock(RouteMock::class); $route->expects($this->any()) ->method('compile') ->will($this->returnValue($this->routeCompiled)) @@ -155,7 +156,7 @@ public function testGenerateRouteMultilangDefaultLocale() public function testGenerateRouteMultilangLocaleNomatch() { - $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); + $route_en = $this->buildMock(RouteMock::class, array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -194,7 +195,7 @@ public function testGenerateNoncmfRouteMultilang() public function testGenerateRoutenameMultilang() { $name = 'foo/bar'; - $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile', 'getContent')); + $route_en = $this->buildMock(RouteMock::class, array('getDefaults', 'compile', 'getContent')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -241,7 +242,7 @@ public function testGenerateRoutenameMultilangNotFound() public function testGenerateDocumentMultilang() { - $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); + $route_en = $this->buildMock(RouteMock::class, array('getDefaults', 'compile')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); @@ -263,7 +264,7 @@ public function testGenerateDocumentMultilang() public function testGenerateDocumentMultilangLocaleNomatch() { - $route_en = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults', 'compile')); + $route_en = $this->buildMock(RouteMock::class, array('getDefaults', 'compile')); $route_en->setLocale('en'); $route_de = $this->routeDocument; $route_de->setLocale('de'); diff --git a/tests/Unit/Routing/DynamicRouterTest.php b/tests/Unit/Routing/DynamicRouterTest.php index ca04749d..f0b52cd5 100644 --- a/tests/Unit/Routing/DynamicRouterTest.php +++ b/tests/Unit/Routing/DynamicRouterTest.php @@ -33,7 +33,7 @@ class DynamicRouterTest extends CmfUnitTestCase public function setUp() { - $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Routing\RouteMock', array('getDefaults')); + $this->routeDocument = $this->buildMock('Symfony\Cmf\Component\Routing\Tests\Unit\Routing\RouteMock', array('getDefaults')); $this->matcher = $this->buildMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $this->generator = $this->buildMock('Symfony\Cmf\Component\Routing\VersatileGeneratorInterface', array('supports', 'generate', 'setContext', 'getContext', 'getRouteDebugMessage')); diff --git a/tests/Unit/Routing/RouteMock.php b/tests/Unit/Routing/RouteMock.php index c0af406a..6ac438c2 100644 --- a/tests/Unit/Routing/RouteMock.php +++ b/tests/Unit/Routing/RouteMock.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Cmf\Component\Routing\Tests\Routing; +namespace Symfony\Cmf\Component\Routing\Tests\Unit\Routing; use Symfony\Component\Routing\Route as SymfonyRoute; use Symfony\Cmf\Component\Routing\RouteObjectInterface;