Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit c4e142e

Browse files
committed
1 parent f8f7ce4 commit c4e142e

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

tests/Functional/EventListener/AutoRouteListenerTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article;
1818
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Blog;
1919
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\ConcreteContent;
20+
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\ConflictProneArticle;
2021
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Page;
2122
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Post;
2223
use Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\SeoArticle;
@@ -359,6 +360,26 @@ public function testUpdateMultilangArticle($data, $expectedPaths)
359360
}
360361
}
361362

363+
public function testResolveConflictOnSingleMultilangArticle()
364+
{
365+
$article = new ConflictProneArticle();
366+
$article->path = '/test/article';
367+
$article->title = 'Weekend';
368+
$this->getDm()->persist($article);
369+
$this->getDm()->bindTranslation($article, 'fr');
370+
371+
$article->title = 'Weekend';
372+
$this->getDm()->bindTranslation($article, 'en');
373+
374+
$this->getDm()->flush();
375+
376+
$route = $this->getDm()->find(AutoRoute::class, 'test/auto-route/conflict-prone-articles/weekend');
377+
$this->assertNotNull($route);
378+
379+
$route = $this->getDm()->find(AutoRoute::class, 'test/auto-route/conflict-prone-articles/weekend-1');
380+
$this->assertNotNull($route);
381+
}
382+
362383
public function provideLeaveRedirect()
363384
{
364385
return [
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document;
13+
14+
use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;
15+
16+
/**
17+
* @PHPCR\Document(translator="child", referenceable=true)
18+
*/
19+
class ConflictProneArticle extends Article
20+
{
21+
}

tests/Resources/app/config/routing_auto.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Blog:
88
blog_title: [content_method, { method: getTitle } ]
99

1010
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Post:
11-
definitions:
12-
view:
11+
definitions:
12+
view:
1313
uri_schema: /blog/{blog_title}/{post_date}/{post_title}
1414
token_providers:
1515
blog_title: [content_method, { method: getBlogTitle } ]
@@ -18,7 +18,7 @@ Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Post:
1818
conflict_resolver: [auto_increment, { }]
1919

2020
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article:
21-
definitions:
21+
definitions:
2222
view:
2323
uri_schema: /articles/{article_locale}/{article_title}
2424
defaults:
@@ -35,6 +35,14 @@ Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\Article:
3535
article_title: [content_method, { method: getTitle } ]
3636
article_locale: [content_locale, {} ]
3737

38+
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\ConflictProneArticle:
39+
definitions:
40+
view:
41+
uri_schema: /conflict-prone-articles/{article_title}
42+
token_providers:
43+
article_title: [content_method, { method: getTitle } ]
44+
conflict_resolver: [auto_increment]
45+
3846
Symfony\Cmf\Bundle\RoutingAutoBundle\Tests\Resources\Document\SeoArticle:
3947
definitions:
4048
view:

0 commit comments

Comments
 (0)