summaryrefslogtreecommitdiff
path: root/plugins/Minify/extlib/minify/min_unit_tests/test_Minify_ImportProcessor.php
blob: 52b19ff2361b4a09c5394e7422027261afada2eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php

require_once '_inc.php';

require_once 'Minify/ImportProcessor.php';

function test_Minify_ImportProcessor()
{
    global $thisDir;
    
    $linDir = $thisDir . '/_test_files/importProcessor';
    
    $testFilesUri = substr(
        realpath($thisDir . '/_test_files')
        ,strlen(realpath($_SERVER['DOCUMENT_ROOT']))
    );
    $testFilesUri = str_replace('\\', '/', $testFilesUri);
        
    $expected = str_replace(
        '%TEST_FILES_URI%'
        ,$testFilesUri
        ,file_get_contents($linDir . '/output.css')
    );
    
    $actual = Minify_ImportProcessor::process($linDir . '/input.css');

    $passed = assertTrue($expected === $actual, 'ImportProcessor');
    
    if (__FILE__ === realpath($_SERVER['SCRIPT_FILENAME'])) {
        echo "\n---Output: " .strlen($actual). " bytes\n\n{$actual}\n\n";
        if (!$passed) {
            echo "---Expected: " .strlen($expected). " bytes\n\n{$expected}\n\n\n";
        }
    }
    
    $expectedIncludes = array (
        realpath($linDir .  '/input.css')
        ,realpath($linDir . '/adjacent.css')
        ,realpath($linDir . '/../css/styles.css')
        ,realpath($linDir . '/1/tv.css')
        ,realpath($linDir . '/1/adjacent.css')
    );
    
    $passed = assertTrue($expectedIncludes === Minify_ImportProcessor::$filesIncluded
        , 'ImportProcessor : included right files in right order');
}

test_Minify_ImportProcessor();