priceBackendPlugin = $objectManager->getObject(\Magento\Bundle\Model\Plugin\PriceBackend::class); $this->closure = function () { return static::CLOSURE_VALUE; }; $this->priceAttributeMock = $this->getMockBuilder(\Magento\Catalog\Model\Product\Attribute\Backend\Price::class) ->disableOriginalConstructor() ->getMock(); $this->productMock = $this->getMockBuilder(\Magento\Catalog\Model\Product::class) ->disableOriginalConstructor() ->setMethods(['getTypeId', 'getPriceType', '__wakeUp']) ->getMock(); } /** * @dataProvider aroundValidateDataProvider * * @param $typeId * @param $priceType * @param $expectedResult */ public function testAroundValidate($typeId, $priceType, $expectedResult) { $this->productMock->expects($this->any())->method('getTypeId')->will($this->returnValue($typeId)); $this->productMock->expects($this->any())->method('getPriceType')->will($this->returnValue($priceType)); $result = $this->priceBackendPlugin->aroundValidate( $this->priceAttributeMock, $this->closure, $this->productMock ); $this->assertEquals($expectedResult, $result); } /** * Data provider for testAroundValidate * * @return array */ public function aroundValidateDataProvider() { return [ ['type' => Type::TYPE_SIMPLE, 'priceType' => Price::PRICE_TYPE_FIXED, 'result' => static::CLOSURE_VALUE], ['type' => Type::TYPE_SIMPLE, 'priceType' => Price::PRICE_TYPE_DYNAMIC, 'result' => static::CLOSURE_VALUE], ['type' => Type::TYPE_BUNDLE, 'priceType' => Price::PRICE_TYPE_FIXED, 'result' => static::CLOSURE_VALUE], ['type' => Type::TYPE_BUNDLE, 'priceType' => Price::PRICE_TYPE_DYNAMIC, 'result' => true], ['type' => Type::TYPE_VIRTUAL, 'priceType' => Price::PRICE_TYPE_FIXED, 'result' => static::CLOSURE_VALUE], ['type' => Type::TYPE_VIRTUAL, 'priceType' => Price::PRICE_TYPE_DYNAMIC, 'result' => static::CLOSURE_VALUE], ]; } }