RuleTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\CatalogWidget\Test\Unit\Model;
  7. class RuleTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  11. */
  12. private $objectManager;
  13. /**
  14. * @var \Magento\CatalogWidget\Model\Rule
  15. */
  16. protected $rule;
  17. /**
  18. * @var \Magento\CatalogWidget\Model\Rule\Condition\CombineFactory|\PHPUnit_Framework_MockObject_MockObject
  19. */
  20. protected $combineFactory;
  21. protected function setUp()
  22. {
  23. $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  24. $this->combineFactory = $this->getMockBuilder(\Magento\CatalogWidget\Model\Rule\Condition\CombineFactory::class)
  25. ->setMethods(['create'])
  26. ->disableOriginalConstructor()
  27. ->getMock();
  28. $this->rule = $this->objectManager->getObject(
  29. \Magento\CatalogWidget\Model\Rule::class,
  30. [
  31. 'conditionsFactory' => $this->combineFactory
  32. ]
  33. );
  34. }
  35. public function testGetConditionsInstance()
  36. {
  37. $condition = $this->getMockBuilder(\Magento\CatalogWidget\Model\Rule\Condition\Combine::class)
  38. ->setMethods([])
  39. ->disableOriginalConstructor()
  40. ->getMock();
  41. $this->combineFactory->expects($this->once())->method('create')->will($this->returnValue($condition));
  42. $this->assertSame($condition, $this->rule->getConditionsInstance());
  43. }
  44. public function testGetActionsInstance()
  45. {
  46. $this->assertNull($this->rule->getActionsInstance());
  47. }
  48. }