1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
6
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
7
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
8
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
9
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
10
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
11
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
12
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
13
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
14
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
15
|
|
|
* |
16
|
|
|
* This software consists of voluntary contributions made by many individuals |
17
|
|
|
* and is licensed under the LGPL. For more information please see |
18
|
|
|
* <http://phing.info>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace Phing\Test\Task\Optional; |
22
|
|
|
|
23
|
|
|
use Phing\Test\Support\BuildFileTest; |
24
|
|
|
|
25
|
|
|
class PDOTaskTest extends BuildFileTest |
26
|
|
|
{ |
27
|
|
|
public function setUp(): void |
28
|
|
|
{ |
29
|
|
|
$this->configureProject(PHING_TEST_BASE . '/etc/tasks/ext/pdo/test.xml'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function tearDown(): void |
33
|
|
|
{ |
34
|
|
|
@unlink('test.db'); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
public function testPDOTask(): void |
38
|
|
|
{ |
39
|
|
|
$this->expectLogContaining(__FUNCTION__, '2 of 2 SQL statements executed successfully'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testWriteXMLResutFile(): void |
43
|
|
|
{ |
44
|
|
|
$this->executeTarget(__FUNCTION__); |
45
|
|
|
$this->assertFileExists('result.xml'); |
46
|
|
|
@unlink('result.xml'); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testWritePlainResutFile(): void |
50
|
|
|
{ |
51
|
|
|
$this->executeTarget(__FUNCTION__); |
52
|
|
|
$this->assertFileExists('result.txt'); |
53
|
|
|
@unlink('result.txt'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function testContinue(): void |
57
|
|
|
{ |
58
|
|
|
$this->expectLogContaining(__FUNCTION__, 'Failed to execute: THIS IS NO SQL'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function testErrorProp(): void |
62
|
|
|
{ |
63
|
|
|
$this->executeTarget(__FUNCTION__); |
64
|
|
|
$this->assertPropertyEquals('sql.error', 'true'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testFileList(): void |
68
|
|
|
{ |
69
|
|
|
$this->expectLogContaining(__FUNCTION__, '2 of 2 SQL statements executed successfully'); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testFileSet(): void |
73
|
|
|
{ |
74
|
|
|
$this->expectLogContaining(__FUNCTION__, '2 of 2 SQL statements executed successfully'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function testStatementCountProp(): void |
78
|
|
|
{ |
79
|
|
|
$this->executeTarget(__FUNCTION__); |
80
|
|
|
$this->assertPropertyEquals('statement.count', 2); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|