1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Tests PDOSQLExecTask as condition |
5
|
|
|
* |
6
|
|
|
* @author Jawira Portugal <[email protected]> |
7
|
|
|
* @package phing.tasks.system |
8
|
|
|
*/ |
9
|
|
|
class PDOSQLExecTaskConditionTest extends BuildFileTest |
10
|
|
|
{ |
11
|
|
|
public function setUp(): void |
12
|
|
|
{ |
13
|
|
|
$this->configureProject( |
14
|
|
|
PHING_TEST_BASE . '/etc/tasks/ext/PDOSQLExecTaskConditionTest.xml' |
|
|
|
|
15
|
|
|
); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
public function testUrlIsRequiredException() |
19
|
|
|
{ |
20
|
|
|
$this->expectSpecificBuildException(__FUNCTION__, |
21
|
|
|
'url property not set in database condition', |
22
|
|
|
'url is required'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testFalseWhenInvalidHost() |
26
|
|
|
{ |
27
|
|
|
$this->executeTarget(__FUNCTION__); |
28
|
|
|
$this->assertInLogs('Trying to reach mysql:host=dummy', Project::MSG_DEBUG); |
29
|
|
|
$this->assertInLogs('SQLSTATE[HY000] [2002]', Project::MSG_VERBOSE); |
30
|
|
|
$this->assertInLogs('pdosqlexec condition returned false', Project::MSG_INFO); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testFalseWhenInvalidDriver() |
34
|
|
|
{ |
35
|
|
|
$this->executeTarget(__FUNCTION__); |
36
|
|
|
$this->assertInLogs('Trying to reach invalid:host=localhost', Project::MSG_DEBUG); |
37
|
|
|
$this->assertInLogs('could not find driver', Project::MSG_VERBOSE); |
38
|
|
|
$this->assertInLogs('pdosqlexec condition returned false', Project::MSG_INFO); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testCompatibleWithConditionTask() |
42
|
|
|
{ |
43
|
|
|
$this->executeTarget(__FUNCTION__); |
44
|
|
|
$this->assertPropertyEquals('condition.result', 'condition-not-met'); |
45
|
|
|
$this->assertInLogs('Trying to reach mysql:host=localhost', Project::MSG_DEBUG); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testCompatibleWithWaitForTask() |
49
|
|
|
{ |
50
|
|
|
$this->executeTarget(__FUNCTION__); |
51
|
|
|
$this->assertPropertyEquals('waitfor.timeout', 'true'); |
52
|
|
|
$this->assertInLogs('Trying to reach mysql:host=localhost', Project::MSG_DEBUG); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function testSuccessfulCondition() |
56
|
|
|
{ |
57
|
|
|
$this->executeTarget(__FUNCTION__); |
58
|
|
|
$this->assertInLogs('pdosqlexec condition returned true', Project::MSG_INFO); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|