Add a test for the new Iterarator implementation in BSDBResult
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jun 2008 14:25:50 +0000 (10:25 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jun 2008 14:25:50 +0000 (10:25 -0400)
* UnitTest/DatabaseTestAbstract.php
(DatabaseTestAbstract::testIterator): New method

UnitTest/DatabaseTestAbstract.php

index 8970121008c8b148d33aae5925c11fcef3f743f6..9655cf03a843c694871b73f971dcfb52b8f8d57a 100644 (file)
@@ -20,7 +20,7 @@ abstract class DatabaseTestAbstract extends PHPUnit_Framework_TestCase
        {
                try
                {
-                       $this->fixture->query("INSERT INTO test (textstuff) VALUES ('moo'), ('foo'), ('hey'), ('foo'), ('boo'), ('poo')");      
+                       $this->fixture->query("INSERT INTO test (textstuff) VALUES ('moo'), ('foo'), ('hey'), ('foo'), ('boo'), ('poo')");
                }
                catch (BSDbException $e)
                {
@@ -46,6 +46,20 @@ abstract class DatabaseTestAbstract extends PHPUnit_Framework_TestCase
                }
        }
        
+       public function testIterator()
+       {
+               $this->fixture->query("INSERT INTO test (textstuff) VALUES ('a'), ('b'), ('c')");
+               $result = $this->fixture->query("SELECT * FROM test");
+               
+               $i = 0;
+               foreach ($result as $item)
+               {
+                       $i++;
+               }
+               
+               $this->assertEquals(3, $i);
+       }
+       
        public function testEscapeString()
        {
                $this->assertEquals("Robert\'s castle", $this->fixture->escapeString("Robert's castle"));