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

Commit f8f7ce4

Browse files
committed
Updated the adapter implementation to follow changes made by symfony-cmf/routing-auto#91
1 parent 3ce9e7c commit f8f7ce4

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/Adapter/PhpcrOdmAdapter.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,20 @@ public function compareAutoRouteContent(AutoRouteInterface $autoRoute, $contentD
200200
return false;
201201
}
202202

203+
/**
204+
* {@inheritdoc}
205+
*/
206+
public function compareAutoRouteLocale(AutoRouteInterface $autoRoute, $locale)
207+
{
208+
$autoRouteLocale = $autoRoute->getLocale();
209+
210+
if ($autoRouteLocale === self::TAG_NO_MULTILANG) {
211+
$autoRouteLocale = null;
212+
}
213+
214+
return $autoRouteLocale === $locale;
215+
}
216+
203217
/**
204218
* {@inheritdoc}
205219
*/

tests/Unit/Adapter/PhpcrOdmAdapterTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,44 @@ public function testCompareRouteContent($isMatch)
224224
$this->adapter->compareAutoRouteContent($this->route->reveal(), $this->contentDocument);
225225
}
226226

227+
public function provideCompareAutoRouteLocale()
228+
{
229+
return [
230+
'a not localized route and a null locale' => [
231+
PhpcrOdmAdapter::TAG_NO_MULTILANG,
232+
null,
233+
true,
234+
],
235+
'a not localized route and a locale' => [
236+
PhpcrOdmAdapter::TAG_NO_MULTILANG,
237+
'en',
238+
false,
239+
],
240+
'a localized route and the matching locale' => [
241+
'en',
242+
'en',
243+
true,
244+
],
245+
'a localized route and a not matching locale' => [
246+
'en',
247+
'fr',
248+
false,
249+
],
250+
];
251+
}
252+
253+
/**
254+
* @dataProvider provideCompareAutoRouteLocale
255+
*/
256+
public function testCompareAutoRouteLocale($autoRouteLocale, $locale, $shouldMatch)
257+
{
258+
$this->route->getLocale()->willReturn($autoRouteLocale);
259+
260+
$areMatching = $this->adapter->compareAutoRouteLocale($this->route->reveal(), $locale);
261+
262+
$this->assertSame($shouldMatch, $areMatching);
263+
}
264+
227265
public function testGetReferringRoutes()
228266
{
229267
$this->dm->getReferrers($this->contentDocument, null, null, null, 'Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface')

0 commit comments

Comments
 (0)