本文整理汇总了PHP中Webmozart\Assert\Assert::true方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::true方法的具体用法?PHP Assert::true怎么用?PHP Assert::true使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::true方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createForPromotion
/**
* {@inheritdoc}
*/
public function createForPromotion(PromotionInterface $promotion)
{
Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
$coupon = $this->factory->createNew();
$coupon->setPromotion($promotion);
return $coupon;
}
示例2: createForPromotion
/**
* {@inheritdoc}
*/
public function createForPromotion($promotionId)
{
/** @var PromotionInterface $promotion */
Assert::notNull($promotion = $this->promotionRepository->find($promotionId), sprintf('Promotion with id %s does not exist.', $promotionId));
Assert::true($promotion->isCouponBased(), sprintf('Promotion with name %s is not coupon based.', $promotion->getName()));
$coupon = $this->factory->createNew();
$coupon->setPromotion($promotion);
return $coupon;
}
示例3: getSupportedMethods
/**
* {@inheritdoc}
*/
public function getSupportedMethods(ShippingSubjectInterface $subject)
{
/** @var ShipmentInterface $subject */
Assert::true($this->supports($subject));
/** @var OrderInterface $order */
$order = $subject->getOrder();
$zones = $this->zoneMatcher->matchAll($order->getShippingAddress());
if (empty($zones)) {
return [];
}
return $this->shippingMethodRepository->findEnabledForZonesAndChannel($zones, $order->getChannel());
}
示例4: generate
/**
* {@inheritdoc}
*/
public function generate(ProductInterface $product)
{
Assert::true($product->hasOptions(), 'Cannot generate variants for an object without options.');
$optionSet = [];
$optionMap = [];
foreach ($product->getOptions() as $key => $option) {
foreach ($option->getValues() as $value) {
$optionSet[$key][] = $value->getId();
$optionMap[$value->getId()] = $value;
}
}
$permutations = $this->setBuilder->build($optionSet);
foreach ($permutations as $permutation) {
$variant = $this->createVariant($product, $optionMap, $permutation);
$product->addVariant($variant);
}
}
示例5: getSupportedMethods
/**
* {@inheritdoc}
*/
public function getSupportedMethods(ShippingSubjectInterface $subject)
{
/** @var ShipmentInterface $subject */
Assert::true($this->supports($subject));
/** @var OrderInterface $order */
$order = $subject->getOrder();
$zones = $this->zoneMatcher->matchAll($order->getShippingAddress());
if (empty($zones)) {
return [];
}
$methods = [];
$shippingMethods = $this->shippingMethodRepository->findEnabledForZonesAndChannel($zones, $order->getChannel());
foreach ($shippingMethods as $shippingMethod) {
if ($this->eligibilityChecker->isEligible($subject, $shippingMethod)) {
$methods[] = $shippingMethod;
}
}
return $methods;
}
示例6: assertIfFieldIsTrue
/**
* @param PromotionInterface $promotion
* @param string $field
*/
private function assertIfFieldIsTrue(PromotionInterface $promotion, $field)
{
$this->iWantToModifyAPromotion($promotion);
Assert::true($this->updatePage->hasResourceValues([$field => 1]), sprintf('Promotion %s is not %s, but it should be.', $promotion->getName(), str_replace('_', ' ', $field)));
}
示例7: assertElementValidationMessage
/**
* @param string $type
* @param string $element
* @param string $expectedMessage
*
* @throws \InvalidArgumentException
*/
private function assertElementValidationMessage($type, $element, $expectedMessage)
{
$element = sprintf('%s_%s', $type, implode('_', explode(' ', $element)));
Assert::true($this->addressPage->checkValidationMessageFor($element, $expectedMessage), sprintf('The %s should be required.', $element));
}
示例8: thisProvinceShouldStillBeNamed
/**
* @Then /^the province should still be named "([^"]*)" in (this country)$/
*/
public function thisProvinceShouldStillBeNamed($provinceName, CountryInterface $country)
{
$this->updatePage->open(['id' => $country->getId()]);
Assert::true($this->updatePage->isThereProvince($provinceName), sprintf('%s is not a province of this country.', $provinceName));
}
示例9: assertFieldValidationMessage
/**
* @param string $element
* @param string $expectedMessage
*/
private function assertFieldValidationMessage($element, $expectedMessage)
{
$currentPage = $this->currentPageResolver->getCurrentPageWithForm($this->createPage, $this->updatePage);
Assert::true($currentPage->checkValidationMessageFor($element, $expectedMessage), sprintf('Tax rate %s should be required.', $element));
}
示例10: iShouldBeNotifiedThatProvinceCodeMustBeUnique
/**
* @Then /^I should be notified that province code must be unique$/
*/
public function iShouldBeNotifiedThatProvinceCodeMustBeUnique()
{
Assert::true($this->updatePage->checkValidationMessageFor('code', 'Province code must be unique.'), 'Unique code violation message should appear on page, but it does not.');
}
示例11: thisChannelNameShouldBe
/**
* @Then /^(this customer group) should still be named "([^"]+)"$/
*/
public function thisChannelNameShouldBe(CustomerGroupInterface $customerGroup, $customerGroupName)
{
$this->iWantToBrowseCustomerGroupsOfTheStore();
Assert::true($this->indexPage->isSingleResourceOnPage(['name' => $customerGroup->getName()]), sprintf('Customer group name %s has not been assigned properly.', $customerGroupName));
}
示例12: iShouldBeNotifiedThatIsRequired
/**
* @Then I should be notified that :element is required
*/
public function iShouldBeNotifiedThatIsRequired($element)
{
$currentPage = $this->currentPageResolver->getCurrentPageWithForm($this->createPage, $this->updatePage);
Assert::true($currentPage->checkValidationMessageFor($element, sprintf('Please enter tax category %s.', $element)), sprintf('Tax category %s should be required.', $element));
}
示例13: iShouldBeNotifiedThatGeneratingCouponsWithCodeLengthIsNotPossible
/**
* @Then /^I should be notified that generating (\d+) coupons with code length equal to (\d+) is not possible$/
*/
public function iShouldBeNotifiedThatGeneratingCouponsWithCodeLengthIsNotPossible($amount, $codeLength)
{
$message = sprintf('Invalid coupons code length or coupons amount. It is not possible to generate %d unique coupons with code length equals %d. Possible generate amount is 8.', $amount, $codeLength);
Assert::true($this->generatePage->checkGenerationValidation($message), 'Generate violation message should appear on page, but it does not.');
}
示例14: iShouldBeNotifiedThatThisProductDoesNotHaveSufficientStock
/**
* @Then /^I should be notified that (this product) cannot be updated$/
*/
public function iShouldBeNotifiedThatThisProductDoesNotHaveSufficientStock(ProductInterface $product)
{
Assert::true($this->summaryPage->hasProductOutOfStockValidationMessage($product), sprintf('I should see validation message for %s product', $product->getName()));
}
示例15: thisProductOptionShouldHaveTheOptionValue
/**
* @Then /^(this product option) should have the "([^"]*)" option value$/
*/
public function thisProductOptionShouldHaveTheOptionValue(ProductOptionInterface $productOption, $optionValue)
{
$this->iWantToModifyAProductOption($productOption);
Assert::true($this->updatePage->isThereOptionValue($optionValue), sprintf('%s is not a value of this product option.', $optionValue));
}