|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Core\Tests\Asset; |
|
4
|
|
|
|
|
5
|
|
|
use Modules\Core\Foundation\Asset\Types\AssetType; |
|
6
|
|
|
use Modules\Core\Foundation\Asset\Types\AssetTypeFactory; |
|
7
|
|
|
use Modules\Core\Tests\BaseTestCase; |
|
8
|
|
|
|
|
9
|
|
|
class AssetFactoryTest extends BaseTestCase |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var AssetTypeFactory |
|
13
|
|
|
*/ |
|
14
|
|
|
private $assetFactory; |
|
15
|
|
|
|
|
16
|
|
|
public function setUp() |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct(); |
|
|
|
|
|
|
19
|
|
|
$this->refreshApplication(); |
|
20
|
|
|
$this->assetFactory = app(AssetTypeFactory::class); |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
/** @test */ |
|
24
|
|
|
public function it_throws_exception_if_asset_type_not_found() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->setExpectedException(\InvalidArgumentException::class); |
|
27
|
|
|
|
|
28
|
|
|
$path = ['somehting' => 'some/path.something']; |
|
29
|
|
|
|
|
30
|
|
|
$this->assetFactory->make($path)->url(); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** @test */ |
|
34
|
|
|
public function it_returns_an_asset_type_class() |
|
35
|
|
|
{ |
|
36
|
|
|
$themePath = ['theme' => 'some/path.js']; |
|
37
|
|
|
$modulePath = ['module' => 'some/path.js']; |
|
38
|
|
|
$cdnPath = ['module' => 'some/path.js']; |
|
39
|
|
|
|
|
40
|
|
|
$themeClass = $this->assetFactory->make($themePath); |
|
41
|
|
|
$moduleClass = $this->assetFactory->make($modulePath); |
|
42
|
|
|
$cdnClass = $this->assetFactory->make($cdnPath); |
|
43
|
|
|
|
|
44
|
|
|
$this->assertInstanceOf(AssetType::class, $themeClass); |
|
45
|
|
|
$this->assertInstanceOf(AssetType::class, $moduleClass); |
|
46
|
|
|
$this->assertInstanceOf(AssetType::class, $cdnClass); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** @test */ |
|
50
|
|
|
public function it_returns_theme_asset() |
|
51
|
|
|
{ |
|
52
|
|
|
$themePath = ['theme' => 'some/path.js']; |
|
53
|
|
|
|
|
54
|
|
|
$asset = $this->assetFactory->make($themePath)->url(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertEquals('http://localhost/some/path.js', $asset); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** @test */ |
|
60
|
|
|
public function it_returns_module_asset() |
|
61
|
|
|
{ |
|
62
|
|
|
$modulePath = ['module' => 'core:some/path.js']; |
|
63
|
|
|
|
|
64
|
|
|
$asset = $this->assetFactory->make($modulePath)->url(); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertEquals('//localhost/modules/core/some/path.js', $asset); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** @test */ |
|
70
|
|
|
public function it_returns_cdn_asset() |
|
71
|
|
|
{ |
|
72
|
|
|
$cdnPath = ['cdn' => 'https://js.stripe.com/v2']; |
|
73
|
|
|
|
|
74
|
|
|
$asset = $this->assetFactory->make($cdnPath)->url(); |
|
75
|
|
|
|
|
76
|
|
|
$this->assertEquals('https://js.stripe.com/v2', $asset); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.