|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class AOW_ConditionTest extends PHPUnit_Framework_TestCase { |
|
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
public function testAOW_Condition(){ |
|
7
|
|
|
|
|
8
|
|
|
//execute the contructor and check for the Object type and attributes |
|
9
|
|
|
$aowCondition = new AOW_Condition(); |
|
10
|
|
|
$this->assertInstanceOf('AOW_Condition',$aowCondition); |
|
11
|
|
|
$this->assertInstanceOf('Basic',$aowCondition); |
|
12
|
|
|
$this->assertInstanceOf('SugarBean',$aowCondition); |
|
13
|
|
|
|
|
14
|
|
|
$this->assertAttributeEquals('AOW_Conditions', 'module_dir', $aowCondition); |
|
15
|
|
|
$this->assertAttributeEquals('AOW_Condition', 'object_name', $aowCondition); |
|
16
|
|
|
$this->assertAttributeEquals('aow_conditions', 'table_name', $aowCondition); |
|
17
|
|
|
$this->assertAttributeEquals(true, 'new_schema', $aowCondition); |
|
18
|
|
|
$this->assertAttributeEquals(true, 'disable_row_level_security', $aowCondition); |
|
19
|
|
|
$this->assertAttributeEquals(false, 'importable', $aowCondition); |
|
20
|
|
|
$this->assertAttributeEquals(false, 'tracker_visibility', $aowCondition); |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testbean_implements(){ |
|
26
|
|
|
|
|
27
|
|
|
error_reporting(E_ERROR | E_PARSE); |
|
28
|
|
|
|
|
29
|
|
|
$aowCondition = new AOW_Condition(); |
|
30
|
|
|
$this->assertEquals(false, $aowCondition->bean_implements('')); //test with blank value |
|
31
|
|
|
$this->assertEquals(false, $aowCondition->bean_implements('test')); //test with invalid value |
|
32
|
|
|
$this->assertEquals(false, $aowCondition->bean_implements('ACL')); //test with valid value |
|
33
|
|
|
|
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function testsave_lines(){ |
|
37
|
|
|
|
|
38
|
|
|
$aowCondition = new AOW_Condition(); |
|
39
|
|
|
|
|
40
|
|
|
//populate required values |
|
41
|
|
|
$post_data= Array(); |
|
42
|
|
|
$post_data["name"] = Array('test1','test2'); |
|
43
|
|
|
$post_data["field"] = Array('field1','field2'); |
|
44
|
|
|
$post_data["operator"] = Array('=','!='); |
|
45
|
|
|
$post_data["value_type"] = Array('int','string'); |
|
46
|
|
|
$post_data["value"] = Array('1','abc'); |
|
47
|
|
|
|
|
48
|
|
|
|
|
49
|
|
|
//create parent bean |
|
50
|
|
|
$aowWorkFlow = new AOW_WorkFlow(); |
|
51
|
|
|
$aowWorkFlow->id = 1; |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
$aowCondition->save_lines($post_data, $aowWorkFlow); |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
//get the linked beans and verify if records created |
|
58
|
|
|
$aow_conditions = $aowWorkFlow->get_linked_beans('aow_conditions', $aowWorkFlow->object_name); |
|
59
|
|
|
$this->assertEquals(count($post_data["field"]), count($aow_conditions) ); |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
//cleanup afterwards |
|
63
|
|
|
foreach($aow_conditions as $lineItem){ |
|
64
|
|
|
$lineItem->mark_deleted($lineItem->id); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
?> |
|
72
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.