public function testGetData() { $items = ['testProduct1', 'testProduct2']; $expectedData = ['totalRecords' => count($items), 'items' => $items]; $this->configMock->expects($this->once())->method('getComposableTypes')->willReturn([self::ALLOWED_TYPE]); $this->collectionMock->expects($this->once())->method('isLoaded')->willReturn(false); $this->collectionMock->expects($this->once())->method('addAttributeToFilter')->with('type_id', [self::ALLOWED_TYPE]); $this->collectionMock->expects($this->once())->method('toArray')->willReturn($items); $this->collectionMock->expects($this->once())->method('getSize')->willReturn(count($items)); $this->assertEquals($expectedData, $this->getModel()->getData()); }
public function testGetIsQtyTypeIds() { $configAll = [1 => ['is_qty' => true], 2 => ['is_qty' => false], 3 => []]; $resultAll = [1 => true, 2 => false, 3 => false]; $resultTrue = [1 => true]; $resultFalse = [2 => false, 3 => false]; $this->config->expects($this->once())->method('getAll')->will($this->returnValue($configAll)); $this->assertEquals($resultAll, $this->model->getIsQtyTypeIds()); $this->assertEquals($resultTrue, $this->model->getIsQtyTypeIds(true)); $this->assertEquals($resultFalse, $this->model->getIsQtyTypeIds(false)); }
public function testGetAllowedSelectionTypesIfTypesIsNotSet() { $configData = []; $this->config->expects($this->once())->method('getType')->with(\Magento\Catalog\Model\Product\Type::TYPE_BUNDLE)->will($this->returnValue($configData)); $this->assertEquals([], $this->helper->getAllowedSelectionTypes()); }