| @@ 50-59 (lines=10) @@ | ||
| 47 | * |
|
| 48 | * @return void |
|
| 49 | */ |
|
| 50 | public function testItemSchema() |
|
| 51 | { |
|
| 52 | $client = static::createRestClient(); |
|
| 53 | $this->getRequest($client, '/schema/testcase/translatable-array/item'); |
|
| 54 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
|
| 55 | ||
| 56 | $schema = $client->getResults(); |
|
| 57 | $this->assertEquals('object', $schema->type); |
|
| 58 | $this->assertItemSchema($schema); |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * Test collection schema |
|
| @@ 83-91 (lines=9) @@ | ||
| 80 | * |
|
| 81 | * @return void |
|
| 82 | */ |
|
| 83 | public function testCheckGetOne() |
|
| 84 | { |
|
| 85 | $client = static::createRestClient(); |
|
| 86 | $this->getRequest($client, '/testcase/translatable-array/testdata'); |
|
| 87 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
|
| 88 | $this->assertNotEmpty($client->getResults()); |
|
| 89 | ||
| 90 | $this->assertFixtureData($client->getResults()); |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Test GET all method |
|
| @@ 98-106 (lines=9) @@ | ||
| 95 | * |
|
| 96 | * @return void |
|
| 97 | */ |
|
| 98 | public function testCheckGetAll() |
|
| 99 | { |
|
| 100 | $client = static::createRestClient(); |
|
| 101 | $this->getRequest($client, '/testcase/translatable-array/'); |
|
| 102 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
|
| 103 | $this->assertCount(1, $client->getResults()); |
|
| 104 | ||
| 105 | $this->assertFixtureData($client->getResults()[0]); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Test POST method |
|
| @@ 41-51 (lines=11) @@ | ||
| 38 | * |
|
| 39 | * @return void |
|
| 40 | */ |
|
| 41 | public function testAllowedMethod() |
|
| 42 | { |
|
| 43 | $client = static::createRestClient(); |
|
| 44 | $client->request('GET', "/testcase/readonly/"); |
|
| 45 | ||
| 46 | $response = $client->getResponse(); |
|
| 47 | $result = $client->getResults(); |
|
| 48 | ||
| 49 | $this->assertEquals(Response::HTTP_OK, $response->getStatusCode()); |
|
| 50 | $this->assertCount(2, $result); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * test not allowed methods of a readOnly service |
|
| @@ 48-56 (lines=9) @@ | ||
| 45 | * |
|
| 46 | * @return void |
|
| 47 | */ |
|
| 48 | public function testPutMethodIncludeRequiredTranslatable($data, $complainField, $errorMessage) |
|
| 49 | { |
|
| 50 | $client = static::createRestClient(); |
|
| 51 | $client->put('/testcase/translatable-required/testdata', $data); |
|
| 52 | ||
| 53 | $this->assertEquals(Response::HTTP_BAD_REQUEST, $client->getResponse()->getStatusCode()); |
|
| 54 | $this->assertSame($complainField, $client->getResults()[0]->propertyPath); |
|
| 55 | $this->assertSame($errorMessage, $client->getResults()[0]->message); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * Posts that the backend shall accept |
|
| @@ 243-250 (lines=8) @@ | ||
| 240 | * @param integer $limit limit value that should fail |
|
| 241 | * @return void |
|
| 242 | */ |
|
| 243 | public function testInvalidPagingPageSize($limit) |
|
| 244 | { |
|
| 245 | $client = static::createRestClient(); |
|
| 246 | $client->request('GET', sprintf('/core/app/?limit(%s)', $limit)); |
|
| 247 | ||
| 248 | $this->assertEquals(Response::HTTP_BAD_REQUEST, $client->getResponse()->getStatusCode()); |
|
| 249 | $this->assertContains('negative or null limit in rql', $client->getResults()->message); |
|
| 250 | } |
|
| 251 | ||
| 252 | /** |
|
| 253 | * page size test provides |
|
| @@ 275-287 (lines=13) @@ | ||
| 272 | * |
|
| 273 | * @return void |
|
| 274 | */ |
|
| 275 | public function testFindByAppRef($ref, $url, $count) |
|
| 276 | { |
|
| 277 | $url = sprintf( |
|
| 278 | '/core/module/?%s=%s', |
|
| 279 | $this->encodeRqlString($ref), |
|
| 280 | $this->encodeRqlString($url) |
|
| 281 | ); |
|
| 282 | ||
| 283 | $client = static::createRestClient(); |
|
| 284 | $client->request('GET', $url); |
|
| 285 | $results = $client->getResults(); |
|
| 286 | $this->assertCount($count, $results); |
|
| 287 | } |
|
| 288 | ||
| 289 | /** |
|
| 290 | * @return array |
|
| @@ 60-69 (lines=10) @@ | ||
| 57 | * |
|
| 58 | * @return void |
|
| 59 | */ |
|
| 60 | public function testItemSchema() |
|
| 61 | { |
|
| 62 | $client = static::createRestClient(); |
|
| 63 | $client->request('GET', '/schema/testcase/primitivearray/item'); |
|
| 64 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
|
| 65 | ||
| 66 | $schema = $client->getResults(); |
|
| 67 | $this->assertEquals('object', $schema->type); |
|
| 68 | $this->assertItemSchema($schema); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Test collection schema |
|
| @@ 93-101 (lines=9) @@ | ||
| 90 | * |
|
| 91 | * @return void |
|
| 92 | */ |
|
| 93 | public function testCheckGetOne() |
|
| 94 | { |
|
| 95 | $client = static::createRestClient(); |
|
| 96 | $client->request('GET', '/testcase/primitivearray/testdata'); |
|
| 97 | $this->assertEquals(Response::HTTP_OK, $client->getResponse()->getStatusCode()); |
|
| 98 | $this->assertNotEmpty($client->getResults()); |
|
| 99 | ||
| 100 | $this->assertFixtureData($client->getResults()); |
|
| 101 | } |
|
| 102 | ||
| 103 | /** |
|
| 104 | * Test GET all method |
|
| @@ 985-991 (lines=7) @@ | ||
| 982 | * @dataProvider rqlDataProvider |
|
| 983 | * @return void |
|
| 984 | */ |
|
| 985 | public function testTrigger301($url, $redirectUrl) |
|
| 986 | { |
|
| 987 | $client = static::createRestClient(); |
|
| 988 | $client->request('GET', $url); |
|
| 989 | $this->assertEquals(301, $client->getResponse()->getStatusCode()); |
|
| 990 | $this->assertEquals($redirectUrl, $client->getResponse()->headers->get('Location')); |
|
| 991 | } |
|
| 992 | ||
| 993 | /** |
|
| 994 | * Provides urls for the testTrigger301() test. |
|
| @@ 39-46 (lines=8) @@ | ||
| 36 | * test options request |
|
| 37 | * @return void |
|
| 38 | */ |
|
| 39 | public function testOptions() |
|
| 40 | { |
|
| 41 | $client = static::createRestClient(); |
|
| 42 | $client->request('OPTIONS', '/analytics/schema/app'); |
|
| 43 | $this->assertEquals(Response::HTTP_NO_CONTENT, $client->getResponse()->getStatusCode()); |
|
| 44 | $this->assertEquals('GET, OPTIONS', $client->getResponse()->headers->get('Access-Control-Allow-Methods')); |
|
| 45 | $this->assertEmpty($client->getResults()); |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Testing basic functionality |
|