summaryrefslogtreecommitdiff
path: root/tests/simple_unit/ActiveRecord/UserRecordTestCase.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
committerFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
commita3388622287e218beddfa14a47ed677d4307b36b (patch)
tree1b4c7ac8597b1cc798b6683d4a81c90d38de12f6 /tests/simple_unit/ActiveRecord/UserRecordTestCase.php
parentc7fd3e1167b6f2fa7746edbd0fb8f8c1694c61f9 (diff)
Removed simpletest and moved all tests in the unit tree
Tests are executed now, but a lot of them need fixing.
Diffstat (limited to 'tests/simple_unit/ActiveRecord/UserRecordTestCase.php')
-rw-r--r--tests/simple_unit/ActiveRecord/UserRecordTestCase.php64
1 files changed, 0 insertions, 64 deletions
diff --git a/tests/simple_unit/ActiveRecord/UserRecordTestCase.php b/tests/simple_unit/ActiveRecord/UserRecordTestCase.php
deleted file mode 100644
index 85b12594..00000000
--- a/tests/simple_unit/ActiveRecord/UserRecordTestCase.php
+++ /dev/null
@@ -1,64 +0,0 @@
-<?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_different_instance()
- {
- $user1 = UserRecord::finder()->findByPk('admin');
- $this->assertNotNull($user1);
-
- $user2 = UserRecord::finder()->findByPk('admin');
- $this->assertFalse($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);
- }
-}