diff --git a/.github/workflows/test-application.yaml b/.github/workflows/test-application.yaml
index 000a0a3f..d90227b4 100644
--- a/.github/workflows/test-application.yaml
+++ b/.github/workflows/test-application.yaml
@@ -21,16 +21,16 @@ jobs:
fail-fast: false
matrix:
include:
- - php-version: '8.0'
+ - php-version: '8.1'
dependencies: 'lowest'
- - php-version: '8.0'
- symfony-version: '6.0.*'
- php-version: '8.1'
- symfony-version: '6.0.*'
+ - php-version: '8.2'
+ - php-version: '8.3'
+ symfony-version: '7.0.*'
steps:
- name: Checkout project
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
- name: Install and configure PHP
uses: shivammathur/setup-php@v2
@@ -45,7 +45,7 @@ jobs:
composer global require --no-progress --no-scripts --no-plugins symfony/flex
- name: Install dependencies with Composer
- uses: ramsey/composer-install@v1
+ uses: ramsey/composer-install@v2
with:
dependency-versions: ${{ matrix.dependencies }}
composer-options: --prefer-dist
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ff50f97..f54c7871 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,13 @@
Changelog
=========
+3.1.0
+-----
+
+* Symfony 7 support
+* Doctrine ORM 3 support
+ If you use the ORM route entity, you need to migrate your database configuration as the array fields needed to be changed to the `json` type (because `array` has been removed)
+
3.0.2
-----
diff --git a/composer.json b/composer.json
index 83ebce9a..47bc78ef 100644
--- a/composer.json
+++ b/composer.json
@@ -15,28 +15,28 @@
}
],
"require": {
- "php": "^8.0",
- "symfony-cmf/routing": "^3.0",
- "symfony/framework-bundle": "^6.0"
+ "php": "^8.1",
+ "symfony-cmf/routing": "^3.0.3",
+ "symfony/framework-bundle": "^6.4 || ^7.0"
},
"require-dev": {
- "jackalope/jackalope-doctrine-dbal": "^1.3",
- "doctrine/phpcr-odm": "^1.4|^2.0",
- "symfony/phpunit-bridge": "^6.0",
- "matthiasnoback/symfony-dependency-injection-test": "^4.1.0",
- "matthiasnoback/symfony-config-test": "^4.1.0",
- "doctrine/orm": "^2.9",
- "symfony-cmf/testing": "dev-master as 4.2.0",
"doctrine/data-fixtures": "^1.0.0",
- "symfony/form": "^6.0",
- "symfony/translation": "^6.0",
- "symfony/validator": "^6.0",
- "symfony/security-bundle": "^6.0",
- "doctrine/doctrine-bundle": "^2.0",
- "symfony/twig-bundle": "^6.0",
+ "doctrine/doctrine-bundle": "^2.8",
+ "doctrine/orm": "^2.9 || ^3.0",
+ "doctrine/phpcr-bundle": "^3.0",
+ "doctrine/phpcr-odm": "^2.0",
+ "jackalope/jackalope-doctrine-dbal": "^2.0",
+ "matthiasnoback/symfony-dependency-injection-test": "^4.1.0 || ^5.1.0",
+ "matthiasnoback/symfony-config-test": "^4.1.0 || ^5.1.0",
+ "symfony/phpunit-bridge": "^7.0.3",
+ "symfony/form": "^6.4 || ^7.0",
"symfony/monolog-bundle": "^3.5",
- "doctrine/phpcr-bundle": "^2.3",
- "symfony/serializer": "^6.0",
+ "symfony/security-bundle": "^6.4 || ^7.0",
+ "symfony/serializer": "^6.4 || ^7.0",
+ "symfony/translation": "^6.4 || ^7.0",
+ "symfony/validator": "^6.4 || ^7.0",
+ "symfony/twig-bundle": "^6.4 || ^7.0",
+ "symfony-cmf/testing": "dev-fix-test-kernel as 5.0.2",
"twig/twig": "^2.4.4 || ^3.0"
},
"suggest": {
@@ -45,10 +45,10 @@
"doctrine/orm": "To enable support for the ORM entities (^2.5)"
},
"conflict": {
- "doctrine/phpcr-odm": "<1.4",
"doctrine/common": "<3.1.1",
"doctrine/persistence": "<1.3.0",
- "phpunit/phpunit": "<6"
+ "symfony/doctrine-bridge": "<6.4.0",
+ "symfony/security-core": "<6.4.0"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index f40ee5f1..8f6f0ec5 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,36 +1,33 @@
-
-
-
./tests/Unit
-
./tests/Functional
./tests/Functional/Doctrine/Orm
-
./tests/Functional/Doctrine/Orm
-
-
+
+
src/
-
- Resources/
-
-
-
+
+
+ src/Resources/
+
+
-
+
diff --git a/src/Doctrine/Orm/RedirectRoute.php b/src/Doctrine/Orm/RedirectRoute.php
index 5bc160d6..3bb5f210 100644
--- a/src/Doctrine/Orm/RedirectRoute.php
+++ b/src/Doctrine/Orm/RedirectRoute.php
@@ -17,16 +17,11 @@
* {@inheritdoc}
*
* Provides a redirect route stored in the Doctrine ORM and used as content for generic route to provide redirects
+ *
+ * @property int $id
*/
class RedirectRoute extends RedirectRouteModel
{
- /**
- * Unique id of this route.
- *
- * @var int
- */
- protected $id;
-
protected string $serialisedParameters;
/**
diff --git a/src/Resources/config/doctrine-base/Symfony.Component.Routing.Route.orm.xml b/src/Resources/config/doctrine-base/Symfony.Component.Routing.Route.orm.xml
index f7fac5fe..09c2fe67 100644
--- a/src/Resources/config/doctrine-base/Symfony.Component.Routing.Route.orm.xml
+++ b/src/Resources/config/doctrine-base/Symfony.Component.Routing.Route.orm.xml
@@ -4,11 +4,11 @@
-
-
-
-
-
+
+
+
+
+
diff --git a/tests/Fixtures/App/Document/Content.php b/tests/Fixtures/App/Document/Content.php
index 2d4ab25c..c9eab724 100644
--- a/tests/Fixtures/App/Document/Content.php
+++ b/tests/Fixtures/App/Document/Content.php
@@ -11,31 +11,21 @@
namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Fixtures\App\Document;
-use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
+use Doctrine\ODM\PHPCR\Mapping\Attributes as PHPCRODM;
-/**
- * @PHPCRODM\Document(referenceable=true)
- */
+#[PHPCRODM\Document(referenceable: true)]
class Content
{
- /**
- * @PHPCRODM\Id
- */
+ #[PHPCRODM\Id()]
private $id;
- /**
- * @PHPCRODM\ParentDocument
- */
+ #[PHPCRODM\ParentDocument]
private $parent;
- /**
- * @PHPCRODM\NodeName
- */
+ #[PHPCRODM\NodeName]
private $name;
- /**
- * @PHPCRODM\Field(type="string")
- */
+ #[PHPCRODM\Field(type: 'string')]
private $title;
public function setId($id)
diff --git a/tests/Fixtures/App/Kernel.php b/tests/Fixtures/App/Kernel.php
index 101fd36e..8dbc25a2 100644
--- a/tests/Fixtures/App/Kernel.php
+++ b/tests/Fixtures/App/Kernel.php
@@ -17,7 +17,7 @@
class Kernel extends TestKernel
{
- public function configure()
+ public function configure(): void
{
$this->requireBundleSet('default');
@@ -39,7 +39,7 @@ public function configure()
}
}
- public function registerContainerConfiguration(LoaderInterface $loader)
+ public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/config_'.$this->environment.'.php');
}
diff --git a/tests/Fixtures/App/config/config.yml b/tests/Fixtures/App/config/config.yml
index 9c4e1301..9a139cae 100644
--- a/tests/Fixtures/App/config/config.yml
+++ b/tests/Fixtures/App/config/config.yml
@@ -1,5 +1,3 @@
framework:
- serializer:
- enable_annotations: false
+ serializer: ~
property_access: ~
- annotations: ~
diff --git a/tests/Functional/Doctrine/Orm/RedirectRouteTest.php b/tests/Functional/Doctrine/Orm/RedirectRouteTest.php
index a46b65ac..1e938f68 100644
--- a/tests/Functional/Doctrine/Orm/RedirectRouteTest.php
+++ b/tests/Functional/Doctrine/Orm/RedirectRouteTest.php
@@ -14,13 +14,10 @@
use Symfony\Cmf\Bundle\RoutingBundle\Controller\RedirectController;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\RedirectRoute;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Orm\Route;
-use Symfony\Component\HttpFoundation\RedirectResponse;
class RedirectRouteTest extends OrmTestCase
{
- private $repository;
-
- private $controller;
+ private RedirectController $controller;
public function setUp(): void
{
@@ -28,11 +25,10 @@ public function setUp(): void
$this->clearDb(Route::class);
$this->clearDb(RedirectRoute::class);
- $this->repository = $this->getContainer()->get('cmf_routing.route_provider');
$this->controller = new RedirectController($this->getContainer()->get('router'));
}
- public function testRedirectDoctrine()
+ public function testRedirectDoctrine(): void
{
$route = $this->createRoute('route1', '/test');
@@ -52,7 +48,6 @@ public function testRedirectDoctrine()
$response = $this->controller->redirectAction($redirectRoute->getContent());
- $this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertSame(301, $response->getStatusCode());
$this->assertSame('http://localhost/test', $response->getTargetUrl());
}
diff --git a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php
index f480de83..54931348 100644
--- a/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php
+++ b/tests/Functional/Doctrine/Phpcr/RouteProviderTest.php
@@ -113,7 +113,7 @@ public function testGetRouteCollectionForRequestFormat()
*/
public function testGetRouteCollectionForRequestNonPhpcrUrl()
{
- $routes = $this->repository->getRouteCollectionForRequest(Request::create('http:///'));
+ $routes = $this->repository->getRouteCollectionForRequest(Request::create('http://localhost/'));
$this->assertInstanceOf(RouteCollection::class, $routes);
$this->assertCount(1, $routes);
diff --git a/tests/Unit/Doctrine/Orm/RouteProviderTest.php b/tests/Unit/Doctrine/Orm/RouteProviderTest.php
index a4a8f737..138f2331 100644
--- a/tests/Unit/Doctrine/Orm/RouteProviderTest.php
+++ b/tests/Unit/Doctrine/Orm/RouteProviderTest.php
@@ -201,15 +201,7 @@ public function testGetRoutesByNames(): void
];
$this->objectRepositoryMock
- ->expects($this->at(0))
->method('findOneBy')
- ->with(['name' => $paths[0]])
- ->willReturn($this->routeMock)
- ;
- $this->objectRepositoryMock
- ->expects($this->at(1))
- ->method('findOneBy')
- ->with(['name' => $paths[1]])
->willReturn($this->routeMock)
;
@@ -217,22 +209,9 @@ public function testGetRoutesByNames(): void
$candidatesMock = $this->createMock(CandidatesInterface::class);
$candidatesMock
- ->expects($this->at(0))
->method('isCandidate')
- ->with($paths[0])
- ->willReturn(true)
- ;
- $candidatesMock
- ->expects($this->at(1))
- ->method('isCandidate')
- ->with($paths[1])
- ->willReturn(true)
- ;
- $candidatesMock
- ->expects($this->at(2))
- ->method('isCandidate')
- ->with($paths[2])
- ->willReturn(false)
+ ->withConsecutive([$paths[0]], [$paths[1]], [$paths[2]])
+ ->willReturnOnConsecutiveCalls(true, true, false)
;
$routeProvider = new RouteProvider($this->managerRegistryMock, $candidatesMock, 'Route');
diff --git a/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php b/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php
index d6995937..f4104fa3 100644
--- a/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php
+++ b/tests/Unit/Doctrine/Phpcr/ContentRepositoryTest.php
@@ -12,9 +12,9 @@
namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Doctrine\Phpcr;
use Doctrine\ODM\PHPCR\DocumentManager;
+use Doctrine\ODM\PHPCR\DocumentManagerInterface;
use Doctrine\ODM\PHPCR\UnitOfWork;
use Doctrine\Persistence\ManagerRegistry;
-use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\TestCase;
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\ContentRepository;
@@ -34,24 +34,22 @@ public function setUp(): void
{
$this->document = new \stdClass();
$this->document2 = new \stdClass();
- $this->objectManager = $this->createMock(ObjectManager::class);
- $this->objectManager2 = $this->createMock(ObjectManager::class);
+ $this->objectManager = $this->createMock(DocumentManagerInterface::class);
+ $this->objectManager2 = $this->createMock(DocumentManagerInterface::class);
$this->managerRegistry = $this->createMock(ManagerRegistry::class);
}
- public function testFindById()
+ public function testFindById(): void
{
$this->objectManager
- ->expects($this->any())
->method('find')
->with(null, 'id-123')
- ->will($this->returnValue($this->document))
+ ->willReturn($this->document)
;
$this->managerRegistry
- ->expects($this->any())
->method('getManager')
- ->will($this->returnValue($this->objectManager))
+ ->willReturn($this->objectManager)
;
$contentRepository = new ContentRepository($this->managerRegistry);
@@ -60,25 +58,25 @@ public function testFindById()
$this->assertSame($this->document, $contentRepository->findById('id-123'));
}
- public function testGetContentId()
+ public function testGetContentId(): void
{
$uow = $this->createMock(UnitOfWork::class);
$uow->expects($this->once())
->method('getDocumentId')
->with($this->document)
- ->will($this->returnValue('id-123'))
+ ->willReturn('id-123')
;
$dm = $this->createMock(DocumentManager::class);
$dm
->expects($this->once())
->method('getUnitOfWork')
- ->will($this->returnValue($uow))
+ ->willReturn($uow)
;
$this->managerRegistry
->expects($this->once())
->method('getManager')
- ->will($this->returnValue($dm))
+ ->willReturn($dm)
;
$contentRepository = new ContentRepository($this->managerRegistry);
@@ -87,18 +85,18 @@ public function testGetContentId()
$this->assertEquals('id-123', $contentRepository->getContentId($this->document));
}
- public function testGetContentIdNoObject()
+ public function testGetContentIdNoObject(): void
{
$contentRepository = new ContentRepository($this->managerRegistry);
$this->assertNull($contentRepository->getContentId('hello'));
}
- public function testGetContentIdException()
+ public function testGetContentIdException(): void
{
$this->managerRegistry
->expects($this->once())
->method('getManager')
- ->will($this->throwException(new \Exception()))
+ ->willThrowException(new \Exception())
;
$contentRepository = new ContentRepository($this->managerRegistry);
@@ -111,20 +109,18 @@ public function testGetContentIdException()
* Use findById() with two different document managers.
* The two document managers will return different documents when searching for the same id.
*/
- public function testChangingDocumentManager()
+ public function testChangingDocumentManager(): void
{
$this->objectManager
- ->expects($this->any())
->method('find')
->with(null, 'id-123')
- ->will($this->returnValue($this->document))
+ ->willReturn($this->document)
;
$this->objectManager2
- ->expects($this->any())
->method('find')
->with(null, 'id-123')
- ->will($this->returnValue($this->document2))
+ ->willReturn($this->document2)
;
$objectManagers = [
@@ -132,14 +128,11 @@ public function testChangingDocumentManager()
'new_manager' => $this->objectManager2,
];
$this->managerRegistry
- ->expects($this->any())
->method('getManager')
- ->will(
- $this->returnCallback(
- function ($name) use ($objectManagers) {
- return $objectManagers[$name];
- }
- )
+ ->willReturnCallback(
+ function ($name) use ($objectManagers) {
+ return $objectManagers[$name];
+ }
);
$contentRepository = new ContentRepository($this->managerRegistry);
diff --git a/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php b/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php
index a283fd07..0a4c9188 100644
--- a/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php
+++ b/tests/Unit/Doctrine/Phpcr/PrefixCandidatesTest.php
@@ -12,8 +12,9 @@
namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Unit\Doctrine\Phpcr;
use Doctrine\ODM\PHPCR\DocumentManager;
-use Doctrine\ODM\PHPCR\Query\Builder\ConstraintFactory;
+use Doctrine\ODM\PHPCR\Query\Builder\ConstraintOrx;
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
+use Doctrine\ODM\PHPCR\Query\Builder\WhereAnd;
use Doctrine\ODM\PHPCR\Translation\LocaleChooser\LocaleChooserInterface;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\TestCase;
@@ -22,7 +23,7 @@
class PrefixCandidatesTest extends TestCase
{
- public function testAddPrefix()
+ public function testAddPrefix(): void
{
$candidates = new PrefixCandidates(['/routes']);
$this->assertEquals(['/routes'], $candidates->getPrefixes());
@@ -32,7 +33,7 @@ public function testAddPrefix()
$this->assertEquals(['/other'], $candidates->getPrefixes());
}
- public function testGetCandidates()
+ public function testGetCandidates(): void
{
$request = Request::create('/my/path.html');
@@ -54,7 +55,7 @@ public function testGetCandidates()
);
}
- public function testGetCandidatesPercentEncoded()
+ public function testGetCandidatesPercentEncoded(): void
{
$request = Request::create('/my/path%20percent%20encoded.html');
@@ -76,7 +77,7 @@ public function testGetCandidatesPercentEncoded()
);
}
- public function testGetCandidatesLocales()
+ public function testGetCandidatesLocales(): void
{
$request = Request::create('/de/path.html');
@@ -102,16 +103,15 @@ public function testGetCandidatesLocales()
);
}
- public function testGetCandidatesLocalesDm()
+ public function testGetCandidatesLocalesDm(): void
{
$request = Request::create('/de/path.html');
$dmMock = $this->createMock(DocumentManager::class);
$managerRegistryMock = $this->createMock(ManagerRegistry::class);
$managerRegistryMock
- ->expects($this->any())
->method('getManager')
- ->will($this->returnValue($dmMock))
+ ->willReturn($dmMock)
;
$localeMock = $this->createMock(LocaleChooserInterface::class);
$localeMock
@@ -122,14 +122,14 @@ public function testGetCandidatesLocalesDm()
$dmMock
->expects($this->once())
->method('getLocaleChooserStrategy')
- ->will($this->returnValue($localeMock))
+ ->willReturn($localeMock)
;
$candidates = new PrefixCandidates(['/simple'], ['de', 'fr'], $managerRegistryMock);
$candidates->getCandidates($request);
}
- public function testGetCandidatesLocalesDmNoLocale()
+ public function testGetCandidatesLocalesDmNoLocale(): void
{
$request = Request::create('/it/path.html');
$managerRegistryMock = $this->createMock(ManagerRegistry::class);
@@ -142,7 +142,7 @@ public function testGetCandidatesLocalesDmNoLocale()
$candidates->getCandidates($request);
}
- public function testIsCandidate()
+ public function testIsCandidate(): void
{
$candidates = new PrefixCandidates(['/routes']);
$this->assertTrue($candidates->isCandidate('/routes'));
@@ -152,33 +152,33 @@ public function testIsCandidate()
$this->assertFalse($candidates->isCandidate('/routesnotsame'));
}
- public function testRestrictQuery()
+ public function testRestrictQuery(): void
{
- $orX = $this->createMock(ConstraintFactory::class);
+ $orX = $this->createMock(ConstraintOrx::class);
$orX->expects($this->once())
->method('descendant')
->with('/routes', 'd')
;
- $andWhere = $this->createMock(ConstraintFactory::class);
+ $andWhere = $this->createMock(WhereAnd::class);
$andWhere->expects($this->once())
->method('orX')
- ->will($this->returnValue($orX))
+ ->willReturn($orX)
;
$qb = $this->createMock(QueryBuilder::class);
$qb->expects($this->once())
->method('andWhere')
- ->will($this->returnValue($andWhere))
+ ->willReturn($andWhere)
;
$qb->expects($this->once())
->method('getPrimaryAlias')
- ->will($this->returnValue('d'))
+ ->willReturn('d')
;
$candidates = new PrefixCandidates(['/routes']);
$candidates->restrictQuery($qb);
}
- public function testRestrictQueryGlobal()
+ public function testRestrictQueryGlobal(): void
{
$qb = $this->createMock(QueryBuilder::class);
$qb->expects($this->never())
diff --git a/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php b/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php
index b5a21e1c..8eb3ef4e 100644
--- a/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php
+++ b/tests/Unit/Doctrine/Phpcr/RouteProviderTest.php
@@ -13,8 +13,8 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ODM\PHPCR\DocumentManager;
+use Doctrine\ODM\PHPCR\Query\Builder\From;
use Doctrine\ODM\PHPCR\Query\Builder\QueryBuilder;
-use Doctrine\ODM\PHPCR\Query\Builder\SourceFactory;
use Doctrine\ODM\PHPCR\Query\Query;
use Doctrine\ODM\PHPCR\UnitOfWork;
use Doctrine\Persistence\ManagerRegistry;
@@ -87,10 +87,10 @@ public function testGetRouteCollectionForRequest(): void
->willReturn($candidates)
;
- $objects = [
+ $objects = new ArrayCollection([
new Route('/my'),
$this,
- ];
+ ]);
$this->dmMock
->expects($this->once())
@@ -327,28 +327,9 @@ public function testGetRoutesByNames(): void
;
$this->candidatesMock
- ->expects($this->at(0))
->method('isCandidate')
- ->with('/cms/routes/test-route')
- ->willReturn(true)
- ;
- $this->candidatesMock
- ->expects($this->at(1))
- ->method('isCandidate')
- ->with('/cms/simple/other-route')
- ->willReturn(true)
- ;
- $this->candidatesMock
- ->expects($this->at(2))
- ->method('isCandidate')
- ->with('/cms/routes/not-a-route')
- ->willReturn(true)
- ;
- $this->candidatesMock
- ->expects($this->at(3))
- ->method('isCandidate')
- ->with('/outside/prefix')
- ->willReturn(false)
+ ->withConsecutive(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'], ['/outside/prefix'])
+ ->willReturnOnConsecutiveCalls(true, true, true, false)
;
$paths[] = '/outside/prefix';
@@ -374,21 +355,8 @@ public function testGetRoutesByNamesNotCandidates(): void
;
$this->candidatesMock
- ->expects($this->at(0))
- ->method('isCandidate')
- ->with('/cms/routes/test-route')
- ->willReturn(false)
- ;
- $this->candidatesMock
- ->expects($this->at(1))
->method('isCandidate')
- ->with('/cms/simple/other-route')
- ->willReturn(false)
- ;
- $this->candidatesMock
- ->expects($this->at(2))
- ->method('isCandidate')
- ->with('/cms/routes/not-a-route')
+ ->withConsecutive(['/cms/routes/test-route'], ['/cms/simple/other-route'], ['/cms/routes/not-a-route'])
->willReturn(false)
;
@@ -429,29 +397,15 @@ public function testGetRoutesByNamesUuid(): void
->willReturn($uow)
;
$uow
- ->expects($this->at(0))
->method('getDocumentId')
- ->with($route1)
- ->willReturn('/cms/routes/test-route')
- ;
- $uow
- ->expects($this->at(1))
- ->method('getDocumentId')
- ->with($route2)
- ->willReturn('/cms/routes/other-route')
+ ->withConsecutive([$route1], [$route2])
+ ->willReturnOnConsecutiveCalls('/cms/routes/test-route', '/cms/routes/other-route')
;
$this->candidatesMock
- ->expects($this->at(0))
- ->method('isCandidate')
- ->with('/cms/routes/test-route')
- ->willReturn(true)
- ;
- $this->candidatesMock
- ->expects($this->at(1))
->method('isCandidate')
- ->with('/cms/routes/other-route')
- ->willReturn(false)
+ ->withConsecutive(['/cms/routes/test-route'], ['/cms/routes/other-route'])
+ ->willReturnOnConsecutiveCalls(true, false)
;
$routeProvider = new RouteProvider($this->managerRegistryMock, $this->candidatesMock);
@@ -463,7 +417,7 @@ public function testGetRoutesByNamesUuid(): void
private function doRouteDump($limit): void
{
- $from = $this->createMock(SourceFactory::class);
+ $from = $this->createMock(From::class);
$from->expects($this->once())
->method('document')
->with(Route::class, 'd')
diff --git a/tests/Unit/Validator/Constraints/RouteDefaultsTemplatingValidatorTest.php b/tests/Unit/Validator/Constraints/RouteDefaultsTemplatingValidatorTest.php
index e6e74ae1..55c3e17f 100644
--- a/tests/Unit/Validator/Constraints/RouteDefaultsTemplatingValidatorTest.php
+++ b/tests/Unit/Validator/Constraints/RouteDefaultsTemplatingValidatorTest.php
@@ -13,6 +13,7 @@
use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaultsTemplatingValidator;
use Symfony\Component\Templating\EngineInterface;
+use Symfony\Component\Validator\ConstraintValidatorInterface;
class RouteDefaultsTemplatingValidatorTest extends RouteDefaultsValidatorTest
{
@@ -30,7 +31,7 @@ protected function setUp(): void
parent::setUp();
}
- protected function createValidator()
+ protected function createValidator(): ConstraintValidatorInterface
{
return new RouteDefaultsTemplatingValidator($this->controllerResolver, $this->engine);
}
diff --git a/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php b/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php
index 32f4dbf2..5894ff98 100644
--- a/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php
+++ b/tests/Unit/Validator/Constraints/RouteDefaultsTwigValidatorTest.php
@@ -13,6 +13,7 @@
use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaults;
use Symfony\Cmf\Bundle\RoutingBundle\Validator\Constraints\RouteDefaultsTwigValidator;
+use Symfony\Component\Validator\ConstraintValidatorInterface;
use Twig\Loader\LoaderInterface;
class RouteDefaultsTwigValidatorTest extends RouteDefaultsValidatorTest
@@ -22,12 +23,12 @@ protected function mockEngine()
return $this->createMock(LoaderInterface::class);
}
- protected function createValidator()
+ protected function createValidator(): ConstraintValidatorInterface
{
return new RouteDefaultsTwigValidator($this->controllerResolver, $this->engine);
}
- public function testNoTemplateViolationWithoutTwig()
+ public function testNoTemplateViolationWithoutTwig(): void
{
$this->validator = new RouteDefaultsTwigValidator($this->controllerResolver, null);
$this->validator->validate(
diff --git a/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php b/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php
index 18157c8c..c7ec58b6 100644
--- a/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php
+++ b/tests/Unit/Validator/Constraints/RouteDefaultsValidatorTest.php
@@ -43,18 +43,18 @@ protected function setUp(): void
*/
abstract protected function mockEngine();
- public function testCorrectControllerPath()
+ public function testCorrectControllerPath(): void
{
$this->validator->validate(['_controller' => 'FrameworkBundle:Redirect:redirect'], new RouteDefaults());
$this->assertNoViolation();
}
- public function testControllerPathViolation()
+ public function testControllerPathViolation(): void
{
- $this->controllerResolver->expects($this->any())
+ $this->controllerResolver
->method('getController')
- ->will($this->throwException(new \LogicException('Invalid controller')))
+ ->willThrowException(new \LogicException('Invalid controller'))
;
$this->validator->validate(['_controller' => 'NotExistingBundle:Foo:bar'], new RouteDefaults());
@@ -62,11 +62,11 @@ public function testControllerPathViolation()
$this->buildViolation('Invalid controller')->assertRaised();
}
- public function testCorrectTemplate()
+ public function testCorrectTemplate(): void
{
- $this->engine->expects($this->any())
+ $this->engine
->method('exists')
- ->will($this->returnValue(true))
+ ->willReturn(true)
;
$this->validator->validate(['_template' => 'TwigBundle::layout.html.twig'], $this->constraint);
@@ -74,13 +74,12 @@ public function testCorrectTemplate()
$this->assertNoViolation();
}
- public function testTemplateViolation()
+ public function testTemplateViolation(): void
{
$this
->engine
- ->expects($this->any())
->method('exists')
- ->will($this->returnValue(false))
+ ->willReturn(false)
;
$this->validator->validate(