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