|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace ByTIC\Assets\Tests\Assets; |
|
4
|
|
|
|
|
5
|
|
|
use ByTIC\Assets\Assets\Asset; |
|
6
|
|
|
use ByTIC\Assets\Assets\AssetCollection; |
|
7
|
|
|
use ByTIC\Assets\Assets\EntryPoint; |
|
8
|
|
|
use ByTIC\Assets\AssetsServiceProvider; |
|
9
|
|
|
use ByTIC\Assets\Encore\EntrypointLookupFactory; |
|
10
|
|
|
use ByTIC\Assets\Tests\AbstractTest; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Class EntryPointTest |
|
14
|
|
|
* @package ByTIC\Assets\Tests\Assets |
|
15
|
|
|
*/ |
|
16
|
|
|
class EntryPointTest extends AbstractTest |
|
17
|
|
|
{ |
|
18
|
|
|
public function test_collection_init() |
|
19
|
|
|
{ |
|
20
|
|
|
$entrypoint = new EntryPoint(); |
|
21
|
|
|
|
|
22
|
|
|
$scripts = $entrypoint->scripts(); |
|
23
|
|
|
self::assertInstanceOf(AssetCollection::class, $scripts); |
|
24
|
|
|
self::assertSame(Asset::TYPE_SCRIPTS, $scripts->getAssetType()); |
|
25
|
|
|
self::assertSame($scripts, $entrypoint->scripts()); |
|
26
|
|
|
|
|
27
|
|
|
$styles = $entrypoint->styles(); |
|
28
|
|
|
self::assertInstanceOf(AssetCollection::class, $styles); |
|
29
|
|
|
self::assertSame(Asset::TYPE_STYLES, $styles->getAssetType()); |
|
30
|
|
|
self::assertSame($styles, $entrypoint->styles()); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function test_addFromWebpack() |
|
34
|
|
|
{ |
|
35
|
|
|
$provider = new AssetsServiceProvider(); |
|
36
|
|
|
$provider->initContainer(); |
|
37
|
|
|
$provider->register(); |
|
38
|
|
|
|
|
39
|
|
|
EntrypointLookupFactory::setConfig([ |
|
40
|
|
|
'assets' => [ |
|
41
|
|
|
'output_path' => TEST_FIXTURE_PATH.'/build/', |
|
42
|
|
|
], |
|
43
|
|
|
]); |
|
44
|
|
|
|
|
45
|
|
|
$entrypoint = new EntryPoint(); |
|
46
|
|
|
$entrypoint->addFromWebpack('my_entry'); |
|
47
|
|
|
|
|
48
|
|
|
$styles = $entrypoint->styles(); |
|
49
|
|
|
self::assertCount(2, $styles); |
|
50
|
|
|
|
|
51
|
|
|
$scripts = $entrypoint->scripts(); |
|
52
|
|
|
self::assertCount(2, $scripts); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|