当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper::checkArray方法代码示例

本文整理汇总了PHP中Shopware\Tests\Mink\Helper::checkArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Helper::checkArray方法的具体用法?PHP Helper::checkArray怎么用?PHP Helper::checkArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shopware\Tests\Mink\Helper的用法示例。


在下文中一共展示了Helper::checkArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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'];
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:31,代码来源:CartPosition.php

示例2: 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);
     }
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:16,代码来源:HeaderCart.php

示例3: 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);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:14,代码来源:Blog.php

示例4: checkAggregation

 /**
  * Checks the aggregation
  * @param $aggregation
  * @throws \Exception
  */
 public function checkAggregation($aggregation)
 {
     $elements = Helper::findAllOfElements($this, ['aggregationLabels', 'aggregationValues']);
     $lang = Helper::getCurrentLanguage();
     $check = [];
     foreach ($aggregation as $property) {
         $key = $this->getAggregationPosition($elements['aggregationLabels'], $property['label'], $lang);
         $check[$property['label']] = Helper::floatArray([$property['value'], $elements['aggregationValues'][$key]->getText()]);
         unset($elements['aggregationLabels'][$key]);
         unset($elements['aggregationValues'][$key]);
     }
     $result = Helper::checkArray($check);
     if ($result !== true) {
         $message = sprintf('The value of "%s" is "%s"! (should be "%s")', $result, $check[$result][1], $check[$result][0]);
         Helper::throwException($message);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:22,代码来源:CheckoutCart.php

示例5: 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);
     }
 }
开发者ID:BucherStoerzbachGbR,项目名称:shopware,代码行数:24,代码来源:Detail.php

示例6: checkXml

 /**
  * @param array $links
  * @throws \Exception
  */
 public function checkXml(array $links)
 {
     $homepageUrl = rtrim($this->getParameter('base_url'), '/');
     $xml = new \SimpleXMLElement($this->getContent());
     $check = [];
     $i = 0;
     foreach ($xml as $link) {
         if (empty($links[$i])) {
             $messages = ['There are more links in the sitemap.xml as expected!', sprintf('(%d sites in sitemap.xml, %d in test data', count($xml), count($links))];
             Helper::throwException($messages);
         }
         $check[] = [(string) $link->loc, $homepageUrl . $links[$i]['link']];
         $i++;
     }
     $result = Helper::checkArray($check, true);
     if ($result === true) {
         return;
     }
     $messages = ['A link is different!', 'Read: ' . $check[$result][0], 'Expected: ' . $check[$result][1]];
     Helper::throwException($messages);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:25,代码来源:Sitemap.php

示例7: checkRating

 /**
  * @param ArticleEvaluation $articleEvaluations
  * @param $average
  * @throws \Exception
  */
 protected function checkRating(ArticleEvaluation $articleEvaluations, $average)
 {
     $elements = Helper::findElements($this, ['productRating', 'productRatingCount', 'productEvaluationAverage', 'productEvaluationCount']);
     $check = ['productRating' => [$elements['productRating']->getAttribute('class'), $average], 'productRatingCount' => [$elements['productRatingCount']->getText(), count($articleEvaluations)], 'productEvaluationAverage' => [$elements['productEvaluationAverage']->getAttribute('class'), $average], 'productEvaluationCount' => [$elements['productEvaluationCount']->getText(), count($articleEvaluations)]];
     $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);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:16,代码来源:Detail.php


注:本文中的Shopware\Tests\Mink\Helper::checkArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。