From b37d663352750a2818b78623d072c198b4a3a706 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Sun, 2 Jan 2011 23:59:42 +0100 Subject: [PATCH] Add Stack test. --- framework/Support/test/Horde/Support/ArrayTest.php | 5 +- framework/Support/test/Horde/Support/StackTest.php | 89 ++++++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 framework/Support/test/Horde/Support/StackTest.php diff --git a/framework/Support/test/Horde/Support/ArrayTest.php b/framework/Support/test/Horde/Support/ArrayTest.php index 6b71f39db..3cd6bc6d7 100644 --- a/framework/Support/test/Horde/Support/ArrayTest.php +++ b/framework/Support/test/Horde/Support/ArrayTest.php @@ -3,16 +3,15 @@ * @category Horde * @package Support * @subpackage UnitTests - * @copyright 2007-2009 The Horde Project (http://www.horde.org/) + * @copyright 2007-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php */ /** - * @group support * @category Horde * @package Support * @subpackage UnitTests - * @copyright 2007-2009 The Horde Project (http://www.horde.org/) + * @copyright 2007-2010 The Horde Project (http://www.horde.org/) * @license http://opensource.org/licenses/bsd-license.php */ class Horde_Support_ArrayTest extends PHPUnit_Framework_TestCase diff --git a/framework/Support/test/Horde/Support/StackTest.php b/framework/Support/test/Horde/Support/StackTest.php new file mode 100644 index 000000000..17e590aa2 --- /dev/null +++ b/framework/Support/test/Horde/Support/StackTest.php @@ -0,0 +1,89 @@ +push('one'); + $stack->push('two'); + return $stack; + } + + /** + * @depends testPushOnEmptyStack + */ + public function testPeekOnEmptyStack($stack) + { + $this->assertEquals('two', $stack->peek()); + $this->assertEquals('two', $stack->peek(1)); + $this->assertEquals('one', $stack->peek(2)); + $this->assertNull($stack->peek(3)); + $this->assertNull($stack->peek(0)); + } + + /** + * @depends testPushOnEmptyStack + */ + public function testPopFromEmptyStack($stack) + { + $this->assertEquals('two', $stack->pop()); + $this->assertEquals('one', $stack->pop()); + $this->assertNull($stack->pop()); + } + + public function testPrefilledConstructor() + { + return new Horde_Support_Stack(array('foo', 'bar')); + } + + /** + * @depends testPrefilledConstructor + */ + public function testPeekOnPrefilledStack($stack) + { + $this->assertEquals('bar', $stack->peek(1)); + $this->assertEquals('foo', $stack->peek(2)); + } + + /** + * @depends testPrefilledConstructor + */ + public function testPushOnPrefilledStack($stack) + { + $stack->push('baz'); + return $stack; + } + + /** + * @depends testPushOnPrefilledStack + */ + public function testPopFromPrefilledStack($stack) + { + $this->assertEquals('baz', $stack->pop()); + $this->assertEquals('bar', $stack->pop()); + $this->assertEquals('foo', $stack->pop()); + $this->assertNull($stack->pop()); + } +} \ No newline at end of file -- 2.11.0