1<?php 2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4namespace ILIAS\Tests\Refinery\Logical; 5 6use ILIAS\Data\Factory; 7use ILIAS\Refinery\Integer\GreaterThan; 8use ILIAS\Refinery\Integer\LessThan; 9use ILIAS\Refinery\Logical\LogicalOr; 10use ILIAS\Refinery\Logical\Not; 11use ILIAS\Refinery\Logical\Parallel; 12use ILIAS\Refinery\Logical\Sequential; 13use ILIAS\Refinery\Logical\Group; 14use ILIAS\Tests\Refinery\TestCase; 15 16require_once('./libs/composer/vendor/autoload.php'); 17 18class GroupTest extends TestCase 19{ 20 /** 21 * @var Group 22 */ 23 private $group; 24 25 /** 26 * @var Factory 27 */ 28 private $dataFactory; 29 30 /** 31 * @var \ilLanguage 32 */ 33 private $language; 34 35 /** 36 * @var GreaterThan 37 */ 38 private $greaterThanConstraint; 39 40 /** 41 * @var LessThan 42 */ 43 private $lessThanConstaint; 44 45 public function setUp() : void 46 { 47 $this->dataFactory = new Factory(); 48 $this->language = $this->getMockBuilder('\ilLanguage') 49 ->disableOriginalConstructor() 50 ->getMock(); 51 52 $this->group = new Group($this->dataFactory, $this->language); 53 54 $this->greaterThanConstraint = new GreaterThan(2, $this->dataFactory, $this->language); 55 $this->lessThanConstaint = new LessThan(5, $this->dataFactory, $this->language); 56 } 57 58 public function testLogicalOrGroup() 59 { 60 $instance = $this->group->logicalOr(array($this->greaterThanConstraint, $this->lessThanConstaint)); 61 $this->assertInstanceOf(LogicalOr::class, $instance); 62 } 63 64 public function testNotGroup() 65 { 66 $instance = $this->group->not($this->greaterThanConstraint); 67 $this->assertInstanceOf(Not::class, $instance); 68 } 69 70 public function testParallelGroup() 71 { 72 $instance = $this->group->parallel(array($this->greaterThanConstraint, $this->lessThanConstaint)); 73 $this->assertInstanceOf(Parallel::class, $instance); 74 } 75 76 public function testSequentialGroup() 77 { 78 $instance = $this->group->sequential(array($this->greaterThanConstraint, $this->lessThanConstaint)); 79 $this->assertInstanceOf(Sequential::class, $instance); 80 } 81} 82