Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scalar types in Behat/Page/Admin directory #10045

Merged
merged 1 commit into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/Sylius/Behat/Behaviour/ChecksCodeImmutability.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,9 @@

trait ChecksCodeImmutability
{
/**
* @return NodeElement
*/
abstract protected function getCodeElement();
abstract protected function getCodeElement(): NodeElement;

/**
* @return bool
*/
public function isCodeDisabled()
public function isCodeDisabled(): bool
{
return 'disabled' === $this->getCodeElement()->getAttribute('disabled');
}
Expand Down
5 changes: 1 addition & 4 deletions src/Sylius/Behat/Behaviour/ChoosesName.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ trait ChoosesName
{
use DocumentAccessor;

/**
* @param string $name
*/
public function chooseName($name)
public function chooseName(string $name): void
{
$this->getDocument()->selectFieldOption('Name', $name);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Sylius/Behat/Behaviour/DescribesIt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ trait DescribesIt
{
use DocumentAccessor;

/**
* @param string $description
*/
public function describeItAs($description)
public function describeItAs(string $description): void
{
$this->getDocument()->fillField('Description', $description);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Sylius/Behat/Behaviour/NamesIt.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ trait NamesIt
{
use DocumentAccessor;

/**
* @param string $name
*/
public function nameIt($name)
public function nameIt(string $name): void
{
$this->getDocument()->fillField('Name', $name);
}
Expand Down
5 changes: 1 addition & 4 deletions src/Sylius/Behat/Behaviour/SpecifiesItsCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ trait SpecifiesItsCode
{
use DocumentAccessor;

/**
* @param string $code
*/
public function specifyCode($code)
public function specifyCode(string $code): void
{
$this->getDocument()->fillField('Code', $code);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Sylius/Behat/Behaviour/Toggles.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ trait Toggles
/**
* @return NodeElement
*/
abstract protected function getToggleableElement();
abstract protected function getToggleableElement(): NodeElement;

/**
* @throws \RuntimeException If already enabled
*/
public function enable()
public function enable(): void
{
$toggleableElement = $this->getToggleableElement();
$this->assertCheckboxState($toggleableElement, false);
Expand All @@ -36,7 +36,7 @@ public function enable()
/**
* @throws \RuntimeException If already disabled
*/
public function disable()
public function disable(): void
{
$toggleableElement = $this->getToggleableElement();
$this->assertCheckboxState($toggleableElement, true);
Expand Down
16 changes: 8 additions & 8 deletions src/Sylius/Behat/Context/Setup/ProductContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function __construct(
* @Given /^the store(?:| also) has a product "([^"]+)" priced at ("[^"]+")$/
* @Given /^the store(?:| also) has a product "([^"]+)" priced at ("[^"]+") in ("[^"]+" channel)$/
*/
public function storeHasAProductPricedAt($productName, $price = 100, ChannelInterface $channel = null)
public function storeHasAProductPricedAt($productName, int $price = 100, ChannelInterface $channel = null)
{
$product = $this->createProduct($productName, $price, $channel);

Expand All @@ -143,7 +143,7 @@ public function storeHasAProductPricedAt($productName, $price = 100, ChannelInte
/**
* @Given /^(this product) is(?:| also) priced at ("[^"]+") in ("[^"]+" channel)$/
*/
public function thisProductIsAlsoPricedAtInChannel(ProductInterface $product, $price, ChannelInterface $channel)
public function thisProductIsAlsoPricedAtInChannel(ProductInterface $product, int $price, ChannelInterface $channel)
{
$product->addChannel($channel);

Expand Down Expand Up @@ -178,7 +178,7 @@ public function storeHasProductWithCode($productName, $code, $date = 'now')
/**
* @Given /^the store(?:| also) has a product "([^"]+)" priced at ("[^"]+") available in (channel "[^"]+") and (channel "[^"]+")$/
*/
public function storeHasAProductPricedAtAvailableInChannels($productName, $price = 100, ...$channels)
public function storeHasAProductPricedAtAvailableInChannels($productName, int $price = 100, ...$channels)
{
$product = $this->createProduct($productName, $price);
/** @var ProductVariantInterface $productVariant */
Expand Down Expand Up @@ -381,7 +381,7 @@ public function theProductHasVariantAtPosition(
/**
* @Given /^(this variant) is also priced at ("[^"]+") in ("([^"]+)" channel)$/
*/
public function thisVariantIsAlsoPricedAtInChannel(ProductVariantInterface $productVariant, $price, ChannelInterface $channel)
public function thisVariantIsAlsoPricedAtInChannel(ProductVariantInterface $productVariant, string $price, ChannelInterface $channel)
{
$productVariant->addChannelPricing($this->createChannelPricingForChannel(
$this->getPriceFromString(str_replace(['$', '€', '£'], '', $price)),
Expand Down Expand Up @@ -578,7 +578,7 @@ public function thisProductIsTrackedByTheInventory(ProductInterface $product)
/**
* @Given /^(this product) is available in "([^"]+)" ([^"]+) priced at ("[^"]+")$/
*/
public function thisProductIsAvailableInSize(ProductInterface $product, $optionValueName, $optionName, $price)
public function thisProductIsAvailableInSize(ProductInterface $product, $optionValueName, $optionName, int $price)
{
/** @var ProductVariantInterface $variant */
$variant = $this->productVariantFactory->createNew();
Expand Down Expand Up @@ -681,7 +681,7 @@ public function theProductVariantIsTrackedByTheInventory(ProductVariantInterface
* @Given /^the (product "[^"]+") changed its price to ("[^"]+")$/
* @Given /^(this product) price has been changed to ("[^"]+")$/
*/
public function theProductChangedItsPriceTo(ProductInterface $product, $price)
public function theProductChangedItsPriceTo(ProductInterface $product, int $price)
{
/** @var ProductVariantInterface $productVariant */
$productVariant = $this->defaultVariantResolver->getVariant($product);
Expand Down Expand Up @@ -752,7 +752,7 @@ private function getPriceFromString(string $price): int
*
* @return ProductInterface
*/
private function createProduct($productName, $price = 100, ChannelInterface $channel = null)
private function createProduct($productName, int $price = 100, ChannelInterface $channel = null)
{
if (null === $channel && $this->sharedStorage->has('channel')) {
$channel = $this->sharedStorage->get('channel');
Expand Down Expand Up @@ -904,7 +904,7 @@ private function addProductVariantTranslation(ProductVariantInterface $productVa
*
* @return ChannelPricingInterface
*/
private function createChannelPricingForChannel($price, ChannelInterface $channel = null)
private function createChannelPricingForChannel(int $price, ChannelInterface $channel = null)
{
/** @var ChannelPricingInterface $channelPricing */
$channelPricing = $this->channelPricingFactory->createNew();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function iWantToBrowseAdministrators()
*/
public function iSpecifyItsNameAs($username = null)
{
$this->createPage->specifyUsername($username);
$this->createPage->specifyUsername($username ?? '');
}

/**
Expand All @@ -97,7 +97,7 @@ public function iChangeItsNameTo($username)
*/
public function iSpecifyItsEmailAs($email = null)
{
$this->createPage->specifyEmail($email);
$this->createPage->specifyEmail($email ?? '');
}

/**
Expand Down Expand Up @@ -131,7 +131,7 @@ public function iSetMyLocaleTo($localeCode)
*/
public function iSpecifyItsPasswordAs($password = null)
{
$this->createPage->specifyPassword($password);
$this->createPage->specifyPassword($password ?? '');
}

/**
Expand Down
11 changes: 6 additions & 5 deletions src/Sylius/Behat/Context/Ui/Admin/ManagingChannelsContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Sylius\Behat\Service\Resolver\CurrentPageResolverInterface;
use Sylius\Component\Core\Formatter\StringInflector;
use Sylius\Component\Core\Model\ChannelInterface;
use Sylius\Component\Currency\Model\CurrencyInterface;
use Webmozart\Assert\Assert;

final class ManagingChannelsContext implements Context
Expand Down Expand Up @@ -69,7 +70,7 @@ public function iWantToCreateANewChannel()
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand All @@ -80,16 +81,16 @@ public function iSpecifyItsCodeAs($code = null)
*/
public function iNameIt($name = null)
{
$this->createPage->nameIt($name);
$this->createPage->nameIt($name ?? '');
}

/**
* @When I choose :currency as the base currency
* @When I do not choose base currency
*/
public function iChooseAsABaseCurrency($currency = null)
public function iChooseAsABaseCurrency(?CurrencyInterface $currency = null)
{
$this->createPage->chooseBaseCurrency($currency);
$this->createPage->chooseBaseCurrency($currency ? $currency->getName() : null);
}

/**
Expand Down Expand Up @@ -427,7 +428,7 @@ public function iSelectDefaultTaxZone($taxZone)
*/
public function iRemoveItsDefaultTaxZone()
{
$this->updatePage->chooseDefaultTaxZone(null);
$this->updatePage->chooseDefaultTaxZone('');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function iWantToCreateANewProvinceInCountry(CountryInterface $country)
*/
public function iNameTheProvince($provinceName = null)
{
$this->updatePage->nameProvince($provinceName);
$this->updatePage->nameProvince($provinceName ?? '');
}

/**
Expand All @@ -253,7 +253,7 @@ public function iNameTheProvince($provinceName = null)
*/
public function iSpecifyTheProvinceCode($provinceCode = null)
{
$this->updatePage->specifyProvinceCode($provinceCode);
$this->updatePage->specifyProvinceCode($provinceCode ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function iWantToCreateANewCustomerGroup()
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand All @@ -64,7 +64,7 @@ public function iSpecifyItsCodeAs($code = null)
*/
public function iSpecifyItsNameAs($name = null)
{
$this->createPage->nameIt($name);
$this->createPage->nameIt($name ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ public function iSpecifyItsLastNameAs($name)
*/
public function iSpecifyItsEmailAs($email = null)
{
$this->createPage->specifyEmail($email);
$this->createPage->specifyEmail($email ?? '');
}

/**
* @When I change their email to :email
* @When I remove its email
*/
public function iChangeTheirEmailTo(?string $email = null): void
public function iChangeTheirEmailTo($email = null): void
{
$this->updatePage->changeEmail($email);
$this->updatePage->changeEmail($email ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function iWantToBrowseExchangeRatesOfTheStore()
*/
public function iSpecifyItsRatioAs($ratio = null)
{
$this->createPage->specifyRatio($ratio);
$this->createPage->specifyRatio($ratio ?? '');
}

/**
Expand Down Expand Up @@ -107,7 +107,7 @@ public function iAddIt()
*/
public function iChangeRatioTo($ratio)
{
$this->updatePage->changeRatio((float) $ratio);
$this->updatePage->changeRatio($ratio);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function iNameItIn($name = null, $language)
/** @var CreatePageInterface|UpdatePageInterface $currentPage */
$currentPage = $this->currentPageResolver->getCurrentPageWithForm([$this->createPage, $this->updatePage]);

$currentPage->nameIt($name, $language);
$currentPage->nameIt($name ?? '', $language);
}

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ public function iWantToCreateANewPaymentMethod($factory = 'Offline')
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function iDoNotNameIt()
*/
public function iRenameItToInLanguage($name = null, $language)
{
$this->updatePage->nameItIn($name, $language);
$this->updatePage->nameItIn($name ?? '', $language);
}

/**
Expand All @@ -103,7 +103,7 @@ public function iRenameItToInLanguage($name = null, $language)
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function iWantToCreateANewTextProductAttribute($type)
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function iNameItInLanguage($name, $language)
*/
public function iRenameItToInLanguage($name = null, $language)
{
$this->updatePage->nameItIn($name, $language);
$this->updatePage->nameItIn($name ?? '', $language);
}

/**
Expand All @@ -120,7 +120,7 @@ public function iDoNotNameIt()
*/
public function iSpecifyItsCodeAs($code = null)
{
$this->createPage->specifyCode($code);
$this->createPage->specifyCode($code ?? '');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function iWantToModifyTheProductReview(ReviewInterface $productReview)
*/
public function iChangeItsTitleTo($title = null)
{
$this->updatePage->specifyTitle($title);
$this->updatePage->specifyTitle($title ?? '');
}

/**
Expand All @@ -107,7 +107,7 @@ public function iChangeItsTitleTo($title = null)
*/
public function iChangeItsCommentTo($comment = null)
{
$this->updatePage->specifyComment($comment);
$this->updatePage->specifyComment($comment ?? '');
}

/**
Expand Down