From c622b6e21bbab4ad6c9d421da9014d14dcd193a8 Mon Sep 17 00:00:00 2001 From: Damien Flament Date: Fri, 9 Jun 2017 13:53:59 +0200 Subject: [PATCH 1/6] Made Git ignore testing app cache/logs directories --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 26ad278..31f9b0b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -Tests/Resources/app/cache -Tests/Resources/app/logs +tests/Resources/app/cache +tests/Resources/app/logs composer.lock vendor From 3ce9e7c06ee3bd69bf692ec114acb7cb13415284 Mon Sep 17 00:00:00 2001 From: Damien Flament Date: Fri, 9 Jun 2017 13:55:21 +0200 Subject: [PATCH 2/6] Added a Composer script to run tests like Travis do it --- composer.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/composer.json b/composer.json index 394d6f0..0e5e3bf 100644 --- a/composer.json +++ b/composer.json @@ -45,5 +45,11 @@ "branch-alias": { "dev-master": "2.0-dev" } + }, + "scripts": { + "test": [ + "vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh", + "SYMFONY_PHPUNIT_REMOVE=\"symfony/yaml\" vendor/bin/simple-phpunit" + ] } } From f8f7ce4f8fdced5b5123632188ea60cdc71c4895 Mon Sep 17 00:00:00 2001 From: Damien Flament Date: Mon, 12 Jun 2017 11:31:44 +0200 Subject: [PATCH 3/6] Updated the adapter implementation to follow changes made by symfony-cmf/routing-auto#91 --- src/Adapter/PhpcrOdmAdapter.php | 14 ++++++++ tests/Unit/Adapter/PhpcrOdmAdapterTest.php | 38 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/Adapter/PhpcrOdmAdapter.php b/src/Adapter/PhpcrOdmAdapter.php index 7029462..5a6ff94 100644 --- a/src/Adapter/PhpcrOdmAdapter.php +++ b/src/Adapter/PhpcrOdmAdapter.php @@ -200,6 +200,20 @@ public function compareAutoRouteContent(AutoRouteInterface $autoRoute, $contentD return false; } + /** + * {@inheritdoc} + */ + public function compareAutoRouteLocale(AutoRouteInterface $autoRoute, $locale) + { + $autoRouteLocale = $autoRoute->getLocale(); + + if ($autoRouteLocale === self::TAG_NO_MULTILANG) { + $autoRouteLocale = null; + } + + return $autoRouteLocale === $locale; + } + /** * {@inheritdoc} */ diff --git a/tests/Unit/Adapter/PhpcrOdmAdapterTest.php b/tests/Unit/Adapter/PhpcrOdmAdapterTest.php index f295b47..ce0a43b 100644 --- a/tests/Unit/Adapter/PhpcrOdmAdapterTest.php +++ b/tests/Unit/Adapter/PhpcrOdmAdapterTest.php @@ -224,6 +224,44 @@ public function testCompareRouteContent($isMatch) $this->adapter->compareAutoRouteContent($this->route->reveal(), $this->contentDocument); } + public function provideCompareAutoRouteLocale() + { + return [ + 'a not localized route and a null locale' => [ + PhpcrOdmAdapter::TAG_NO_MULTILANG, + null, + true, + ], + 'a not localized route and a locale' => [ + PhpcrOdmAdapter::TAG_NO_MULTILANG, + 'en', + false, + ], + 'a localized route and the matching locale' => [ + 'en', + 'en', + true, + ], + 'a localized route and a not matching locale' => [ + 'en', + 'fr', + false, + ], + ]; + } + + /** + * @dataProvider provideCompareAutoRouteLocale + */ + public function testCompareAutoRouteLocale($autoRouteLocale, $locale, $shouldMatch) + { + $this->route->getLocale()->willReturn($autoRouteLocale); + + $areMatching = $this->adapter->compareAutoRouteLocale($this->route->reveal(), $locale); + + $this->assertSame($shouldMatch, $areMatching); + } + public function testGetReferringRoutes() { $this->dm->getReferrers($this->contentDocument, null, null, null, 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface') From c4e142ecbf42b7cc2b4ff5c7149d67c666c2229a Mon Sep 17 00:00:00 2001 From: Damien Flament Date: Sun, 18 Jun 2017 21:42:07 +0200 Subject: [PATCH 4/6] Revealed symfony-cmf/routing-auto#88 --- .../EventListener/AutoRouteListenerTest.php | 21 +++++++++++++++++++ .../Document/ConflictProneArticle.php | 21 +++++++++++++++++++ tests/Resources/app/config/routing_auto.yml | 14 ++++++++++--- 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 tests/Resources/Document/ConflictProneArticle.php diff --git a/tests/Functional/EventListener/AutoRouteListenerTest.php b/tests/Functional/EventListener/AutoRouteListenerTest.php index 6c904e1..150854e 100644 --- a/tests/Functional/EventListener/AutoRouteListenerTest.php +++ b/tests/Functional/EventListener/AutoRouteListenerTest.php @@ -17,6 +17,7 @@ use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article; use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Blog; use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\ConcreteContent; +use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\ConflictProneArticle; use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Page; use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Post; use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\SeoArticle; @@ -359,6 +360,26 @@ public function testUpdateMultilangArticle($data, $expectedPaths) } } + public function testResolveConflictOnSingleMultilangArticle() + { + $article = new ConflictProneArticle(); + $article->path = '/test/article'; + $article->title = 'Weekend'; + $this->getDm()->persist($article); + $this->getDm()->bindTranslation($article, 'fr'); + + $article->title = 'Weekend'; + $this->getDm()->bindTranslation($article, 'en'); + + $this->getDm()->flush(); + + $route = $this->getDm()->find(AutoRoute::class, 'test/auto-route/conflict-prone-articles/weekend'); + $this->assertNotNull($route); + + $route = $this->getDm()->find(AutoRoute::class, 'test/auto-route/conflict-prone-articles/weekend-1'); + $this->assertNotNull($route); + } + public function provideLeaveRedirect() { return [ diff --git a/tests/Resources/Document/ConflictProneArticle.php b/tests/Resources/Document/ConflictProneArticle.php new file mode 100644 index 0000000..ebb238e --- /dev/null +++ b/tests/Resources/Document/ConflictProneArticle.php @@ -0,0 +1,21 @@ + Date: Mon, 19 Jun 2017 03:52:07 +0200 Subject: [PATCH 5/6] Bumped component required version to 2.0.0-RC2 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0e5e3bf..f159709 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require": { "php": "^5.6|^7.0", "symfony/framework-bundle": "^2.8|^3.0", - "symfony-cmf/routing-auto": "^2.0", + "symfony-cmf/routing-auto": "^2.0.0-RC2", "symfony-cmf/routing-bundle": "^1.2.0|^2.0", "aferrandini/urlizer": "1.0.*" }, From f85c39d4fabc0560da43d43725e23167a2d6bc56 Mon Sep 17 00:00:00 2001 From: Damien Flament Date: Mon, 19 Jun 2017 03:54:56 +0200 Subject: [PATCH 6/6] Removed the global RC stability As the RC version of the component is explicitly specified, specifying it globally is useless. Moreover, this will prevents building using RC version of other dependencies. --- composer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/composer.json b/composer.json index f159709..5a4e764 100644 --- a/composer.json +++ b/composer.json @@ -24,8 +24,6 @@ "matthiasnoback/symfony-config-test": "^1.3.1", "doctrine/phpcr-odm": "^1.3" }, - "minimum-stability": "RC", - "prefer-stable": true, "suggest": { "doctrine/phpcr-odm": "To enable support for the PHPCR ODM documents", "doctrine/phpcr-bundle": "To enable support for the PHPCR ODM documents",