/** * @magentoDataFixture Magento/Catalog/_files/product_with_image.php */ public function testThumbnail() { \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea(\Magento\Framework\App\Area::AREA_FRONTEND); $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Product'); $product->load(1); $size = $this->_block->getThumbnailSize(); $this->assertGreaterThan(1, $size); $this->assertContains('/' . $size, $this->_block->getThumbnailUrl($product)); $this->assertStringEndsWith('magento_image.jpg', $this->_block->getThumbnailUrl($product)); }
public function testGetImage() { $imageId = 'test_image_id'; $attributes = []; $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock(); $imageMock = $this->getMockBuilder('Magento\\Catalog\\Block\\Product\\Image')->disableOriginalConstructor()->getMock(); $this->imageBuilder->expects($this->once())->method('setProduct')->with($productMock)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('setImageId')->with($imageId)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('setAttributes')->with($attributes)->willReturnSelf(); $this->imageBuilder->expects($this->once())->method('create')->willReturn($imageMock); $this->assertInstanceOf('Magento\\Catalog\\Block\\Product\\Image', $this->_block->getImage($productMock, $imageId, $attributes)); }