|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +namespace Magento\ConfigurableProduct\Block\Cart\Item\Renderer; |
| 7 | + |
| 8 | +use Magento\Catalog\Api\ProductRepositoryInterface; |
| 9 | +use Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable as ConfigurableRenderer; |
| 10 | +use Magento\Framework\ObjectManagerInterface; |
| 11 | +use Magento\Framework\View\LayoutInterface; |
| 12 | + |
| 13 | +/** |
| 14 | + * Test \Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable block |
| 15 | + * |
| 16 | + * @magentoAppArea frontend |
| 17 | + */ |
| 18 | +class ConfigurableTest extends \PHPUnit\Framework\TestCase |
| 19 | +{ |
| 20 | + /** |
| 21 | + * @var ConfigurableRenderer |
| 22 | + */ |
| 23 | + private $block; |
| 24 | + |
| 25 | + /** |
| 26 | + * @var ObjectManagerInterface |
| 27 | + */ |
| 28 | + private $objectManager; |
| 29 | + |
| 30 | + /** |
| 31 | + * @inheritdoc |
| 32 | + */ |
| 33 | + protected function setUp() |
| 34 | + { |
| 35 | + $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); |
| 36 | + $this->block = $this->objectManager->get(LayoutInterface::class) |
| 37 | + ->createBlock(ConfigurableRenderer::class); |
| 38 | + } |
| 39 | + |
| 40 | + /** |
| 41 | + * @magentoDbIsolation enabled |
| 42 | + * @magentoAppIsolation enabled |
| 43 | + * @magentoDataFixture Magento/ConfigurableProduct/_files/quote_with_configurable_product.php |
| 44 | + */ |
| 45 | + public function testGetProductPriceHtml() |
| 46 | + { |
| 47 | + $productRepository = $this->objectManager->get(ProductRepositoryInterface::class); |
| 48 | + $configurableProduct = $productRepository->getById(1); |
| 49 | + |
| 50 | + $layout = $this->objectManager->get(LayoutInterface::class); |
| 51 | + $layout->createBlock( |
| 52 | + \Magento\Framework\Pricing\Render::class, |
| 53 | + 'product.price.render.default', |
| 54 | + [ |
| 55 | + 'data' => [ |
| 56 | + 'price_render_handle' => 'catalog_product_prices', |
| 57 | + 'use_link_for_as_low_as' => true |
| 58 | + ] |
| 59 | + ] |
| 60 | + ); |
| 61 | + |
| 62 | + $this->block->setItem( |
| 63 | + $this->block->getCheckoutSession()->getQuote()->getAllVisibleItems()[0] |
| 64 | + ); |
| 65 | + $html = $this->block->getProductPriceHtml($configurableProduct); |
| 66 | + $this->assertContains('<span class="price">$10.00</span>', $html); |
| 67 | + } |
| 68 | +} |
0 commit comments