Skip to content

Commit

Permalink
Fix code smell
Browse files Browse the repository at this point in the history
  • Loading branch information
sambolek committed Apr 1, 2017
1 parent 3f671db commit 9c44917
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,18 +403,17 @@ protected function _getMediaConfig()
return $this->_mediaConfig;
}


/**
* Get product image URL from image filename and path
*
* @param $image
* @param string $image
* @return mixed
*/
protected function getProductImageUrl($image)
{
$productObject = ObjectManager::getInstance()->get('Magento\Catalog\Model\Product');
$productObject = ObjectManager::getInstance()->get(\Magento\Catalog\Model\Product::class);
$imgUrl = ObjectManager::getInstance()
->get('Magento\Catalog\Helper\Image')
->get(\Magento\Catalog\Helper\Image::class)
->init($productObject, 'product_page_image_large')
->setImageFile($image)
->getUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,41 +71,51 @@ public function testGetCollectionAll()
$this->assertEmpty($products[1]->getImages(), 'Images were loaded');
$this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded');
$this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title');
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/m/a/magento_image_sitemap.png',
$products[4]->getImages()->getThumbnail(),
'Incorrect thumbnail'
);
// @codingStandardsIgnoreEnd
$this->assertCount(2, $products[4]->getImages()->getCollection(), 'Not all images were loaded');

$imagesCollection = $products[4]->getImages()->getCollection();
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/m/a/magento_image_sitemap.png',
$imagesCollection[0]->getUrl(),
'Incorrect image url'
);
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/s/e/second_image.png',
$imagesCollection[1]->getUrl(),
'Incorrect image url'
);
// @codingStandardsIgnoreEnd
$this->assertEmpty($imagesCollection[0]->getCaption(), 'Caption not empty');

// Check no selection
$this->assertEmpty($products[5]->getImage(), 'image is not empty');
$this->assertEquals('no_selection', $products[5]->getThumbnail(), 'thumbnail is incorrect');
$imagesCollection = $products[5]->getImages()->getCollection();
$this->assertCount(1, $imagesCollection);
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/s/e/second_image_1.png',
$imagesCollection[0]->getUrl(),
'Image url is incorrect'
);
// @codingStandardsIgnoreEnd
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/s/e/second_image_1.png',
$products[5]->getImages()->getThumbnail(),
'Product thumbnail is incorrect'
);
// @codingStandardsIgnoreEnd
}

/**
Expand Down Expand Up @@ -139,19 +149,23 @@ public function testGetCollectionBase()
$this->assertEmpty($products[1]->getImages(), 'Images were loaded');
$this->assertNotEmpty($products[4]->getImages(), 'Images were not loaded');
$this->assertEquals('Simple Images', $products[4]->getImages()->getTitle(), 'Incorrect title');
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/s/e/second_image.png',
$products[4]->getImages()->getThumbnail(),
'Incorrect thumbnail'
);
// @codingStandardsIgnoreEnd
$this->assertCount(1, $products[4]->getImages()->getCollection(), 'Number of loaded images is incorrect');

$imagesCollection = $products[4]->getImages()->getCollection();
// @codingStandardsIgnoreStart
$this->assertEquals(
'http://localhost/pub/media/catalog/product/cache/c9e0b0ef589f3508e5ba515cde53c5ff/s/e/second_image.png',
$imagesCollection[0]->getUrl(),
'Incorrect image url'
);
// @codingStandardsIgnoreEnd
$this->assertEmpty($imagesCollection[0]->getCaption(), 'Caption not empty');

// Check no selection
Expand Down

0 comments on commit 9c44917

Please sign in to comment.