mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
77 lines
2.4 KiB
PHP
77 lines
2.4 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Sylius package.
|
|
*
|
|
* (c) Paweł Jędrzejewski
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Sylius\Tests\Controller;
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
/**
|
|
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
|
|
*/
|
|
final class CheckoutReaddressingApiTest extends CheckoutApiTestCase
|
|
{
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_denies_order_readdressing_for_non_authenticated_user()
|
|
{
|
|
$this->client->request('PUT', '/api/checkouts/readdress/1');
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_does_not_allow_to_readdress_unexisting_order()
|
|
{
|
|
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
|
|
|
$this->client->request('PUT', '/api/checkouts/readdress/1', [], [], static::$authorizedHeaderWithContentType);
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertResponseCode($response, Response::HTTP_NOT_FOUND);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_does_not_allow_to_readdress_order_that_is_not_addressed()
|
|
{
|
|
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
|
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
|
|
|
|
$url = sprintf('/api/checkouts/readdress/%d', $checkoutData['order1']->getId());
|
|
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertResponseCode($response, Response::HTTP_BAD_REQUEST);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function it_allows_to_readdress_addressed_order()
|
|
{
|
|
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
|
$checkoutData = $this->loadFixturesFromFile('resources/checkout.yml');
|
|
|
|
$orderId = $checkoutData['order1']->getId();
|
|
$this->addressOrder($orderId);
|
|
|
|
$url = sprintf('/api/checkouts/readdress/%d', $orderId);
|
|
$this->client->request('PUT', $url, [], [], static::$authorizedHeaderWithContentType);
|
|
|
|
$response = $this->client->getResponse();
|
|
$this->assertResponse($response, 'checkout/readdressing_response', Response::HTTP_OK);
|
|
}
|
|
}
|