mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[Behat][API] Introduce common ResponseContext service
This commit is contained in:
parent
d40ecdffc0
commit
3dccd16479
2 changed files with 50 additions and 0 deletions
40
src/Sylius/Behat/Context/Api/Common/ResponseContext.php
Normal file
40
src/Sylius/Behat/Context/Api/Common/ResponseContext.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Sylius\Behat\Context\Api\Common;
|
||||
|
||||
use Behat\Behat\Context\Context;
|
||||
use Sylius\Behat\Client\ApiClientInterface;
|
||||
use Sylius\Behat\Client\ResponseCheckerInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
final class ResponseContext implements Context
|
||||
{
|
||||
public function __construct(private ResponseCheckerInterface $responseChecker, private ApiClientInterface $client)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should be notified that it has been successfully edited
|
||||
*/
|
||||
public function iShouldBeNotifiedThatItHasBeenSuccessfullyEdited(): void
|
||||
{
|
||||
Assert::true(
|
||||
$this->responseChecker->isUpdateSuccessful($this->client->getLastResponse()),
|
||||
sprintf(
|
||||
'Resource could not be edited: %s',
|
||||
$this->responseChecker->getError($this->client->getLastResponse()),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,5 +22,15 @@
|
|||
<service id="sylius.behat.context.api.shop.save" class="Sylius\Behat\Context\Api\Common\SaveContext">
|
||||
<argument type="service" id="sylius.behat.api_platform_client.shop" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.api.admin.response" class="Sylius\Behat\Context\Api\Common\ResponseContext">
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.api_platform_client.admin" />
|
||||
</service>
|
||||
|
||||
<service id="sylius.behat.context.api.shop.response" class="Sylius\Behat\Context\Api\Common\ResponseContext">
|
||||
<argument type="service" id="Sylius\Behat\Client\ResponseCheckerInterface" />
|
||||
<argument type="service" id="sylius.behat.api_platform_client.shop" />
|
||||
</service>
|
||||
</services>
|
||||
</container>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue