Completed
Push — master ( cab007...c861ff )
by Mazarini
02:36
created

UrlControllerTest::testPostUrls()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * Copyright (C) 2019 Mazarini <[email protected]>.
5
 * This file is part of mazarini/design.
6
 *
7
 * mazarini/design is free software: you can redistribute it and/or
8
 * modify it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or (at your
10
 * option) any later version.
11
 *
12
 * mazarini/design is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15
 * more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 */
19
20
namespace App\Tests\Controller;
21
22
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
23
use Symfony\Component\HttpFoundation\Response;
24
25
class UrlControllerTest extends WebTestCase
26
{
27
    /**
28
     * @dataProvider getUrls
29
     */
30
    public function testUrls(string $url)
31
    {
32
        $client = static::createClient();
33
        $client->request('GET', $url);
34
35
        $this->assertSame(
36
            Response::HTTP_OK,
37
            $client->getResponse()->getStatusCode(),
38
            sprintf('The %s public URL loads correctly.', $url)
39
        );
40
    }
41
42
    /**
43
     * @dataProvider getUrlsParams
44
     */
45
    public function testPostUrls(string $step, string $page = '')
46
    {
47
        $client = static::createClient();
48
        $client->request('POST', '/', ['step' => $step, 'page' => $page]);
49
50
        $this->assertSame(
51
            Response::HTTP_OK,
52
            $client->getResponse()->getStatusCode(),
53
            sprintf('The / with[%s,%s] public URL with loads correctly.', $step, $page)
54
        );
55
    }
56
57
    public function getUrls()
58
    {
59
        yield ['/'];
60
        yield ['/info'];
61
        yield ['/debug'];
62
    }
63
64
    public function getUrlsParams()
65
    {
66
        yield ['01-asset'];
67
        yield ['01-asset', 'x'];
68
        yield ['01-asset', '01-files.html.twig'];
69
        yield ['01-asset', '02-jquery.html.twig'];
70
    }
71
}
72