AssetSourceTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 11
c 2
b 0
f 1
dl 0
loc 28
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_check() 0 8 1
A data_check() 0 7 1
1
<?php
2
3
namespace ByTIC\Assets\Tests\Assets\Asset;
4
5
use ByTIC\Assets\Assets\Asset;
6
use ByTIC\Assets\Assets\Asset\AssetSource;
7
use ByTIC\Assets\Tests\AbstractTest;
8
9
/**
10
 * Class AssetSourceTest
11
 * @package ByTIC\Assets\Tests\Assets\Asset
12
 */
13
class AssetSourceTest extends AbstractTest
14
{
15
    /**
16
     * @dataProvider data_check
17
     * @param $source
18
     * @param $type
19
     * @param $output
20
     */
21
    public function test_check($source, $type, $output)
22
    {
23
        $mock = \Mockery::mock(AssetSource::class)->shouldAllowMockingProtectedMethods()->makePartial();
24
        $mock->shouldReceive('transformSourceWithAsset')->andReturnUsing(function ($argument) {
25
            return '/assets'.$argument;
26
        });
27
        $source = $mock->buildSource($source, $type);
28
        self::assertSame($output, $source);
29
    }
30
31
    /**
32
     * @return array[]
33
     */
34
    public function data_check()
35
    {
36
        return [
37
            ['http://test.com/css', Asset::TYPE_STYLES, 'http://test.com/css'],
38
            ['test.css', Asset::TYPE_STYLES, 'test.css'],
39
            ['test', Asset::TYPE_STYLES, '/assets/stylesheets/test.css'],
40
            ['test', Asset::TYPE_SCRIPTS, '/assets/scripts/test.js'],
41
        ];
42
    }
43
}
44