ItemTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Test\Unit\Model\Order\Admin;
  7. /**
  8. * Class ValidatorTest
  9. */
  10. class ItemTest extends \PHPUnit\Framework\TestCase
  11. {
  12. /**
  13. * @var \PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $orderItemMock;
  16. /** @var \Magento\Sales\Model\Order\Admin\Item */
  17. protected $item;
  18. protected function setUp()
  19. {
  20. $this->orderItemMock = $this->getMockBuilder(\Magento\Sales\Model\Order\Item::class)
  21. ->disableOriginalConstructor()
  22. ->getMock();
  23. $this->item = new \Magento\Sales\Model\Order\Admin\Item();
  24. }
  25. public function testGetSku()
  26. {
  27. $sku = 'sku';
  28. $this->orderItemMock->expects($this->once())
  29. ->method('getSku')
  30. ->willReturn($sku);
  31. $result = $this->item->getSku($this->orderItemMock);
  32. $this->assertEquals($sku, $result);
  33. }
  34. public function testGetName()
  35. {
  36. $name = 'name';
  37. $this->orderItemMock->expects($this->once())
  38. ->method('getName')
  39. ->willReturn($name);
  40. $result = $this->item->getName($this->orderItemMock);
  41. $this->assertEquals($name, $result);
  42. }
  43. public function testGetProductId()
  44. {
  45. $productId = 1;
  46. $this->orderItemMock->expects($this->once())
  47. ->method('getProductId')
  48. ->willReturn($productId);
  49. $result = $this->item->getProductId($this->orderItemMock);
  50. $this->assertEquals($productId, $result);
  51. }
  52. }