ItemTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Sales\Model\Order;
  7. class ItemTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @param string $options
  11. * @param array $expectedData
  12. * @dataProvider getProductOptionsDataProvider
  13. */
  14. public function testGetProductOptions($options, $expectedData)
  15. {
  16. $model = \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Sales\Model\Order\Item::class);
  17. $model->setData('product_options', $options);
  18. $this->assertEquals($expectedData, $model->getProductOptions());
  19. }
  20. /**
  21. * @return array
  22. */
  23. public function getProductOptionsDataProvider()
  24. {
  25. return [
  26. [
  27. '{"option1":1,"option2":2}',
  28. ["option1" => 1, "option2" => 2]
  29. ],
  30. [
  31. ["option1" => 1, "option2" => 2],
  32. ["option1" => 1, "option2" => 2]
  33. ],
  34. ];
  35. }
  36. }