Elcodi\Store\ProductBundle\Behat\Context::iShouldSeeCategoryMenuItem PHP Method

iShouldSeeCategoryMenuItem() public method

public iShouldSeeCategoryMenuItem ( Behat\Gherkin\Node\TableNode $table )
$table Behat\Gherkin\Node\TableNode
    public function iShouldSeeCategoryMenuItem(TableNode $table)
    {
        foreach ($table as $node) {
            $categoryName = $node['name'];
            $active = $node['active'];
            $activeXpath = $active == 'true' ? 'a[contains(@class, "active")]' : 'a[not(contains(@class, "active"))]';
            $element = $this->getSession()->getPage()->find('xpath', '//ul[contains(@class, "category-nav")]/li/' . $activeXpath . '[contains(text(), "' . $categoryName . '")]');
            if (is_null($element)) {
                $activeExpression = $active ? 'active' : 'non active';
                throw new Exception(sprintf('Category with name "%s" not found as a %s root menu', $categoryName, $activeExpression));
            }
        }
    }