Passed
Push — master ( 972120...1c77fc )
by Michiel
08:19
created

PDOSQLExecTaskConditionTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
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