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