本文整理汇总了PHP中Shopware\Tests\Mink\Helper::throwException方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::throwException方法的具体用法?PHP Helper::throwException怎么用?PHP Helper::throwException使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shopware\Tests\Mink\Helper
的用法示例。
在下文中一共展示了Helper::throwException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUniqueName
/**
* @param array $names
* @return string
* @throws \Exception
*/
protected function getUniqueName(array $names)
{
$name = array_unique($names);
switch (count($name)) {
//normal case
case 1:
return current($name);
//if articleName is too long, it will be cut. So it's different from the other and has to be checked separately
//if articleName is too long, it will be cut. So it's different from the other and has to be checked separately
case 2:
$check = array($name);
$result = Helper::checkArray($check);
break;
default:
$result = false;
break;
}
if ($result !== true) {
$messages = ['The cart item has different names!'];
foreach ($name as $key => $value) {
$messages[] = sprintf('"%s" (Key: "%s")', $value, $key);
}
Helper::throwException($messages);
}
return $name['articleTitle'];
}
示例2: verifyPage
/**
* Verify if we're on an expected page. Throw an exception if not.
* @throws \Exception
*/
public function verifyPage()
{
$errors = [];
if (!$this->hasSelect('subscribeToNewsletter')) {
$errors[] = '- There is no newsletter subscription select!';
}
if (!$this->hasField('newsletter')) {
$errors[] = '- There is no email field!';
}
if (!$this->hasSelect('salutation')) {
$errors[] = '- There is no salutation select!';
}
if (!$this->hasField('firstname')) {
$errors[] = '- There is no firstname field!';
}
if (!$this->hasField('lastname')) {
$errors[] = '- There is no lastname field!';
}
if (!$this->hasField('street')) {
$errors[] = '- There is no street field!';
}
if (!$this->hasField('zipcode')) {
$errors[] = '- There is no zip code field!';
}
if (!$this->hasField('city')) {
$errors[] = '- There is no city field!';
}
if (!$errors) {
return;
}
$message = ['You are not on the newsletter page:'];
$message = array_merge($message, $errors);
$message[] = 'Current URL: ' . $this->getSession()->getCurrentUrl();
Helper::throwException($message);
}
示例3: changeCurrency
/**
* Changes the currency
* @param string $currency
* @throws \Behat\Mink\Exception\ElementNotFoundException
*/
public function changeCurrency($currency)
{
if (!$this->getDriver() instanceof Selenium2Driver) {
Helper::throwException('Changing the currency in Responsive template requires Javascript!');
}
$valid = ['EUR' => '€ EUR', 'USD' => '$ USD'];
$this->selectFieldOption('__currency', $valid[$currency]);
}
示例4: verifyPage
/**
* @param string $language
* @return bool
* @throws \Exception
*/
public function verifyPage($language = '')
{
$info = Helper::getPageInfo($this->getSession(), ['controller', 'action']);
if ($info['controller'] === 'checkout' && $info['action'] === 'cart') {
return Helper::hasNamedLink($this, 'checkout', $language);
}
$message = ['You are not on the cart!', 'Current URL: ' . $this->getSession()->getCurrentUrl()];
Helper::throwException($message);
return false;
}
示例5: checkCart
/**
*
* @param string $quantity
* @param float $amount
* @throws \Exception
*/
public function checkCart($quantity, $amount)
{
$element = Helper::findElements($this, ['quantity', 'amount']);
$check = array('quantity' => array($element['quantity']->getText(), $quantity), 'amount' => Helper::floatArray(array($element['amount']->getText(), $amount)));
$result = Helper::checkArray($check);
if ($result !== true) {
$message = sprintf('The %s of the header cart is wrong! (%s instead of %s)', $result, $check[$result][0], $check[$result][1]);
Helper::throwException($message);
}
}
示例6: checkRating
/**
* @inheritdoc
*/
protected function checkRating(BlogComment $blogComments, $average)
{
$elements = Helper::findElements($this, ['articleRating', 'articleRatingCount']);
$check = ['articleRating' => [$elements['articleRating']->getAttribute('content'), $average], 'articleRatingCount' => [$elements['articleRatingCount']->getText(), count($blogComments)]];
$check = Helper::floatArray($check);
$result = Helper::checkArray($check);
if ($result !== true) {
$message = sprintf('There was a different value of the rating! (%s: "%s" instead of "%s")', $result, $check[$result][0], $check[$result][1]);
Helper::throwException($message);
}
}
示例7: checkNoteProducts
/**
* @param NotePosition $notePositions
* @param array $items
*/
public function checkNoteProducts(NotePosition $notePositions, array $items)
{
Helper::assertElementCount($notePositions, count($items));
$result = Helper::searchElements($items, $notePositions);
if ($result !== true) {
$messages = ['The following articles were not found:'];
foreach ($result as $product) {
$messages[] = $product['number'] . ' - ' . $product['name'];
}
Helper::throwException($messages);
}
}
示例8: checkCaptcha
public function checkCaptcha()
{
$locators = array('captchaPlaceholder', 'captchaImage', 'captchaHidden');
$element = Helper::findElements($this, $locators);
$captchaPlaceholder = $element['captchaPlaceholder']->getAttribute('data-src');
$captchaImage = $element['captchaImage']->getAttribute('src');
$captchaHidden = $element['captchaHidden']->getValue();
if ($captchaPlaceholder !== '/shopware/widgets/Captcha/refreshCaptcha' || strpos($captchaImage, 'data:image/png;base64') === false || empty($captchaHidden)) {
$message = 'There is no capture in this form!';
Helper::throwException($message);
}
}
示例9: checkComments
/**
* Checks the evaluations of the current article
* @param BlogComment $blogComments
* @param $average
* @param array $comments
* @throws \Exception
*/
public function checkComments(BlogComment $blogComments, $average, array $comments)
{
$this->checkRating($blogComments, $average);
$comments = Helper::floatArray($comments, ['stars']);
$result = Helper::assertElements($comments, $blogComments);
if ($result === true) {
return;
}
$messages = array('The following comments are wrong:');
foreach ($result as $evaluation) {
$messages[] = sprintf('%s - Bewertung: %s (%s is "%s", should be "%s")', $evaluation['properties']['author'], $evaluation['properties']['stars'], $evaluation['result']['key'], $evaluation['result']['value'], $evaluation['result']['value2']);
}
Helper::throwException($messages);
}
示例10: checkNoteProducts
/**
* @param NotePosition $notePositions
* @param array $items
*/
public function checkNoteProducts(NotePosition $notePositions, array $items)
{
if (count($notePositions) !== count($items)) {
$message = sprintf('There are %d products on the note! (should be %d)', count($notePositions), count($items));
Helper::throwException($message);
}
$result = Helper::searchElements($items, $notePositions);
if ($result !== true) {
$messages = array('The following articles were not found:');
foreach ($result as $product) {
$messages[] = $product['number'] . ' - ' . $product['name'];
}
Helper::throwException($messages);
}
}
示例11: checkRobots
/**
* Checks if the robots meta exists and matches the expected content
*
* @param $content
*/
public function checkRobots($content = [])
{
$elements = Helper::findElements($this, ['robots']);
$robotsElement = $elements['robots'];
$robotsValue = $robotsElement->getAttribute('content');
$robotsParts = explode(',', $robotsValue);
$robotsParts = array_map('trim', $robotsParts);
if (empty($robotsParts)) {
Helper::throwException(['Missing robots data']);
}
if ($robotsParts != $content) {
$message = sprintf('Canonical link "%s" does not match expected value "%s"', implode(', ', $robotsParts), implode(', ', $content));
Helper::throwException([$message]);
}
}
示例12: checkCaptcha
/**
* Checks, whether a captcha exists and has loaded correctly
* @throws \Exception
*/
public function checkCaptcha()
{
$placeholderSelector = Helper::getRequiredSelector($this, 'captchaPlaceholder');
if (!$this->getSession()->wait(5000, "\$('{$placeholderSelector}').children().length > 0")) {
$message = 'The captcha was not loaded or does not exist!';
Helper::throwException($message);
}
$element = Helper::findElements($this, ['captchaPlaceholder', 'captchaImage', 'captchaHidden']);
$captchaPlaceholder = $element['captchaPlaceholder']->getAttribute('data-src');
$captchaImage = $element['captchaImage']->getAttribute('src');
$captchaHidden = $element['captchaHidden']->getValue();
if (strpos($captchaPlaceholder, '/widgets/Captcha/refreshCaptcha') === false || strpos($captchaImage, 'data:image/png;base64') === false || empty($captchaHidden)) {
$message = 'The captcha was not loaded correctly!';
Helper::throwException($message);
}
}
示例13: verifyPage
/**
* @inheritdoc
*/
public function verifyPage()
{
if (Helper::hasNamedLink($this, 'moreProducts')) {
return;
}
$errors = [];
if (!$this->hasLink('Filtern')) {
$errors[] = '- There is no filter link!';
}
if (!$this->hasSelect('o')) {
$errors[] = '- There is no order select!';
}
if (!$errors) {
return;
}
$message = ['You are not on a listing:'];
$message = array_merge($message, $errors);
$message[] = 'Current URL: ' . $this->getSession()->getCurrentUrl();
Helper::throwException($message);
}
示例14: checkRating
protected function checkRating(MultipleElement $articleEvaluations, $average)
{
$locators = array('productRating', 'productRatingCount');
$elements = Helper::findElements($this, $locators);
$check = array();
foreach ($elements as $locator => $element) {
switch ($locator) {
case 'productRating':
$rating = $element->getAttribute('content');
$rating = floatval($rating);
$check[$locator] = array($rating, $average);
break;
case 'productRatingCount':
$check[$locator] = array($element->getText(), count($articleEvaluations));
break;
}
}
$check = Helper::floatArray($check);
$result = Helper::checkArray($check);
if ($result !== true) {
$message = sprintf('There was a different value of the evaluation! (%s: "%s" instead of %s)', $result, $check[$result][0], $check[$result][1]);
Helper::throwException($message);
}
}
示例15: changeConfigValue
/**
* @param string $configName
* @param mixed $value
*/
public function changeConfigValue($configName, $value)
{
/** @var Connection $dbal */
$dbal = $this->getService('dbal_connection');
$configId = $dbal->fetchColumn('SELECT `id` FROM `s_core_config_elements` WHERE `name` = ?', [$configName]);
if (!$configId) {
$message = sprintf('Configuration "%s" doesn\'t exist!', $configName);
Helper::throwException($message);
}
$this->dirtyConfigElements[] = $configId;
/** @var \Shopware\Components\ConfigWriter $configWriter */
$configWriter = $this->getService('config_writer');
$configWriter->save($configName, $value, null, 1);
$configWriter->save($configName, $value, null, 2);
$config = $this->getService('config');
$config->offsetSet($configName, $value);
$this->clearCache();
}