/**
  * @depends testApply
  */
 public function testGetItems(\Magento\Catalog\Model\Layer\Filter\Category $modelApplied)
 {
     $items = $modelApplied->getItems();
     $this->assertInternalType('array', $items);
     $this->assertEquals(1, count($items));
     /** @var $item \Magento\Catalog\Model\Layer\Filter\Item */
     $item = $items[0];
     $this->assertInstanceOf('Magento\\Catalog\\Model\\Layer\\Filter\\Item', $item);
     $this->assertSame($modelApplied, $item->getFilter());
     $this->assertEquals('Category 1.1', $item->getLabel());
     $this->assertEquals(4, $item->getValue());
     $this->assertEquals(1, $item->getCount());
 }
 public function testGetItems()
 {
     $this->category->expects($this->any())->method('getIsActive')->will($this->returnValue(true));
     $category1 = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Category')->disableOriginalConstructor()->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount'])->getMock();
     $category1->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(120));
     $category1->expects($this->once())->method('getName')->will($this->returnValue('Category 1'));
     $category1->expects($this->once())->method('getIsActive')->will($this->returnValue(true));
     $category1->expects($this->any())->method('getProductCount')->will($this->returnValue(10));
     $category2 = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Category')->disableOriginalConstructor()->setMethods(['getId', 'getName', 'getIsActive', 'getProductCount'])->getMock();
     $category2->expects($this->atLeastOnce())->method('getId')->will($this->returnValue(5641));
     $category2->expects($this->once())->method('getName')->will($this->returnValue('Category 2'));
     $category2->expects($this->once())->method('getIsActive')->will($this->returnValue(true));
     $category2->expects($this->any())->method('getProductCount')->will($this->returnValue(45));
     $categories = [$category1, $category2];
     $this->category->expects($this->once())->method('getChildrenCategories')->will($this->returnValue($categories));
     $builtData = [['label' => 'Category 1', 'value' => 120, 'count' => 10], ['label' => 'Category 2', 'value' => 5641, 'count' => 45]];
     $this->itemDataBuilder->expects($this->at(0))->method('addItemData')->with('Category 1', 120, 10)->will($this->returnSelf());
     $this->itemDataBuilder->expects($this->at(1))->method('addItemData')->with('Category 2', 5641, 45)->will($this->returnSelf());
     $this->itemDataBuilder->expects($this->once())->method('build')->will($this->returnValue($builtData));
     $this->target->getItems();
 }
Example #3
0
 public function testGetName()
 {
     $this->assertEquals('Category', $this->_model->getName());
 }