1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace Aimeos\Shop\Tests\Unit\Controller; |
5
|
|
|
|
6
|
|
|
|
7
|
|
|
class AbstractControllerTest extends \Neos\Flow\Tests\UnitTestCase |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
private $object; |
10
|
|
|
private $view; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
public function setUp() |
14
|
|
|
{ |
15
|
|
|
$this->object = $this->getMockBuilder( '\Aimeos\Shop\Controller\AbstractController' ) |
16
|
|
|
->disableOriginalConstructor() |
17
|
|
|
->getMock(); |
18
|
|
|
|
19
|
|
|
$this->view = $this->getMockBuilder( '\Neos\Flow\Mvc\View\JsonView' ) |
20
|
|
|
->setMethods( array( 'assign' ) ) |
21
|
|
|
->disableOriginalConstructor() |
22
|
|
|
->getMock(); |
23
|
|
|
|
24
|
|
|
$this->inject( $this->object, 'view', $this->view ); |
25
|
|
|
|
26
|
|
|
$request = $this->getMockBuilder( '\Neos\Flow\Mvc\ActionRequest' ) |
27
|
|
|
->disableOriginalConstructor() |
28
|
|
|
->getMock(); |
29
|
|
|
|
30
|
|
|
$this->inject( $this->object, 'request', $request ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @test |
36
|
|
|
*/ |
37
|
|
|
public function getOutput() |
38
|
|
|
{ |
39
|
|
|
$aimeos = new \Aimeos\Shop\Base\Aimeos(); |
40
|
|
|
$this->inject( $this->object, 'aimeos', $aimeos ); |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
$context = $this->getMockBuilder( '\Aimeos\Shop\Base\Context' ) |
44
|
|
|
->setMethods( array( 'get' ) ) |
45
|
|
|
->disableOriginalConstructor() |
46
|
|
|
->getMock(); |
47
|
|
|
|
48
|
|
|
$ctx = new \Aimeos\MShop\Context\Item\Standard(); |
49
|
|
|
$ctx->setConfig( new \Aimeos\MW\Config\PHPArray() ); |
50
|
|
|
$ctx->setLocale( new \Aimeos\MShop\Locale\Item\Standard( array( 'langid' => 'de' ) ) ); |
51
|
|
|
|
52
|
|
|
$context->expects( $this->once() )->method( 'get' ) |
53
|
|
|
->will( $this->returnValue( $ctx ) ); |
54
|
|
|
|
55
|
|
|
$this->inject( $this->object, 'context', $context ); |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
$viewContainer = $this->getMockBuilder( '\Aimeos\Shop\Base\View' ) |
59
|
|
|
->setMethods( array( 'create' ) ) |
60
|
|
|
->disableOriginalConstructor() |
61
|
|
|
->getMock(); |
62
|
|
|
|
63
|
|
|
$mwView = new \Aimeos\MW\View\Standard(); |
64
|
|
|
|
65
|
|
|
$viewContainer->expects( $this->once() )->method( 'create' ) |
66
|
|
|
->will( $this->returnValue( $mwView ) ); |
67
|
|
|
|
68
|
|
|
$this->inject( $this->object, 'viewContainer', $viewContainer ); |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
$uriBuilder = $this->getMockBuilder( '\Neos\Flow\Mvc\Routing\UriBuilder' ) |
72
|
|
|
->disableOriginalConstructor() |
73
|
|
|
->getMock(); |
74
|
|
|
|
75
|
|
|
$this->inject( $this->object, 'uriBuilder', $uriBuilder ); |
76
|
|
|
|
77
|
|
|
|
78
|
|
|
$client = $this->getMockBuilder( '\Aimeos\Client\Html\Catalog\Lists\Standard' ) |
79
|
|
|
->setMethods( array( 'getBody', 'getHeader', 'process') ) |
80
|
|
|
->disableOriginalConstructor() |
81
|
|
|
->getMock(); |
82
|
|
|
|
83
|
|
|
$client->expects( $this->once() )->method( 'getBody' ) |
84
|
|
|
->will( $this->returnValue( 'body' ) ); |
85
|
|
|
|
86
|
|
|
$client->expects( $this->once() )->method( 'getHeader' ) |
87
|
|
|
->will( $this->returnValue( 'header' ) ); |
88
|
|
|
|
89
|
|
|
$client->expects( $this->once() )->method( 'process' ); |
90
|
|
|
|
91
|
|
|
\Aimeos\Client\Html\Catalog\Lists\Factory::injectClient( '\Aimeos\Client\Html\Catalog\Lists\Standard', $client ); |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
$this->view->expects( $this->once() )->method( 'assign' ) |
95
|
|
|
->with( $this->equalTo( 'aimeos_component_header' ), $this->equalTo( 'header' ) ); |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
$class = new \ReflectionClass( '\Aimeos\Shop\Controller\AbstractController' ); |
99
|
|
|
$method = $class->getMethod( 'getOutput' ); |
100
|
|
|
$method->setAccessible( true ); |
101
|
|
|
|
102
|
|
|
|
103
|
|
|
$result = $method->invokeArgs( $this->object, array( 'catalog/lists' ) ); |
104
|
|
|
|
105
|
|
|
$this->assertEquals( 'body', $result ); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* @test |
111
|
|
|
*/ |
112
|
|
|
public function get() |
113
|
|
|
{ |
114
|
|
|
$expected = array( 'aibody' => 'body', 'aiheader' => 'header' ); |
115
|
|
|
|
116
|
|
|
$shop = $this->getMockBuilder( '\Aimeos\Shop\Base\Shop' ) |
117
|
|
|
->setMethods( array( 'get' ) ) |
118
|
|
|
->disableOriginalConstructor() |
119
|
|
|
->getMock(); |
120
|
|
|
|
121
|
|
|
$this->inject( $this->object, 'shop', $shop ); |
122
|
|
|
|
123
|
|
|
$shop->expects( $this->once() )->method( 'get' ) |
124
|
|
|
->will( $this->returnValue( $expected ) ); |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
$class = new \ReflectionClass( '\Aimeos\Shop\Controller\AbstractController' ); |
128
|
|
|
$method = $class->getMethod( 'get' ); |
129
|
|
|
$method->setAccessible( true ); |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
$result = $method->invokeArgs( $this->object, array( 'test' ) ); |
133
|
|
|
|
134
|
|
|
$this->assertEquals( $expected, $result ); |
135
|
|
|
} |
136
|
|
|
} |
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