diff options
author | Tom Gregory <[email protected]> | 2013-01-22 00:23:04 -0500 |
---|---|---|
committer | Tom Gregory <[email protected]> | 2013-01-22 00:23:04 -0500 |
commit | 98b806652bab694797c0d09b41f198b7bf6f2c4c (patch) | |
tree | 077eefaaea3098418fa9eea317b87a854abd6f51 /test/IdiormResultSetTest.php | |
parent | 349532a2c5b8d968f8fa7743b33b8d50d3525630 (diff) | |
parent | 6391acb3371e07742cf94c7c4bc4cc3888a6cae5 (diff) |
Merge remote-tracking branch 'upstream/develop' into dev-multi. Updated documentation to rat format, and tests to use phpunit.
(Resolved)Conflicts:
README.markdown
idiorm.php
test/test_queries.php
Diffstat (limited to 'test/IdiormResultSetTest.php')
-rw-r--r-- | test/IdiormResultSetTest.php | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/IdiormResultSetTest.php b/test/IdiormResultSetTest.php new file mode 100644 index 0000000..34d42a0 --- /dev/null +++ b/test/IdiormResultSetTest.php @@ -0,0 +1,67 @@ +<?php + +class IdiormResultSetTest extends PHPUnit_Framework_TestCase { + + public function testGet() { + $IdiormResultSet = new IdiormResultSet(); + $this->assertInternalType('array', $IdiormResultSet->get_results()); + } + + public function testConstructor() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet($result_set); + $this->assertSame($IdiormResultSet->get_results(), $result_set); + } + + public function testSetResultsAndGetResults() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet(); + $IdiormResultSet->set_results($result_set); + $this->assertSame($IdiormResultSet->get_results(), $result_set); + } + + public function testAsArray() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet(); + $IdiormResultSet->set_results($result_set); + $this->assertSame($IdiormResultSet->as_array(), $result_set); + } + + public function testCount() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet($result_set); + $this->assertSame($IdiormResultSet->count(), 1); + $this->assertSame(count($IdiormResultSet), 1); + } + + public function testGetIterator() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet($result_set); + $this->assertInstanceOf('ArrayIterator', $IdiormResultSet->getIterator()); + } + + public function testForeach() { + $result_set = array('item' => new stdClass); + $IdiormResultSet = new IdiormResultSet($result_set); + $return_array = array(); + foreach($IdiormResultSet as $key => $record) { + $return_array[$key] = $record; + } + $this->assertSame($result_set, $return_array); + } + + public function testCallingMethods() { + $result_set = array('item' => ORM::for_table('test'), 'item2' => ORM::for_table('test')); + $IdiormResultSet = new IdiormResultSet($result_set); + $IdiormResultSet->set('field', 'value')->set('field2', 'value'); + + foreach($IdiormResultSet as $record) { + $this->assertTrue(isset($record->field)); + $this->assertSame($record->field, 'value'); + + $this->assertTrue(isset($record->field2)); + $this->assertSame($record->field2, 'value'); + } + } + +}
\ No newline at end of file |