GroupPluginTest.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Vertex\Tax\Test\Unit\Model\Plugin;
  3. use Magento\Config\Model\Config\Structure\Element\Group;
  4. use Vertex\Tax\Model\ModuleManager;
  5. use Vertex\Tax\Model\Plugin\GroupPlugin;
  6. use Vertex\Tax\Test\Unit\TestCase;
  7. class GroupPluginTest extends TestCase
  8. {
  9. /** @var \PHPUnit_Framework_MockObject_MockObject|GroupPlugin */
  10. private $plugin;
  11. /** @var \PHPUnit_Framework_MockObject_MockObject|ModuleManager */
  12. private $moduleManager;
  13. protected function setUp()
  14. {
  15. parent::setUp();
  16. $this->moduleManager = $this->createPartialMock(ModuleManager::class, ['isEnabled']);
  17. $this->plugin = $this->getObject(GroupPlugin::class, ['moduleManager' => $this->moduleManager]);
  18. }
  19. public function testAroundSetData()
  20. {
  21. /** @var \PHPUnit_Framework_MockObject_MockObject|Group $subject */
  22. $subject = $this->createMock(Group::class);
  23. $data = [
  24. 'path' => 'tax',
  25. 'id' => 'classes',
  26. 'children' => [
  27. 'giftwrap_order_class' => [
  28. 'showInDefault' => 1,
  29. 'showInWebsite' => 1,
  30. 'showInStore' => 1
  31. ],
  32. 'giftwrap_order_code' => [
  33. 'showInDefault' => 1,
  34. 'showInWebsite' => 1,
  35. 'showInStore' => 1
  36. ],
  37. 'giftwrap_item_class' => [
  38. 'showInDefault' => 1,
  39. 'showInWebsite' => 1,
  40. 'showInStore' => 1
  41. ],
  42. 'giftwrap_item_code' => [
  43. 'showInDefault' => 1,
  44. 'showInWebsite' => 1,
  45. 'showInStore' => 1
  46. ],
  47. 'printed_giftcard_class' => [
  48. 'showInDefault' => 1,
  49. 'showInWebsite' => 1,
  50. 'showInStore' => 1
  51. ],
  52. 'printed_giftcard_code' => [
  53. 'showInDefault' => 1,
  54. 'showInWebsite' => 1,
  55. 'showInStore' => 1
  56. ],
  57. 'reward_points_class' => [
  58. 'showInDefault' => 1,
  59. 'showInWebsite' => 1,
  60. 'showInStore' => 1
  61. ],
  62. 'reward_points_code' => [
  63. 'showInDefault' => 1,
  64. 'showInWebsite' => 1,
  65. 'showInStore' => 1
  66. ]
  67. ]
  68. ];
  69. $scope = 'default';
  70. $proceed = function () use ($scope) {
  71. return $scope;
  72. };
  73. $this->moduleManager->method('isEnabled')
  74. ->with($this->logicalOr('Magento_GiftWrapping', 'Magento_Reward'))
  75. ->willReturn(false);
  76. $this->plugin->aroundSetData($subject, $proceed, $data, $scope);
  77. }
  78. }