|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class ViewQuickeditTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
|
|
6
|
|
|
public function testpreDisplay() |
|
7
|
|
|
{ |
|
8
|
|
|
//check without setting any values, it should execute without any issues. |
|
9
|
|
|
$view = new ViewQuickedit(); |
|
10
|
|
|
$view->preDisplay(); |
|
11
|
|
|
$this->assertEquals(0,count($_REQUEST)); |
|
12
|
|
|
|
|
13
|
|
|
//check with values preset but without a valid bean id, it sould not change Request parameters |
|
14
|
|
|
$_REQUEST['source_module'] = "Users"; |
|
15
|
|
|
$_REQUEST['module']= 'Users'; |
|
16
|
|
|
$_REQUEST['record'] = ''; |
|
17
|
|
|
$request = $_REQUEST; |
|
18
|
|
|
|
|
19
|
|
|
$view->preDisplay(); |
|
20
|
|
|
$this->assertSame($request,$_REQUEST); |
|
21
|
|
|
|
|
22
|
|
|
//check with values preset, it sould set some addiiotnal Request parameters |
|
23
|
|
|
$_REQUEST['record'] = 1; |
|
24
|
|
|
$view->preDisplay(); |
|
25
|
|
|
$this->assertNotSame($request,$_REQUEST); |
|
26
|
|
|
|
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
public function testdisplay() |
|
31
|
|
|
{ |
|
32
|
|
|
error_reporting(E_ALL); |
|
33
|
|
|
//error_reporting(E_ERROR | E_PARSE |E_NOTICE); |
|
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
//execute the method with required child objects and paramerers preset. it will rteturn some html. |
|
36
|
|
|
$view = new ViewQuickedit(); |
|
37
|
|
|
$_REQUEST['module'] = 'Accounts'; |
|
38
|
|
|
$_REQUEST['action'] = 'SubpanelCreates'; |
|
39
|
|
|
|
|
40
|
|
|
try{ |
|
41
|
|
|
$view->bean = new Account(); |
|
42
|
|
|
} |
|
43
|
|
|
Catch(Exception $e){ |
|
44
|
|
|
$this->assertStringStartsWith('mysqli_query()',$e->getMessage()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
try{ |
|
49
|
|
|
ob_start(); |
|
50
|
|
|
|
|
51
|
|
|
$view->display(); |
|
52
|
|
|
|
|
53
|
|
|
$renderedContent = ob_get_contents(); |
|
54
|
|
|
ob_end_clean(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertGreaterThan(0,strlen($renderedContent)); |
|
57
|
|
|
$this->assertNotEquals(False,json_decode($renderedContent)); |
|
58
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
Catch(Exception $e){ |
|
61
|
|
|
$this->assertStringStartsWith('mysqli_query()',$e->getMessage()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
|
|
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.