From 2955d3fcb976706311f0db37f800d09c1e482564 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sat, 5 Sep 2015 17:25:35 +0200 Subject: [PATCH 1/3] Added test for RedirectMigrate --- .../EventListener/AutoRouteListenerTest.php | 43 +++++++++++++++++-- composer.json | 2 +- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Tests/Functional/EventListener/AutoRouteListenerTest.php b/Tests/Functional/EventListener/AutoRouteListenerTest.php index 036d2ef..a82af4f 100644 --- a/Tests/Functional/EventListener/AutoRouteListenerTest.php +++ b/Tests/Functional/EventListener/AutoRouteListenerTest.php @@ -341,7 +341,7 @@ public function provideLeaveRedirect() array( 'test/auto-route/seo-articles/en/goodbye-everybody', 'test/auto-route/seo-articles/fr/aurevoir-le-monde', - 'test/auto-route/seo-articles/de/aud-weidersehn', + 'test/auto-route/seo-articles/de/auf-weidersehn', 'test/auto-route/seo-articles/es/adios-todo-el-mundo', ), ), @@ -376,14 +376,17 @@ public function testLeaveRedirect($data, $updatedData, $expectedRedirectRoutePat foreach ($expectedRedirectRoutePaths as $originalPath) { $redirectRoute = $this->getDm()->find(null, $originalPath); - $this->assertNotNull($redirectRoute, 'Autoroute exists for: ' . $originalPath); + $this->assertNotNull($redirectRoute, 'Redirect exists for: ' . $originalPath); $this->assertEquals(AutoRouteInterface::TYPE_REDIRECT, $redirectRoute->getDefault('type')); } foreach ($expectedAutoRoutePaths as $newPath) { $autoRoute = $this->getDm()->find(null, $newPath); - $this->assertNotNull($redirectRoute, 'Autoroute exists for: ' . $originalPath); - $this->assertEquals(AutoRouteInterface::TYPE_REDIRECT, $redirectRoute->getDefault('type')); + if (null === $autoRoute) { + var_dump($newPath);die();; + } + $this->assertNotNull($autoRoute, 'Autoroute exists for: ' . $newPath); + $this->assertEquals(AutoRouteInterface::TYPE_PRIMARY, $autoRoute->getDefault('type')); } } @@ -409,6 +412,38 @@ public function testLeaveRedirectAndRenameToOriginal() $this->getDm()->flush(); } + /** + * Leave direct should migrate children + */ + public function testLeaveRedirectChildrenMigrations() + { + $article1 = new SeoArticle; + $article1->title = 'Hai'; + $article1->path = '/test/article-1'; + $this->getDm()->persist($article1); + $this->getDm()->flush(); + + // add a child to the route + $parentRoute = $this->getDm()->find(null, '/test/auto-route/seo-articles/hai'); + $childRoute = new AutoRoute(); + $childRoute->setName('foo'); + $childRoute->setParent($parentRoute); + $this->getDm()->persist($childRoute); + $this->getDm()->flush(); + + $article1->title = 'Ho'; + $this->getDm()->persist($article1); + $this->getDm()->flush(); + + $originalRoute = $this->getDm()->find(null, '/test/auto-route/seo-articles/hai'); + $this->assertNotNull($originalRoute); + $this->assertCount(0, $this->getDm()->getChildren($originalRoute)); + + $newRoute = $this->getDm()->find(null, '/test/auto-route/seo-articles/ho'); + $this->assertNotNull($newRoute); + $this->assertCount(1, $this->getDm()->getChildren($newRoute)); + } + /** * Ensure that we can map parent classes: #56 */ diff --git a/composer.json b/composer.json index 6c81a1e..55ebc8d 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "prefer-stable": true, "require": { "php": ">=5.3.9", - "symfony-cmf/routing-auto": "~1.1", + "symfony-cmf/routing-auto": "dev-redirect_migrate", "symfony-cmf/routing-bundle": "~1.2,>=1.2.0", "symfony-cmf/core-bundle": "~1.2", "aferrandini/urlizer": "1.0.*", From cf66450e57a0e45a48762d0f293e39b873ba53a5 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sat, 5 Sep 2015 17:29:23 +0200 Subject: [PATCH 2/3] Removed debug statement --- Tests/Functional/EventListener/AutoRouteListenerTest.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Tests/Functional/EventListener/AutoRouteListenerTest.php b/Tests/Functional/EventListener/AutoRouteListenerTest.php index a82af4f..d7bbbe1 100644 --- a/Tests/Functional/EventListener/AutoRouteListenerTest.php +++ b/Tests/Functional/EventListener/AutoRouteListenerTest.php @@ -382,9 +382,6 @@ public function testLeaveRedirect($data, $updatedData, $expectedRedirectRoutePat foreach ($expectedAutoRoutePaths as $newPath) { $autoRoute = $this->getDm()->find(null, $newPath); - if (null === $autoRoute) { - var_dump($newPath);die();; - } $this->assertNotNull($autoRoute, 'Autoroute exists for: ' . $newPath); $this->assertEquals(AutoRouteInterface::TYPE_PRIMARY, $autoRoute->getDefault('type')); } From ef3c4e45bcfcc8331d1c3f178d272f01aced6b25 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 6 Sep 2015 21:47:11 +0200 Subject: [PATCH 3/3] Updated composer --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 55ebc8d..6c81a1e 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "prefer-stable": true, "require": { "php": ">=5.3.9", - "symfony-cmf/routing-auto": "dev-redirect_migrate", + "symfony-cmf/routing-auto": "~1.1", "symfony-cmf/routing-bundle": "~1.2,>=1.2.0", "symfony-cmf/core-bundle": "~1.2", "aferrandini/urlizer": "1.0.*",