|
7 | 7 | namespace Magento\Sales\Test\Unit\Model\Order;
|
8 | 8 |
|
9 | 9 | use Magento\Framework\Serialize\Serializer\Json;
|
| 10 | +use Magento\Sales\Api\Data\OrderItemInterface; |
10 | 11 | use Magento\Sales\Model\ResourceModel\OrderFactory;
|
11 |
| -use \Magento\Sales\Model\Order; |
12 | 12 |
|
13 | 13 | /**
|
14 |
| - * Class ItemTest |
15 |
| - * |
16 |
| - * @package Magento\Sales\Model\Order |
| 14 | + * Unit test for order item class. |
17 | 15 | */
|
18 | 16 | class ItemTest extends \PHPUnit\Framework\TestCase
|
19 | 17 | {
|
@@ -72,7 +70,7 @@ public function testSetParentItem()
|
72 | 70 | public function testGetPatentItem()
|
73 | 71 | {
|
74 | 72 | $item = $this->objectManager->getObject(\Magento\Sales\Model\Order\Item::class, []);
|
75 |
| - $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::PARENT_ITEM, $item); |
| 73 | + $this->model->setData(OrderItemInterface::PARENT_ITEM, $item); |
76 | 74 | $this->assertEquals($item, $this->model->getParentItem());
|
77 | 75 | }
|
78 | 76 |
|
@@ -184,7 +182,7 @@ public function testGetOriginalPrice()
|
184 | 182 | $this->assertEquals($price, $this->model->getOriginalPrice());
|
185 | 183 |
|
186 | 184 | $originalPrice = 5.55;
|
187 |
| - $this->model->setData(\Magento\Sales\Api\Data\OrderItemInterface::ORIGINAL_PRICE, $originalPrice); |
| 185 | + $this->model->setData(OrderItemInterface::ORIGINAL_PRICE, $originalPrice); |
188 | 186 | $this->assertEquals($originalPrice, $this->model->getOriginalPrice());
|
189 | 187 | }
|
190 | 188 |
|
@@ -348,4 +346,24 @@ public function getItemQtyVariants()
|
348 | 346 | ]
|
349 | 347 | ];
|
350 | 348 | }
|
| 349 | + |
| 350 | + /** |
| 351 | + * Test getPrice() method returns float |
| 352 | + */ |
| 353 | + public function testGetPriceReturnsFloat() |
| 354 | + { |
| 355 | + $price = 9.99; |
| 356 | + $this->model->setPrice($price); |
| 357 | + $this->assertEquals($price, $this->model->getPrice()); |
| 358 | + } |
| 359 | + |
| 360 | + /** |
| 361 | + * Test getPrice() method returns null |
| 362 | + */ |
| 363 | + public function testGetPriceReturnsNull() |
| 364 | + { |
| 365 | + $nullablePrice = null; |
| 366 | + $this->model->setData(OrderItemInterface::PRICE, $nullablePrice); |
| 367 | + $this->assertEquals($nullablePrice, $this->model->getPrice()); |
| 368 | + } |
351 | 369 | }
|
0 commit comments