1 | <?php |
||
2 | |||
3 | namespace Aimeos\Shop\Tests\Functional\Controller; |
||
4 | |||
5 | use Neos\Flow\Annotations as Flow; |
||
6 | |||
7 | |||
8 | class JsonapiControllerTest extends \Neos\Flow\Tests\FunctionalTestCase |
||
0 ignored issues
–
show
|
|||
9 | { |
||
10 | public function testOptionsAction() |
||
11 | { |
||
12 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi', 'OPTIONS' ); |
||
13 | $json = json_decode( $response->getContent(), true ); |
||
14 | |||
15 | $this->assertNotNull( $json ); |
||
16 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
17 | $this->assertArrayHasKey( 'resources', $json['meta'] ); |
||
18 | $this->assertGreaterThan( 1, count( $json['meta']['resources'] ) ); |
||
19 | } |
||
20 | |||
21 | |||
22 | public function testGetAction() |
||
23 | { |
||
24 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap']]; |
||
25 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi/product', 'GET', $params ); |
||
26 | $json = json_decode( $response->getContent(), true ); |
||
27 | |||
28 | $this->assertNotNull( $json ); |
||
29 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
30 | $this->assertEquals( 2, $json['meta']['total'] ); |
||
31 | $this->assertEquals( 2, count( $json['data'] ) ); |
||
32 | $this->assertArrayHasKey( 'id', $json['data'][0] ); |
||
33 | $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
||
34 | |||
35 | $id = $json['data'][0]['id']; |
||
36 | |||
37 | |||
38 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi/product', 'GET', ['id' => $id] ); |
||
39 | $json = json_decode( $response->getContent(), true ); |
||
40 | |||
41 | $this->assertNotNull( $json ); |
||
42 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
43 | $this->assertEquals( 1, $json['meta']['total'] ); |
||
44 | $this->assertArrayHasKey( 'id', $json['data'] ); |
||
45 | $this->assertEquals( 'CNC', $json['data']['attributes']['product.code'] ); |
||
46 | } |
||
47 | |||
48 | |||
49 | /* |
||
50 | * @Flow\Session(autoStart = TRUE) |
||
51 | */ |
||
52 | public function testPostAction() |
||
53 | { |
||
54 | // get CNC product |
||
55 | $params = ['filter' => ['f_search' => 'Cafe Noire Cap', 'f_listtype' => 'unittype19']]; |
||
56 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi/product', 'GET', $params ); |
||
57 | $json = json_decode( $response->getContent(), true ); |
||
58 | $this->assertEquals( 'CNC', $json['data'][0]['attributes']['product.code'] ); |
||
59 | |||
60 | // add CNC product to basket |
||
61 | $params = ['id' => 'default', 'related' => 'product']; |
||
62 | $content = json_encode( ['data' => ['attributes' => ['product.id' => $json['data'][0]['id']]]] ); |
||
63 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi/basket', 'POST', $params, [], [], $content ); |
||
64 | $json = json_decode( $response->getContent(), true ); |
||
65 | |||
66 | $this->assertEquals( 201, $response->getStatusCode() ); |
||
67 | $this->assertEquals( 'CNC', $json['included'][0]['attributes']['order.base.product.prodcode'] ); |
||
68 | } |
||
69 | |||
70 | |||
71 | public function testPutAction() |
||
72 | { |
||
73 | $response = $this->browser->request( 'http://localhost/unittest/jsonapi/basket', 'PUT' ); |
||
74 | $json = json_decode( $response->getContent(), true ); |
||
75 | $this->assertArrayHasKey( 'errors', $json ); |
||
76 | } |
||
77 | } |
||
78 |
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