Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow php 8.0 #230

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"jangregor/phpstan-prophecy": "^0.8.1",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-phpunit": "^0.12.17",
"symplify/easy-coding-standard": "^8.3"
"symplify/easy-coding-standard": "^8.3",
"phpspec/prophecy-phpunit": "^2.0",
"ext-pdo": "*"
},
"autoload": {
"psr-4": {
Expand Down
56 changes: 54 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</phpunit>
16 changes: 11 additions & 5 deletions tests/Integration/FlowderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@

final class FlowderTest extends TestCase
{
public function testItLoadsFixturesFromAFileIfGivenThePathToAFile(): void
private function getDatabaseConnection(): PDO
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

return $db;
}

public function testItLoadsFixturesFromAFileIfGivenThePathToAFile(): void
{
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS loader_test_data (
column1 INT PRIMARY KEY,
Expand Down Expand Up @@ -65,8 +73,7 @@ public function testItLoadsFixturesFromAFileIfGivenThePathToAFile(): void

public function testItTruncatesDataBeforeInsertingAgain(): void
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS loader_test_data (
column1 INT PRIMARY KEY,
Expand Down Expand Up @@ -119,8 +126,7 @@ public function testItTruncatesDataBeforeInsertingAgain(): void

public function testItLoadsFixturesFromADirectoryIfGivenThePathToADirectory(): void
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS empty (column1 INT PRIMARY KEY)');

Expand Down
16 changes: 11 additions & 5 deletions tests/Integration/Persister/SqlitePersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@

final class SqlitePersisterTest extends TestCase
{
public function testItRunsOneInsertForASingleRowOfData(): void
private function getDatabaseConnection(): PDO
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

return $db;
}

public function testItRunsOneInsertForASingleRowOfData(): void
{
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS test_table (
column1 INT PRIMARY KEY,
Expand Down Expand Up @@ -49,8 +57,7 @@ public function testItRunsOneInsertForASingleRowOfData(): void

public function testItRunsOneInsertForMultipleRowsOfData(): void
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS test_table (
column1 INT PRIMARY KEY,
Expand Down Expand Up @@ -106,8 +113,7 @@ public function testItRunsOneInsertForMultipleRowsOfData(): void

public function testItCanHandleBrokenForeignKeys(): void
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = $this->getDatabaseConnection();

$db->exec('PRAGMA foreign_keys = ON');

Expand Down
13 changes: 10 additions & 3 deletions tests/Integration/Truncator/SqliteTruncatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@

final class SqliteTruncatorTest extends TestCase
{
public function testItTruncatesAGivenTable(): void
private function getDatabaseConnection(): PDO
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);

return $db;
}

public function testItTruncatesAGivenTable(): void
{
$db = $this->getDatabaseConnection();

$db->exec('CREATE TABLE IF NOT EXISTS test_truncate_table (
column1 INT PRIMARY KEY
Expand All @@ -40,8 +48,7 @@ public function testItTruncatesAGivenTable(): void

public function testItDoesntBreakWhenThereAreForeignKeys(): void
{
$db = new PDO('sqlite::memory:');
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db = $this->getDatabaseConnection();

$db->exec('PRAGMA foreign_keys = ON');

Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Persister/MySqlPersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
use PDO;
use PDOStatement;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

final class MySqlPersisterTest extends TestCase
{
use ProphecyTrait;

public function testItRunsOneInsertForASingleRowOfData(): void
{
$db = $this->prophesize(PDO::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Persister/SqlitePersisterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
use PDOException;
use PDOStatement;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

final class SqlitePersisterTest extends TestCase
{
use ProphecyTrait;

public function testItRollsbackUponError(): void
{
$db = $this->prophesize(PDO::class);
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Truncator/MySqlTruncatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
use Imjoehaines\Flowder\Truncator\MySqlTruncator;
use PDO;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

final class MySqlTruncatorTest extends TestCase
{
use ProphecyTrait;

public function testItTruncatesAGivenTable(): void
{
$db = $this->prophesize(PDO::class);
Expand Down