|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class ViewClassicTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
|
|
6
|
|
|
public function test__construct( ) |
|
7
|
|
|
{ |
|
8
|
|
|
//execute the contructor and check for the Object type and type attribute |
|
9
|
|
|
|
|
10
|
|
|
//test with no paramerters |
|
11
|
|
|
$view = new ViewClassic(); |
|
12
|
|
|
$this->assertInstanceOf('ViewClassic',$view); |
|
13
|
|
|
$this->assertInstanceOf('SugarView',$view); |
|
14
|
|
|
$this->assertAttributeEquals('','type', $view); |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
//test with bean parameter; |
|
18
|
|
|
$bean = new User(); |
|
19
|
|
|
$view = new ViewClassic($bean); |
|
20
|
|
|
$this->assertInstanceOf('ViewClassic',$view); |
|
21
|
|
|
$this->assertInstanceOf('SugarView',$view); |
|
22
|
|
|
$this->assertAttributeEquals('','type', $view); |
|
23
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
public function testdisplay() |
|
28
|
|
|
{ |
|
29
|
|
|
error_reporting(E_ERROR | E_PARSE); |
|
30
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
//test with a valid module but invalid action. it should return false. |
|
33
|
|
|
$view = new ViewClassic(); |
|
34
|
|
|
$view->module = "Home"; |
|
35
|
|
|
$view->action = ""; |
|
36
|
|
|
$ret = $view->display(); |
|
37
|
|
|
$this->assertFalse($ret); |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
//test with a valid module and uncustomized action. it should return true |
|
42
|
|
|
$view = new ViewClassic(); |
|
43
|
|
|
$view->module = "Home"; |
|
44
|
|
|
$view->action = "About"; |
|
45
|
|
|
|
|
46
|
|
|
ob_start(); |
|
47
|
|
|
$ret = $view->display(); |
|
48
|
|
|
$renderedContent = ob_get_contents(); |
|
49
|
|
|
ob_end_clean(); |
|
50
|
|
|
$this->assertGreaterThan(0,strlen($renderedContent)); |
|
51
|
|
|
$this->assertTrue($ret); |
|
52
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
//test with a valid module and customized action. it should return true |
|
56
|
|
|
$view = new ViewClassic(); |
|
57
|
|
|
$view->module = "Home"; |
|
58
|
|
|
$view->action = "index"; |
|
59
|
|
|
|
|
60
|
|
|
ob_start(); |
|
61
|
|
|
$ret = $view->display(); |
|
62
|
|
|
$renderedContent = ob_get_contents(); |
|
63
|
|
|
ob_end_clean(); |
|
64
|
|
|
$this->assertGreaterThan(0,strlen($renderedContent)); |
|
65
|
|
|
$this->assertTrue($ret); |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
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.