mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-16 01:47:49 +00:00
Add assertion for disabled code field
This commit is contained in:
parent
8594b3a092
commit
77be94f4b5
5 changed files with 49 additions and 13 deletions
|
|
@ -25,7 +25,7 @@ Feature: Editing country
|
|||
Then I should be notified about successful edition
|
||||
And this country should be enabled
|
||||
|
||||
@todo
|
||||
@ui
|
||||
Scenario: Seeing disabled code field while editing country
|
||||
Given the store has country "France"
|
||||
When I want to edit this country
|
||||
|
|
|
|||
|
|
@ -126,15 +126,13 @@ final class ManagingCountriesContext implements Context
|
|||
*/
|
||||
public function iShouldBeNotifiedAboutSuccessfulCreation()
|
||||
{
|
||||
$doesSuccessMessageAppear = $this->notificationAccessor->hasSuccessMessage();
|
||||
Assert::true(
|
||||
$doesSuccessMessageAppear,
|
||||
$this->notificationAccessor->hasSuccessMessage(),
|
||||
sprintf('Message type is not positive')
|
||||
);
|
||||
|
||||
$doesSuccessfulCreationMessageAppear = $this->notificationAccessor->isSuccessfullyCreatedFor(self::RESOURCE_NAME);
|
||||
Assert::true(
|
||||
$doesSuccessfulCreationMessageAppear,
|
||||
$this->notificationAccessor->isSuccessfullyCreatedFor(self::RESOURCE_NAME),
|
||||
sprintf('Successful creation message does not appear')
|
||||
);
|
||||
}
|
||||
|
|
@ -144,15 +142,13 @@ final class ManagingCountriesContext implements Context
|
|||
*/
|
||||
public function iShouldBeNotifiedAboutSuccessfulEdition()
|
||||
{
|
||||
$doesSuccessMessageAppear = $this->notificationAccessor->hasSuccessMessage();
|
||||
Assert::true(
|
||||
$doesSuccessMessageAppear,
|
||||
$this->notificationAccessor->hasSuccessMessage(),
|
||||
'Message type is not positive'
|
||||
);
|
||||
|
||||
$doesSuccessfulEditionMessageAppear = $this->notificationAccessor->isSuccessfullyUpdatedFor(self::RESOURCE_NAME);
|
||||
Assert::true(
|
||||
$doesSuccessfulEditionMessageAppear,
|
||||
$this->notificationAccessor->isSuccessfullyUpdatedFor(self::RESOURCE_NAME),
|
||||
'Successful edition message does not appear'
|
||||
);
|
||||
}
|
||||
|
|
@ -162,9 +158,8 @@ final class ManagingCountriesContext implements Context
|
|||
*/
|
||||
public function countryShouldAppearInTheStore(CountryInterface $country)
|
||||
{
|
||||
$doesCountryExist = $this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]);
|
||||
Assert::true(
|
||||
$doesCountryExist,
|
||||
$this->countryIndexPage->isResourceOnPage(['code' => $country->getCode()]),
|
||||
sprintf('Country %s should exist but it does not', $country->getCode())
|
||||
);
|
||||
}
|
||||
|
|
@ -174,9 +169,8 @@ final class ManagingCountriesContext implements Context
|
|||
*/
|
||||
public function thisCountryShouldBeEnabled(CountryInterface $country)
|
||||
{
|
||||
$isCountryEnabled = $this->countryIndexPage->isCountryEnabled($country);
|
||||
Assert::true(
|
||||
$isCountryEnabled,
|
||||
$this->countryIndexPage->isCountryEnabled($country),
|
||||
sprintf('Country %s should be enabled but it is not', $country->getCode())
|
||||
);
|
||||
}
|
||||
|
|
@ -201,4 +195,14 @@ final class ManagingCountriesContext implements Context
|
|||
expect($this->countryCreatePage)->toThrow(ElementNotFoundException::class)->during('chooseName', [$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the code field should be disabled
|
||||
*/
|
||||
public function theCodeFieldShouldBeDisabled()
|
||||
{
|
||||
Assert::true(
|
||||
$this->countryUpdatePage->isCodeFieldDisabled(),
|
||||
'Code field should be disabled but is not'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ namespace Sylius\Behat\Page\Admin\Country;
|
|||
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
|
||||
use Sylius\Behat\Page\ElementNotFoundException;
|
||||
|
||||
/**
|
||||
* @author Arkadiusz Krakowiak <arkadiusz.krakowiak@lakion.com>
|
||||
|
|
@ -24,6 +25,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
*/
|
||||
protected $elements = [
|
||||
'enabled' => '#sylius_country_enabled',
|
||||
'code' => '#sylius_country_code',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -48,6 +50,19 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
$enabled->uncheck();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function isCodeFieldDisabled()
|
||||
{
|
||||
try {
|
||||
$codeField = $this->getElement('code');
|
||||
return $codeField->getAttribute('disabled') === 'disabled';
|
||||
} catch (ElementNotFoundException $exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param NodeElement $toggleableElement
|
||||
* @param bool $expectedState
|
||||
|
|
|
|||
|
|
@ -27,4 +27,9 @@ interface UpdatePageInterface extends BaseUpdatePageInterface
|
|||
* @throws \RuntimeException
|
||||
*/
|
||||
public function disable();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCodeFieldDisabled();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,4 +200,16 @@ class ManagingCountriesContextSpec extends ObjectBehavior
|
|||
|
||||
$this->shouldThrow(\Exception::class)->during('iShouldNotBeAbleToChoose', ['France']);
|
||||
}
|
||||
|
||||
function it_asserts_that_country_code_field_is_disabled(UpdatePageInterface $countryUpdatePage)
|
||||
{
|
||||
$countryUpdatePage->isCodeFieldDisabled()->willReturn(true);
|
||||
$this->theCodeFieldShouldBeDisabled();
|
||||
}
|
||||
|
||||
function it_throws_not_equal_exception_if_country_code_field_is_not_disabled(UpdatePageInterface $countryUpdatePage)
|
||||
{
|
||||
$countryUpdatePage->isCodeFieldDisabled()->willReturn(false);
|
||||
$this->shouldThrow(\InvalidArgumentException::class)->during('theCodeFieldShouldBeDisabled');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue