Passed
Push — master ( 75387a...e2c3a7 )
by Iman
02:08
created

WidgetMinificationTest::test_minifies_the_output()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 12

Duplication

Lines 19
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 12
c 0
b 0
f 0
nc 1
nop 0
dl 19
loc 19
rs 9.4285
1
<?php
2
3
require_once 'test_stubs.php';
4
5
class WidgetMinificationTest extends TestCase
6
{
7
    public function test_minifies_the_output()
8
    {
9
        config(['widgetize.minify_html' => true]);
10
        config(['widgetize.debug_info' => false]);
11
12
        app()['env'] = 'local';
13
14
        $widgetOutput = '  <p>        </p>  ';
15
        $minified = ' <p> </p> ';
16
17
        View::shouldReceive('exists')->once()->andReturn(true);
18
        View::shouldReceive('make')->once()->with('hello', ['data' => null], [])->andReturn(app('view'));
19
        View::shouldReceive('render')->once()->andReturn($widgetOutput);
20
21
        //act
22
        $widget = new Widget7();
23
        $widgetOutput = render_widget($widget);
24
        $this->assertEquals($minified, $widgetOutput);
25
    }
26
27
    public function test_minifies_the_output_in_production_with_cache_turned_off()
28
    {
29
        config(['widgetize.minify_html' => false]);
30
        config(['widgetize.debug_info' => false]);
31
        app()['env'] = 'production';
32
33
        $html = '  <p>        </p>  ';
34
        $minified = ' <p> </p> ';
35
36
        View::shouldReceive('exists')->once()->andReturn(true);
37
        View::shouldReceive('make')->once()->with('hello', ['data' => null], [])->andReturn(app('view'));
38
        View::shouldReceive('render')->once()->andReturn($html);
39
40
        //act
41
        $widget = new Widget7();
42
        $html = render_widget($widget);
43
        $this->assertEquals($minified, $html);
44
    }
45
}
46