1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8/** 9 * @group unit 10 * 11 */ 12 13class Transition_AtLeastTest extends PHPUnit_Framework_TestCase 14{ 15 function testOver() 16 { 17 $transition = new Tiki_Transition('A', 'B'); 18 $transition->setStates(['A', 'C', 'D', 'F']); 19 $transition->addGuard('atLeast', 2, ['C', 'D', 'E', 'F', 'G']); 20 21 $this->assertEquals([], $transition->explain()); 22 } 23 24 function testRightOn() 25 { 26 $transition = new Tiki_Transition('A', 'B'); 27 $transition->setStates(['A', 'C', 'D', 'F']); 28 $transition->addGuard('atLeast', 3, ['C', 'D', 'E', 'F', 'G']); 29 30 $this->assertEquals([], $transition->explain()); 31 } 32 33 function testUnder() 34 { 35 $transition = new Tiki_Transition('A', 'B'); 36 $transition->setStates(['A', 'C', 'D', 'F']); 37 $transition->addGuard('atLeast', 4, ['C', 'D', 'E', 'F', 'G']); 38 39 $this->assertEquals( 40 [['class' => 'missing', 'count' => 1, 'set' => ['E', 'G']],], 41 $transition->explain() 42 ); 43 } 44 45 function testImpossibleCondition() 46 { 47 $transition = new Tiki_Transition('A', 'B'); 48 $transition->setStates(['A', 'C', 'D', 'F']); 49 $transition->addGuard('atLeast', 4, ['C', 'D', 'E']); 50 51 $this->assertEquals( 52 [['class' => 'invalid', 'count' => 4, 'set' => ['C', 'D', 'E']],], 53 $transition->explain() 54 ); 55 } 56} 57