Completed
Push — locale-in-url ( b918e2...821ef5 )
by Kamil
48:02 queued 26:12
created

it_allows_paginating_the_index_of_taxons()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Tests\Controller;
13
14
use Lakion\ApiTestCase\JsonApiTestCase;
15
use Symfony\Component\HttpFoundation\File\UploadedFile;
16
use Symfony\Component\HttpFoundation\Response;
17
18
/**
19
 * @author Anna Walasek <[email protected]>
20
 */
21
final class TaxonApiTest extends JsonApiTestCase
22
{
23
    /**
24
     * @var array
25
     */
26
    private static $authorizedHeaderWithContentType = [
27
        'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ',
28
        'CONTENT_TYPE' => 'application/json',
29
    ];
30
31
    /**
32
     * @var array
33
     */
34
    private static $authorizedHeaderWithAccept = [
35
        'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ',
36
        'ACCEPT' => 'application/json',
37
    ];
38
39
    /**
40
     * @test
41
     */
42
    public function it_does_not_allow_to_show_taxon_list_when_access_is_denied()
43
    {
44
        $this->loadFixturesFromFile('resources/taxons.yml');
45
        $this->client->request('GET', '/api/v1/taxons/');
46
47
        $response = $this->client->getResponse();
48
        $this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function it_does_not_allow_to_show_taxon_when_it_does_not_exist()
55
    {
56
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
57
58
        $this->client->request('GET', '/api/v1/taxons/-1', [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
59
60
        $response = $this->client->getResponse();
61
        $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND);
62
    }
63
64
    /**
65
     * @test
66
     */
67
    public function it_allows_indexing_taxons()
68
    {
69
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
70
        $this->loadFixturesFromFile('resources/taxons.yml');
71
72
        $this->client->request('GET', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
73
74
        $response = $this->client->getResponse();
75
        $this->assertResponse($response, 'taxon/index_response', Response::HTTP_OK);
76
    }
77
78
    /**
79
     * @test
80
     */
81
    public function it_allows_showing_taxon()
82
    {
83
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
84
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
85
        $taxon = $taxons['women'];
86
87
        $this->client->request('GET', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
88
89
        $response = $this->client->getResponse();
90
        $this->assertResponse($response, 'taxon/show_response', Response::HTTP_OK);
91
    }
92
93
    /**
94
     * @test
95
     */
96
    public function it_allows_showing_root_taxon()
97
    {
98
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
99
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
100
        $taxon = $taxons['category'];
101
102
        $this->client->request('GET', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
103
104
        $response = $this->client->getResponse();
105
        $this->assertResponse($response, 'taxon/show_root_response', Response::HTTP_OK);
106
    }
107
108
    /**
109
     * @test
110
     */
111
    public function it_does_not_allow_to_delete_taxon_if_it_does_not_exist()
112
    {
113
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
114
115
        $this->client->request('DELETE', '/api/v1/taxons/-1', [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
116
117
        $response = $this->client->getResponse();
118
        $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND);
119
    }
120
121
    /**
122
     * @test
123
     */
124
    public function it_allows_deleting_taxon()
125
    {
126
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
127
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
128
        $taxon = $taxons['men'];
129
130
        $this->client->request('DELETE', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithContentType);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
131
132
        $response = $this->client->getResponse();
133
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
134
135
        $this->client->request('GET', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
136
137
        $response = $this->client->getResponse();
138
        $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND);
139
    }
140
141
    /**
142
     * @test
143
     */
144
    public function it_allows_deleting_root_taxon()
145
    {
146
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
147
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
148
        $taxon = $taxons['category'];
149
150
        $this->client->request('DELETE', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithContentType);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
151
152
        $response = $this->client->getResponse();
153
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
154
155
        $this->client->request('GET', '/api/v1/taxons/'.$taxon->getId(), [], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
156
157
        $response = $this->client->getResponse();
158
        $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND);
159
    }
160
161
    /**
162
     * @test
163
     */
164
    public function it_allows_creating_root_taxon_with_multiple_translations()
165
    {
166
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
167
        $this->loadFixturesFromFile('resources/locales.yml');
168
169
        $data =
170
<<<EOT
171
        {
172
            "code": "fluffy_pets",
173
            "translations": {
174
                "en_US": {
175
                    "name": "Fluffy Pets",
176
                    "slug": "fluffy-pets"
177
                },
178
                "nl_NL": {
179
                    "name": "Pluizige Huisdieren",
180
                    "slug": "pluizige-huisdieren"
181
                }
182
            }
183
        }
184
EOT;
185
186
        $this->client->request('POST', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
187
188
        $response = $this->client->getResponse();
189
        $this->assertResponse($response, 'taxon/create_root_with_multiple_translations_response', Response::HTTP_CREATED);
190
    }
191
192
    /**
193
     * @test
194
     */
195
    public function it_allows_creating_root_taxon()
196
    {
197
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
198
199
        $data =
200
<<<EOT
201
        {
202
            "code": "fluffy_pets"
203
        }
204
EOT;
205
206
        $this->client->request('POST', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
207
208
        $response = $this->client->getResponse();
209
        $this->assertResponse($response, 'taxon/create_root_response', Response::HTTP_CREATED);
210
    }
211
212
    /**
213
     * @test
214
     */
215
    public function it_allows_creating_taxon_with_multiple_translations()
216
    {
217
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
218
        $this->loadFixturesFromFile('resources/locales.yml');
219
        $this->loadFixturesFromFile('resources/taxons.yml');
220
221
        $data =
222
<<<EOT
223
        {
224
            "code": "fluffy_pets",
225
            "parent": "category",
226
            "translations": {
227
                "en_US": {
228
                    "name": "Fluffy Pets",
229
                    "slug": "fluffy-pets"
230
                },
231
                "nl_NL": {
232
                    "name": "Pluizige Huisdieren",
233
                    "slug": "pluizige-huisdieren"
234
                }
235
            }
236
        }
237
EOT;
238
239
        $this->client->request('POST', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
240
241
        $response = $this->client->getResponse();
242
        $this->assertResponse($response, 'taxon/create_with_multiple_translations_response', Response::HTTP_CREATED);
243
    }
244
245
246
    /**
247
     * @test
248
     */
249
    public function it_allows_creating_taxon_with_parent()
250
    {
251
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
252
        $this->loadFixturesFromFile('resources/taxons.yml');
253
254
        $data =
255
<<<EOT
256
        {
257
            "code": "horror",
258
            "parent": "books"
259
        }
260
EOT;
261
262
        $this->client->request('POST', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
263
264
        $response = $this->client->getResponse();
265
        $this->assertResponse($response, 'taxon/create_with_parent_response', Response::HTTP_CREATED);
266
    }
267
268
    /**
269
     * @test
270
     */
271
    public function it_does_not_allow_to_create_taxon_without_required_fields()
272
    {
273
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
274
275
        $this->client->request('POST', '/api/v1/taxons/', [], [], static::$authorizedHeaderWithContentType);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
276
277
        $response = $this->client->getResponse();
278
        $this->assertResponse($response, 'taxon/create_validation_fail_response', Response::HTTP_BAD_REQUEST);
279
    }
280
281
    /**
282
     * @test
283
     */
284
    public function it_allows_creating_taxon_with_images()
285
    {
286
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
287
288
        $data =
289
<<<EOT
290
        {
291
            "code": "toys",
292
            "images": [
293
                {
294
                    "type": "ford"                
295
                },
296
                {
297
                    "type": "mugs"
298
                }
299
            ]
300
        }
301
EOT;
302
303
        $this->client->request('POST', '/api/v1/taxons/', [], [
304
            'images' => [
305
                ['file' => new UploadedFile(sprintf('%s/../Resources/fixtures/ford.jpg', __DIR__), "ford")],
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal ford does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
306
                ['file' => new UploadedFile(sprintf('%s/../Resources/fixtures/mugs.jpg', __DIR__), "mugs")],
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal mugs does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
307
            ]
308
        ], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
309
310
        $response = $this->client->getResponse();
311
        $this->assertResponse($response, 'taxon/create_with_images_response', Response::HTTP_CREATED);
312
    }
313
314
    /**
315
     * @test
316
     */
317
    public function it_allows_updating_taxon_with_parent()
318
    {
319
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
320
        $this->loadFixturesFromFile('resources/locales.yml');
321
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
322
        $taxon = $taxons["women"];
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal women does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
323
324
        $data =
325
<<<EOT
326
        {
327
            "translations": {
328
                "en_US": {
329
                  "name": "Women",
330
                  "slug": "books/women"
331
                }
332
            },
333
            "parent": "books"
334
        }
335
EOT;
336
        $this->client->request('PUT', '/api/v1/taxons/'. $taxon->getId(), [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
337
        $response = $this->client->getResponse();
338
339
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
340
    }
341
342
    /**
343
     * @test
344
     */
345
    public function it_allows_updating_root_taxon()
346
    {
347
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
348
        $this->loadFixturesFromFile('resources/locales.yml');
349
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
350
        $taxon = $taxons["category"];
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal category does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
351
352
        $data =
353
<<<EOT
354
        {
355
            "translations": {
356
                "en_US": {
357
                  "name": "Categories",
358
                  "slug": "categories"
359
                }
360
            }
361
        }
362
EOT;
363
        $this->client->request('PUT', '/api/v1/taxons/'. $taxon->getId(), [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
364
        $response = $this->client->getResponse();
365
366
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
367
    }
368
369
    /**
370
     * @test
371
     */
372
    public function it_allows_updating_partial_information_about_taxon()
373
    {
374
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
375
        $this->loadFixturesFromFile('resources/locales.yml');
376
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
377
        $taxon = $taxons["women"];
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal women does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
378
379
        $data =
380
<<<EOT
381
        {
382
            "translations": {
383
                "en_US": {
384
                    "name": "Girl",
385
                    "slug": "girl"
386
                }
387
            }
388
        }
389
EOT;
390
        $this->client->request('PATCH', '/api/v1/taxons/'. $taxon->getId(), [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
391
        $response = $this->client->getResponse();
392
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
393
    }
394
395
    /**
396
     * @test
397
     */
398
    public function it_allows_updating_partial_information_about_root_taxon()
399
    {
400
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
401
        $this->loadFixturesFromFile('resources/locales.yml');
402
        $taxons = $this->loadFixturesFromFile('resources/taxons.yml');
403
        $taxon = $taxons["category"];
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal category does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
404
405
        $data =
406
<<<EOT
407
        {
408
            "translations": {
409
                "en_US": {
410
                    "name": "Category",
411
                    "slug": "category"
412
                }
413
            }
414
        }
415
EOT;
416
        $this->client->request('PATCH', '/api/v1/taxons/'. $taxon->getId(), [], [], static::$authorizedHeaderWithContentType, $data);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
417
        $response = $this->client->getResponse();
418
        $this->assertResponseCode($response, Response::HTTP_NO_CONTENT);
419
    }
420
421
    /**
422
     * @test
423
     */
424
    public function it_allows_paginating_the_index_of_taxons()
425
    {
426
        $this->loadFixturesFromFile('authentication/api_administrator.yml');
427
        $this->loadFixturesFromFile('resources/taxons.yml');
428
        $this->loadFixturesFromFile('resources/many_taxons.yml');
429
430
        $this->client->request('GET', '/api/v1/taxons/', ['page' => 2], [], static::$authorizedHeaderWithAccept);
0 ignored issues
show
Comprehensibility introduced by
Since Sylius\Tests\Controller\TaxonApiTest is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
431
        $response = $this->client->getResponse();
432
        $this->assertResponse($response, 'taxon/paginated_index_response');
433
    }
434
}
435