*/ class ShippingCategoryApiTest extends JsonApiTestCase { public function testCreateShippingCategoryAccessDeniedResponse() { $this->client->request('POST', '/api/shipping-categories/'); $response = $this->client->getResponse(); $this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED); } public function testCreateShippingCategoryValidationFailResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->client->request('POST', '/api/shipping-categories/', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/create_validation_fail_response', Response::HTTP_BAD_REQUEST); } public function testCreateShippingCategoryResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $data = <<client->request('POST', '/api/shipping-categories/', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ], $data); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/create_response', Response::HTTP_CREATED); } public function testGetShippingCategoriesListAccessDeniedResponse() { $this->client->request('GET', '/api/shipping-categories/'); $response = $this->client->getResponse(); $this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED); } public function testGetShippingCategoriesListResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->loadFixturesFromFile('resources/shipping_categories.yml'); $this->client->request('GET', '/api/shipping-categories/', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/index_response', Response::HTTP_OK); } public function testGetShippingCategoryAccessDeniedResponse() { $this->client->request('GET', '/api/shipping-categories/1'); $response = $this->client->getResponse(); $this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED); } public function testGetShippingCategoryWhichDoesNotExistResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->client->request('GET', '/api/shipping-categories/-1', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND); } public function testGetShippingCategoryResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $shippingCategories = $this->loadFixturesFromFile('resources/shipping_categories.yml'); $this->client->request('GET', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/show_response', Response::HTTP_OK); } public function testFullUpdateShippingCategoryAccessDeniedResponse() { $this->client->request('PUT', '/api/shipping-categories/1'); $response = $this->client->getResponse(); $this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED); } public function testFullUpdateShippingCategoryWhichDoesNotExistResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->client->request('PUT', '/api/shipping-categories/-1', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND); } public function testFullUpdateShippingCategoryValidationFailResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $shippingCategories = $this->loadFixturesFromFile('resources/shipping_categories.yml'); $this->client->request('PUT', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/update_validation_fail_response', Response::HTTP_BAD_REQUEST); } public function testFullUpdateShippingCategoryResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $shippingCategories = $this->loadFixturesFromFile('resources/shipping_categories.yml'); $data = <<client->request('PUT', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ], $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); $this->client->request('GET', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/update_response', Response::HTTP_OK); } public function testPartialUpdateShippingCategoryWhichDoesNotExistResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->client->request('PATCH', '/api/shipping-categories/-1', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND); } public function testPartialUpdateShippingCategoryResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $shippingCategories = $this->loadFixturesFromFile('resources/shipping_categories.yml'); $data = <<client->request('PATCH', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ], $data); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); $this->client->request('GET', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'shipping_category/update_response', Response::HTTP_OK); } public function testDeleteShippingCategoryWhichDoesNotExistResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $this->client->request('DELETE', '/api/shipping-categories/-1', [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND); } public function testDeleteShippingCategoryResponse() { $this->loadFixturesFromFile('authentication/api_administrator.yml'); $shippingCategories = $this->loadFixturesFromFile('resources/shipping_categories.yml'); $this->client->request('DELETE', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'CONTENT_TYPE' => 'application/json', ], []); $response = $this->client->getResponse(); $this->assertResponseCode($response, Response::HTTP_NO_CONTENT); $this->client->request('GET', '/api/shipping-categories/'.$shippingCategories['shipping_category_1']->getId(), [], [], [ 'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ', 'ACCEPT' => 'application/json', ]); $response = $this->client->getResponse(); $this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND); } }