summaryrefslogtreecommitdiff
path: root/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php')
-rw-r--r--tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php
new file mode 100644
index 00000000..8f8868e9
--- /dev/null
+++ b/tests/simple_unit/ActiveRecord/ActiveRecordDynamicCallTestCase.php
@@ -0,0 +1,52 @@
+<?php
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+class ActiveRecordDynamicCallTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_dynamic_call()
+ {
+ $finder = DepartmentRecord::finder();
+ $r2 = $finder->findByName('Facilities');
+ $this->assertNotNull($r2);
+ }
+
+ function test_dynamic_multiple_field_call()
+ {
+ $finder = DepartmentRecord::finder();
+ $rs = $finder->findByNameAndActive('Marketing',true);
+ $this->assertNotNull($rs);
+ }
+
+ function test_dynamic_call_missing_parameters_throws_exception()
+ {
+ $finder = DepartmentRecord::finder();
+ try
+ {
+ $rs = $finder->findByNameAndActive('Marketing');
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_dynamic_call_extras_parameters_ok()
+ {
+ $finder = DepartmentRecord::finder();
+ $rs = $finder->findByNameAndActive('Marketing',true,true);
+ $this->assertNotNull($rs);
+ }
+
+}
+
+?> \ No newline at end of file