Completed
Pull Request — master (#13)
by Pierre
12:10 queued 09:45
created

CssEmbedTestable::mimeType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
    public function testEmbedCss()
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
    public function testEmbedString()
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
    public function mimeTypeProvider()
40
    {
41
        return array(
42
          array('application/octet-stream', 'binary.file'),
43
          array('image/gif', 'php.gif')
44
        );
45
    }
46
47
    /**
48
     * @dataProvider mimeTypeProvider
49
     */
50
    public function testMimeType($expected, $file)
51
    {
52
        $cssEmbed = new CssEmbedTestable();
53
        $file = __DIR__.'/rsc/'.$file;
54
        $this->assertEquals($expected, $cssEmbed->mimeType($file));
55
    }
56
}
57
58
class CssEmbedTestable extends CssEmbed
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
59
{
60
    public function mimeType($file)
61
    {
62
        return parent::mimeType($file);
63
    }
64
}
65