/** * @param Category $category * * @throws \Exception */ public function clickCategoryFilterLink($category) { $elt = $this->getElement('Categories tree')->find('css', sprintf('#node_%s a', $category->getId())); if (!$elt) { throw new \Exception(sprintf('Could not find category filter "%s".', $category->getId())); } $elt->click(); }
/** * {@inheritDoc} */ public function getId() { if ($this->__isInitialized__ === false) { return (int) parent::getId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::getId(); }
/** * @param Category $category * * @Given /^I should be on the (category "([^"]*)") node creation page$/ */ public function iShouldBeOnTheCategoryNodeCreationPage(Category $category) { $expectedAddress = $this->getPage('Category node creation')->getUrl(['id' => $category->getId()]); $this->spin(function () use($expectedAddress) { $this->assertAddress($expectedAddress); return true; }, sprintf('Expected to be on the %s category node creation page. But was not', $category->getCode())); }
/** * @param Category $category * * @Given /^I should be on the (category "([^"]*)") node creation page$/ */ public function iShouldBeOnTheCategoryNodeCreationPage(Category $category) { $expectedAddress = $this->getPage('Category node creation')->getUrl(array('id' => $category->getId())); $this->assertAddress($expectedAddress); }
function it_lists_and_format_categories($manager, Category $category0, Category $category1, Category $category2) { $manager->getProductsCountInCategory(Argument::any(), false)->willReturn(5); $category1->getId()->willReturn(2); $category1->getLabel()->willReturn('Some category 1'); $category1->hasChildren()->willReturn(false); $category1->isRoot()->willReturn(false); $category1Array = ['item' => $category1, '__children' => []]; $category2->getId()->willReturn(3); $category2->getLabel()->willReturn('Some category 2'); $category2->hasChildren()->willReturn(false); $category2->isRoot()->willReturn(false); $category2Array = ['item' => $category2, '__children' => []]; $category0->getId()->willReturn(1); $category0->getLabel()->willReturn('Parent category'); $category0->hasChildren()->willReturn(true); $category0->isRoot()->willReturn(false); $category0Array = ['item' => $category0, '__children' => [$category1Array, $category2Array]]; $expected = [['attr' => ['id' => 'node_1'], 'data' => 'Parent category', 'state' => 'open', 'children' => [['attr' => ['id' => 'node_2'], 'data' => 'Some category 1', 'state' => 'leaf', 'children' => [], 'selectedChildrenCount' => 0], ['attr' => ['id' => 'node_3'], 'data' => 'Some category 2', 'state' => 'leaf', 'children' => [], 'selectedChildrenCount' => 0]], 'selectedChildrenCount' => 0]]; $this->listCategoriesResponse([$category0Array], new ArrayCollection())->shouldEqualUsingJSON($expected); }