Skip to content
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
19 changes: 19 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ jobs:
composer-options: --no-ansi --no-interaction --no-progress
- name: Run ECS
run: vendor/bin/ecs check
rector:
name: Rector
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
coverage: none
- name: Install composer dependencies
uses: ramsey/composer-install@v3
with:
dependency-versions: locked
composer-options: --no-ansi --no-interaction --no-progress
- name: Run Rector
run: vendor/bin/rector --dry-run
tests:
name: Tests
runs-on: ${{ matrix.operating-system }}
Expand Down Expand Up @@ -54,6 +72,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
ini-values: display_errors=1
extensions: pdo_mysql, libxml, dom
coverage: none
- name: Install composer dependencies
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misantron/dbunit",
"description": "DbUnit fork supporting PHPUnit 10/11/12",
"description": "DbUnit fork supporting modern PHPUnit versions",
"type": "library",
"license": "MIT",
"keywords": [
Expand All @@ -19,11 +19,13 @@
"php": ">=8.1",
"ext-pdo": "*",
"phpunit/phpunit": "^10.5 || ^11.5 || ^12.0",
"symfony/yaml": "^6.4 || ^7.4 || ^8.0"
"symfony/yaml": "^6.4 || ^7.4 || ^8.0",
"webmozart/assert": "^1.12 || ^2.0"
},
"require-dev": {
"phpstan/extension-installer": "^1.4",
"phpstan/phpstan": "^2.1",
"rector/rector": "^2.3",
"symplify/easy-coding-standard": "^13.0"
},
"autoload": {
Expand Down
49 changes: 20 additions & 29 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\Comment\HeaderCommentFixer;
use PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer;
use PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return static function (ECSConfig $ecsConfig): void {
$ecsConfig->parallel();

$ecsConfig->paths([
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$header = <<<'EOF'
$header = <<<'EOF'
This file is part of DbUnit.

(c) Sebastian Bergmann <sebastian@phpunit.de>
Expand All @@ -22,22 +16,19 @@
file that was distributed with this source code.
EOF;

$ecsConfig->ruleWithConfiguration(PhpCsFixer\Fixer\Comment\HeaderCommentFixer::class, [
'header' => $header,
]);

$ecsConfig->skip([
PhpCsFixer\Fixer\Operator\NotOperatorWithSuccessorSpaceFixer::class,
PhpCsFixer\Fixer\StringNotation\ExplicitStringVariableFixer::class,
]);

$ecsConfig->sets([
SetList::PSR_12,
SetList::SPACES,
SetList::CLEAN_CODE,
SetList::ARRAY,
SetList::PHPUNIT,
SetList::CONTROL_STRUCTURES,
SetList::NAMESPACES,
]);
};
return ECSConfig::configure()
->withParallel()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSkip([
NotOperatorWithSuccessorSpaceFixer::class,
ExplicitStringVariableFixer::class,
])
->withConfiguredRule(HeaderCommentFixer::class, ['header' => $header])
->withPreparedSets(
psr12: true,
common: true,
)
;
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
bootstrap="tests/bootstrap.php"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
colors="true">

<testsuites>
Expand Down
30 changes: 30 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSkip([
UseIdenticalOverEqualWithSameTypeRector::class,
ChangeSwitchToMatchRector::class => [
__DIR__ . '/tests/Operation/RowBasedTest.php',
],
])
->withImportNames(importShortClasses: false)
->withPhpSets()
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
earlyReturn: true,
phpunitCodeQuality: true,
)
;
44 changes: 11 additions & 33 deletions src/AbstractTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@
*/
abstract class AbstractTester implements Tester
{
/**
* @var Operation
*/
protected $setUpOperation;
protected Operation $setUpOperation;

/**
* @var Operation
*/
protected $tearDownOperation;
protected Operation $tearDownOperation;

/**
* @var IDataSet
Expand All @@ -52,8 +46,6 @@ public function __construct()

/**
* Closes the specified connection.
*
* @param Connection $connection
*/
public function closeConnection(Connection $connection): void
{
Expand All @@ -62,10 +54,8 @@ public function closeConnection(Connection $connection): void

/**
* Returns the test dataset.
*
* @return IDataSet
*/
public function getDataSet()
public function getDataSet(): IDataSet
{
return $this->dataSet;
}
Expand All @@ -75,21 +65,21 @@ public function getDataSet()
*/
public function onSetUp(): void
{
$this->getSetUpOperation()->execute($this->getConnection(), $this->getDataSet());
$this->getSetUpOperation()
->execute($this->getConnection(), $this->getDataSet());
}

/**
* TestCases must call this method inside tearDown().
*/
public function onTearDown(): void
{
$this->getTearDownOperation()->execute($this->getConnection(), $this->getDataSet());
$this->getTearDownOperation()
->execute($this->getConnection(), $this->getDataSet());
}

/**
* Sets the test dataset to use.
*
* @param IDataSet $dataSet
*/
public function setDataSet(IDataSet $dataSet): void
{
Expand All @@ -98,18 +88,14 @@ public function setDataSet(IDataSet $dataSet): void

/**
* Sets the schema value.
*
* @param string $schema
*/
public function setSchema($schema): void
public function setSchema(string $schema): void
{
$this->schema = $schema;
}

/**
* Sets the DatabaseOperation to call when starting the test.
*
* @param Operation $setUpOperation
*/
public function setSetUpOperation(Operation $setUpOperation): void
{
Expand All @@ -118,8 +104,6 @@ public function setSetUpOperation(Operation $setUpOperation): void

/**
* Sets the DatabaseOperation to call when ending the test.
*
* @param Operation $tearDownOperation
*/
public function setTearDownOperation(Operation $tearDownOperation): void
{
Expand All @@ -128,30 +112,24 @@ public function setTearDownOperation(Operation $tearDownOperation): void

/**
* Returns the schema value
*
* @return string
*/
protected function getSchema()
protected function getSchema(): string
{
return $this->schema;
}

/**
* Returns the database operation that will be called when starting the test.
*
* @return Operation
*/
protected function getSetUpOperation()
protected function getSetUpOperation(): Operation
{
return $this->setUpOperation;
}

/**
* Returns the database operation that will be called when ending the test.
*
* @return Operation
*/
protected function getTearDownOperation()
protected function getTearDownOperation(): Operation
{
return $this->tearDownOperation;
}
Expand Down
26 changes: 7 additions & 19 deletions src/Constraint/DataSetIsEqual.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/*
* This file is part of DbUnit.
*
Expand All @@ -20,23 +22,13 @@
*/
class DataSetIsEqual extends Constraint
{
/**
* @var IDataSet
*/
protected IDataSet $value;

/**
* @param IDataSet $value
*/
public function __construct(IDataSet $value)
{
$this->value = $value;
public function __construct(
protected IDataSet $value
) {
}

/**
* Returns a string representation of the constraint.
*
* @return string
*/
public function toString(): string
{
Expand All @@ -53,10 +45,8 @@ public function toString(): string
* This method can be overridden to implement the evaluation algorithm.
*
* @param IDataSet $other value or object to evaluate
*
* @return bool
*/
protected function matches($other): bool
protected function matches(mixed $other): bool
{
if (!$other instanceof IDataSet) {
throw new InvalidArgumentException('Only dataset instance can be matched');
Expand All @@ -72,10 +62,8 @@ protected function matches($other): bool
* cases. This method should return the second part of that sentence.
*
* @param mixed $other evaluated value or object
*
* @return string
*/
protected function failureDescription($other): string
protected function failureDescription(mixed $other): string
{
return $other . ' ' . $this->toString();
}
Expand Down
Loading
Loading