|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © 2015 Magento. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +namespace testsuite\Magento\GroupedProduct\Pricing\Price; |
| 8 | + |
| 9 | +use Magento\Catalog\Api\Data\ProductTierPriceInterface; |
| 10 | +use Magento\GroupedProduct\Pricing\Price\FinalPrice; |
| 11 | +use Magento\TestFramework\Helper\Bootstrap; |
| 12 | + |
| 13 | +class FinalPriceTest extends \PHPUnit_Framework_TestCase |
| 14 | +{ |
| 15 | + /** |
| 16 | + * @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php |
| 17 | + * @magentoAppIsolation enabled |
| 18 | + */ |
| 19 | + public function testFinalPrice() |
| 20 | + { |
| 21 | + $productRepository = Bootstrap::getObjectManager() |
| 22 | + ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); |
| 23 | + /** @var $product \Magento\Catalog\Model\Product */ |
| 24 | + $product = $productRepository->get('grouped-product'); |
| 25 | + |
| 26 | + $this->assertEquals(10, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php |
| 31 | + * @magentoAppIsolation enabled |
| 32 | + */ |
| 33 | + public function testFinalPriceWithTearPrice() |
| 34 | + { |
| 35 | + $productRepository = Bootstrap::getObjectManager() |
| 36 | + ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); |
| 37 | + /** @var ProductTierPriceInterface $tierPrice */ |
| 38 | + $tierPrice = Bootstrap::getObjectManager()->create(ProductTierPriceInterface::class); |
| 39 | + $tierPrice->setQty(1); |
| 40 | + $tierPrice->setCustomerGroupId(\Magento\Customer\Model\GroupManagement::CUST_GROUP_ALL); |
| 41 | + $tierPrice->setValue(5); |
| 42 | + |
| 43 | + |
| 44 | + /** @var $simpleProduct \Magento\Catalog\Api\Data\ProductInterface */ |
| 45 | + $simpleProduct = $productRepository->get('simple'); |
| 46 | + $simpleProduct->setTierPrices([ |
| 47 | + $tierPrice |
| 48 | + ]); |
| 49 | + $productRepository->save($simpleProduct); |
| 50 | + |
| 51 | + |
| 52 | + /** @var $product \Magento\Catalog\Model\Product */ |
| 53 | + $product = $productRepository->get('grouped-product'); |
| 54 | + $this->assertEquals(5, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); |
| 55 | + } |
| 56 | + |
| 57 | + /** |
| 58 | + * @magentoDataFixture Magento/GroupedProduct/_files/product_grouped.php |
| 59 | + * @magentoAppIsolation enabled |
| 60 | + */ |
| 61 | + public function testFinalPriceWithSpecialPrice() |
| 62 | + { |
| 63 | + $productRepository = Bootstrap::getObjectManager() |
| 64 | + ->get('\Magento\Catalog\Api\ProductRepositoryInterface'); |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + /** @var $simpleProduct \Magento\Catalog\Api\Data\ProductInterface */ |
| 69 | + $simpleProduct = $productRepository->get('simple'); |
| 70 | + $simpleProduct->setCustomAttribute('special_price', 6); |
| 71 | + $productRepository->save($simpleProduct); |
| 72 | + |
| 73 | + |
| 74 | + /** @var $product \Magento\Catalog\Model\Product */ |
| 75 | + $product = $productRepository->get('grouped-product'); |
| 76 | + $this->assertEquals(6, $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE)->getValue()); |
| 77 | + } |
| 78 | +} |
0 commit comments