Conditions | 1 |
Paths | 1 |
Total Lines | 71 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
79 | public function testActionsBulk() |
||
80 | { |
||
81 | $content = '{"data":[ |
||
82 | {"type":"stock/type","attributes":{"stock.type.code":"flow","stock.type.label":"flow"}}, |
||
83 | {"type":"stock/type","attributes":{"stock.type.code":"flow2","stock.type.label":"flow"}} |
||
84 | ]}'; |
||
85 | $response = $this->browser->request( 'http://localhost/unittest/jsonadm/stock%2Ftype', 'POST', [], [], [], $content ); |
||
86 | $json = json_decode( $response->getContent(), true ); |
||
87 | |||
88 | $this->assertNotNull( $json ); |
||
89 | $this->assertEquals( 201, $response->getStatusCode() ); |
||
90 | $this->assertEquals( 2, count( $json['data'] ) ); |
||
91 | $this->assertArrayHasKey( 'stock.type.id', $json['data'][0]['attributes'] ); |
||
92 | $this->assertArrayHasKey( 'stock.type.id', $json['data'][1]['attributes'] ); |
||
93 | $this->assertEquals( 'flow', $json['data'][0]['attributes']['stock.type.label'] ); |
||
94 | $this->assertEquals( 'flow', $json['data'][1]['attributes']['stock.type.label'] ); |
||
95 | $this->assertEquals( 2, $json['meta']['total'] ); |
||
96 | |||
97 | $ids = array( $json['data'][0]['attributes']['stock.type.id'], $json['data'][1]['attributes']['stock.type.id'] ); |
||
98 | |||
99 | |||
100 | $content = '{"data":[ |
||
101 | {"type":"stock/type","id":' . $ids[0] . ',"attributes":{"stock.type.label":"flow2"}}, |
||
102 | {"type":"stock/type","id":' . $ids[1] . ',"attributes":{"stock.type.label":"flow2"}} |
||
103 | ]}'; |
||
104 | $response = $this->browser->request( 'http://localhost/unittest/jsonadm/stock%2Ftype', 'PATCH', [], [], [], $content ); |
||
105 | $json = json_decode( $response->getContent(), true ); |
||
106 | |||
107 | $this->assertNotNull( $json ); |
||
108 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
109 | $this->assertEquals( 2, count( $json['data'] ) ); |
||
110 | $this->assertArrayHasKey( 'stock.type.id', $json['data'][0]['attributes'] ); |
||
111 | $this->assertArrayHasKey( 'stock.type.id', $json['data'][1]['attributes'] ); |
||
112 | $this->assertEquals( 'flow2', $json['data'][0]['attributes']['stock.type.label'] ); |
||
113 | $this->assertEquals( 'flow2', $json['data'][1]['attributes']['stock.type.label'] ); |
||
114 | $this->assertTrue( in_array( $json['data'][0]['attributes']['stock.type.id'], $ids ) ); |
||
115 | $this->assertTrue( in_array( $json['data'][1]['attributes']['stock.type.id'], $ids ) ); |
||
116 | $this->assertEquals( 2, $json['meta']['total'] ); |
||
117 | |||
118 | |||
119 | $getParams = array( 'filter' => array( '&&' => array( |
||
120 | array( '=~' => array( 'stock.type.code' => 'flow' ) ), |
||
121 | array( '==' => array( 'stock.type.label' => 'flow2' ) ) |
||
122 | ) ), |
||
123 | 'sort' => 'stock.type.code', 'page' => array( 'offset' => 0, 'limit' => 3 ) |
||
124 | ); |
||
125 | $response = $this->browser->request( 'http://localhost/unittest/jsonadm/stock%2Ftype', 'GET', $getParams ); |
||
126 | $json = json_decode( $response->getContent(), true ); |
||
127 | |||
128 | $this->assertNotNull( $json ); |
||
129 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
130 | $this->assertEquals( 2, count( $json['data'] ) ); |
||
131 | $this->assertEquals( 'flow', $json['data'][0]['attributes']['stock.type.code'] ); |
||
132 | $this->assertEquals( 'flow2', $json['data'][1]['attributes']['stock.type.code'] ); |
||
133 | $this->assertEquals( 'flow2', $json['data'][0]['attributes']['stock.type.label'] ); |
||
134 | $this->assertEquals( 'flow2', $json['data'][1]['attributes']['stock.type.label'] ); |
||
135 | $this->assertTrue( in_array( $json['data'][0]['attributes']['stock.type.id'], $ids ) ); |
||
136 | $this->assertTrue( in_array( $json['data'][1]['attributes']['stock.type.id'], $ids ) ); |
||
137 | $this->assertEquals( 2, $json['meta']['total'] ); |
||
138 | |||
139 | |||
140 | $content = '{"data":[ |
||
141 | {"type":"stock/type","id":' . $ids[0] . '}, |
||
142 | {"type":"stock/type","id":' . $ids[1] . '} |
||
143 | ]}'; |
||
144 | $response = $this->browser->request( 'http://localhost/unittest/jsonadm/stock%2Ftype', 'DELETE', [], [], [], $content ); |
||
145 | $json = json_decode( $response->getContent(), true ); |
||
146 | |||
147 | $this->assertNotNull( $json ); |
||
148 | $this->assertEquals( 200, $response->getStatusCode() ); |
||
149 | $this->assertEquals( 2, $json['meta']['total'] ); |
||
150 | } |
||
152 |
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