1 | <?php |
||
2 | /** |
||
3 | * Copyright (c) 2019. Volodymyr Hryvinskyi. All rights reserved. |
||
4 | * @author: <mailto:[email protected]> |
||
5 | * @github: <https://github.com/hryvinskyi> |
||
6 | */ |
||
7 | |||
8 | declare(strict_types=1); |
||
9 | |||
10 | namespace Hryvinskyi\DeferJs\Test\Unit\Model; |
||
11 | |||
12 | use Hryvinskyi\DeferJs\Helper\Config; |
||
13 | use Hryvinskyi\DeferJs\Model\Minify\MinifyJsInterface; |
||
14 | use Hryvinskyi\DeferJs\Model\MoveJsToFooter; |
||
15 | use Hryvinskyi\DeferJs\Model\PassesValidator\ValidateSkipper; |
||
16 | use Magento\Framework\App\Response\Http; |
||
17 | use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
||
18 | use PHPUnit\Framework\TestCase; |
||
0 ignored issues
–
show
|
|||
19 | |||
20 | class MoveJsToFooterTest extends TestCase |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * @var Config|\PHPUnit_Framework_MockObject_MockObject |
||
25 | */ |
||
26 | private $config; |
||
27 | |||
28 | /** |
||
29 | * @var MinifyJsInterface|\PHPUnit_Framework_MockObject_MockObject |
||
30 | */ |
||
31 | private $minifyJs; |
||
32 | |||
33 | /** |
||
34 | * @var ValidateSkipper|\PHPUnit_Framework_MockObject_MockObject |
||
35 | */ |
||
36 | private $validateSkipper; |
||
37 | |||
38 | /** |
||
39 | * @var Http |
||
40 | */ |
||
41 | private $http; |
||
42 | |||
43 | /** |
||
44 | * @var MoveJsToFooter |
||
45 | */ |
||
46 | private $model; |
||
47 | |||
48 | /** |
||
49 | * Sets up the fixture |
||
50 | * |
||
51 | * @return void |
||
52 | */ |
||
53 | protected function setUp() |
||
54 | { |
||
55 | $this->config = $this->createPartialMock( |
||
56 | Config::class, |
||
57 | ['isMinifyBodyScript'] |
||
58 | ); |
||
59 | |||
60 | $this->minifyJs = $this->createPartialMock( |
||
61 | MinifyJsInterface::class, |
||
62 | ['execute'] |
||
63 | ); |
||
64 | |||
65 | $this->validateSkipper = $this->createPartialMock( |
||
66 | ValidateSkipper::class, |
||
67 | ['execute'] |
||
68 | ); |
||
69 | |||
70 | $this->http = (new ObjectManager($this))->getObject(Http::class); |
||
71 | $this->model = (new ObjectManager($this))->getObject(MoveJsToFooter::class, [ |
||
72 | 'config' => $this->config, |
||
73 | 'minifyJs' => $this->minifyJs, |
||
74 | 'validateSkipper' => $this->validateSkipper, |
||
75 | ]); |
||
76 | } |
||
77 | |||
78 | public function testExecute(): void |
||
79 | { |
||
80 | $beforeBody = '<!DOCTYPE html>' . |
||
81 | '<html>' . |
||
82 | '<head>' . |
||
83 | '<script> <!-- ko i18n: \'test\' --> <!-- /ko --> </script>' . |
||
84 | '</head>' . |
||
85 | '<body>' . |
||
86 | '<h1>My First Heading</h1>' . |
||
87 | '<p>My first paragraph.</p>' . |
||
88 | '</body>' . |
||
89 | '</html>'; |
||
90 | |||
91 | $afterBody = '<!DOCTYPE html>' . |
||
92 | '<html>' . |
||
93 | '<head></head>' . |
||
94 | '<body>' . |
||
95 | '<h1>My First Heading</h1>' . |
||
96 | '<p>My first paragraph.</p>' . |
||
97 | '<script> <!-- ko i18n: \'test\' --> <!-- /ko --> </script>' . |
||
98 | '</body>' . |
||
99 | '</html>'; |
||
100 | $this->http->setBody($beforeBody); |
||
101 | $this->model->execute($this->http); |
||
102 | |||
103 | |||
104 | $this->assertEquals($this->http->getBody(), $afterBody); |
||
105 | } |
||
106 | } |
||
107 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths