1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the core-bundle package. |
5
|
|
|
* |
6
|
|
|
* (c) 2019 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\Helper; |
13
|
|
|
|
14
|
|
|
use InvalidArgumentException; |
15
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
16
|
|
|
use Throwable; |
17
|
|
|
use WBW\Bundle\CoreBundle\Helper\SkeletonHelper; |
18
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Skeleton helper test. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
24
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\Helper |
25
|
|
|
*/ |
26
|
|
|
class SkeletonHelperTest extends AbstractTestCase { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Directory "illegal". |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
private $directoryIllegal; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Directory "resources". |
37
|
|
|
* |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
private $directoryResources; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Directory "skeleton". |
44
|
|
|
* |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $directorySkeleton; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* {@inheritDoc} |
51
|
|
|
*/ |
52
|
|
|
protected function setUp(): void { |
53
|
|
|
parent::setUp(); |
54
|
|
|
|
55
|
|
|
// Set the directories. |
56
|
|
|
$this->directoryIllegal = realpath(__DIR__ . "/../../composer.json"); |
57
|
|
|
$this->directoryResources = __DIR__ . "/../Fixtures/app/Resources"; |
58
|
|
|
$this->directorySkeleton = realpath(__DIR__ . "/../../Resources/views"); |
59
|
|
|
|
60
|
|
|
(new Filesystem())->remove($this->directoryResources); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Test copySkeleton() |
65
|
|
|
* |
66
|
|
|
* @return void |
67
|
|
|
*/ |
68
|
|
|
public function testCopySkeleton(): void { |
69
|
|
|
|
70
|
|
|
$res = SkeletonHelper::copySkeleton($this->directorySkeleton, $this->directoryResources); |
71
|
|
|
$this->assertCount(15, $res); |
72
|
|
|
|
73
|
|
|
foreach ($res as $current) { |
74
|
|
|
$this->assertTrue($current); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Test listSkeleton() |
80
|
|
|
* |
81
|
|
|
* @return void |
82
|
|
|
* @throws Throwable Throws an exception if an error occurs. |
83
|
|
|
*/ |
84
|
|
|
public function testListSkeleton(): void { |
85
|
|
|
|
86
|
|
|
$res = SkeletonHelper::listSkeleton($this->directorySkeleton); |
87
|
|
|
$this->assertCount(15, $res); |
88
|
|
|
|
89
|
|
|
$i = -1; |
90
|
|
|
|
91
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/WBWCoreJQueryInputMask.js.twig", $res[++$i]); |
92
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/WBWCoreLeaflet.js.twig", $res[++$i]); |
93
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/WBWCoreMaterialDesignColorPalette.js.twig", $res[++$i]); |
94
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/WBWCoreSweetAlert.js.twig", $res[++$i]); |
95
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/WBWCoreWaitMe.js.twig", $res[++$i]); |
96
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/_helper_css.html.twig", $res[++$i]); |
97
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/_javascripts.html.twig", $res[++$i]); |
98
|
|
|
$this->assertEquals($this->directorySkeleton . "/assets/_stylesheets.html.twig", $res[++$i]); |
99
|
|
|
$this->assertEquals($this->directorySkeleton . "/email/_content.html.twig", $res[++$i]); |
100
|
|
|
$this->assertEquals($this->directorySkeleton . "/email/_footer.html.twig", $res[++$i]); |
101
|
|
|
$this->assertEquals($this->directorySkeleton . "/email/_header.html.twig", $res[++$i]); |
102
|
|
|
$this->assertEquals($this->directorySkeleton . "/email/_stylesheet.html.twig", $res[++$i]); |
103
|
|
|
$this->assertEquals($this->directorySkeleton . "/email/layout.html.twig", $res[++$i]); |
104
|
|
|
$this->assertEquals($this->directorySkeleton . "/layout/exception.html.twig", $res[++$i]); |
105
|
|
|
$this->assertEquals($this->directorySkeleton . "/macros.html.twig", $res[++$i]); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* Test listSkeleton() |
110
|
|
|
* |
111
|
|
|
* @return void |
112
|
|
|
*/ |
113
|
|
|
public function testListSkeletonWithDirectoryNotFoundException(): void { |
114
|
|
|
|
115
|
|
|
try { |
116
|
|
|
|
117
|
|
|
SkeletonHelper::listSkeleton($this->directoryIllegal); |
118
|
|
|
} catch (Throwable $ex) { |
119
|
|
|
|
120
|
|
|
$this->assertInstanceOf(InvalidArgumentException::class, $ex); |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
} |
124
|
|
|
|