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 Mazarini\DesignBundle\Tools\Folder; |
23
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
24
|
|
|
use Symfony\Component\HttpFoundation\Response; |
25
|
|
|
|
26
|
|
|
class UrlControllerTest extends WebTestCase |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* @dataProvider getUrls |
30
|
|
|
*/ |
31
|
|
|
public function testUrls(string $url) |
32
|
|
|
{ |
33
|
|
|
$client = static::createClient(); |
34
|
|
|
$client->request('GET', $url); |
35
|
|
|
|
36
|
|
|
$this->assertSame( |
37
|
|
|
Response::HTTP_OK, |
38
|
|
|
$client->getResponse()->getStatusCode(), |
39
|
|
|
sprintf('The %s public URL loads correctly.', $url) |
40
|
|
|
); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testPostUrls() |
44
|
|
|
{ |
45
|
|
|
$folder = new Folder(\dirname(\dirname(__DIR__))); |
46
|
|
|
$steps = $folder->getSteps(); |
47
|
|
|
foreach ($steps as $step) { |
48
|
|
|
$this->postUrls($step); |
49
|
|
|
$pages = $folder->getPages($step); |
50
|
|
|
foreach ($pages as $page) { |
51
|
|
|
$this->postUrls($step, $page); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
protected function postUrls(string $step, string $page = '') |
57
|
|
|
{ |
58
|
|
|
$client = static::createClient(); |
59
|
|
|
$client->request('POST', '/', ['step' => $step, 'page' => $page]); |
60
|
|
|
|
61
|
|
|
$this->assertSame( |
62
|
|
|
Response::HTTP_OK, |
63
|
|
|
$client->getResponse()->getStatusCode(), |
64
|
|
|
sprintf('The / with[%s,%s] public URL with loads correctly.', $step, $page) |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getUrls() |
69
|
|
|
{ |
70
|
|
|
yield ['/']; |
71
|
|
|
yield ['/info']; |
72
|
|
|
yield ['/debug']; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|