/** * @Then /^I should see (?P<quantity>\d+) element of type "(?P<elementClass>[^"]*)"$/ * @Then /^I should see (?P<quantity>\d+) elements of type "(?P<elementClass>[^"]*)"$/ */ public function iShouldSeeElementsOfType($count, $elementClass) { /** @var Homepage $page */ $page = $this->getPage('Homepage'); $elements = $this->getMultipleElement($page, $elementClass); Helper::assertElementCount($elements, $count); }
/** * @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); } }
/** * 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); } }
/** * Checks the product comparison * Available properties are: image, name, ranking, description, price, link * * @param CompareColumn $compareColumns * @param array $items */ public function checkComparisonProducts(CompareColumn $compareColumns, array $items) { Helper::assertElementCount($compareColumns, count($items)); $result = Helper::searchElements($items, $compareColumns); if ($result !== true) { $messages = ['The following articles were not found:']; foreach ($result as $product) { $messages[] = $product['name']; } Helper::throwException($messages); } }