Skip to content

Commit 36389e0

Browse files
authored
Merge pull request #2 from hrodic/1.0-beta
allow phpunit8, fix namespaces and tests
2 parents e665c56 + 196d797 commit 36389e0

File tree

10 files changed

+29
-11
lines changed

10 files changed

+29
-11
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":1962:{a:2:{s:7:"defects";a:7:{s:98:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testBeforeFirstTestBehaviour";i:5;s:93:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testBeforeTestBehaviour";i:5;s:92:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testAfterTestBehaviour";i:5;s:96:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testAfterLastTestBehaviour";i:5;s:92:"IntegrationTesting\Tests\Integration\MariaDB\PDOIntegrationTest::testReadFixtureFromDatabase";i:5;s:124:"IntegrationTesting\Tests\Integration\MariaDB\PDOWithoutBeforeOrAfterTestFixturesTest::testReadingEphemeralTableHasNoContents";i:5;s:137:"IntegrationTesting\Tests\Integration\MariaDB\PDOWithoutBeforeOrAfterTestFixturesTest::testPersistentTableHasRowCountEqualsToTestsExecuted";i:3;}s:5:"times";a:9:{s:98:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testBeforeFirstTestBehaviour";d:0.005;s:93:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testBeforeTestBehaviour";d:0.005;s:92:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testAfterTestBehaviour";d:0.02;s:96:"IntegrationTesting\PHPUnit\Runner\Extension\PDODatabaseExtensionTest::testAfterLastTestBehaviour";d:0.005;s:92:"IntegrationTesting\Tests\Integration\MariaDB\PDOIntegrationTest::testReadFixtureFromDatabase";d:0.006;s:124:"IntegrationTesting\Tests\Integration\MariaDB\PDOWithoutBeforeOrAfterTestFixturesTest::testReadingEphemeralTableHasNoContents";d:0.002;s:137:"IntegrationTesting\Tests\Integration\MariaDB\PDOWithoutBeforeOrAfterTestFixturesTest::testPersistentTableHasRowCountEqualsToTestsExecuted";d:0.011;s:121:"IntegrationTesting\Tests\Integration\MariaDB\PDOWithoutBeforeOrAfterTestFixturesTest::testPersistentTableHasAtLeastOneRow";d:0.002;s:100:"IntegrationTesting\Tests\Integration\MariaDB\PDOIntegrationTest::testPersistentTableHasAtLeastOneRow";d:0.002;}}}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"ext-mbstring": "*",
3030
"ext-pdo_mysql": "*",
3131
"ext-xml": "*",
32-
"phpunit/phpunit": "^9.0",
32+
"phpunit/phpunit": "^8.5",
3333
"friendsofphp/php-cs-fixer": "^2.16",
3434
"squizlabs/php_codesniffer": "^3.5"
3535
},

src/Driver/FileSystem.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use ArrayIterator;
66
use FilesystemIterator;
7+
use IntegrationTesting\Exception\TestingException;
78
use Iterator;
89

910
class FileSystem

src/Exception/TestingException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace IntegrationTesting\Driver;
3+
namespace IntegrationTesting\Exception;
44

55
class TestingException extends \Exception
66
{

src/PHPUnit/Runner/Extension/PDODatabaseExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use IntegrationTesting\Driver\FileSystem;
66
use IntegrationTesting\Driver\PDOConnection;
7-
use IntegrationTesting\Driver\TestingException;
7+
use IntegrationTesting\Exception\TestingException;
88
use PHPUnit\Runner\BeforeFirstTestHook;
99
use PHPUnit\Runner\BeforeTestHook;
1010
use PHPUnit\Runner\AfterTestHook;

src/PHPUnit/Runner/Extension/PDODatabaseExtensionConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace IntegrationTesting\PHPUnit\Runner\Extension;
44

5-
use IntegrationTesting\Driver\TestingException;
5+
use IntegrationTesting\Exception\TestingException;
66

77
class PDODatabaseExtensionConfig
88
{

tests/fixtures/before-first-test/01.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE TABLE IF NOT EXISTS `test`.`ephemeral_table`
99

1010
CREATE TABLE IF NOT EXISTS `test`.`persistent_table`
1111
(
12-
`id` INT NOT NULL AUTO_INCREMENT,
12+
`id` INT NOT NULL AUTO_INCREMENT,
13+
`varchar` VARCHAR(45) NULL,
1314
PRIMARY KEY (`id`)
1415
);

tests/fixtures/before-test/01.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-- in this example we truncate also before each test
22
TRUNCATE TABLE `test`.`ephemeral_table`;
33

4-
INSERT INTO `test`.`persistent_table` (`id`) VALUES (NULL);
4+
INSERT INTO `test`.`persistent_table` (`varchar`) VALUES ('example');

tests/integration/MariaDB/PDOIntegrationTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace IntegrationTesting\Tests\Integration;
3+
namespace IntegrationTesting\Tests\Integration\MariaDB;
44

55
use IntegrationTesting\Driver\PDOConnection;
66
use IntegrationTesting\WithAfterTestFixtureName;
@@ -39,4 +39,18 @@ public function testReadFixtureFromDatabase(): void
3939
$data
4040
);
4141
}
42+
43+
public function testPersistentTableHasAtLeastOneRow(): void
44+
{
45+
$conn = new PDOConnection(
46+
constant('DB_DSN'),
47+
constant('DB_USERNAME'),
48+
constant('DB_PASSWORD')
49+
);
50+
$conn->PDO()->beginTransaction();
51+
$statement = $conn->PDO()->query("SELECT * FROM `test`.`persistent_table`");
52+
$conn->PDO()->commit();
53+
// this is the third test to run a beforeTest hook!
54+
$this->assertTrue($statement->rowCount() >= 1);
55+
}
4256
}

tests/integration/MariaDB/PDOWithoutBeforeOrAfterTestFixturesTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php declare(strict_types=1);
22

3-
namespace IntegrationTesting\Tests\Integration;
3+
namespace IntegrationTesting\Tests\Integration\MariaDB;
44

55
use IntegrationTesting\Driver\PDOConnection;
66
use PHPUnit\Framework\TestCase;
@@ -11,7 +11,6 @@
1111
*/
1212
final class PDOWithoutBeforeOrAfterTestFixturesTest extends TestCase
1313
{
14-
1514
public function testReadingEphemeralTableHasNoContents(): void
1615
{
1716
$conn = new PDOConnection(
@@ -23,15 +22,17 @@ public function testReadingEphemeralTableHasNoContents(): void
2322
$this->assertSame(0, $statement->rowCount());
2423
}
2524

26-
public function testPersistentTableHasRowCountEqualsToTestsExecuted(): void
25+
public function testPersistentTableHasAtLeastOneRow(): void
2726
{
2827
$conn = new PDOConnection(
2928
constant('DB_DSN'),
3029
constant('DB_USERNAME'),
3130
constant('DB_PASSWORD')
3231
);
32+
$conn->PDO()->beginTransaction();
3333
$statement = $conn->PDO()->query("SELECT * FROM `test`.`persistent_table`");
34+
$conn->PDO()->commit();
3435
// this is the third test to run a beforeTest hook!
35-
$this->assertSame(3, $statement->rowCount());
36+
$this->assertTrue($statement->rowCount() >= 1);
3637
}
3738
}

0 commit comments

Comments
 (0)