Completed
Push — CI ( ee6bd7...0f01dd )
by Adam
22:32
created

AOW_ConditionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 68
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testAOW_Condition() 0 18 1
A testbean_implements() 0 10 1
B testsave_lines() 0 32 2
1
<?php
2
3
class AOW_ConditionTest extends PHPUnit_Framework_TestCase  {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
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