diff options
Diffstat (limited to 'tests/simple_unit/ActiveRecord')
18 files changed, 714 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 diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php new file mode 100644 index 00000000..597f8a6b --- /dev/null +++ b/tests/simple_unit/ActiveRecord/ActiveRecordFinderTestCase.php @@ -0,0 +1,45 @@ +<?php +Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+
+class ActiveRecordFinderTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function testFindBySQL_returns_one_record()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ?', 5);
+ $this->assertNotNull($department);
+ }
+
+ function testFindBySQL_returns_zero_records()
+ {
+ $department = DepartmentRecord::finder()->find('department_id > ?', 15);
+ $this->assertNull($department);
+ }
+
+ function test_find_by_sql_returns_iterator()
+ {
+ $deps = DepartmentRecord::finder()->findAll('department_id < :id', array('id'=>5));
+ $this->assertEqual(count($deps),4);
+ }
+
+ function test_find_by_multiple_parameters()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', 5,2);
+ $this->assertNotNull($department);
+ }
+
+ function test_find_by_array_parameter()
+ {
+ $department = DepartmentRecord::finder()->find('department_id < ? AND "order" > ?', array(5,2));
+ $this->assertNotNull($department);
+ }
+
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php new file mode 100644 index 00000000..b02de3de --- /dev/null +++ b/tests/simple_unit/ActiveRecord/ActiveRecordMySql5TestCase.php @@ -0,0 +1,47 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/Blogs.php');
+
+class ActiveRecordMySql5TestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('mysql:host=localhost;dbname=ar_test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_find_first_blog()
+ {
+ $blog = Blogs::finder()->findByPk(1);
+ $this->assertNotNull($blog);
+ }
+
+ function test_insert_new_blog()
+ {
+ $blog = new Blogs();
+ $blog->blog_name = 'test1';
+ $blog->blog_author = 'wei';
+
+ $this->assertTrue($blog->save());
+
+ $blog->blog_name = 'test2';
+
+ $this->assertTrue($blog->save());
+
+ $check = Blogs::finder()->findByPk($blog->blog_id);
+
+ $this->assertSameBlog($check,$blog);
+
+ $this->assertTrue($blog->delete());
+ }
+
+ function assertSameBlog($check, $blog)
+ {
+ $props = array('blog_id', 'blog_name', 'blog_author');
+ foreach($props as $prop)
+ $this->assertEqual($check->{$prop}, $blog->{$prop});
+ }
+
+} +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php b/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php new file mode 100644 index 00000000..5ab89206 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/ActiveRecordRegistryTestCase.php @@ -0,0 +1,168 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecordStateRegistry');
+Prado::using('System.Data.ActiveRecord.Exceptions.*');
+
+class StateTestObject
+{
+ public $propA = 'a';
+ public $propB;
+}
+
+class ActiveRecordRegistryTestCase extends UnitTestCase
+{
+ function test_new_object()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+
+ $this->assertTrue($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+ }
+
+ function test_clean_object_registers_without_error()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+ $registry->registerClean($obj);
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertTrue($registry->getIsCleanObject($obj));
+ }
+
+ function test_clean_object_becomes_dirty_when_changed()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+
+ $registry->registerClean($obj);
+
+ $obj->propB='b';
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertTrue($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+ }
+
+ function test_removed_object_must_register_as_clean_first()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+
+ try
+ {
+ $registry->registerRemoved($obj);
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_removed_object_registers_without_error()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+ $registry->registerClean($obj);
+
+ $registry->registerRemoved($obj);
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertTrue($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+ }
+
+
+ function test_removed_object_can_not_become_clean()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+ $registry->registerClean($obj);
+
+ $registry->registerRemoved($obj);
+
+ try
+ {
+ $registry->registerClean($obj);
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertTrue($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+ }
+
+ function test_remove_dirty_object()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+
+ $registry->registerClean($obj);
+
+ $obj->propB='b';
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertTrue($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+
+ $registry->registerRemoved($obj);
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertTrue($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+
+ try
+ {
+ $registry->registerClean($obj);
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_clean_dirty_clean_object()
+ {
+ $obj = new StateTestObject();
+ $registry = new TActiveRecordStateRegistry();
+
+ $registry->registerClean($obj);
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertTrue($registry->getIsCleanObject($obj));
+
+ $obj->propB='b';
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertTrue($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertFalse($registry->getIsCleanObject($obj));
+
+ $registry->registerClean($obj);
+
+ $this->assertFalse($registry->getIsNewObject($obj));
+ $this->assertFalse($registry->getIsDirtyObject($obj));
+ $this->assertFalse($registry->getIsRemovedObject($obj));
+ $this->assertTrue($registry->getIsCleanObject($obj));
+ }
+
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php new file mode 100644 index 00000000..9e48fe5f --- /dev/null +++ b/tests/simple_unit/ActiveRecord/BaseActiveRecordTestCase.php @@ -0,0 +1,34 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+
+class BaseRecordTest extends TActiveRecord
+{
+
+}
+
+class BaseActiveRecordTestCase extends UnitTestCase
+{
+ function test_finder_returns_same_instance()
+ {
+ $obj1 = TActiveRecord::getRecordFinder('BaseRecordTest');
+ $obj2 = TActiveRecord::getRecordFinder('BaseRecordTest');
+ $this->assertIdentical($obj1,$obj2);
+ }
+
+ function test_finder_throw_exception_when_save()
+ {
+ $obj = TActiveRecord::getRecordFinder('BaseRecordTest');
+ try
+ {
+ $obj->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php b/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php new file mode 100644 index 00000000..d9a98622 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/CountRecordsTestCase.php @@ -0,0 +1,29 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+
+class CountRecordsTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_count()
+ {
+ $finder = DepartmentRecord::finder();
+ $count = $finder->count('"order" > ?', 2);
+ $this->assertTrue($count > 0);
+ }
+
+ function test_count_zero()
+ {
+ $finder = DepartmentRecord::finder();
+ $count = $finder->count('"order" > ?', 11);
+ $this->assertEqual($count,0);
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php b/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php new file mode 100644 index 00000000..45415b90 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/DeleteByPkTestCase.php @@ -0,0 +1,31 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+require_once(dirname(__FILE__).'/records/DepSections.php');
+
+class DeleteByPkTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_delete_by_pks()
+ {
+ $finder = DepartmentRecord::finder();
+ $this->assertEqual($finder->deleteByPk(100),0);
+ $this->assertEqual($finder->deleteByPk(100, 101),0);
+ $this->assertEqual($finder->deleteByPk(array(100, 101)),0);
+ }
+
+ function test_delete_by_composite_pks()
+ {
+ $finder = DepSections::finder();
+ $this->assertEqual($finder->deleteByPk(array(100,101)),0);
+ $this->assertEqual($finder->deleteByPk(array(100, 101), array(102, 103)),0);
+ $this->assertEqual($finder->deleteByPk(array(array(100, 101), array(102, 103))),0);
+ }
+} +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php b/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php new file mode 100644 index 00000000..953f83e6 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/FindBySqlTestCase.php @@ -0,0 +1,21 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
+
+class FindBySqlTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_find_by_sql()
+ {
+ $deps = DepartmentRecord::finder()->findBySql('SELECT * FROM departments');
+ $this->assertTrue(count($deps) > 0);
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/SqliteTestCase.php b/tests/simple_unit/ActiveRecord/SqliteTestCase.php new file mode 100644 index 00000000..01026c91 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/SqliteTestCase.php @@ -0,0 +1,22 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/SqliteUsers.php');
+
+class SqliteTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('sqlite2:c:/Wei/workspace/ar2/tests/unit/ar_test.db');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_finder()
+ {
+ $finder = SqliteUsers::finder();
+ $user = $finder->findByPk('test');
+ $this->assertNotNull($user);
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/UserRecordTestCase.php b/tests/simple_unit/ActiveRecord/UserRecordTestCase.php new file mode 100644 index 00000000..483dc42f --- /dev/null +++ b/tests/simple_unit/ActiveRecord/UserRecordTestCase.php @@ -0,0 +1,67 @@ +<?php +
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/UserRecord.php');
+
+class UserRecordTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function testFindByPk()
+ {
+ $user1 = UserRecord::finder()->findByPk('admin');
+ $this->assertNotNull($user1);
+ }
+
+ function test_same_data_returns_same_object()
+ {
+ $user1 = UserRecord::finder()->findByPk('admin');
+ $this->assertNotNull($user1);
+
+ $user2 = UserRecord::finder()->findByPk('admin');
+ $this->assertTrue($user1===$user2);
+ }
+
+ function testFindByPk_returns_null()
+ {
+ $user = UserRecord::finder()->findByPk('me');
+ $this->assertNull($user);
+ }
+
+ function test_Create_new_user_returns_true()
+ {
+ $user = new UserRecord;
+ $user->username = 'hello';
+ $user->password = md5('asd');
+ $user->email = 'asdasd';
+ $user->first_name = 'wei';
+ $user->last_name = 'zhuo';
+
+ $this->assertTrue($user->save());
+
+ $user->password = md5('more');
+
+ $this->assertTrue($user->save());
+
+ $check = UserRecord::finder()->findByPk('hello');
+
+ $this->assertSameUser($user, $check);
+
+ $this->assertTrue($user->delete());
+ }
+
+ function assertSameUser($user,$check)
+ {
+ $props = array('username', 'password', 'email', 'first_name', 'last_name', 'job_title',
+ 'work_phone', 'work_fax', 'active', 'department_id', 'salutation',
+ 'hint_question', 'hint_answer');
+ foreach($props as $prop)
+ $this->assertEqual($user->$prop,$check->$prop);
+ }
+}
+
+?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php b/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php new file mode 100644 index 00000000..29fdee49 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/ViewRecordTestCase.php @@ -0,0 +1,76 @@ +<?php +
+
+Prado::using('System.Data.ActiveRecord.TActiveRecord');
+require_once(dirname(__FILE__).'/records/SimpleUser.php');
+
+class ViewRecordTestCase extends UnitTestCase
+{
+ function setup()
+ {
+ $conn = new TDbConnection('pgsql:host=localhost;dbname=test', 'test','test');
+ TActiveRecordManager::getInstance()->setDbConnection($conn);
+ }
+
+ function test_view_record()
+ {
+ $users = SimpleUser::finder()->findAll();
+ $this->assertTrue(count($users) > 0);
+ }
+
+ function test_save_view_record_throws_exception()
+ {
+ $user = new SimpleUser();
+ try
+ {
+ $user->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_update_view_record_throws_exception()
+ {
+ $user = SimpleUser::finder()->findByUsername('admin');
+ $user->username = 'ads';
+ try
+ {
+ $user->save();
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_find_by_pk_throws_exception()
+ {
+ try
+ {
+ $user = SimpleUser::finder()->findByPk('admin');
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+
+ function test_delete_by_pk_throws_exception()
+ {
+ try
+ {
+ SimpleUser::finder()->deleteByPk('admin');
+ $this->fail();
+ }
+ catch(TActiveRecordException $e)
+ {
+ $this->pass();
+ }
+ }
+} +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/ar_test.db b/tests/simple_unit/ActiveRecord/ar_test.db Binary files differnew file mode 100644 index 00000000..7549bb66 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/ar_test.db diff --git a/tests/simple_unit/ActiveRecord/records/Blogs.php b/tests/simple_unit/ActiveRecord/records/Blogs.php new file mode 100644 index 00000000..69bdecd9 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/Blogs.php @@ -0,0 +1,15 @@ +<?php +
+class Blogs extends TActiveRecord
+{
+ public $blog_id;
+ public $blog_name;
+ public $blog_author;
+
+ public static function finder()
+ {
+ return self::getRecordFinder('Blogs');
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/DepSections.php b/tests/simple_unit/ActiveRecord/records/DepSections.php new file mode 100644 index 00000000..9563dda6 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/DepSections.php @@ -0,0 +1,17 @@ +<?php +
+class DepSections extends TActiveRecord
+{
+ public $department_id;
+ public $section_id;
+ public $order;
+
+ private static $_tablename='department_sections';
+
+ public static function finder()
+ {
+ return self::getRecordFinder('DepSections');
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php new file mode 100644 index 00000000..62e5c3e4 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/DepartmentRecord.php @@ -0,0 +1,19 @@ +<?php +
+class DepartmentRecord extends TActiveRecord
+{
+ public $department_id;
+ public $name;
+ public $description;
+ public $active;
+ public $order;
+
+ private static $_tablename = 'departments';
+
+ public static function finder()
+ {
+ return self::getRecordFinder('DepartmentRecord');
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/SimpleUser.php b/tests/simple_unit/ActiveRecord/records/SimpleUser.php new file mode 100644 index 00000000..a6eb2f81 --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/SimpleUser.php @@ -0,0 +1,15 @@ +<?php +
+class SimpleUser extends TActiveRecord
+{
+ public $username;
+
+ private static $_tablename='simple_users';
+
+ public static function finder()
+ {
+ return self::getRecordFinder('SimpleUser');
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/SqliteUsers.php b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php new file mode 100644 index 00000000..7a8f3cbb --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/SqliteUsers.php @@ -0,0 +1,17 @@ +<?php +
+class SqliteUsers extends TActiveRecord
+{
+ public $username;
+ public $password;
+ public $email;
+
+ private static $_tablename='users';
+
+ public static function finder()
+ {
+ return self::getRecordFinder('SqliteUsers');
+ }
+}
+ +?>
\ No newline at end of file diff --git a/tests/simple_unit/ActiveRecord/records/UserRecord.php b/tests/simple_unit/ActiveRecord/records/UserRecord.php new file mode 100644 index 00000000..45b74d3a --- /dev/null +++ b/tests/simple_unit/ActiveRecord/records/UserRecord.php @@ -0,0 +1,39 @@ +<?php +
+class UserRecord extends TActiveRecord
+{
+ public $username;
+ public $password;
+ public $email;
+ public $first_name;
+ public $last_name;
+ public $job_title;
+ public $work_phone;
+ public $work_fax;
+ public $active=true;
+ public $department_id;
+ public $salutation;
+ public $hint_question;
+ public $hint_answer;
+
+ private $_level=-1;
+
+ protected static $_tablename='users';
+
+ public function getLevel()
+ {
+ return $this->_level;
+ }
+
+ public function setLevel($level)
+ {
+ $this->_level=TPropertyValue::ensureInteger($level);
+ }
+
+ public static function finder()
+ {
+ return self::getRecordFinder('UserRecord');
+ }
+}
+ +?>
\ No newline at end of file |