mixFunctionReturnManifest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Iulyanp\ElixirMixBundle\Tests\Twig;
4
5
use Iulyanp\ElixirMixBundle\Twig\MixExtension;
6
use PHPUnit_Framework_TestCase;
7
8
/**
9
 * Class ElixirMixExtensionTest
10
 */
11
class ElixirMixExtensionTest extends PHPUnit_Framework_TestCase
12
{
13
    const WEB_DIR = __DIR__.'/stub';
14
15
    /**
16
     * @var MixExtension
17
     */
18
    private $mixExtension;
19
20
    /**
21
     * Set UP.
22
     *
23
     * Instantiate ElixirExtension for all tests
24
     */
25
    public function setUp()
26
    {
27
        $this->mixExtension = new MixExtension(self::WEB_DIR);
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function mixFunctionReturnManifest()
34
    {
35
        $this->assertEquals(
36
            'css/app-db9165hf67.css',
37
            $this->mixExtension->mix('css/app.css')
38
        );
39
        $this->assertEquals(
40
            'css/index-9rt53c9u67.css',
41
            $this->mixExtension->mix('css/index.css')
42
        );
43
        $this->assertEquals(
44
            'js/app-db9183c967.js',
45
            $this->mixExtension->mix('js/app.js')
46
        );
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function elixirFunctionThrowsErrorWhenFileNotExists()
53
    {
54
        $this->expectException('\Exception');
55
        $this->expectExceptionMessage(
56
            'The "css/not_existing.css" key could not be found in the manifest file. '.
57
            'Please pass just the asset filename as a parameter to the mix() method.'
58
        );
59
        $this->mixExtension->mix('css/not_existing.css');
60
    }
61
}
62