mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Add put operation to ShopBillingDataResource
This commit is contained in:
parent
6e0edf1db3
commit
4b9df1dc0b
8 changed files with 173 additions and 1 deletions
|
|
@ -0,0 +1,22 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Sylius Sp. z o.o.
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
|
||||
<class name="Sylius\Component\Core\Model\Channel">
|
||||
<property name="shopBillingData">
|
||||
<constraint name="Valid">
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
</constraint-mapping>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
|
||||
This file is part of the Sylius package.
|
||||
|
||||
(c) Sylius Sp. z o.o.
|
||||
|
||||
For the full copyright and license information, please view the LICENSE
|
||||
file that was distributed with this source code.
|
||||
|
||||
-->
|
||||
|
||||
<constraint-mapping xmlns="http://symfony.com/schema/dic/constraint-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping http://symfony.com/schema/dic/services/constraint-mapping-1.0.xsd">
|
||||
<class name="Sylius\Component\Core\Model\ShopBillingData">
|
||||
<property name="countryCode">
|
||||
<constraint name="Country">
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
<constraint name="NotBlank" >
|
||||
<option name="allowNull">true</option>
|
||||
<option name="groups">sylius</option>
|
||||
</constraint>
|
||||
</property>
|
||||
</class>
|
||||
</constraint-mapping>
|
||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Tests\Api\Admin;
|
||||
|
||||
use Sylius\Component\Core\Model\ChannelInterface;
|
||||
use Sylius\Component\Core\Model\ShopBillingData;
|
||||
use Sylius\Tests\Api\JsonApiTestCase;
|
||||
use Sylius\Tests\Api\Utils\AdminUserLoginTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
|
@ -168,4 +169,48 @@ final class ChannelsTest extends JsonApiTestCase
|
|||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_updates_a_shop_billing_data(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml']);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ChannelInterface $channel */
|
||||
$channel = $fixtures['channel_web'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'PUT',
|
||||
uri: sprintf('/api/v2/admin/channels/%s', $channel->getCode()),
|
||||
server: $header,
|
||||
content: json_encode([
|
||||
'shopBillingData' => [
|
||||
'@id' => sprintf('/api/v2/admin/shop-billing-datas/%s', $channel->getShopBillingData()->getId()),
|
||||
'company' => 'DifferentCompany',
|
||||
'taxId' => '123',
|
||||
'countryCode' => 'DE',
|
||||
'street' => 'Different Street',
|
||||
'city' => 'different City',
|
||||
'postcode' => '12-124'
|
||||
]
|
||||
], JSON_THROW_ON_ERROR),
|
||||
);
|
||||
|
||||
$this->assertResponseCode(
|
||||
$this->client->getResponse(),
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/admin/channels/%s/shop-billing-data', $channel->getCode()),
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/put_shop_billing_data_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
46
tests/Api/Admin/ShopBillingDataTest.php
Normal file
46
tests/Api/Admin/ShopBillingDataTest.php
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Sylius package.
|
||||
*
|
||||
* (c) Sylius Sp. z o.o.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Tests\Api\Admin;
|
||||
|
||||
use Sylius\Component\Core\Model\ShopBillingData;
|
||||
use Sylius\Tests\Api\JsonApiTestCase;
|
||||
use Sylius\Tests\Api\Utils\AdminUserLoginTrait;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class ShopBillingDataTest extends JsonApiTestCase
|
||||
{
|
||||
use AdminUserLoginTrait;
|
||||
|
||||
/** @test */
|
||||
public function it_gets_a_shop_billing_data(): void
|
||||
{
|
||||
$fixtures = $this->loadFixturesFromFiles(['authentication/api_administrator.yaml', 'channel.yaml']);
|
||||
$header = array_merge($this->logInAdminUser('api@example.com'), self::CONTENT_TYPE_HEADER);
|
||||
|
||||
/** @var ShopBillingData $shopBillingData */
|
||||
$shopBillingData = $fixtures['billing_data'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/admin/shop-billing-datas/%s', $shopBillingData->getId()),
|
||||
server: $header,
|
||||
);
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'admin/get_shop_billing_data_response',
|
||||
Response::HTTP_OK,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -25,6 +25,7 @@ Sylius\Component\Core\Model\Channel:
|
|||
enabled: true
|
||||
taxCalculationStrategy: 'order_items_based'
|
||||
channelPriceHistoryConfig: '@mobile_price_history_config'
|
||||
shopBillingData: '@billing_data'
|
||||
|
||||
Sylius\Component\Core\Model\ChannelPriceHistoryConfig:
|
||||
web_price_history_config:
|
||||
|
|
@ -36,6 +37,14 @@ Sylius\Component\Core\Model\ChannelPriceHistoryConfig:
|
|||
Sylius\Component\Currency\Model\Currency:
|
||||
currency_usd:
|
||||
code: 'USD'
|
||||
|
||||
Sylius\Component\Core\Model\ShopBillingData:
|
||||
billing_data:
|
||||
company: 'Sylius'
|
||||
taxId: 'PL1234567890'
|
||||
street: 'Wall Street 1'
|
||||
city: 'New York'
|
||||
postcode: '00-000'
|
||||
|
||||
Sylius\Component\Locale\Model\Locale:
|
||||
locale_en:
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
"skippingPaymentStepAllowed": false,
|
||||
"accountVerificationRequired": true,
|
||||
"shippingAddressInCheckoutRequired": false,
|
||||
"shopBillingData": null,
|
||||
"shopBillingData": "\/api\/v2\/admin\/shop-billing-datas\/@integer@",
|
||||
"menuTaxon": null,
|
||||
"channelPriceHistoryConfig": "\/api\/v2\/admin\/channel-price-history-configs\/@integer@"
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"@context": "\/api\/v2\/contexts\/ShopBillingData",
|
||||
"@id": "\/api\/v2\/admin\/shop-billing-datas\/@integer@",
|
||||
"@type": "ShopBillingData",
|
||||
"id": @integer@,
|
||||
"company": "Sylius",
|
||||
"taxId": "PL1234567890",
|
||||
"countryCode": null,
|
||||
"street": "Wall Street 1",
|
||||
"city": "New York",
|
||||
"postcode": "00-000"
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"@context": "\/api\/v2\/contexts\/ShopBillingData",
|
||||
"@id": "\/api\/v2\/admin\/shop-billing-datas\/@integer@",
|
||||
"@type": "ShopBillingData",
|
||||
"id": @integer@,
|
||||
"company": "DifferentCompany",
|
||||
"taxId": "123",
|
||||
"countryCode": "DE",
|
||||
"street": "Different Street",
|
||||
"city": "different City",
|
||||
"postcode": "12-124"
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue