1<?php 2 3namespace dokuwiki\test\Parsing\Lexer; 4 5use dokuwiki\Parsing\Lexer\StateStack; 6 7class StateStackTest extends \DokuWikiTest 8{ 9 function testStartState() 10 { 11 $stack = new StateStack("one"); 12 $this->assertEquals("one", $stack->getCurrent()); 13 } 14 15 function testExhaustion() 16 { 17 $stack = new StateStack("one"); 18 $this->assertFalse($stack->leave()); 19 } 20 21 function testStateMoves() 22 { 23 $stack = new StateStack("one"); 24 $stack->enter("two"); 25 $this->assertEquals("two", $stack->getCurrent()); 26 $stack->enter("three"); 27 $this->assertEquals("three", $stack->getCurrent()); 28 $this->assertTrue($stack->leave()); 29 $this->assertEquals("two", $stack->getCurrent()); 30 $stack->enter("third"); 31 $this->assertEquals("third", $stack->getCurrent()); 32 $this->assertTrue($stack->leave()); 33 $this->assertTrue($stack->leave()); 34 $this->assertEquals("one", $stack->getCurrent()); 35 } 36} 37