Passed
Push — master ( 30bcbc...eba4fe )
by Siad
06:53
created

testFalseWhenInvalidDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 1
b 0
f 0
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'
0 ignored issues
show
Bug introduced by
The constant PHING_TEST_BASE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
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