forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSupportServiceProviderTest.php
More file actions
114 lines (102 loc) · 5.96 KB
/
SupportServiceProviderTest.php
File metadata and controls
114 lines (102 loc) · 5.96 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
use Mockery as m;
use Illuminate\Support\ServiceProvider;
class SupportServiceProviderTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$app = m::mock('Illuminate\\Foundation\\Application')->makePartial();
$one = new ServiceProviderForTestingOne($app);
$one->boot();
$two = new ServiceProviderForTestingTwo($app);
$two->boot();
}
public function tearDown()
{
m::close();
}
public function testSimpleAssetsArePublishedCorrectly()
{
$toPublish = ServiceProvider::pathsToPublish('ServiceProviderForTestingOne');
$this->assertArrayHasKey('source/unmarked/one', $toPublish, 'Service provider does not return expected published path key.');
$this->assertArrayHasKey('source/tagged/one', $toPublish, 'Service provider does not return expected published path key.');
$this->assertEquals(['source/unmarked/one' => 'destination/unmarked/one', 'source/tagged/one' => 'destination/tagged/one'], $toPublish, 'Service provider does not return expected set of published paths.');
}
public function testMultipleAssetsArePublishedCorrectly()
{
$toPublish = ServiceProvider::pathsToPublish('ServiceProviderForTestingTwo');
$this->assertArrayHasKey('source/unmarked/two/a', $toPublish, 'Service provider does not return expected published path key.');
$this->assertArrayHasKey('source/unmarked/two/b', $toPublish, 'Service provider does not return expected published path key.');
$this->assertArrayHasKey('source/unmarked/two/c', $toPublish, 'Service provider does not return expected published path key.');
$this->assertArrayHasKey('source/tagged/two/a', $toPublish, 'Service provider does not return expected published path key.');
$this->assertArrayHasKey('source/tagged/two/b', $toPublish, 'Service provider does not return expected published path key.');
$expected = [
'source/unmarked/two/a' => 'destination/unmarked/two/a',
'source/unmarked/two/b' => 'destination/unmarked/two/b',
'source/unmarked/two/c' => 'destination/tagged/two/a',
'source/tagged/two/a' => 'destination/tagged/two/a',
'source/tagged/two/b' => 'destination/tagged/two/b',
];
$this->assertEquals($expected, $toPublish, 'Service provider does not return expected set of published paths.');
}
public function testSimpleTaggedAssetsArePublishedCorrectly()
{
$toPublish = ServiceProvider::pathsToPublish('ServiceProviderForTestingOne', 'some_tag');
$this->assertArrayNotHasKey('source/tagged/two/a', $toPublish, 'Service provider does return unexpected tagged path key.');
$this->assertArrayNotHasKey('source/tagged/two/b', $toPublish, 'Service provider does return unexpected tagged path key.');
$this->assertArrayHasKey('source/tagged/one', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertEquals(['source/tagged/one' => 'destination/tagged/one'], $toPublish, 'Service provider does not return expected set of published tagged paths.');
}
public function testMultipleTaggedAssetsArePublishedCorrectly()
{
$toPublish = ServiceProvider::pathsToPublish('ServiceProviderForTestingTwo', 'some_tag');
$this->assertArrayHasKey('source/tagged/two/a', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertArrayHasKey('source/tagged/two/b', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertArrayNotHasKey('source/tagged/one', $toPublish, 'Service provider does return unexpected tagged path key.');
$this->assertArrayNotHasKey('source/unmarked/two/c', $toPublish, 'Service provider does return unexpected tagged path key.');
$expected = [
'source/tagged/two/a' => 'destination/tagged/two/a',
'source/tagged/two/b' => 'destination/tagged/two/b',
];
$this->assertEquals($expected, $toPublish, 'Service provider does not return expected set of published tagged paths.');
}
public function testMultipleTaggedAssetsAreMergedCorrectly()
{
$toPublish = ServiceProvider::pathsToPublish(null, 'some_tag');
$this->assertArrayHasKey('source/tagged/two/a', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertArrayHasKey('source/tagged/two/b', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertArrayHasKey('source/tagged/one', $toPublish, 'Service provider does not return expected tagged path key.');
$this->assertArrayNotHasKey('source/unmarked/two/c', $toPublish, 'Service provider does return unexpected tagged path key.');
$expected = [
'source/tagged/one' => 'destination/tagged/one',
'source/tagged/two/a' => 'destination/tagged/two/a',
'source/tagged/two/b' => 'destination/tagged/two/b',
];
$this->assertEquals($expected, $toPublish, 'Service provider does not return expected set of published tagged paths.');
}
}
class ServiceProviderForTestingOne extends ServiceProvider
{
public function register()
{
}
public function boot()
{
$this->publishes(['source/unmarked/one' => 'destination/unmarked/one']);
$this->publishes(['source/tagged/one' => 'destination/tagged/one'], 'some_tag');
}
}
class ServiceProviderForTestingTwo extends ServiceProvider
{
public function register()
{
}
public function boot()
{
$this->publishes(['source/unmarked/two/a' => 'destination/unmarked/two/a']);
$this->publishes(['source/unmarked/two/b' => 'destination/unmarked/two/b']);
$this->publishes(['source/unmarked/two/c' => 'destination/tagged/two/a']);
$this->publishes(['source/tagged/two/a' => 'destination/tagged/two/a'], 'some_tag');
$this->publishes(['source/tagged/two/b' => 'destination/tagged/two/b'], 'some_tag');
}
}