Code Duplication    Length = 38-39 lines in 2 locations

Tests/Controller/PageControllerTest.php 2 locations

@@ 36-73 (lines=38) @@
33
        static::assertEquals(404, $client->getResponse()->getStatusCode());
34
    }
35
36
    public function testOneHomepage()
37
    {
38
        $client = static::createClient();
39
40
        $homepage = $this->createPage([
41
            'homepage' => true,
42
            'enabled'  => true,
43
            'slug'     => 'home',
44
            'title'    => 'My homepage',
45
            'host'     => 'localhost',
46
            'content'  => 'Hello world!',
47
        ]);
48
49
        /** @var EntityManager $em */
50
        $em = $client->getKernel()->getContainer()->get('doctrine')->getManager();
51
        $em->persist($homepage);
52
        $em->flush();
53
54
        $crawler = $client->request('GET', '/page/');
55
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('title')->html()));
56
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('article > h1')->html()));
57
        static::assertContains($homepage->getContent(), trim($crawler->filter('article')->html()));
58
59
        // Repeat with the homepage directly in the url
60
61
        // First, check that any right trimming "/" will redirect
62
        $client->request('GET', '/page/home/');
63
        static::assertTrue($client->getResponse()->isRedirect('/page/home'));
64
        $client->followRedirect();
65
66
        // Check that the homepage with slug is redirected to the root page
67
        static::assertTrue($client->getResponse()->isRedirect('/page'));
68
        $crawler = $client->followRedirect();
69
70
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('title')->html()));
71
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('article > h1')->html()));
72
        static::assertContains($homepage->getContent(), trim($crawler->filter('article')->html()));
73
    }
74
75
    public function testOneHomepageWithLocale()
76
    {
@@ 75-113 (lines=39) @@
72
        static::assertContains($homepage->getContent(), trim($crawler->filter('article')->html()));
73
    }
74
75
    public function testOneHomepageWithLocale()
76
    {
77
        $client = static::createClient();
78
79
        $homepage = $this->createPage([
80
            'homepage' => true,
81
            'enabled'  => true,
82
            'locale'   => 'en',
83
            'slug'     => 'home',
84
            'title'    => 'My homepage',
85
            'host'     => 'localhost',
86
            'content'  => 'Hello world!',
87
        ]);
88
89
        /** @var EntityManager $em */
90
        $em = $client->getKernel()->getContainer()->get('doctrine')->getManager();
91
        $em->persist($homepage);
92
        $em->flush();
93
94
        $crawler = $client->request('GET', '/page/');
95
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('title')->html()));
96
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('article > h1')->html()));
97
        static::assertContains($homepage->getContent(), trim($crawler->filter('article')->html()));
98
99
        // Repeat with the homepage directly in the url
100
101
        // First, check that any right trimming "/" will redirect
102
        $client->request('GET', '/page/home/');
103
        static::assertTrue($client->getResponse()->isRedirect('/page/home'));
104
        $client->followRedirect();
105
106
        // Check that the homepage with slug is redirected to the root page
107
        static::assertTrue($client->getResponse()->isRedirect('/page?_locale=en'));
108
        $crawler = $client->followRedirect();
109
110
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('title')->html()));
111
        static::assertEquals($homepage->getTitle(), trim($crawler->filter('article > h1')->html()));
112
        static::assertContains($homepage->getContent(), trim($crawler->filter('article')->html()));
113
    }
114
115
    public function testTree()
116
    {