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

ViewDetailTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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