|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the core-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\CoreBundle\Tests\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\Routing\RouterInterface; |
|
15
|
|
|
use WBW\Bundle\CoreBundle\Provider\JavascriptProvider; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractWebTestCase; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Views controller test. |
|
20
|
|
|
* |
|
21
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
22
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\Controller |
|
23
|
|
|
*/ |
|
24
|
|
|
class ViewsControllerTest extends AbstractWebTestCase { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Test Resources/views/assets/_javascripts.html.twig |
|
28
|
|
|
* |
|
29
|
|
|
* @return void |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testAssetsJavascriptsAction(): void { |
|
32
|
|
|
|
|
33
|
|
|
$client = $this->client; |
|
34
|
|
|
|
|
35
|
|
|
$client->request("GET", "/assets/javascripts"); |
|
36
|
|
|
$this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
37
|
|
|
$this->assertEquals("text/html; charset=UTF-8", $client->getResponse()->headers->get("Content-Type")); |
|
38
|
|
|
|
|
39
|
|
|
/** @var RouterInterface $router */ |
|
40
|
|
|
$router = static::$kernel->getContainer()->get("router"); |
|
41
|
|
|
|
|
42
|
|
|
$provider = new JavascriptProvider(); |
|
43
|
|
|
foreach ($provider->getJavascripts() as $k => $v) { |
|
44
|
|
|
|
|
45
|
|
|
$uri = $router->generate("wbw_core_twig_resource", ["name" => $k, "type" => "js"]); |
|
46
|
|
|
|
|
47
|
|
|
$client->request("GET", $uri); |
|
48
|
|
|
$this->assertEquals(200, $client->getResponse()->getStatusCode(), $v); |
|
49
|
|
|
$this->assertEquals("application/javascript", $client->getResponse()->headers->get("Content-Type"), $v); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Test Resources/views/assets/_stylesheets.html.twig |
|
55
|
|
|
* |
|
56
|
|
|
* @return void |
|
57
|
|
|
*/ |
|
58
|
|
|
public function testAssetsStylesheetsAction(): void { |
|
59
|
|
|
|
|
60
|
|
|
$client = $this->client; |
|
61
|
|
|
|
|
62
|
|
|
$client->request("GET", "/assets/stylesheets"); |
|
63
|
|
|
$this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
64
|
|
|
$this->assertEquals("text/html; charset=UTF-8", $client->getResponse()->headers->get("Content-Type")); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Test Resources/views/email/layout.html.twig |
|
69
|
|
|
* |
|
70
|
|
|
* @return void |
|
71
|
|
|
*/ |
|
72
|
|
|
public function testEmailLayoutAction(): void { |
|
73
|
|
|
|
|
74
|
|
|
$client = $this->client; |
|
75
|
|
|
|
|
76
|
|
|
$client->request("GET", "/email/layout"); |
|
77
|
|
|
$this->assertEquals(200, $client->getResponse()->getStatusCode()); |
|
78
|
|
|
$this->assertEquals("text/html; charset=UTF-8", $client->getResponse()->headers->get("Content-Type")); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Test kernelExceptionAction() |
|
83
|
|
|
* |
|
84
|
|
|
* @return void |
|
85
|
|
|
*/ |
|
86
|
|
|
public function testKernelExceptionAction(): void { |
|
87
|
|
|
|
|
88
|
|
|
$client = $this->client; |
|
89
|
|
|
|
|
90
|
|
|
$client->request("GET", "/kernel-exception"); |
|
91
|
|
|
$this->assertEquals(500, $client->getResponse()->getStatusCode()); |
|
92
|
|
|
$this->assertEquals("text/html; charset=UTF-8", $client->getResponse()->headers->get("Content-Type")); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|