public function testGetTotalBundleItemsPriceWithNoItems() { $storeId = 1; $dataObjectMock = $this->getMockBuilder('Magento\\Framework\\DataObject')->setMethods(['getValue'])->disableOriginalConstructor()->getMock(); $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $productTypeMock = $this->getMockBuilder('Magento\\Bundle\\Model\\Product\\Type')->disableOriginalConstructor()->getMock(); $selectionsMock = $this->getMockBuilder('Magento\\Bundle\\Model\\ResourceModel\\Selection\\Collection')->disableOriginalConstructor()->getMock(); $productMock->expects($this->once())->method('hasCustomOptions')->willReturn(true); $productMock->expects($this->once())->method('getCustomOption')->with('bundle_selection_ids')->willReturn($dataObjectMock); $productMock->expects($this->once())->method('getTypeInstance')->willReturn($productTypeMock); $productMock->expects($this->once())->method('getStoreId')->willReturn($storeId); $dataObjectMock->expects($this->once())->method('getValue')->willReturn('a:1:{i:0;s:1:"1";}'); $productTypeMock->expects($this->once())->method('getSelectionsByIds')->with([1], $productMock)->willReturn($selectionsMock); $selectionsMock->expects($this->once())->method('addTierPriceData')->willReturnSelf(); $selectionsMock->expects($this->once())->method('getItems')->willReturn([]); $this->eventManagerMock->expects($this->once())->method('dispatch')->with('prepare_catalog_product_collection_prices', ['collection' => $selectionsMock, 'store_id' => $storeId])->willReturnSelf(); $this->assertEquals(0, $this->model->getTotalBundleItemsPrice($productMock)); }