/** * {@inheritDoc} */ public function hasChildren() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'hasChildren', array()); return parent::hasChildren(); }
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); }