Add Stack test.
authorJan Schneider <jan@horde.org>
Sun, 2 Jan 2011 22:59:42 +0000 (23:59 +0100)
committerJan Schneider <jan@horde.org>
Sun, 2 Jan 2011 22:59:42 +0000 (23:59 +0100)
framework/Support/test/Horde/Support/ArrayTest.php
framework/Support/test/Horde/Support/StackTest.php [new file with mode: 0644]

index 6b71f39..3cd6bc6 100644 (file)
@@ -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 (file)
index 0000000..17e590a
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * @category   Horde
+ * @package    Support
+ * @subpackage UnitTests
+ * @copyright  2007-2010 The Horde Project (http://www.horde.org/)
+ * @license    http://opensource.org/licenses/bsd-license.php
+ */
+
+/**
+ * @category   Horde
+ * @package    Support
+ * @subpackage UnitTests
+ * @copyright  2007-2010 The Horde Project (http://www.horde.org/)
+ * @license    http://opensource.org/licenses/bsd-license.php
+ */
+class Horde_Support_StackTest extends PHPUnit_Framework_TestCase
+{
+    public function testEmptyConstructor()
+    {
+        return new Horde_Support_Stack();
+    }
+
+    /**
+     * @depends testEmptyConstructor
+     */
+    public function testPushOnEmptyStack($stack)
+    {
+        $stack->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