AbstractTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * Test class for \Magento\Rule\Model\Condition\AbstractCondition
  8. */
  9. namespace Magento\Rule\Model\Condition;
  10. class AbstractTest extends \PHPUnit\Framework\TestCase
  11. {
  12. public function testGetValueElement()
  13. {
  14. $layoutMock = $this->createMock(\Magento\Framework\View\Layout::class);
  15. $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
  16. $context = $objectManager->create(\Magento\Rule\Model\Condition\Context::class, ['layout' => $layoutMock]);
  17. /** @var \Magento\Rule\Model\Condition\AbstractCondition $model */
  18. $model = $this->getMockForAbstractClass(
  19. \Magento\Rule\Model\Condition\AbstractCondition::class,
  20. [$context],
  21. '',
  22. true,
  23. true,
  24. true,
  25. ['getValueElementRenderer']
  26. );
  27. $editableBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
  28. \Magento\Rule\Block\Editable::class
  29. );
  30. $model->expects($this->any())->method('getValueElementRenderer')->will($this->returnValue($editableBlock));
  31. $rule = $this->getMockBuilder(\Magento\Rule\Model\AbstractModel::class)
  32. ->setMethods(['getForm'])
  33. ->disableOriginalConstructor()
  34. ->getMockForAbstractClass();
  35. $rule->expects($this->any())
  36. ->method('getForm')
  37. ->willReturn(
  38. \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Framework\Data\Form::class)
  39. );
  40. $model->setRule($rule);
  41. $property = new \ReflectionProperty(\Magento\Rule\Model\Condition\AbstractCondition::class, '_inputType');
  42. $property->setAccessible(true);
  43. $property->setValue($model, 'date');
  44. $element = $model->getValueElement();
  45. $this->assertNotNull($element);
  46. $this->assertNotEmpty($element->getDateFormat());
  47. }
  48. }