| @@ 32-52 (lines=21) @@ | ||
| 29 | $this->client = static::createClient([], ['HTTP_ACCEPT' => 'application/json']); |
|
| 30 | } |
|
| 31 | ||
| 32 | public function testApiGetNoKey() |
|
| 33 | { |
|
| 34 | $this->client->request( |
|
| 35 | 'GET', |
|
| 36 | '/v1/keys/test_get_ke', |
|
| 37 | [], |
|
| 38 | [], |
|
| 39 | ['HTTP_CONTENT_TYPE' => 'application/json', 'CONTENT_TYPE' => 'application/json'] |
|
| 40 | ); |
|
| 41 | $this->assertTrue( |
|
| 42 | $this->client->getResponse()->headers->contains( |
|
| 43 | 'Content-Type', |
|
| 44 | 'application/json' |
|
| 45 | ) |
|
| 46 | ); |
|
| 47 | $this->assertEquals( |
|
| 48 | '{"code":404,"message":"The key \"test_get_ke\" does not exist."}', |
|
| 49 | $this->client->getResponse()->getContent() |
|
| 50 | ); |
|
| 51 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); |
|
| 52 | } |
|
| 53 | ||
| 54 | public function testApiGet() |
|
| 55 | { |
|
| @@ 54-76 (lines=23) @@ | ||
| 51 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); |
|
| 52 | } |
|
| 53 | ||
| 54 | public function testApiGet() |
|
| 55 | { |
|
| 56 | $this->createKeyValue('test_get_key', 'test_get_value'); |
|
| 57 | ||
| 58 | $this->client->request( |
|
| 59 | 'GET', |
|
| 60 | '/v1/keys/test_get_key', |
|
| 61 | [], |
|
| 62 | [], |
|
| 63 | ['HTTP_CONTENT_TYPE' => 'application/json', 'CONTENT_TYPE' => 'application/json'] |
|
| 64 | ); |
|
| 65 | $this->assertTrue( |
|
| 66 | $this->client->getResponse()->headers->contains( |
|
| 67 | 'Content-Type', |
|
| 68 | 'application/json' |
|
| 69 | ) |
|
| 70 | ); |
|
| 71 | $this->assertEquals( |
|
| 72 | '{"key":"test_get_key","value":"test_get_value"}', |
|
| 73 | $this->client->getResponse()->getContent() |
|
| 74 | ); |
|
| 75 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
|
| 76 | } |
|
| 77 | ||
| 78 | public function testApiCreate() |
|
| 79 | { |
|