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

layout_utilsTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 113
rs 10
c 1
b 0
f 1

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testget_form_header() 0 23 1
B testget_module_title() 0 26 1
A testgetClassicModuleTitle() 0 17 1
A testinsert_popup_header() 0 22 1
A testinsert_popup_footer() 0 11 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 5 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
4
require_once 'include/utils/layout_utils.php';
5
class layout_utilsTest 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...
6
{
7
	
8
9
	public function testget_form_header()
10
	{
11
		error_reporting(E_ERROR | E_PARSE);
12
		
13
		//execute the method and test if it returns html and contains the values provided in parameters
14
		
15
		//help param true
16
		$html1 = get_form_header("test Header", "test subheader", true);
17
		$this->assertGreaterThan(0,strlen($html1));
18
		$this->assertNotFalse(strpos($html1,"test Header"));
19
		$this->assertNotFalse(strpos($html1,"test subheader"));
20
		
21
		
22
		// help param false
23
		$html2 = get_form_header("new test Header", "new test subheader", false);
24
		$this->assertGreaterThan(0,strlen($html2));
25
		$this->assertNotFalse(strpos($html2,"new test Header"));
26
		$this->assertNotFalse(strpos($html2,"new test subheader"));
27
		
28
		
29
		$this->assertGreaterThan(strlen($html2),strlen($html1));
30
		
31
	}
32
	
33
	
34
	public function testget_module_title( )
35
	{
36
		//execute the method and test if it returns html and contains the values provided in parameters
37
		
38
		//with show_create true, generates more html
39
		$html1 = get_module_title("Users", "Users Home", true );
0 ignored issues
show
Deprecated Code introduced by
The function get_module_title() has been deprecated with message: use SugarView::getModuleTitle() for MVC modules, or getClassicModuleTitle() for non-MVC modules

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
40
		$this->assertGreaterThan(0,strlen($html1));
41
		$this->assertNotFalse(strpos($html1,"Users"));
42
		$this->assertNotFalse(strpos($html1,"Users Home"));
43
		
44
		//with show_create false, generates less html
45
		$html2 = get_module_title("Users", "Users Home", false );
0 ignored issues
show
Deprecated Code introduced by
The function get_module_title() has been deprecated with message: use SugarView::getModuleTitle() for MVC modules, or getClassicModuleTitle() for non-MVC modules

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
46
		$this->assertGreaterThan(0,strlen($html2));
47
		$this->assertNotFalse(strpos($html2,"Users"));
48
		$this->assertNotFalse(strpos($html2,"Users Home"));
49
		$this->assertGreaterThan(strlen($html2),strlen($html1));
50
51
		//with show_create flase and count > 1, generates more html compared to count =0
52
		$html3 = get_module_title("Users", "Users Home", false, 2 );
0 ignored issues
show
Deprecated Code introduced by
The function get_module_title() has been deprecated with message: use SugarView::getModuleTitle() for MVC modules, or getClassicModuleTitle() for non-MVC modules

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
53
		$this->assertGreaterThan(0,strlen($html3));
54
		$this->assertNotFalse(strpos($html3,"Users"));
55
		$this->assertNotFalse(strpos($html3,"Users Home"));
56
		$this->assertGreaterThan(strlen($html2),strlen($html3));
57
		$this->assertGreaterThan(strlen($html3),strlen($html1));
58
		
59
	}
60
	
61
	
62
	public function testgetClassicModuleTitle()
63
	{
64
		//execute the method and test if it returns html and contains the values provided in parameters
65
		
66
		//with show_create false, generates less html
67
		$html1 = getClassicModuleTitle("users", Array('Users Home'));
68
		$this->assertGreaterThan(0,strlen($html1));
69
		$this->assertNotFalse(strpos($html1,"Users Home"));
70
		
71
72
		//with show_create true, generates more html
73
		$html2 = getClassicModuleTitle("users", Array('Users Home'),true);
74
		$this->assertGreaterThan(0,strlen($html2));
75
		$this->assertNotFalse(strpos($html2,"Users Home"));
76
		$this->assertGreaterThan(strlen($html1),strlen($html2));
77
		
78
	}
79
	
80
	
81
	public function testinsert_popup_header()
82
	{
83
		//execute the method and test if it returns html/JS
84
		
85
		//with includeJS true, generates more html		
86
		ob_start();
87
		insert_popup_header();
88
		$renderedContent1 = ob_get_contents();
89
		ob_end_clean();
90
		$this->assertGreaterThan(0,strlen($renderedContent1));
91
		
92
		
93
		//with includeJS false, generates less html
94
		ob_start();
95
		insert_popup_header('',false);
96
		$renderedContent2 = ob_get_contents();
97
		ob_end_clean();
98
		$this->assertGreaterThan(0,strlen($renderedContent2));		
99
		
100
		$this->assertGreaterThan(strlen($renderedContent2),strlen($renderedContent1));
101
		
102
	}
103
	
104
	
105
	public function testinsert_popup_footer()
106
	{
107
		//execute the method and test if it returns html 
108
		
109
		ob_start();
110
		insert_popup_footer();
111
		$renderedContent = ob_get_contents();
112
		ob_end_clean();
113
		$this->assertGreaterThan(0,strlen($renderedContent));
114
		
115
	}
116
117
}
118
?>
119