mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57:12 +00:00
[Behat] Use test attributes in PaymentMethod update page
This commit is contained in:
parent
060bebeb4d
commit
3dc269f189
1 changed files with 38 additions and 4 deletions
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
|||
namespace Sylius\Behat\Page\Admin\PaymentMethod;
|
||||
|
||||
use Behat\Mink\Element\NodeElement;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Sylius\Behat\Behaviour\ChecksCodeImmutability;
|
||||
use Sylius\Behat\Behaviour\Toggles;
|
||||
use Sylius\Behat\Page\Admin\Crud\UpdatePage as BaseUpdatePage;
|
||||
|
|
@ -23,63 +24,96 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
use ChecksCodeImmutability;
|
||||
use Toggles;
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function setPaypalGatewayUsername(string $username): void
|
||||
{
|
||||
$this->getDocument()->fillField('Username', $username);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function setPaypalGatewayPassword(string $password): void
|
||||
{
|
||||
$this->getDocument()->fillField('Password', $password);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function setPaypalGatewaySignature(string $signature): void
|
||||
{
|
||||
$this->getDocument()->fillField('Signature', $signature);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function nameIt(string $name, string $languageCode): void
|
||||
{
|
||||
$this->getDocument()->fillField(sprintf('sylius_payment_method_translations_%s_name', $languageCode), $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function isPaymentMethodEnabled(): bool
|
||||
{
|
||||
return (bool) $this->getToggleableElement()->getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function isFactoryNameFieldDisabled(): bool
|
||||
{
|
||||
return 'disabled' === $this->getElement('factory_name')->getAttribute('disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function isAvailableInChannel(string $channelName): bool
|
||||
{
|
||||
return $this->getElement('channel', ['%channel%' => $channelName])->hasAttribute('checked');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
public function getPaymentMethodInstructions(string $language): string
|
||||
{
|
||||
return $this->getElement('instructions', ['%language%' => $language])->getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
protected function getCodeElement(): NodeElement
|
||||
{
|
||||
return $this->getElement('code');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ElementNotFoundException
|
||||
*/
|
||||
protected function getToggleableElement(): NodeElement
|
||||
{
|
||||
return $this->getElement('enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
protected function getDefinedElements(): array
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'channel' => '.checkbox:contains("%channel%") input',
|
||||
'code' => '#sylius_payment_method_code',
|
||||
'enabled' => '#sylius_payment_method_enabled',
|
||||
'factory_name' => '#sylius_payment_method_gatewayConfig_factoryName',
|
||||
'channel' => '[data-test-channels] .form-switch:contains("%channel%") input',
|
||||
'code' => '[data-test-code]',
|
||||
'enabled' => '[data-test-enabled]',
|
||||
'factory_name' => '[data-test-factory-name]',
|
||||
'instructions' => '#sylius_payment_method_translations_%language%_instructions',
|
||||
'name' => '#sylius_payment_method_translations_en_US_name',
|
||||
]);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue