diff options
Diffstat (limited to 'tests/modules/database/driver/mysql/resultTest.php')
-rw-r--r-- | tests/modules/database/driver/mysql/resultTest.php | 150 |
1 files changed, 80 insertions, 70 deletions
diff --git a/tests/modules/database/driver/mysql/resultTest.php b/tests/modules/database/driver/mysql/resultTest.php index 5159e39..7142313 100644 --- a/tests/modules/database/driver/mysql/resultTest.php +++ b/tests/modules/database/driver/mysql/resultTest.php @@ -1,125 +1,135 @@ <?php + require_once('/../../../../../modules/database/classes/database/result.php'); require_once('/../../../../../modules/database/classes/driver/mysql/result.php'); + /** * Generated by PHPUnit_SkeletonGenerator 1.2.0 on 2013-02-06 at 20:48:50. */ class Result_Mysql_DriverTest extends PHPUnit_Framework_TestCase { - /** - * @var Result_Mysql_Driver - */ - protected $object; - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { + /** + * @var Result_Mysql_Driver + */ + protected $object; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { $stub = $this->getMockBuilder('mysqli_result') - ->disableOriginalConstructor() - ->getMock(); + ->disableOriginalConstructor() + ->getMock(); $stub->expects($this->any()) ->method('fetch_object') ->will($this->onConsecutiveCalls( - (object) array('id' => 1, 'name' => 'Tinkerbell'), - (object) array('id' => 2, 'name' => 'Trixie'), - null - )); + (object) array('id' => 1, 'name' => 'Tinkerbell'), (object) array('id' => 2, 'name' => 'Trixie'), null + )); - $this->object = new Result_Mysql_Driver($stub); - } + $this->object = new Result_Mysql_Driver($stub); + } - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - } + /** + * Tears down the fixture, for example, closes a network connection. + * This method is called after a test is executed. + */ + protected function tearDown() + { - /** - * @covers Result_Mysql_Driver::rewind - * @todo Implement testRewind(). - */ - public function testRewind() - { - $except = false; + } + + /** + * @covers Result_Mysql_Driver::rewind + * @todo Implement testRewind(). + */ + public function testRewind() + { + $except = false; $this->object->valid(); $this->object->rewind(); $this->object->next(); try { $this->object->rewind(); - }catch(Exception $e) { - $except=true; + } catch (Exception $e) { + $except = true; } - $this->assertEquals(true,$except); - } + $this->assertEquals(true, $except); + } - /** - * @covers Result_Mysql_Driver::current - */ - public function testCurrent() { - $this->assertEquals($this->object->current()->name,'Tinkerbell'); + * @covers Result_Mysql_Driver::current + */ + public function testCurrent() + { + $this->assertEquals($this->object->current()->name, 'Tinkerbell'); } - + /** - * @covers Result_Mysql_Driver::valid - */ - public function testVaid() { - $this->assertEquals($this->object->valid(),true); + * @covers Result_Mysql_Driver::valid + */ + public function testVaid() + { + $this->assertEquals($this->object->valid(), true); } - + /** - * @covers Result_Mysql_Driver::key - */ - public function testKey() { - $this->assertEquals($this->object->key(),0); + * @covers Result_Mysql_Driver::key + */ + public function testKey() + { + $this->assertEquals($this->object->key(), 0); } - + /** - * @covers Result_Mysql_Driver::key - */ - public function testGet() { - $this->assertEquals($this->object->get('id'),1); + * @covers Result_Mysql_Driver::key + */ + public function testGet() + { + $this->assertEquals($this->object->get('id'), 1); } - + /** - * @covers Result_Mysql_Driver::as_array - */ - public function testAs_Array() { + * @covers Result_Mysql_Driver::as_array + */ + public function testAs_Array() + { $arr = $this->object->as_array(); $this->assertArrayHasKey(0, $arr); - $this->assertArrayHasKey('name', (array)$arr[0]); + $this->assertArrayHasKey('name', (array) $arr[0]); $this->assertEquals($arr[0]->name, 'Tinkerbell'); $this->assertArrayHasKey(1, $arr); - $this->assertArrayHasKey('id', (array)$arr[1]); + $this->assertArrayHasKey('id', (array) $arr[1]); $this->assertEquals($arr[1]->id, 2); } - - public function testIterator(){ + + public function testIterator() + { $this->assertEquals($this->object->valid(), true); $this->assertEquals($this->object->get('id'), 1); - foreach($this->object as $key => $row) { - if ($key == 0) { + foreach ($this->object as $key => $row) + { + if ($key == 0) + { $this->assertEquals($row->name, 'Tinkerbell'); $this->assertEquals($row->id, 1); } - if ($key == 1) { + if ($key == 1) + { $this->assertEquals($row->name, 'Trixie'); $this->assertEquals(2, $this->object->get('id')); $this->assertEquals($row->id, 2); } } - $this->assertEquals(false,$this->object->valid()); + $this->assertEquals(false, $this->object->valid()); $this->assertEquals(null, $this->object->get('id')); $this->assertEquals(null, $this->object->current()); $this->object->next(); $this->object->next(); $this->object->next(); - $this->assertEquals(1,$this->object->key()); - + $this->assertEquals(1, $this->object->key()); } + } |