mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[Behat] Refactor to use PHP 7.4 syntax
This commit is contained in:
parent
e083ab026b
commit
5477cd090d
35 changed files with 59 additions and 140 deletions
|
|
@ -10,6 +10,7 @@ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigura
|
|||
|
||||
return static function (ContainerConfigurator $containerConfigurator): void
|
||||
{
|
||||
$containerConfigurator->import(SetList::PHP_74);
|
||||
$containerConfigurator->import(SetList::PHP_80);
|
||||
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
|
|
|
|||
|
|
@ -21,16 +21,13 @@ final class Request implements RequestInterface
|
|||
|
||||
private string $method;
|
||||
|
||||
/** @var array */
|
||||
private $headers = ['HTTP_ACCEPT' => 'application/ld+json'];
|
||||
private array $headers = ['HTTP_ACCEPT' => 'application/ld+json'];
|
||||
|
||||
private array $content = [];
|
||||
|
||||
/** @var array */
|
||||
private $parameters = [];
|
||||
private array $parameters = [];
|
||||
|
||||
/** @var array */
|
||||
private $files = [];
|
||||
private array $files = [];
|
||||
|
||||
private function __construct(string $url, string $method, array $headers = [])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,9 +36,7 @@ final class ResponseChecker implements ResponseCheckerInterface
|
|||
|
||||
public function getCollectionItemsWithValue(Response $response, string $key, string $value): array
|
||||
{
|
||||
$items = array_filter($this->getCollection($response), function (array $item) use ($key, $value): bool {
|
||||
return $item[$key] === $value;
|
||||
});
|
||||
$items = array_filter($this->getCollection($response), fn(array $item): bool => $item[$key] === $value);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,9 +63,7 @@ final class AjaxContext implements Context
|
|||
*/
|
||||
public function iShouldSeeTheProductVariantNamedAnd(...$names): void
|
||||
{
|
||||
$itemsNames = array_map(static function ($item) {
|
||||
return strstr($item['descriptor'], ' ', true);
|
||||
}, $this->getJSONResponse());
|
||||
$itemsNames = array_map(static fn($item) => strstr($item['descriptor'], ' ', true), $this->getJSONResponse());
|
||||
|
||||
Assert::allOneOf($itemsNames, $names);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -714,7 +714,7 @@ final class CartContext implements Context
|
|||
|
||||
private function putProductToCart(ProductInterface $product, ?string $tokenValue, int $quantity = 1): void
|
||||
{
|
||||
$tokenValue = $tokenValue ?? $this->pickupCart();
|
||||
$tokenValue ??= $this->pickupCart();
|
||||
|
||||
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_POST, 'items');
|
||||
|
||||
|
|
@ -728,7 +728,7 @@ final class CartContext implements Context
|
|||
|
||||
private function putProductVariantToCart(ProductVariantInterface $productVariant, ?string $tokenValue, int $quantity = 1): void
|
||||
{
|
||||
$tokenValue = $tokenValue ?? $this->pickupCart();
|
||||
$tokenValue ??= $this->pickupCart();
|
||||
|
||||
$request = Request::customItemAction('shop', 'orders', $tokenValue, HttpRequest::METHOD_POST, 'items');
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,9 @@ use Webmozart\Assert\Assert;
|
|||
|
||||
final class LocaleContext implements Context
|
||||
{
|
||||
/** @var ApiClientInterface */
|
||||
private $client;
|
||||
private ApiClientInterface $client;
|
||||
|
||||
/** @var ResponseCheckerInterface */
|
||||
private $responseChecker;
|
||||
private ResponseCheckerInterface $responseChecker;
|
||||
|
||||
public function __construct(ApiClientInterface $client, ResponseCheckerInterface $responseChecker)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -807,7 +807,7 @@ final class CatalogPromotionContext implements Context
|
|||
$channels = [$this->sharedStorage->get('channel')];
|
||||
}
|
||||
|
||||
$code = $code ?? StringInflector::nameToCode($name);
|
||||
$code ??= StringInflector::nameToCode($name);
|
||||
|
||||
/** @var CatalogPromotionInterface $catalogPromotion */
|
||||
$catalogPromotion = $this->catalogPromotionExampleFactory->create([
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@ final class ProductContext implements Context
|
|||
|
||||
private SlugGeneratorInterface $slugGenerator;
|
||||
|
||||
/** @var array */
|
||||
private $minkParameters;
|
||||
private array $minkParameters;
|
||||
|
||||
public function __construct(
|
||||
SharedStorageInterface $sharedStorage,
|
||||
|
|
@ -677,9 +676,7 @@ final class ProductContext implements Context
|
|||
{
|
||||
$code = sprintf('%s_%s', $product->getCode(), $optionValueName);
|
||||
/** @var ProductVariantInterface $productVariant */
|
||||
$productVariant = $product->getVariants()->filter(function ($variant) use ($code) {
|
||||
return $code === $variant->getCode();
|
||||
})->first();
|
||||
$productVariant = $product->getVariants()->filter(fn($variant) => $code === $variant->getCode())->first();
|
||||
|
||||
Assert::notNull($productVariant, sprintf('Product variant with given code %s not exists!', $code));
|
||||
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ final class TaxonomyContext implements Context
|
|||
|
||||
private TaxonSlugGeneratorInterface $taxonSlugGenerator;
|
||||
|
||||
/** @var array */
|
||||
private $minkParameters;
|
||||
private array $minkParameters;
|
||||
|
||||
public function __construct(
|
||||
RepositoryInterface $taxonRepository,
|
||||
|
|
|
|||
|
|
@ -54,8 +54,6 @@ final class ProductContext implements Context
|
|||
*/
|
||||
public function getProductsByNames(...$productsNames)
|
||||
{
|
||||
return array_map(function ($productName) {
|
||||
return $this->getProductByName($productName);
|
||||
}, $productsNames);
|
||||
return array_map(fn($productName) => $this->getProductByName($productName), $productsNames);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ final class ShippingCalculatorContext implements Context
|
|||
public function getShippingCalculatorByName(string $shippingCalculator): string
|
||||
{
|
||||
$flippedCalculators = array_flip(array_map(
|
||||
function (string $translationKey): string { return $this->translator->trans($translationKey); },
|
||||
fn(string $translationKey): string => $this->translator->trans($translationKey),
|
||||
$this->shippingCalculators
|
||||
));
|
||||
|
||||
|
|
|
|||
|
|
@ -233,9 +233,7 @@ final class ManagingCatalogPromotionsContext implements Context
|
|||
*/
|
||||
public function iAddScopeThatAppliesOnVariants(ProductVariantInterface ...$variants): void
|
||||
{
|
||||
$variantCodes = array_map(function (ProductVariantInterface $variant) {
|
||||
return $variant->getCode();
|
||||
}, $variants);
|
||||
$variantCodes = array_map(fn(ProductVariantInterface $variant) => $variant->getCode(), $variants);
|
||||
|
||||
$this->formElement->addScope();
|
||||
$this->formElement->chooseScopeType('For variants');
|
||||
|
|
@ -247,9 +245,7 @@ final class ManagingCatalogPromotionsContext implements Context
|
|||
*/
|
||||
public function iAddScopeThatAppliesOnTaxons(TaxonInterface ...$taxons): void
|
||||
{
|
||||
$taxonsCodes = array_map(function (TaxonInterface $taxon) {
|
||||
return $taxon->getCode();
|
||||
}, $taxons);
|
||||
$taxonsCodes = array_map(fn(TaxonInterface $taxon) => $taxon->getCode(), $taxons);
|
||||
|
||||
$this->formElement->addScope();
|
||||
$this->formElement->chooseScopeType('For taxons');
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ use Webmozart\Assert\Assert;
|
|||
|
||||
final class ManagingCustomersContext implements Context
|
||||
{
|
||||
/** @var CustomerIndexPageInterface */
|
||||
private $indexPage;
|
||||
private CustomerIndexPageInterface $indexPage;
|
||||
|
||||
private CreatePageInterface $createPage;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,7 @@ use Sylius\Behat\Element\BrowserElementInterface;
|
|||
|
||||
final class BrowserContext implements Context
|
||||
{
|
||||
/** @var BrowserElementInterface */
|
||||
private $browserElement;
|
||||
private BrowserElementInterface $browserElement;
|
||||
|
||||
public function __construct(BrowserElementInterface $browserElement)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -228,9 +228,7 @@ final class FormElement extends Element implements FormElementInterface
|
|||
|
||||
$this->getElement($buttonElement)->click();
|
||||
|
||||
$this->getDocument()->waitFor(5, function () use ($count, $collectionElement) {
|
||||
return $count + 1 === count($this->getCollectionItems($collectionElement));
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => $count + 1 === count($this->getCollectionItems($collectionElement)));
|
||||
}
|
||||
|
||||
/** @return NodeElement[] */
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ final class VerticalMenuElement extends Element implements VerticalMenuElementIn
|
|||
{
|
||||
$menu = $this->getElement('vertical-menu');
|
||||
|
||||
return array_map(function (NodeElement $element): string {
|
||||
return $element->getText();
|
||||
}, $menu->findAll('css', '[data-test-vertical-menu-item]'));
|
||||
return array_map(fn(NodeElement $element): string => $element->getText(), $menu->findAll('css', '[data-test-vertical-menu-item]'));
|
||||
}
|
||||
|
||||
public function canNavigateToParentTaxon(): bool
|
||||
|
|
|
|||
|
|
@ -22,9 +22,7 @@ final class MenuElement extends Element implements MenuElementInterface
|
|||
{
|
||||
$menu = $this->getElement('menu');
|
||||
|
||||
return array_map(function (NodeElement $element): string {
|
||||
return $element->getText();
|
||||
}, $menu->findAll('css', '[data-test-menu-item]'));
|
||||
return array_map(fn(NodeElement $element): string => $element->getText(), $menu->findAll('css', '[data-test-menu-item]'));
|
||||
}
|
||||
|
||||
protected function getDefinedElements(): array
|
||||
|
|
|
|||
|
|
@ -186,9 +186,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
->findAll('css', '.row > .column > .statistic > .sylius-channel-name')
|
||||
;
|
||||
|
||||
$statisticsRibs = array_filter($statisticsRibs, function (NodeElement $statistic) use ($channelName) {
|
||||
return $channelName === trim($statistic->getText());
|
||||
});
|
||||
$statisticsRibs = array_filter($statisticsRibs, fn(NodeElement $statistic) => $channelName === trim($statistic->getText()));
|
||||
|
||||
$actualStatisticsCount = count($statisticsRibs);
|
||||
Assert::same(
|
||||
|
|
|
|||
|
|
@ -169,12 +169,10 @@ class CreateSimpleProductPage extends BaseCreatePage implements CreateSimpleProd
|
|||
$dropdown->click();
|
||||
|
||||
foreach ($productsNames as $productName) {
|
||||
$dropdown->waitFor(5, function () use ($productName, $productAssociationType) {
|
||||
return $this->hasElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
'%item%' => $productName,
|
||||
]);
|
||||
});
|
||||
$dropdown->waitFor(5, fn() => $this->hasElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
'%item%' => $productName,
|
||||
]));
|
||||
|
||||
$item = $this->getElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
|
|
@ -294,9 +292,7 @@ class CreateSimpleProductPage extends BaseCreatePage implements CreateSimpleProd
|
|||
private function waitForFormElement(int $timeout = 5): void
|
||||
{
|
||||
$form = $this->getElement('form');
|
||||
$this->getDocument()->waitFor($timeout, function () use ($form) {
|
||||
return false === strpos($form->getAttribute('class'), 'loading');
|
||||
});
|
||||
$this->getDocument()->waitFor($timeout, fn() => false === strpos($form->getAttribute('class'), 'loading'));
|
||||
}
|
||||
|
||||
private function clickTabIfItsNotActive(string $tabName): void
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ class IndexPerTaxonPage extends CrudIndexPage implements IndexPerTaxonPageInterf
|
|||
$saveConfigurationButton = $this->getElement('save_configuration_button');
|
||||
$saveConfigurationButton->press();
|
||||
|
||||
$this->getDocument()->waitFor(5, function () use ($saveConfigurationButton) {
|
||||
return null === $saveConfigurationButton->find('css', '.loading');
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => null === $saveConfigurationButton->find('css', '.loading'));
|
||||
}
|
||||
|
||||
protected function getDefinedElements(): array
|
||||
|
|
|
|||
|
|
@ -57,9 +57,7 @@ class UpdateConfigurableProductPage extends BaseUpdatePage implements UpdateConf
|
|||
|
||||
$this->getDriver()->executeScript(sprintf('$(\'input.search\').val(\'%s\')', $taxon->getName()));
|
||||
$this->getElement('search')->click();
|
||||
$this->getElement('search')->waitFor(10, function () {
|
||||
return $this->hasElement('search_item_selected');
|
||||
});
|
||||
$this->getElement('search')->waitFor(10, fn() => $this->hasElement('search_item_selected'));
|
||||
$itemSelected = $this->getElement('search_item_selected');
|
||||
$itemSelected->click();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,9 +62,7 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd
|
|||
|
||||
$form = $this->getDocument()->find('css', 'form');
|
||||
|
||||
$this->getDocument()->waitFor(1, function () use ($form) {
|
||||
return $form->hasClass('loading');
|
||||
});
|
||||
$this->getDocument()->waitFor(1, fn() => $form->hasClass('loading'));
|
||||
}
|
||||
|
||||
public function removeAttribute(string $attributeName, string $localeCode): void
|
||||
|
|
@ -286,12 +284,10 @@ class UpdateSimpleProductPage extends BaseUpdatePage implements UpdateSimpleProd
|
|||
$dropdown->click();
|
||||
|
||||
foreach ($productsNames as $productName) {
|
||||
$dropdown->waitFor(5, function () use ($productName, $productAssociationType) {
|
||||
return $this->hasElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
'%item%' => $productName,
|
||||
]);
|
||||
});
|
||||
$dropdown->waitFor(5, fn() => $this->hasElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
'%item%' => $productName,
|
||||
]));
|
||||
|
||||
$item = $this->getElement('association_dropdown_item', [
|
||||
'%association%' => $productAssociationType->getName(),
|
||||
|
|
|
|||
|
|
@ -50,9 +50,7 @@ class IndexPage extends BaseIndexPage implements IndexPageInterface
|
|||
{
|
||||
$this->getElement('save_configuration_button')->press();
|
||||
|
||||
$this->getDocument()->waitFor(5, function () {
|
||||
return null === $this->getElement('save_configuration_button')->find('css', '.loading');
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => null === $this->getElement('save_configuration_button')->find('css', '.loading'));
|
||||
}
|
||||
|
||||
protected function getDefinedElements(): array
|
||||
|
|
|
|||
|
|
@ -32,9 +32,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
|
||||
$this->getDocument()->clickLink('Add rule');
|
||||
|
||||
$this->getDocument()->waitFor(5, function () use ($count) {
|
||||
return $count + 1 === count($this->getCollectionItems('rules'));
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => $count + 1 === count($this->getCollectionItems('rules')));
|
||||
|
||||
if (null !== $ruleName) {
|
||||
$this->selectRuleOption('Type', $ruleName);
|
||||
|
|
@ -82,9 +80,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
|
||||
$this->getDocument()->clickLink('Add action');
|
||||
|
||||
$this->getDocument()->waitFor(5, function () use ($count) {
|
||||
return $count + 1 === count($this->getCollectionItems('actions'));
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => $count + 1 === count($this->getCollectionItems('actions')));
|
||||
|
||||
if (null !== $actionName) {
|
||||
$this->selectActionOption('Type', $actionName);
|
||||
|
|
|
|||
|
|
@ -96,9 +96,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
|
||||
$this->getDocument()->clickLink('Add rule');
|
||||
|
||||
$this->getDocument()->waitFor(5, function () use ($count) {
|
||||
return $count + 1 === count($this->getCollectionItems('rules'));
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => $count + 1 === count($this->getCollectionItems('rules')));
|
||||
|
||||
$this->selectRuleOption('Type', $ruleName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,9 +199,7 @@ class UpdatePage extends BaseUpdatePage implements UpdatePageInterface
|
|||
$languageTabTitle->click();
|
||||
}
|
||||
|
||||
$this->getDocument()->waitFor(10, function () use ($languageTabTitle) {
|
||||
return $languageTabTitle->hasClass('active');
|
||||
});
|
||||
$this->getDocument()->waitFor(10, fn() => $languageTabTitle->hasClass('active'));
|
||||
}
|
||||
|
||||
public function enable(): void
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ class CreatePage extends BaseCreatePage implements CreatePageInterface
|
|||
|
||||
public function chooseMember(string $name): void
|
||||
{
|
||||
$selectItems = $this->getDocument()->waitFor(2, function () {
|
||||
return $this->getDocument()->findAll('css', 'div[data-form-type="collection"] select');
|
||||
});
|
||||
$selectItems = $this->getDocument()->waitFor(2, fn() => $this->getDocument()->findAll('css', 'div[data-form-type="collection"] select'));
|
||||
$lastSelectItem = end($selectItems);
|
||||
|
||||
if (false === $lastSelectItem) {
|
||||
|
|
|
|||
|
|
@ -94,8 +94,6 @@ class UpdatePage extends SymfonyPage implements UpdatePageInterface
|
|||
|
||||
private function waitForElement(int $timeout, string $elementName): void
|
||||
{
|
||||
$this->getDocument()->waitFor($timeout, function () use ($elementName) {
|
||||
return $this->hasElement($elementName);
|
||||
});
|
||||
$this->getDocument()->waitFor($timeout, fn() => $this->hasElement($elementName));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -224,9 +224,7 @@ class SummaryPage extends SymfonyPage implements SummaryPageInterface
|
|||
|
||||
public function waitForRedirect(int $timeout): void
|
||||
{
|
||||
$this->getDocument()->waitFor($timeout, function () {
|
||||
return $this->isOpen();
|
||||
});
|
||||
$this->getDocument()->waitFor($timeout, fn() => $this->isOpen());
|
||||
}
|
||||
|
||||
public function getPromotionCouponValidationMessage(): string
|
||||
|
|
|
|||
|
|
@ -169,9 +169,7 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
|
||||
public function specifyPassword(string $password): void
|
||||
{
|
||||
$this->getDocument()->waitFor(5, function () {
|
||||
return $this->getElement('login_password')->isVisible();
|
||||
});
|
||||
$this->getDocument()->waitFor(5, fn() => $this->getElement('login_password')->isVisible());
|
||||
|
||||
$this->getElement('login_password')->setValue($password);
|
||||
}
|
||||
|
|
@ -233,9 +231,7 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
$addressBookSelect = $this->getElement('shipping_address_book');
|
||||
|
||||
$addressBookSelect->click();
|
||||
$addressOption = $addressBookSelect->waitFor(5, function () use ($address, $addressBookSelect) {
|
||||
return $addressBookSelect->find('css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId()));
|
||||
});
|
||||
$addressOption = $addressBookSelect->waitFor(5, fn() => $addressBookSelect->find('css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId())));
|
||||
|
||||
if (null === $addressOption) {
|
||||
throw new ElementNotFoundException($this->getDriver(), 'option', 'css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId()));
|
||||
|
|
@ -250,9 +246,7 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
$addressBookSelect = $this->getElement('billing_address_book');
|
||||
|
||||
$addressBookSelect->click();
|
||||
$addressOption = $addressBookSelect->waitFor(5, function () use ($address, $addressBookSelect) {
|
||||
return $addressBookSelect->find('css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId()));
|
||||
});
|
||||
$addressOption = $addressBookSelect->waitFor(5, fn() => $addressBookSelect->find('css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId())));
|
||||
|
||||
if (null === $addressOption) {
|
||||
throw new ElementNotFoundException($this->getDriver(), 'option', 'css', sprintf('[data-test-address-book-item][data-id="%s"]', $address->getId()));
|
||||
|
|
@ -325,7 +319,7 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
{
|
||||
return array_map(
|
||||
/** @return string[] */
|
||||
static function (NodeElement $element): string { return $element->getText(); },
|
||||
static fn(NodeElement $element): string => $element->getText(),
|
||||
$element->findAll('css', 'option[value!=""]')
|
||||
);
|
||||
}
|
||||
|
|
@ -389,16 +383,12 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
|
||||
private function waitForLoginAction(): bool
|
||||
{
|
||||
return $this->getDocument()->waitFor(5, function () {
|
||||
return !$this->hasElement('login_password');
|
||||
});
|
||||
return $this->getDocument()->waitFor(5, fn() => !$this->hasElement('login_password'));
|
||||
}
|
||||
|
||||
private function waitForElement(int $timeout, string $elementName): bool
|
||||
{
|
||||
return $this->getDocument()->waitFor($timeout, function () use ($elementName) {
|
||||
return $this->hasElement($elementName);
|
||||
});
|
||||
return $this->getDocument()->waitFor($timeout, fn() => $this->hasElement($elementName));
|
||||
}
|
||||
|
||||
private function assertAddressType(string $type): void
|
||||
|
|
|
|||
|
|
@ -56,9 +56,7 @@ class HomePage extends SymfonyPage implements HomePageInterface
|
|||
public function getAvailableCurrencies(): array
|
||||
{
|
||||
return array_map(
|
||||
function (NodeElement $element) {
|
||||
return $element->getText();
|
||||
},
|
||||
fn(NodeElement $element) => $element->getText(),
|
||||
$this->getElement('currency_selector')->findAll('css', '[data-test-available-currency]')
|
||||
);
|
||||
}
|
||||
|
|
@ -81,9 +79,7 @@ class HomePage extends SymfonyPage implements HomePageInterface
|
|||
public function getAvailableLocales(): array
|
||||
{
|
||||
return array_map(
|
||||
function (NodeElement $element) {
|
||||
return $element->getText();
|
||||
},
|
||||
fn(NodeElement $element) => $element->getText(),
|
||||
$this->getElement('locale_selector')->findAll('css', '[data-test-available-locale]')
|
||||
);
|
||||
}
|
||||
|
|
@ -96,9 +92,7 @@ class HomePage extends SymfonyPage implements HomePageInterface
|
|||
public function getLatestProductsNames(): array
|
||||
{
|
||||
return array_map(
|
||||
function (NodeElement $element) {
|
||||
return $element->getText();
|
||||
},
|
||||
fn(NodeElement $element) => $element->getText(),
|
||||
$this->getElement('latest_products')->findAll('css', '[data-test-product-name]')
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,9 +151,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
$productPriceContent = $this->getElement('product_price_content');
|
||||
$catalogPromotions = $productPriceContent->findAll('css', '.promotion_label');
|
||||
|
||||
return array_map(function (NodeElement $element): string {
|
||||
return $element->getText();
|
||||
}, $catalogPromotions);
|
||||
return array_map(fn(NodeElement $element): string => $element->getText(), $catalogPromotions);
|
||||
}
|
||||
|
||||
public function getCurrentUrl(): string
|
||||
|
|
@ -341,9 +339,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
$optionElement = $this->getElement('option_select', ['%optionCode%' => strtoupper($optionCode)]);
|
||||
|
||||
return array_map(
|
||||
function (NodeElement $element) {
|
||||
return $element->getText();
|
||||
},
|
||||
fn(NodeElement $element) => $element->getText(),
|
||||
$optionElement->findAll('css', 'option')
|
||||
);
|
||||
}
|
||||
|
|
@ -387,9 +383,7 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
{
|
||||
if ($this->getDriver() instanceof Selenium2Driver || $this->getDriver() instanceof ChromeDriver) {
|
||||
JQueryHelper::waitForAsynchronousActionsToFinish($this->getSession());
|
||||
$this->getDocument()->waitFor(3, function (): bool {
|
||||
return $this->summaryPage->isOpen();
|
||||
});
|
||||
$this->getDocument()->waitFor(3, fn(): bool => $this->summaryPage->isOpen());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ final class JavaScriptTestHelper implements JavaScriptTestHelperInterface
|
|||
private function waitUntilExceptionDisappears(callable $callable, string $exceptionClass, ?int $timeout = null): void
|
||||
{
|
||||
$start = microtime(true);
|
||||
$timeout = $timeout ?? $this->defaultTimeout;
|
||||
$timeout ??= $this->defaultTimeout;
|
||||
$end = $start + $timeout;
|
||||
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ abstract class JQueryHelper
|
|||
public static function waitForFormToStopLoading(DocumentElement $document, int $timeout = 10): void
|
||||
{
|
||||
$form = $document->find('css', 'form');
|
||||
$document->waitFor($timeout, function () use ($form) {
|
||||
return !$form->hasClass('loading');
|
||||
});
|
||||
$document->waitFor($timeout, fn() => !$form->hasClass('loading'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ final class CookieSetter implements CookieSetterInterface
|
|||
{
|
||||
private Session $minkSession;
|
||||
|
||||
/** @var array */
|
||||
private $minkParameters;
|
||||
private array $minkParameters;
|
||||
|
||||
public function __construct(Session $minkSession, $minkParameters)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue