summaryrefslogtreecommitdiff
path: root/test/ORMTest.php
diff options
context:
space:
mode:
authorSimon Holywell <[email protected]>2013-01-15 12:18:47 +0000
committerSimon Holywell <[email protected]>2013-01-15 12:21:11 +0000
commit5a6d20c7c41c26f6b2db3d518853d931a4c53445 (patch)
tree3e5098095f96eb3fc94fafc3e4597f2047d86fa3 /test/ORMTest.php
parent5f2fbc8151fa9f154b06c073fe4a7d096cb848c9 (diff)
Add ResultSet functionality to Idiorm
Diffstat (limited to 'test/ORMTest.php')
-rw-r--r--test/ORMTest.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ORMTest.php b/test/ORMTest.php
index 8a50479..1773d29 100644
--- a/test/ORMTest.php
+++ b/test/ORMTest.php
@@ -1,7 +1,18 @@
<?php
+require_once 'test_classes.php';
+
class ORMTest extends PHPUnit_Framework_TestCase {
+ public function setUp() {
+ // Enable logging
+ ORM::configure('logging', true);
+
+ // Set up the dummy database connection
+ $db = new MockPDO('sqlite::memory:');
+ ORM::set_db($db);
+ }
+
public function testStaticAtrributes() {
$this->assertEquals('0', ORM::CONDITION_FRAGMENT);
$this->assertEquals('1', ORM::CONDITION_VALUES);
@@ -44,4 +55,24 @@ class ORMTest extends PHPUnit_Framework_TestCase {
$this->assertFalse(isset($model['test']));
}
+ public function testFindResultSet() {
+ $result_set = ORM::for_table('test')->find_result_set();
+ $this->assertInstanceOf('IdiormResultSet', $result_set);
+ $this->assertSame(count($result_set), 5);
+ }
+
+ public function testFindResultSetByDefault() {
+ ORM::configure('return_result_sets', true);
+
+ $result_set = ORM::for_table('test')->find_many();
+ $this->assertInstanceOf('IdiormResultSet', $result_set);
+ $this->assertSame(count($result_set), 5);
+
+ ORM::configure('return_result_sets', false);
+
+ $result_set = ORM::for_table('test')->find_many();
+ $this->assertInternalType('array', $result_set);
+ $this->assertSame(count($result_set), 5);
+ }
+
} \ No newline at end of file