Completed
Pull Request — master (#17)
by
unknown
02:40
created

CssEmbedTest::testSetOptions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 14
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 14
loc 14
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
/**
3
 * For the full copyright and license information, please view the LICENSE
4
 * file that was distributed with this source code.
5
 *  11/05/12 17:20
6
 */
7
namespace CssEmbed\Tests;
8
9
use CssEmbed\CssEmbed;
10
11
/**
12
 * @author Pierre Tachoire <[email protected]>
13
 */
14
class CssEmbedTest extends \PHPUnit_Framework_TestCase
15
{
16 View Code Duplication
    public function testEmbedCss()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        $origin = __DIR__.'/rsc/test.css';
19
        $expected = file_get_contents(__DIR__.'/rsc/expected.css');
20
21
        $cssEmbed = new CssEmbed();
22
        $tested = $cssEmbed->embedCss($origin);
23
24
        $this->assertEquals($expected, $tested);
25
    }
26
27 View Code Duplication
    public function testEmbedString()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $origin = file_get_contents(__DIR__.'/rsc/test.css');
30
        $expected = file_get_contents(__DIR__.'/rsc/expected.css');
31
32
        $cssEmbed = new CssEmbed();
33
        $cssEmbed->setRootDir(__DIR__.'/rsc');
34
        $tested = $cssEmbed->embedString($origin);
35
36
        $this->assertEquals($expected, $tested);
37
    }
38
39 View Code Duplication
    public function testMimeTypes()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $origin = file_get_contents(__DIR__.'/rsc/test-mime.css');
42
        $expected = file_get_contents(__DIR__.'/rsc/expected-mime.css');
43
44
        $cssEmbed = new CssEmbed();
45
        $cssEmbed->setRootDir(__DIR__.'/rsc');
46
        $cssEmbed->enableEnhancedMimeTypes();
47
        $tested = $cssEmbed->embedString($origin);
48
49
        $this->assertEquals($expected, $tested);
50
    }
51
52 View Code Duplication
    public function testSetOptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
53
    {
54
        $origin = file_get_contents(__DIR__.'/rsc/test-options.css');
55
        $expected = file_get_contents(__DIR__.'/rsc/expected-options.css');
56
57
        $cssEmbed = new CssEmbed();
58
        $cssEmbed->enableEnhancedMimeTypes();
59
        $cssEmbed->setOptions(CssEmbed::URL_ON_ERROR|CssEmbed::EMBED_FONTS|CssEmbed::EMBED_SVG);
60
        
61
        $cssEmbed->setRootDir(__DIR__.'/rsc');
62
        $tested = $cssEmbed->embedString($origin);
63
64
        $this->assertEquals($expected, $tested);
65
    }
66
67 View Code Duplication
    public function testHttpEnabledEmbedCss()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    { 
69
        $origin = __DIR__.'/rsc/test-http-enabled.css';
70
        $expected = file_get_contents(__DIR__.'/rsc/expected-http-enabled.css');
71
72
        $cssEmbed = new CssEmbed();
73
        $cssEmbed->enableHttp();
74
        $tested = $cssEmbed->embedCss($origin);
75
76
        $this->assertEquals($expected, $tested);
77
    }
78
79 View Code Duplication
    public function testHttpEnabledEmbedString()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
    {
81
        $origin = file_get_contents(__DIR__.'/rsc/test-http-remote.css');
82
        $expected = file_get_contents(__DIR__.'/rsc/expected-http-remote.css');
83
84
        $cssEmbed = new CssEmbed();
85
        $cssEmbed->enableHttp();
86
        $cssEmbed->setRootDir('//httpbin.org/media/hypothetical-css-dir');
87
        $tested = $cssEmbed->embedString($origin);
88
        $this->assertEquals($expected, $tested);
89
    }
90
91 View Code Duplication
    public function testHttpEnabledEnableOptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93
        $origin = file_get_contents(__DIR__.'/rsc/test-http-options.css');
94
        $expected = file_get_contents(__DIR__.'/rsc/expected-http-options.css');
95
96
        $cssEmbed = new CssEmbed();
97
98
        $cssEmbed->enableHttp(
99
            true,
100
            CssEmbed::HTTP_DEFAULT_HTTPS|CssEmbed::HTTP_EMBED_SCHEME|CssEmbed::HTTP_EMBED_URL_ONLY
101
        );
102
        $cssEmbed->setRootDir('//httpbin.org/media/hypothetical-css-dir');
103
        $tested = $cssEmbed->embedString($origin);
104
105
        $this->assertEquals($expected, $tested);
106
107
    }
108
}
109
110
111