/**
  *
  * @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);
     }
 }
示例#2
0
 /**
  * @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);
     }
 }
示例#3
0
 /**
  * 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);
 }
示例#4
0
 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);
     }
 }
示例#5
0
 /**
  * @Then /^I should see an article slider:$/
  */
 public function iShouldSeeAnArticleSlider(TableNode $articles)
 {
     /** @var Homepage $page */
     $page = $this->getPage('Homepage');
     /** @var \Shopware\Tests\Mink\Element\Emotion\ManufacturerSlider $slider */
     $slider = $this->getMultipleElement($page, 'ArticleSlider', 1);
     $products = Helper::floatArray($articles->getHash(), ['price']);
     $page->checkSlider($slider, $products);
 }
示例#6
0
 /**
  * Checks an emotion article element
  * @param Article $article
  * @param array $data
  */
 public function checkArticle(Article $article, array $data)
 {
     $properties = Helper::convertTableHashToArray($data);
     $properties = Helper::floatArray($properties, ['price']);
     $result = Helper::assertElementProperties($article, $properties);
     if ($result === true) {
         return;
     }
     $message = sprintf('The article %s is "%s" (should be "%s")', $result['key'], $result['value'], $result['value2']);
     Helper::throwException($message);
 }
示例#7
0
 /**
  * @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);
     }
 }
示例#8
0
 /**
  * Helper method checks the order positions
  * @param AccountOrder $order
  * @param array $articles
  * @throws \Exception
  */
 private function checkOrderPositions(AccountOrder $order, array $articles)
 {
     $positions = $order->getPositions(array('product', 'quantity', 'price', 'sum'));
     $data = array();
     foreach ($articles as $key => $article) {
         $data[$key] = Helper::floatArray(array('quantity' => $article['quantity'], 'price' => $article['price'], 'sum' => $article['sum']));
         $data[$key]['product'] = $article['product'];
     }
     $result = Helper::compareArrays($positions, $data);
     if ($result === true) {
         return;
     }
     $message = sprintf('The %s of a position is different! (is "%s", should be "%s")', $result['key'], $result['value'], $result['value2']);
     Helper::throwException($message);
 }
示例#9
0
 /**
  * Checks the cart positions
  * Available properties are: number (required), name (required), quantity, itemPrice, sum
  * @param CartPosition $cartPositions
  * @param array $items
  */
 public function checkCartProducts(CartPosition $cartPositions, array $items)
 {
     Helper::assertElementCount($cartPositions, count($items));
     $items = Helper::floatArray($items, ['quantity', 'itemPrice', 'sum']);
     $result = Helper::assertElements($items, $cartPositions);
     if ($result !== true) {
         $messages = ['The following articles are wrong:'];
         foreach ($result as $product) {
             $messages[] = sprintf('%s - %s (%s is "%s", should be "%s")', $product['properties']['number'], $product['properties']['name'], $product['result']['key'], $product['result']['value'], $product['result']['value2']);
         }
         Helper::throwException($messages);
     }
 }