-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublishTest.php
91 lines (75 loc) · 2.86 KB
/
PublishTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
use CodeIgniter\Files\Exceptions\FileException;
use CodeIgniter\Files\Exceptions\FileNotFoundException;
use Tatter\Assets\Exceptions\ManifestsException;
use Tests\Support\ManifestsTestCase;
use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\visitor\vfsStreamStructureVisitor;
class PublishTest extends ManifestsTestCase
{
public function testExplicitFiles()
{
$result = $this->manifests->publish($this->testManifest);
$this->assertTrue($result);
$expected = [
'root' => [
'assets' => [
'index.html' => $this->manifests->getIndexHtml(),
'vendor' => [
'index.html' => $this->manifests->getIndexHtml(),
'widgets' => [
'index.html' => $this->manifests->getIndexHtml(),
'css' => [
'index.html' => $this->manifests->getIndexHtml(),
'widget_style.css' => "a {\n\tcolor: white;\n}\n",
],
'notAsset.json' => "{\"flower\": \"yes\"}",
],
],
],
],
];
$visitor = new vfsStreamStructureVisitor();
$result = vfsStream::inspect($visitor, $this->root)->getStructure();
$this->assertEquals($expected, $result);
}
public function testRecursiveFlatten()
{
$path = SUPPORTPATH . 'Manifests/frontend.json';
$manifest = $this->manifests->parse($path);
$result = $this->manifests->publish($manifest);
$this->assertTrue($result);
$visitor = new vfsStreamStructureVisitor();
$result = vfsStream::inspect($visitor, $this->root)->getStructure();
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.css'));
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.js'));
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.min.css'));
$this->assertTrue($this->root->hasChild('assets/vendor/frontend/frontend.min.js'));
}
public function testRespectsFilters()
{
$path = SUPPORTPATH . 'Manifests/LawyerPack.json';
$manifest = $this->manifests->parse($path);
$result = $this->manifests->publish($manifest);
$this->assertTrue($result);
$this->assertTrue($this->root->hasChild('assets/vendor/lawyers/file1.css'));
$this->assertTrue($this->root->hasChild('assets/vendor/lawyers/file2.css'));
$this->assertTrue($this->root->hasChild('assets/vendor/lawyers/file3.css'));
$this->assertTrue($this->root->hasChild('assets/vendor/lawyers/image.png'));
$this->assertFalse($this->root->hasChild('assets/vendor/lawyers/ignore.txt'));
}
public function testNothingReturnsTrue()
{
unset($this->testManifest->resources);
$this->testManifest->resources = [
0 => (object)[
'source' => '.',
'filter' => '#noMatch#',
]
];
$result = $this->manifests->publish($this->testManifest);
$this->assertTrue($result);
$this->assertTrue($this->root->hasChild('assets/vendor/widgets/index.html'));
$this->assertFalse($this->root->hasChild('assets/vendor/widgets/widget_style.css'));
}
}