Test Failed
Push — CI ( 0f01dd...c95a04 )
by Adam
55:13
created

ViewEditTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 5
dl 0
loc 58
rs 10
c 1
b 0
f 1
1
<?php
2
3
 class ViewEditTest extends PHPUnit_Framework_TestCase
4
 {
5
6
7
 	public function testViewEdit(){
8
 
9
 		//execute the contructor and check for the Object type and attributes
10
 		$view = new ViewEdit();
11
 		$this->assertInstanceOf('ViewEdit',$view);
12
 		$this->assertInstanceOf('SugarView',$view);
13
 		$this->assertAttributeEquals('edit','type', $view);
14
 		
15
 		$this->assertAttributeEquals(false,'useForSubpanel', $view);
16
 		$this->assertAttributeEquals(false,'useModuleQuickCreateTemplate', $view);
17
 		$this->assertAttributeEquals(true,'showTitle', $view);
18
 		
19
 	}
20
21
22
    public function testpreDisplay()
23
    {
24
    	error_reporting(E_ERROR | E_PARSE);
25
    	
26
    	//execute the method with required attributes preset, it will initialize the ev(edit view) attribute.
27
    	$view = new ViewEdit();
28
    	$view->module = "Users";
29
    	$view->bean = new User();
30
    	$view->preDisplay();
31
    	$this->assertInstanceOf('EditView',$view->ev);
32
    	
33
    	
34
    	//execute the method again for a different module with required attributes preset, it will initialize the ev(edit view) attribute.
35
    	$view = new ViewEdit();
36
    	$view->module = "Meetings";
37
    	$view->bean = new Meeting();
38
    	$view->preDisplay();
39
    	$this->assertInstanceOf('EditView',$view->ev);
40
    	
41
    }
42
43
 	public function testdisplay(){
44
45
 		//execute the method with essential parameters set. it should return some html.
46
 		$view = new ViewEdit();
47
 		$view->module = "Users";
48
 		$view->bean = new User();
49
 		$view->preDisplay();
50
 		$view->ev->ss = new Sugar_Smarty();
51
 		
52
 		ob_start();
53
 		$view->display();
54
 		$renderedContent = ob_get_contents();
55
 		ob_end_clean();
56
 		$this->assertGreaterThan(0,strlen($renderedContent));
57
 		
58
 	}
59
  
60
}
61
62