objectManager = new ObjectManager($this); $this->productTypeChildrenValidationMap = [ 'type1' => true, 'type2' => false, ]; $this->quoteItemMock = $this->getMockBuilder(QuoteItem::class) ->disableOriginalConstructor() ->setMethods(['getProduct']) ->getMockForAbstractClass(); $this->productMock = $this->getMockBuilder(Product::class) ->disableOriginalConstructor() ->setMethods(['getTypeId']) ->getMock(); $this->model = $this->objectManager->getObject( ChildrenValidationLocator::class, [ 'productTypeChildrenValidationMap' => $this->productTypeChildrenValidationMap, ] ); } /** * @dataProvider productTypeDataProvider * @param string $type * @param bool $expected * * @return void */ public function testIsChildrenValidationRequired(string $type, bool $expected): void { $this->quoteItemMock->expects($this->once()) ->method('getProduct') ->willReturn($this->productMock); $this->productMock->expects($this->once()) ->method('getTypeId') ->willReturn($type); $this->assertEquals($this->model->isChildrenValidationRequired($this->quoteItemMock), $expected); } /** * @return array */ public function productTypeDataProvider(): array { return [ ['type1', true], ['type2', false], ['type3', true], ]; } }