Code Duplication    Length = 11-12 lines in 5 locations

src/Kunstmaan/MultiDomainBundle/Tests/unit/Router/DomainBasedLocaleRouterTest.php 3 locations

@@ 16-26 (lines=11) @@
13
14
class DomainBasedLocaleRouterTest extends TestCase
15
{
16
    public function testGenerate()
17
    {
18
        $request = $this->getRequest();
19
        $container = $this->getContainer($request);
20
        $object = new DomainBasedLocaleRouter($container);
21
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'en_GB'), UrlGeneratorInterface::ABSOLUTE_URL);
22
        $this->assertEquals('http://multilangdomain.tld/en/some-uri', $url);
23
24
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'en_GB'), UrlGeneratorInterface::ABSOLUTE_PATH);
25
        $this->assertEquals('/en/some-uri', $url);
26
    }
27
28
    public function testGenerateWithOtherSite()
29
    {
@@ 28-39 (lines=12) @@
25
        $this->assertEquals('/en/some-uri', $url);
26
    }
27
28
    public function testGenerateWithOtherSite()
29
    {
30
        $request = $this->getRequest();
31
        $request->setLocale('nl_BE');
32
        $container = $this->getContainer($request);
33
        $object = new DomainBasedLocaleRouter($container);
34
        $url = $object->generate('_slug', array('url' => 'some-uri', 'otherSite' => 'https://cia.gov'), UrlGeneratorInterface::ABSOLUTE_URL);
35
        $this->assertEquals('http://multilangdomain.tld/nl/some-uri', $url);
36
37
        $url = $object->generate('_slug', array('url' => 'some-uri'), UrlGeneratorInterface::ABSOLUTE_PATH);
38
        $this->assertEquals('/nl/some-uri', $url);
39
    }
40
41
    public function testGenerateWithLocaleBasedOnCurrentRequest()
42
    {
@@ 41-52 (lines=12) @@
38
        $this->assertEquals('/nl/some-uri', $url);
39
    }
40
41
    public function testGenerateWithLocaleBasedOnCurrentRequest()
42
    {
43
        $request = $this->getRequest();
44
        $request->setLocale('nl_BE');
45
        $container = $this->getContainer($request);
46
        $object = new DomainBasedLocaleRouter($container);
47
        $url = $object->generate('_slug', array('url' => 'some-uri'), UrlGeneratorInterface::ABSOLUTE_URL);
48
        $this->assertEquals('http://multilangdomain.tld/nl/some-uri', $url);
49
50
        $url = $object->generate('_slug', array('url' => 'some-uri'), UrlGeneratorInterface::ABSOLUTE_PATH);
51
        $this->assertEquals('/nl/some-uri', $url);
52
    }
53
54
    public function testMatchWithNodeTranslation()
55
    {

src/Kunstmaan/NodeBundle/Tests/unit/Router/SlugRouterTest.php 2 locations

@@ 14-24 (lines=11) @@
11
12
class SlugRouterTest extends TestCase
13
{
14
    public function testGenerateMultiLanguage()
15
    {
16
        $request = $this->getRequest();
17
        $container = $this->getContainer($request, true);
18
        $object = new SlugRouter($container);
19
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'en'), UrlGeneratorInterface::ABSOLUTE_URL);
20
        $this->assertEquals('http://domain.tld/en/some-uri', $url);
21
22
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'en'), UrlGeneratorInterface::ABSOLUTE_PATH);
23
        $this->assertEquals('/en/some-uri', $url);
24
    }
25
26
    public function testGenerateSingleLanguage()
27
    {
@@ 26-36 (lines=11) @@
23
        $this->assertEquals('/en/some-uri', $url);
24
    }
25
26
    public function testGenerateSingleLanguage()
27
    {
28
        $request = $this->getRequest();
29
        $container = $this->getContainer($request);
30
        $object = new SlugRouter($container);
31
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'nl'), UrlGeneratorInterface::ABSOLUTE_URL);
32
        $this->assertEquals('http://domain.tld/some-uri', $url);
33
34
        $url = $object->generate('_slug', array('url' => 'some-uri', '_locale' => 'nl'), UrlGeneratorInterface::ABSOLUTE_PATH);
35
        $this->assertEquals('/some-uri', $url);
36
    }
37
38
    public function testSetContext()
39
    {