Exemplo n.º 1
0
 /**
  * @inheritdoc
  */
 protected function resetFilters()
 {
     $elements = Helper::findAllOfElements($this, ['filterActiveProperties'], false);
     $activeProperties = array_reverse($elements['filterActiveProperties']);
     /** @var NodeElement $property */
     foreach ($activeProperties as $property) {
         $property->click();
     }
 }
Exemplo n.º 2
0
 /**
  * Returns the banner mapping
  * @return array[]
  */
 public function getMapping()
 {
     $elements = Helper::findAllOfElements($this, ['mapping']);
     $mapping = [];
     foreach ($elements['mapping'] as $link) {
         $mapping[] = ['mapping' => $link->getAttribute('href')];
     }
     return $mapping;
 }
Exemplo n.º 3
0
 /**
  * @throws \Behat\Mink\Exception\ElementException
  * @throws \Exception
  */
 protected function resetFilters()
 {
     $elements = Helper::findAllOfElements($this, ['filterFilterProperties']);
     /** @var NodeElement $property */
     foreach ($elements['filterFilterProperties'] as $property) {
         if ($property->isChecked()) {
             $property->uncheck();
         }
     }
     $this->pressShowResults();
 }
Exemplo n.º 4
0
 /**
  * Returns the order positions
  * @param string[] $locators
  * @return array[]
  */
 public function getPositions($locators = ['product', 'currentPrice', 'quantity', 'price', 'sum'])
 {
     $selectors = Helper::getRequiredSelectors($this, $locators);
     $elements = Helper::findAllOfElements($this, ['positions']);
     $positions = [];
     /** @var NodeElement $position */
     foreach ($elements['positions'] as $position) {
         $positions[] = $this->getOrderPositionData($position, $selectors);
     }
     return $positions;
 }
Exemplo n.º 5
0
 /**
  * @throws \Exception
  */
 protected function resetFilters()
 {
     $locators = array('filterCloseLinks');
     $elements = Helper::findAllOfElements($this, $locators, false);
     if (empty($elements['filterCloseLinks'])) {
         return;
     }
     $closeLinks = array_reverse($elements['filterCloseLinks']);
     foreach ($closeLinks as $closeLink) {
         $closeLink->click();
     }
 }
Exemplo n.º 6
0
 /**
  * Returns all blog articles of the element
  * @param string[] $properties
  * @return array[]
  */
 public function getArticles(array $properties)
 {
     $elements = Helper::findAllOfElements($this, ['article']);
     $articles = [];
     /** @var NodeElement $article */
     foreach ($elements['article'] as $article) {
         $articleProperties = [];
         foreach ($properties as $property) {
             $method = 'get' . ucfirst($property) . 'Property';
             $articleProperties[$property] = $this->{$method}($article);
         }
         $articles[] = $articleProperties;
     }
     return $articles;
 }
Exemplo n.º 7
0
 /**
  * Returns the slides
  * @param string[] $properties
  * @return array[]
  */
 public function getSlides(array $properties)
 {
     $elements = Helper::findAllOfElements($this, ['slide']);
     $slides = [];
     /** @var NodeElement $slide */
     foreach ($elements['slide'] as $slide) {
         $slideProperties = [];
         foreach ($properties as $property) {
             $method = 'get' . ucfirst($property) . 'Property';
             $slideProperties[$property] = $this->{$method}($slide);
         }
         $slides[] = $slideProperties;
     }
     return $slides;
 }
Exemplo n.º 8
0
 /**
  * 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);
     }
 }
Exemplo n.º 9
0
 /**
  * Returns the address elements
  * @return Element[]
  */
 public function getAddressProperty()
 {
     $elements = Helper::findAllOfElements($this, ['addressData']);
     return $elements['addressData'];
 }
Exemplo n.º 10
0
 /**
  * Helper method checks the ESD articles
  * @param string $date
  * @param array $articles
  * @throws \Exception
  */
 private function checkEsdArticles($date, array $articles)
 {
     $esd = array();
     foreach ($articles as $key => $article) {
         if (empty($article['esd'])) {
             continue;
         }
         $esd[] = $article['product'];
     }
     if (empty($esd)) {
         return;
     }
     $language = Helper::getCurrentLanguage($this);
     Helper::clickNamedLink($this, 'myEsdDownloads', $language);
     $locators = array('esdDownloads');
     $elements = Helper::findAllOfElements($this, $locators);
     $locator = Helper::getRequiredSelector($this, 'esdDownloadName');
     $downloads = array();
     /** @var NodeElement $esdDownload */
     foreach ($elements['esdDownloads'] as $esdDownload) {
         if (strpos($esdDownload->getText(), $date) !== false) {
             $downloads[] = $this->find('css', $locator)->getText();
         }
     }
     foreach ($esd as $givenEsd) {
         foreach ($downloads as $download) {
             if ($givenEsd === $download) {
                 break;
             }
             if ($download === end($downloads)) {
                 $message = sprintf('ESD-Article "%s" not found in account!', $givenEsd);
                 Helper::throwException($message);
             }
         }
     }
 }
Exemplo n.º 11
0
 /**
  * @return float
  */
 public function getStarsProperty()
 {
     $elements = Helper::findAllOfElements($this, ['stars', 'half-star'], false);
     return 2 * (count($elements['stars']) + 0.5 * count($elements['half-star']));
 }