blob: 8c6b9789438ec2df53bbc1efbdb750cbcb9d5214 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<?php
Prado::using('System.Data.ActiveRecord.TActiveRecord');
require_once(dirname(__FILE__).'/records/DepartmentRecord.php');
require_once(dirname(__FILE__).'/records/DepSections.php');
/**
* @package System.Data.ActiveRecord
*/
class ActiveRecordDynamicCallTest extends PHPUnit_Framework_TestCase
{
function setup()
{
$conn = new TDbConnection('mysql:host=localhost;dbname=prado_unitest', 'prado_unitest','prado_unitest');
TActiveRecordManager::getInstance()->setDbConnection($conn);
}
function test_multiple_field_and_or()
{
$finder = DepartmentRecord::finder();
$r2 = $finder->findAllByName_And_Description_Or_Active_Or_Order('Facilities', null, false, 1);
$this->assertNotNull($r2);
}
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(TDbException $e)
{
return;
}
$this->fail();
}
function test_dynamic_call_extras_parameters_ok()
{
$finder = DepartmentRecord::finder();
try
{
$rs = $finder->findByNameAndActive('Marketing',true,true);
$this->fail();
}
catch(TDbException $e)
{
return;
}
$this->fail();
}
function test_dynamic_delete_by()
{
$finder = DepartmentRecord::finder();
//$finder->RecordManager->OnDelete[] = array($this, 'assertDeleteSql');
$this->assertEquals($finder->deleteByName('tasds'), 0);
}
function assertDeleteSql($sender, $param)
{
var_dump($param);
}
}
|