From 5c6814b79fd6dc22033422f15a586927e6e4812d Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Tue, 29 Sep 2026 15:05:46 +1000 Subject: [PATCH 1/3] Regenerate the Mago baselines under 1.50.0 Drops 18 entries for issues that no longer exist: the seven per-component ExceptionInterface files deleted in PR #190, four exception classes that are now final, three resolved unhandled-thrown-type and mixed-argument sites, and the unfulfilled-expect and prefer-test-attribute entries settled by the mutation coverage work in PR #188. Suppressed issue totals are unchanged at 3948 lint and 1215 analyzer, so no new findings are masked. --- analyzer-baseline.toml | 124 ++++++----------------------- lint-baseline.toml | 174 +++++++++++++++++++---------------------- 2 files changed, 107 insertions(+), 191 deletions(-) diff --git a/analyzer-baseline.toml b/analyzer-baseline.toml index e3f738e6..e17bd353 100644 --- a/analyzer-baseline.toml +++ b/analyzer-baseline.toml @@ -441,13 +441,13 @@ count = 1 [[issues]] file = "src/Adapter/Driver/Pdo/AbstractPdoConnection.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Exception\InvalidQueryException::forDriverError`: expected `string`, but found `mixed`.' +message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Driver\DriverInterface::createResult`: expected `resource`, but found `mixed`.' count = 1 [[issues]] file = "src/Adapter/Driver/Pdo/AbstractPdoConnection.php" code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Driver\DriverInterface::createResult`: expected `resource`, but found `mixed`.' +message = 'Invalid argument type for argument #1 of `PhpDb\Adapter\Exception\InvalidQueryException::forDriverError`: expected `string`, but found `mixed`.' count = 1 [[issues]] @@ -834,12 +834,6 @@ code = "class-must-be-final" message = 'Class `PhpDb\Adapter\Exception\ErrorException` should be declared `final`.' count = 1 -[[issues]] -file = "src/Adapter/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Adapter\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/Adapter/Exception/InvalidArgumentException.php" code = "class-must-be-final" @@ -1386,12 +1380,6 @@ code = "mixed-assignment" message = "Assigning `mixed` type to a variable may lead to unexpected behavior." count = 2 -[[issues]] -file = "src/Container/AdapterInterfaceDelegator.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `PhpDb\Exception\RuntimeException` in `PhpDb\Container\AdapterInterfaceDelegator::__invoke`.' -count = 1 - [[issues]] file = "src/Container/AdapterInterfaceDelegator.php" code = "unused-parameter" @@ -1464,12 +1452,6 @@ code = "missing-api-or-internal" message = 'Interface `PhpDb\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' count = 1 -[[issues]] -file = "src/Metadata/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Metadata\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/Metadata/Exception/InvalidArgumentException.php" code = "class-must-be-final" @@ -1518,12 +1500,6 @@ code = "missing-constant-type" message = "Class constant `DEFAULT_SCHEMA` is missing a type hint." count = 1 -[[issues]] -file = "src/Metadata/Source/AbstractSource.php" -code = "unfulfilled-expect" -message = "This pragma was not used and may be removed." -count = 3 - [[issues]] file = "src/ResultSet/AbstractResultSet.php" code = "imprecise-type" @@ -1662,12 +1638,6 @@ code = "imprecise-type" message = "Type `array` in return type of `toArray` is imprecise, equivalent to `array`." count = 1 -[[issues]] -file = "src/ResultSet/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\ResultSet\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/ResultSet/Exception/InvalidArgumentException.php" code = "class-must-be-final" @@ -1956,6 +1926,12 @@ code = "mixed-argument" message = 'Invalid argument type for argument #1 of `PhpDb\RowGateway\AbstractRowGateway::populate`: expected `array`, but found `mixed`.' count = 1 +[[issues]] +file = "src/RowGateway/AbstractRowGateway.php" +code = "mixed-argument" +message = 'Invalid argument type for argument #1 of `PhpDb\RowGateway\Exception\RuntimeException::forMissingPrimaryKeyData`: expected `string`, but found `mixed`.' +count = 1 + [[issues]] file = "src/RowGateway/AbstractRowGateway.php" code = "mixed-argument" @@ -1974,12 +1950,6 @@ code = "mixed-method-access" message = "Attempting to access a method on a non-object type (`mixed`)." count = 14 -[[issues]] -file = "src/RowGateway/AbstractRowGateway.php" -code = "mixed-argument" -message = 'Invalid argument type for argument #1 of `PhpDb\RowGateway\Exception\RuntimeException::forMissingPrimaryKeyData`: expected `string`, but found `mixed`.' -count = 1 - [[issues]] file = "src/RowGateway/AbstractRowGateway.php" code = "mixed-operand" @@ -2064,12 +2034,6 @@ code = "unhandled-thrown-type" message = 'Potentially unhandled exception `PhpDb\RowGateway\Exception\RuntimeException` in `PhpDb\RowGateway\AbstractRowGateway::save`.' count = 1 -[[issues]] -file = "src/RowGateway/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\RowGateway\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/RowGateway/Exception/InvalidArgumentException.php" code = "class-must-be-final" @@ -3426,24 +3390,6 @@ code = "redundant-null-coalesce" message = "Redundant null coalesce: left-hand side can never be `null` or undefined." count = 1 -[[issues]] -file = "src/Sql/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Sql\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - -[[issues]] -file = "src/Sql/Exception/InvalidArgumentException.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Exception\InvalidArgumentException` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Sql/Exception/RuntimeException.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Exception\RuntimeException` should be declared `final`.' -count = 1 - [[issues]] file = "src/Sql/Expression.php" code = "imprecise-type" @@ -3819,7 +3765,7 @@ count = 1 [[issues]] file = "src/Sql/Join.php" code = "mixed-argument" -message = "Invalid argument type for argument #1 of `PhpDb\\Sql\\Exception\\InvalidArgumentException::forInvalidJoinName`: expected `string`, but found `mixed`." +message = 'Invalid argument type for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forInvalidJoinName`: expected `string`, but found `mixed`.' count = 1 [[issues]] @@ -3990,6 +3936,18 @@ code = "missing-api-or-internal" message = 'Interface `PhpDb\Sql\Platform\PlatformDecoratorInterface` is missing an `@api` or `@internal` annotation.' count = 1 +[[issues]] +file = "src/Sql/Predicate/Exception/InvalidArgumentException.php" +code = "class-must-be-final" +message = 'Class `PhpDb\Sql\Predicate\Exception\InvalidArgumentException` should be declared `final`.' +count = 1 + +[[issues]] +file = "src/Sql/Predicate/Exception/RuntimeException.php" +code = "class-must-be-final" +message = 'Class `PhpDb\Sql\Predicate\Exception\RuntimeException` should be declared `final`.' +count = 1 + [[issues]] file = "src/Sql/Predicate/Expression.php" code = "class-must-be-final" @@ -4206,12 +4164,6 @@ code = "possibly-invalid-argument" message = 'Possible argument type mismatch for argument #3 of `PhpDb\Sql\Predicate\Between::__construct`: expected `PhpDb\Sql\ArgumentInterface|float|int|null|string`, but possibly received `PhpDb\Sql\ArgumentInterface|array|float|int|null|string`.' count = 2 -[[issues]] -file = "src/Sql/Predicate/Predicate.php" -code = "unhandled-thrown-type" -message = 'Potentially unhandled exception `PhpDb\Sql\Exception\RuntimeException` in `PhpDb\Sql\Predicate\Predicate::unnest`.' -count = 1 - [[issues]] file = "src/Sql/Predicate/PredicateInterface.php" code = "missing-api-or-internal" @@ -4905,20 +4857,20 @@ count = 1 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Insert::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' -count = 1 +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forForeignTable`: expected `string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' +count = 4 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Update::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Insert::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' count = 1 [[issues]] file = "src/Sql/Sql.php" code = "possibly-invalid-argument" -message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Exception\InvalidArgumentException::forForeignTable`: expected `string`, but possibly received `PhpDb\Sql\TableIdentifier|array|string`.' -count = 4 +message = 'Possible argument type mismatch for argument #1 of `PhpDb\Sql\Update::__construct`: expected `PhpDb\Sql\TableIdentifier|null|string`, but possibly received `PhpDb\Sql\TableIdentifier|array|null|string`.' +count = 1 [[issues]] file = "src/Sql/Sql.php" @@ -5466,12 +5418,6 @@ code = "redundant-comparison" message = "Redundant `===` comparison: left-hand side is never identical to right-hand side." count = 1 -[[issues]] -file = "src/TableGateway/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\TableGateway\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - [[issues]] file = "src/TableGateway/Exception/InvalidArgumentException.php" code = "class-must-be-final" @@ -5537,21 +5483,3 @@ file = "src/TableGateway/TableGatewayInterface.php" code = "missing-api-or-internal" message = 'Interface `PhpDb\TableGateway\TableGatewayInterface` is missing an `@api` or `@internal` annotation.' count = 1 - -[[issues]] -file = "src/Sql/Predicate/Exception/ExceptionInterface.php" -code = "missing-api-or-internal" -message = 'Interface `PhpDb\Sql\Predicate\Exception\ExceptionInterface` is missing an `@api` or `@internal` annotation.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/Exception/InvalidArgumentException.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Predicate\Exception\InvalidArgumentException` should be declared `final`.' -count = 1 - -[[issues]] -file = "src/Sql/Predicate/Exception/RuntimeException.php" -code = "class-must-be-final" -message = 'Class `PhpDb\Sql\Predicate\Exception\RuntimeException` should be declared `final`.' -count = 1 diff --git a/lint-baseline.toml b/lint-baseline.toml index 84b6ad8d..0de9388f 100644 --- a/lint-baseline.toml +++ b/lint-baseline.toml @@ -66,6 +66,12 @@ code = "too-many-methods" message = "Class has too many methods." count = 1 +[[issues]] +file = "src/Adapter/Driver/Pdo/Statement.php" +code = "halstead" +message = "Method has a high halstead difficulty" +count = 1 + [[issues]] file = "src/Adapter/Driver/Pdo/Statement.php" code = "kan-defect" @@ -90,12 +96,6 @@ code = "no-isset" message = "Use of the `isset` construct." count = 1 -[[issues]] -file = "src/Adapter/Exception/InvalidArgumentException.php" -code = "strict-types" -message = "Missing `declare(strict_types=1);` statement at the beginning of the file." -count = 1 - [[issues]] file = "src/Adapter/ParameterContainer.php" code = "cyclomatic-complexity" @@ -396,12 +396,6 @@ code = "prefer-early-continue" message = "Consider using early continue pattern to reduce nesting." count = 1 -[[issues]] -file = "src/RowGateway/AbstractRowGateway.php" -code = "string-style" -message = "String concatenation can be replaced with interpolation." -count = 2 - [[issues]] file = "src/RowGateway/AbstractRowGateway.php" code = "too-many-methods" @@ -444,6 +438,12 @@ code = "excessive-parameter-list" message = "Parameter list is too long." count = 1 +[[issues]] +file = "src/Sql/AbstractSql.php" +code = "halstead" +message = "Method has a high halstead difficulty" +count = 1 + [[issues]] file = "src/Sql/AbstractSql.php" code = "kan-defect" @@ -588,6 +588,12 @@ code = "excessive-parameter-list" message = "Parameter list is too long." count = 1 +[[issues]] +file = "src/Sql/Ddl/Column/AbstractPrecisionColumn.php" +code = "halstead" +message = "Method has a high halstead difficulty" +count = 1 + [[issues]] file = "src/Sql/Ddl/Column/AbstractTimestampColumn.php" code = "no-isset" @@ -942,6 +948,12 @@ code = "cyclomatic-complexity" message = "Class has high complexity." count = 1 +[[issues]] +file = "src/TableGateway/AbstractTableGateway.php" +code = "halstead" +message = "Method has a high halstead difficulty" +count = 1 + [[issues]] file = "src/TableGateway/AbstractTableGateway.php" code = "kan-defect" @@ -3423,109 +3435,109 @@ count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetExists`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheColumnValue`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownColumn`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicIssetReportsWhetherAColumnIsSet`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnset`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetAssignsTheColumnValue`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPopulate`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicUnsetClearsTheColumnValue`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessPrimaryKeyData`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetExists`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsFalseWhenNew`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGet`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsTrueAfterPopulateWithTrue`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSet`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsertMultiKey`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnset`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsert`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testPopulate`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdateChangingPrimaryKey`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessPrimaryKeyData`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdate`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsFalseWhenNew`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArray`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsTrueAfterPopulateWithTrue`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownColumn`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsertMultiKey`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheColumnValue`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsert`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicIssetReportsWhetherAColumnIsSet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdateChangingPrimaryKey`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetAssignsTheColumnValue`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdate`." count = 1 [[issues]] file = "test/unit/RowGateway/AbstractRowGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicUnsetClearsTheColumnValue`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArray`." count = 1 [[issues]] @@ -4702,7 +4714,7 @@ count = 1 file = "test/unit/Sql/Ddl/Column/IntegerTest.php" code = "assertion-style" message = "Inconsistent assertions style." -count = 7 +count = 6 [[issues]] file = "test/unit/Sql/Ddl/Column/IntegerTest.php" @@ -8004,6 +8016,24 @@ code = "assertion-style" message = "Inconsistent assertions style." count = 47 +[[issues]] +file = "test/unit/TableGateway/AbstractTableGatewayTest.php" +code = "prefer-test-attribute" +message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneKeepsTheAdapter`." +count = 1 + +[[issues]] +file = "test/unit/TableGateway/AbstractTableGatewayTest.php" +code = "prefer-test-attribute" +message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithATableIdentifier`." +count = 1 + +[[issues]] +file = "test/unit/TableGateway/AbstractTableGatewayTest.php" +code = "prefer-test-attribute" +message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithAnAliasedTableIdentifier`." +count = 1 + [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" @@ -8133,139 +8163,121 @@ count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectAppliesColumnsWhenStarSelected`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithArrayTable`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithClosure`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithNoWhere`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallDelegatesToTheFeatureSet`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithWhereString`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallThrowsForUnknownMethod`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoinDefaultType`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetDelegatesToTheFeatureSet`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoin`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheAdapter`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithNoCriteria`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValueAndAdapter`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWith`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValue`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdate`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheTable`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallThrowsForUnknownMethod`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownProperty`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallDelegatesToTheFeatureSet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetDelegatesToTheFeatureSet`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithAnAliasedTableIdentifier`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetThrowsForUnknownProperty`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithATableIdentifier`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectAppliesColumnsWhenStarSelected`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneKeepsTheAdapter`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithArrayTable`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheAdapter`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithClosure`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValue`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithNoWhere`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheTable`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithWhereString`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownProperty`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoinDefaultType`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetDelegatesToTheFeatureSet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoin`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValueAndAdapter`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithNoCriteria`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetThrowsForUnknownProperty`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWith`." count = 1 [[issues]] file = "test/unit/TableGateway/AbstractTableGatewayTest.php" code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetDelegatesToTheFeatureSet`." +message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdate`." count = 1 [[issues]] @@ -8363,27 +8375,3 @@ file = "test/unit/TableGateway/TableGatewayTest.php" code = "strict-assertions" message = "Use strict assertions in PHPUnit tests." count = 2 - -[[issues]] -file = "src/TableGateway/AbstractTableGateway.php" -code = "halstead" -message = "Method has a high halstead difficulty" -count = 1 - -[[issues]] -file = "src/Sql/AbstractSql.php" -code = "halstead" -message = "Method has a high halstead difficulty" -count = 1 - -[[issues]] -file = "src/Sql/Ddl/Column/AbstractPrecisionColumn.php" -code = "halstead" -message = "Method has a high halstead difficulty" -count = 1 - -[[issues]] -file = "src/Adapter/Driver/Pdo/Statement.php" -code = "halstead" -message = "Method has a high halstead difficulty" -count = 1 From 08f8954b2ea92f53e35353720e07118e185cbbbc Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Tue, 29 Sep 2026 15:15:27 +1000 Subject: [PATCH 2/3] Apply the safe Mago lint fixes across the test suite Rewrites the assertion style, strict assertions and test attributes that Mago can fix automatically. Six sites needed manual repair afterwards. Four test methods lost their "test" prefix and collided with final PHPUnit\Framework\TestCase methods, so they are renamed after the behaviour they cover rather than the method they call. assertAttributeSame joins DeprecatedAssertionsTrait, since the rewrite assumed it existed. Like and NotLike assert null rather than the empty string for an unconfigured predicate: getIdentifier() and getLike() return null, and the old loose comparison only passed because '' == null. The uniqid() callback in ResultTest keeps its closure. As a first class callable it receives the three arguments PDOStatement::fetch() passes, which uniqid() does not accept. Source files are left untouched on this branch. --- .../Driver/Pdo/AbstractAdapterTestCase.php | 26 +- .../Adapter/Driver/Pdo/AdapterTrait.php | 2 + test/unit/Adapter/AdapterAwareTraitTest.php | 12 +- test/unit/Adapter/AdapterTest.php | 153 +++--- .../AbstractAdapterInterfaceFactoryTest.php | 45 +- .../AdapterInterfaceDelegatorTest.php | 50 +- .../Adapter/Driver/AbstractConnectionTest.php | 60 ++- .../Driver/Feature/AbstractFeatureTest.php | 7 +- .../DriverFeatureProviderTraitTest.php | 23 +- .../Adapter/Driver/Pdo/ConnectionTest.php | 69 +-- .../Driver/Pdo/ConnectionTransactionsTest.php | 90 ++-- test/unit/Adapter/Driver/Pdo/PdoTest.php | 84 ++-- test/unit/Adapter/Driver/Pdo/ResultTest.php | 180 ++++--- .../Driver/Pdo/StatementIntegrationTest.php | 36 +- .../unit/Adapter/Driver/Pdo/StatementTest.php | 183 ++++--- ...validConnectionParametersExceptionTest.php | 5 +- test/unit/Adapter/ParameterContainerTest.php | 233 +++++---- test/unit/Adapter/Platform/Sql92Test.php | 104 ++-- test/unit/Adapter/Profiler/ProfilerTest.php | 42 +- test/unit/Adapter/StatementContainerTest.php | 24 +- test/unit/ConfigProviderTest.php | 5 +- .../Container/AdapterInterfaceFactoryTest.php | 23 +- .../TableIdentifierFactoryFactoryTest.php | 45 +- test/unit/DeprecatedAssertionsTrait.php | 13 + .../AbstractResultSetIntegrationTest.php | 10 +- test/unit/ResultSet/AbstractResultSetTest.php | 251 +++++---- .../HydratingResultSetIntegrationTest.php | 5 +- .../unit/ResultSet/HydratingResultSetTest.php | 81 +-- .../ResultSet/ResultSetIntegrationTest.php | 152 +++--- .../RowGateway/AbstractRowGatewayTest.php | 177 ++++--- test/unit/RowGateway/RowGatewayTest.php | 48 +- .../Sql/AbstractSqlFunctionalTestCase.php | 5 +- test/unit/Sql/AbstractSqlTest.php | 213 ++++---- test/unit/Sql/Argument/LiteralTest.php | 15 +- test/unit/Sql/ArgumentTest.php | 94 ++-- test/unit/Sql/CombineTest.php | 70 +-- test/unit/Sql/Ddl/AlterTableTest.php | 274 +++++----- .../Ddl/Column/AbstractLengthColumnTest.php | 87 ++-- .../Column/AbstractPrecisionColumnTest.php | 93 ++-- test/unit/Sql/Ddl/Column/BigIntegerTest.php | 30 +- test/unit/Sql/Ddl/Column/BinaryTest.php | 35 +- test/unit/Sql/Ddl/Column/BlobTest.php | 29 +- test/unit/Sql/Ddl/Column/BooleanTest.php | 14 +- test/unit/Sql/Ddl/Column/CharTest.php | 35 +- test/unit/Sql/Ddl/Column/ColumnTest.php | 164 +++--- test/unit/Sql/Ddl/Column/DateTest.php | 7 +- test/unit/Sql/Ddl/Column/DatetimeTest.php | 7 +- test/unit/Sql/Ddl/Column/DecimalTest.php | 108 ++-- test/unit/Sql/Ddl/Column/DoubleTest.php | 35 +- test/unit/Sql/Ddl/Column/FloatingTest.php | 35 +- test/unit/Sql/Ddl/Column/IntegerTest.php | 130 ++--- test/unit/Sql/Ddl/Column/JsonTest.php | 7 +- test/unit/Sql/Ddl/Column/SmallIntegerTest.php | 30 +- test/unit/Sql/Ddl/Column/TextTest.php | 29 +- test/unit/Sql/Ddl/Column/TimeTest.php | 7 +- test/unit/Sql/Ddl/Column/TimestampTest.php | 50 +- test/unit/Sql/Ddl/Column/VarbinaryTest.php | 19 +- test/unit/Sql/Ddl/Column/VarcharTest.php | 47 +- .../Ddl/Constraint/AbstractConstraintTest.php | 19 +- test/unit/Sql/Ddl/Constraint/CheckTest.php | 33 +- .../Sql/Ddl/Constraint/ForeignKeyTest.php | 88 ++-- .../Sql/Ddl/Constraint/PrimaryKeyTest.php | 7 +- .../unit/Sql/Ddl/Constraint/UniqueKeyTest.php | 7 +- test/unit/Sql/Ddl/CreateTableTest.php | 261 +++++----- test/unit/Sql/Ddl/DropTableTest.php | 34 +- test/unit/Sql/Ddl/Index/IndexTest.php | 51 +- test/unit/Sql/DeleteTest.php | 138 ++--- test/unit/Sql/ExpressionTest.php | 92 ++-- test/unit/Sql/InsertIgnoreTest.php | 130 ++--- test/unit/Sql/InsertTest.php | 157 +++--- test/unit/Sql/JoinTest.php | 62 ++- test/unit/Sql/LiteralTest.php | 28 +- .../Sql/Platform/AbstractPlatformTest.php | 42 +- test/unit/Sql/Platform/PlatformTest.php | 78 +-- test/unit/Sql/Predicate/BetweenTest.php | 209 ++++---- test/unit/Sql/Predicate/ExpressionTest.php | 129 ++--- test/unit/Sql/Predicate/InTest.php | 186 +++---- test/unit/Sql/Predicate/IsNullTest.php | 91 ++-- test/unit/Sql/Predicate/LikeTest.php | 135 ++--- test/unit/Sql/Predicate/LiteralTest.php | 19 +- test/unit/Sql/Predicate/NotBetweenTest.php | 52 +- test/unit/Sql/Predicate/NotInTest.php | 76 +-- test/unit/Sql/Predicate/NotLikeTest.php | 87 ++-- test/unit/Sql/Predicate/OperatorTest.php | 159 +++--- test/unit/Sql/Predicate/PredicateSetTest.php | 125 ++--- test/unit/Sql/Predicate/PredicateTest.php | 258 +++++----- test/unit/Sql/SelectTest.php | 476 ++++++++++-------- test/unit/Sql/SqlTest.php | 68 ++- test/unit/Sql/TableIdentifierFactoryTest.php | 110 ++-- test/unit/Sql/TableIdentifierTest.php | 94 ++-- test/unit/Sql/UpdateTest.php | 216 ++++---- .../TableGateway/AbstractTableGatewayTest.php | 226 +++++---- test/unit/TableGateway/TableGatewayTest.php | 100 ++-- 93 files changed, 4485 insertions(+), 3465 deletions(-) diff --git a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php index 6b533d0f..34af92a1 100644 --- a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php +++ b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php @@ -1,5 +1,7 @@ assertInstanceOf(AdapterInterface::class, $this->adapter); + static::assertInstanceOf(AdapterInterface::class, $this->adapter); } - public function testDriverDisconnectAfterQuoteWithPlatform(): void + #[\PHPUnit\Framework\Attributes\Test] + public function driverDisconnectAfterQuoteWithPlatform(): void { $isTcpConnection = $this->isTcpConnection(); $this->getAdapter()->getDriver()->getConnection()->connect(); - self::assertTrue($this->getAdapter()->getDriver()->getConnection()->isConnected()); + static::assertTrue($this->getAdapter()->getDriver()->getConnection()->isConnected()); if ($isTcpConnection) { - self::assertTrue($this->isConnectedTcp()); + static::assertTrue($this->isConnectedTcp()); } $this->getAdapter()->getDriver()->getConnection()->disconnect(); - self::assertFalse($this->getAdapter()->getDriver()->getConnection()->isConnected()); + static::assertFalse($this->getAdapter()->getDriver()->getConnection()->isConnected()); if ($isTcpConnection) { - self::assertFalse($this->isConnectedTcp()); + static::assertFalse($this->isConnectedTcp()); } $this->getAdapter()->getDriver()->getConnection()->connect(); - self::assertTrue($this->getAdapter()->getDriver()->getConnection()->isConnected()); + static::assertTrue($this->getAdapter()->getDriver()->getConnection()->isConnected()); if ($isTcpConnection) { - self::assertTrue($this->isConnectedTcp()); + static::assertTrue($this->isConnectedTcp()); } $this->getAdapter()->getPlatform()->quoteValue('test'); $this->getAdapter()->getDriver()->getConnection()->disconnect(); - self::assertFalse($this->getAdapter()->getDriver()->getConnection()->isConnected()); + static::assertFalse($this->getAdapter()->getDriver()->getConnection()->isConnected()); if ($isTcpConnection) { - self::assertFalse($this->isConnectedTcp()); + static::assertFalse($this->isConnectedTcp()); } } diff --git a/test/integration/Adapter/Driver/Pdo/AdapterTrait.php b/test/integration/Adapter/Driver/Pdo/AdapterTrait.php index 589775f2..dd13f1ac 100644 --- a/test/integration/Adapter/Driver/Pdo/AdapterTrait.php +++ b/test/integration/Adapter/Driver/Pdo/AdapterTrait.php @@ -1,5 +1,7 @@ getAdapter()); + static::assertNull($object->getAdapter()); $driver = $this->createMock(DriverInterface::class); $platform = $this->createMock(PlatformInterface::class); @@ -31,10 +32,11 @@ public function testSetDbAdapter(): void $object->setDbAdapter($adapter); - self::assertSame($adapter, $object->getAdapter()); + static::assertSame($adapter, $object->getAdapter()); } - public function testSetDbAdapterSetsProperty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDbAdapterSetsProperty(): void { $object = new ConcreteAdapterAwareObject(); @@ -46,6 +48,6 @@ public function testSetDbAdapterSetsProperty(): void $object->setDbAdapter($adapter); $reflection = new ReflectionProperty($object, 'adapter'); - self::assertSame($adapter, $reflection->getValue($object)); + static::assertSame($adapter, $reflection->getValue($object)); } } diff --git a/test/unit/Adapter/AdapterTest.php b/test/unit/Adapter/AdapterTest.php index 1a1f94fd..78c475ed 100644 --- a/test/unit/Adapter/AdapterTest.php +++ b/test/unit/Adapter/AdapterTest.php @@ -51,7 +51,8 @@ final class AdapterTest extends TestCase protected Adapter $adapter; - public function testConstructorWithProfilerDelegatesToSetProfiler(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithProfilerDelegatesToSetProfiler(): void { $profilerMock = $this->createMock(Profiler\ProfilerInterface::class); $driverMock = $this->createMock(DriverInterface::class); @@ -63,17 +64,19 @@ public function testConstructorWithProfilerDelegatesToSetProfiler(): void profiler: $profilerMock, ); - self::assertSame($profilerMock, $adapter->getProfiler()); + static::assertSame($profilerMock, $adapter->getProfiler()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test createStatement() produces a statement object')] - public function testCreateStatementDelegatesToDriver(): void + public function createStatementDelegatesToDriver(): void { - self::assertSame($this->mockStatement, $this->adapter->createStatement()); + static::assertSame($this->mockStatement, $this->adapter->createStatement()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test executeQuery() returns the raw result without wrapping query results')] - public function testExecuteQueryReturnsRawResultWithoutWrappingQueryResults(): void + public function executeQueryReturnsRawResultWithoutWrappingQueryResults(): void { $sql = 'SELECT foo'; $result = $this->createMock(ResultInterface::class); @@ -82,11 +85,12 @@ public function testExecuteQueryReturnsRawResultWithoutWrappingQueryResults(): v $result->expects($this->any())->method('isQueryResult')->willReturn(true); $result->expects($this->never())->method('getQueryResult'); - self::assertSame($result, $this->adapter->executeQuery($sql)); + static::assertSame($result, $this->adapter->executeQuery($sql)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test executeQuery() throws when execution does not produce a result')] - public function testExecuteQueryThrowsWhenExecutionDoesNotProduceAResult(): void + public function executeQueryThrowsWhenExecutionDoesNotProduceAResult(): void { $sql = 'SELECT foo'; $this->mockConnection->method('execute')->willReturn(null); @@ -97,47 +101,53 @@ public function testExecuteQueryThrowsWhenExecutionDoesNotProduceAResult(): void $this->adapter->executeQuery($sql); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test executeQuery() with raw SQL delegates to connection execute')] - public function testExecuteQueryWithRawSqlDelegatesToConnectionExecute(): void + public function executeQueryWithRawSqlDelegatesToConnectionExecute(): void { $sql = 'SELECT foo'; $result = $this->createMock(ResultInterface::class); $this->mockConnection->expects($this->once())->method('execute')->with($sql)->willReturn($result); - self::assertSame($result, $this->adapter->executeQuery($sql)); + static::assertSame($result, $this->adapter->executeQuery($sql)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test executeQuery() with a prepared statement executes the statement')] - public function testExecuteQueryWithStatementExecutesStatement(): void + public function executeQueryWithStatementExecutesStatement(): void { $result = $this->createMock(ResultInterface::class); $this->mockStatement->expects($this->once())->method('execute')->willReturn($result); $this->mockConnection->expects($this->never())->method('execute'); - self::assertSame($result, $this->adapter->executeQuery($this->mockStatement)); + static::assertSame($result, $this->adapter->executeQuery($this->mockStatement)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test setProfiler() will store profiler')] - public function testFluentSetProfiler(): void + public function fluentSetProfiler(): void { $ret = $this->adapter->setProfiler(new Profiler\Profiler()); - self::assertSame($this->adapter, $ret); + static::assertSame($this->adapter, $ret); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getCurrentSchema() returns current schema from connection object')] - public function testGetCurrentSchemaDelegatesToConnection(): void + public function getCurrentSchemaDelegatesToConnection(): void { $this->mockConnection->expects($this->any())->method('getCurrentSchema')->willReturn('FooSchema'); - self::assertEquals('FooSchema', $this->adapter->getCurrentSchema()); + static::assertSame('FooSchema', $this->adapter->getCurrentSchema()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getDriver() will return driver object')] - public function testGetDriverReturnsDriver(): void + public function getDriverReturnsDriver(): void { - self::assertSame($this->mockDriver, $this->adapter->getDriver()); + static::assertSame($this->mockDriver, $this->adapter->getDriver()); } - public function testGetHelpersQuoteIdentifierClosureCallsPlatform(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHelpersQuoteIdentifierClosureCallsPlatform(): void { $this->mockPlatform ->method('quoteIdentifier') @@ -147,10 +157,11 @@ public function testGetHelpersQuoteIdentifierClosureCallsPlatform(): void $functions = $this->adapter->getHelpers(Adapter::FUNCTION_QUOTE_IDENTIFIER); $result = $functions[0]('test'); - self::assertSame('"test"', $result); + static::assertSame('"test"', $result); } - public function testGetHelpersQuoteValueClosureCallsPlatform(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHelpersQuoteValueClosureCallsPlatform(): void { $this->mockPlatform ->method('quoteValue') @@ -163,68 +174,75 @@ public function testGetHelpersQuoteValueClosureCallsPlatform(): void $functions[0]('test'); } - public function testGetHelpersReturnsBothFunctions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHelpersReturnsBothFunctions(): void { $functions = $this->adapter->getHelpers( Adapter::FUNCTION_QUOTE_IDENTIFIER, Adapter::FUNCTION_QUOTE_VALUE, ); - self::assertCount(2, $functions); - self::assertIsCallable($functions[0]); - self::assertIsCallable($functions[1]); + static::assertCount(2, $functions); + static::assertIsCallable($functions[0]); + static::assertIsCallable($functions[1]); } - public function testGetHelpersReturnsQuoteIdentifierFunction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHelpersReturnsQuoteIdentifierFunction(): void { $functions = $this->adapter->getHelpers(Adapter::FUNCTION_QUOTE_IDENTIFIER); - self::assertCount(1, $functions); - self::assertIsCallable($functions[0]); + static::assertCount(1, $functions); + static::assertIsCallable($functions[0]); } - public function testGetHelpersReturnsQuoteValueFunction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHelpersReturnsQuoteValueFunction(): void { $functions = $this->adapter->getHelpers(Adapter::FUNCTION_QUOTE_VALUE); - self::assertCount(1, $functions); - self::assertIsCallable($functions[0]); + static::assertCount(1, $functions); + static::assertIsCallable($functions[0]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getPlatform() returns platform object')] - public function testGetPlatformReturnsPlatform(): void + public function getPlatformReturnsPlatform(): void { - self::assertSame($this->mockPlatform, $this->adapter->getPlatform()); + static::assertSame($this->mockPlatform, $this->adapter->getPlatform()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getProfiler() will store profiler')] - public function testGetProfilerReturnsProfiler(): void + public function getProfilerReturnsProfiler(): void { $this->adapter->setProfiler($profiler = new Profiler\Profiler()); - self::assertSame($profiler, $this->adapter->getProfiler()); + static::assertSame($profiler, $this->adapter->getProfiler()); $adapter = new Adapter( driver: $this->mockDriver, platform: $this->mockPlatform, profiler: new Profiler\Profiler(), ); - self::assertInstanceOf(Profiler\Profiler::class, $adapter->getProfiler()); + static::assertInstanceOf(Profiler\Profiler::class, $adapter->getProfiler()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getPlatform() returns platform object')] - public function testGetQueryResultSetPrototypeReturnsResultSet(): void + public function getQueryResultSetPrototypeReturnsResultSet(): void { - self::assertInstanceOf(ResultSetInterface::class, $this->adapter->getQueryResultSetPrototype()); + static::assertInstanceOf(ResultSetInterface::class, $this->adapter->getQueryResultSetPrototype()); } - public function testMagicGetReturnsDriverAndPlatformCaseInsensitively(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsDriverAndPlatformCaseInsensitively(): void { - self::assertSame($this->mockDriver, $this->adapter->driver); + static::assertSame($this->mockDriver, $this->adapter->driver); /** @phpstan-ignore property.notFound */ - self::assertSame($this->mockDriver, $this->adapter->DrivER); + static::assertSame($this->mockDriver, $this->adapter->DrivER); /** @phpstan-ignore property.notFound */ - self::assertSame($this->mockPlatform, $this->adapter->PlatForm); - self::assertSame($this->mockPlatform, $this->adapter->platform); + static::assertSame($this->mockPlatform, $this->adapter->PlatForm); + static::assertSame($this->mockPlatform, $this->adapter->platform); self::expectException('InvalidArgumentException'); self::expectExceptionMessage(InvalidArgumentException::INVALID_MAGIC_PROPERTY); @@ -232,21 +250,23 @@ public function testMagicGetReturnsDriverAndPlatformCaseInsensitively(): void $this->adapter->foo; } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test prepareQuery() binds an array of parameters as a ParameterContainer')] - public function testPrepareQueryBindsParameterArray(): void + public function prepareQueryBindsParameterArray(): void { $this->mockStatement ->expects($this->once()) ->method('setParameterContainer') - ->with(self::callback( + ->with(static::callback( static fn(ParameterContainer $container): bool => $container->getNamedArray() === ['bar' => 'foo'], )); $this->adapter->prepareQuery('SELECT foo, :bar', ['bar' => 'foo']); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test prepareQuery() binds a ParameterContainer directly')] - public function testPrepareQueryBindsParameterContainerDirectly(): void + public function prepareQueryBindsParameterContainerDirectly(): void { $parameterContainer = new ParameterContainer(['bar' => 'foo']); @@ -258,23 +278,25 @@ public function testPrepareQueryBindsParameterContainerDirectly(): void $this->adapter->prepareQuery('SELECT foo, :bar', $parameterContainer); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test prepareQuery() prepares a statement without executing it')] - public function testPrepareQueryPreparesStatementWithoutExecuting(): void + public function prepareQueryPreparesStatementWithoutExecuting(): void { $this->mockStatement->expects($this->once())->method('prepare'); $this->mockStatement->expects($this->never())->method('execute'); $statement = $this->adapter->prepareQuery('SELECT foo'); - self::assertSame($this->mockStatement, $statement); + static::assertSame($this->mockStatement, $statement); } /** * @throws Exception * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('#210')] - public function testProducedResultSetPrototypeIsDifferentForEachQuery(): void + public function producedResultSetPrototypeIsDifferentForEachQuery(): void { $statement = $this->createMock(StatementInterface::class); $result = $this->createMock(ResultInterface::class); @@ -286,13 +308,14 @@ public function testProducedResultSetPrototypeIsDifferentForEachQuery(): void $result->method('getQueryResult') ->willReturnCallback(static fn(): ResultSetInterface => new ResultSet()); - self::assertNotSame( + static::assertNotSame( $this->adapter->query('SELECT foo', []), $this->adapter->query('SELECT foo', []), ); } - public function testQueryThrowsOnInvalidParameterType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function queryThrowsOnInvalidParameterType(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::INCORRECT_FLAG); @@ -303,22 +326,24 @@ public function testQueryThrowsOnInvalidParameterType(): void /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test query() in execute mode produces a driver result object')] - public function testQueryWhenExecutedProducesAResult(): void + public function queryWhenExecutedProducesAResult(): void { $sql = 'SELECT foo'; $result = $this->getMockBuilder(ResultInterface::class)->getMock(); $this->mockConnection->expects($this->any())->method('execute')->with($sql)->willReturn($result); $r = $this->adapter->query($sql, AdapterInterface::QUERY_MODE_EXECUTE); - self::assertSame($result, $r); + static::assertSame($result, $r); } /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test query() in execute mode produces a resultset object')] - public function testQueryWhenExecutedProducesAResultSetObjectWhenResultIsQuery(): void + public function queryWhenExecutedProducesAResultSetObjectWhenResultIsQuery(): void { $sql = 'SELECT foo'; @@ -336,27 +361,29 @@ static function (?ResultSetInterface $resultPrototype = null): ResultSetInterfac ); $r = $this->adapter->query($sql, AdapterInterface::QUERY_MODE_EXECUTE); - self::assertInstanceOf(ResultSet::class, $r); + static::assertInstanceOf(ResultSet::class, $r); $r = $this->adapter->query($sql, AdapterInterface::QUERY_MODE_EXECUTE, new TemporaryResultSet()); - self::assertInstanceOf(TemporaryResultSet::class, $r); + static::assertInstanceOf(TemporaryResultSet::class, $r); } /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test query() in prepare mode produces a statement object')] - public function testQueryWhenPreparedProducesStatement(): void + public function queryWhenPreparedProducesStatement(): void { $s = $this->adapter->query('SELECT foo'); - self::assertSame($this->mockStatement, $s); + static::assertSame($this->mockStatement, $s); } /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test query() in prepare mode, with array of parameters, produces a result object')] - public function testQueryWhenPreparedWithParameterArrayProducesResult(): void + public function queryWhenPreparedWithParameterArrayProducesResult(): void { $parray = ['bar' => 'foo']; $sql = 'SELECT foo, :bar'; @@ -370,14 +397,15 @@ public function testQueryWhenPreparedWithParameterArrayProducesResult(): void $this->mockStatement->expects($this->any())->method('execute')->willReturn($result); $r = $this->adapter->query($sql, $parray); - self::assertSame($result, $r); + static::assertSame($result, $r); } /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test query() in prepare mode, with ParameterContainer, produces a result object')] - public function testQueryWhenPreparedWithParameterContainerProducesResult(): void + public function queryWhenPreparedWithParameterContainerProducesResult(): void { $sql = 'SELECT foo'; $parameterContainer = $this->getMockBuilder(ParameterContainer::class)->getMock(); @@ -392,10 +420,11 @@ public function testQueryWhenPreparedWithParameterContainerProducesResult(): voi $result->expects($this->any())->method('getQueryResult')->willReturn(new ResultSet()); $r = $this->adapter->query($sql, $parameterContainer); - self::assertInstanceOf(ResultSet::class, $r); + static::assertInstanceOf(ResultSet::class, $r); } - public function testSetProfilerDelegatesToDriverWhenProfilerAware(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setProfilerDelegatesToDriverWhenProfilerAware(): void { $profiler = $this->createMock(Profiler\ProfilerInterface::class); $driver = $this->createMockForIntersectionOfInterfaces( diff --git a/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php b/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php index e8de58e1..a85dea92 100644 --- a/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php +++ b/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php @@ -48,17 +48,19 @@ public static function providerValidService(): array ]; } - public function testCanCreateReturnsFalseForEmptyConfig(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canCreateReturnsFalseForEmptyConfig(): void { $container = new ServiceManager(); $container->setService('config', []); $factory = new AbstractAdapterInterfaceFactory(); - self::assertFalse($factory->canCreate($container, 'PhpDb\Adapter\Writer')); + static::assertFalse($factory->canCreate($container, 'PhpDb\Adapter\Writer')); } - public function testGetConfigCachesResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getConfigCachesResult(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -76,28 +78,31 @@ public function testGetConfigCachesResult(): void $factory->canCreate($container, 'anything'); } - public function testGetConfigReturnsEmptyWhenContainerHasNoConfig(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getConfigReturnsEmptyWhenContainerHasNoConfig(): void { $container = $this->createMock(ContainerInterface::class); $container->method('has')->with('config')->willReturn(false); $factory = new AbstractAdapterInterfaceFactory(); - self::assertFalse($factory->canCreate($container, 'anything')); + static::assertFalse($factory->canCreate($container, 'anything')); } /** * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('providerInvalidService')] - public function testInvalidService(string $service): void + public function invalidService(string $service): void { self::expectException(ServiceNotFoundException::class); $this->serviceManager->get($service); } - public function testInvokeThrowsWhenDriverNotConfigured(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeThrowsWhenDriverNotConfigured(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -116,7 +121,8 @@ public function testInvokeThrowsWhenDriverNotConfigured(): void $factory($container, 'PhpDb\Adapter\NoDriver'); } - public function testInvokeUsesResultSetFromContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeUsesResultSetFromContainer(): void { $resultSet = new ResultSet(); $profiler = $this->createMock(ProfilerInterface::class); @@ -148,20 +154,21 @@ public function testInvokeUsesResultSetFromContainer(): void $adapter = $container->get('MyAdapter'); - self::assertInstanceOf(AdapterInterface::class, $adapter); - self::assertSame($resultSet, $adapter->getQueryResultSetPrototype()); - self::assertSame($profiler, $adapter->getProfiler()); + static::assertInstanceOf(AdapterInterface::class, $adapter); + static::assertSame($resultSet, $adapter->getQueryResultSetPrototype()); + static::assertSame($profiler, $adapter->getProfiler()); } /** * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('providerValidService')] - public function testValidService(string $service): void + public function validService(string $service): void { $actual = $this->serviceManager->get($service); - self::assertInstanceOf(AdapterInterface::class, $actual); + static::assertInstanceOf(AdapterInterface::class, $actual); } #[Override] @@ -175,16 +182,12 @@ protected function setUp(): void $config = [ 'abstract_factories' => [AbstractAdapterInterfaceFactory::class], 'factories' => [ - PdoStubDriver::class => static function ( + PdoStubDriver::class => static fn( ContainerInterface $container, - ) use ($pdoDriverInterfaceMock): PdoDriverInterface { - return $pdoDriverInterfaceMock; - }, - PlatformInterface::class => static function ( + ) => $pdoDriverInterfaceMock, + PlatformInterface::class => static fn( ContainerInterface $container, - ) use ($platformMock): PlatformInterface { - return $platformMock; - }, + ) => $platformMock, ], ]; diff --git a/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php b/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php index 85765b3f..bc635a84 100644 --- a/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php +++ b/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php @@ -34,7 +34,8 @@ #[CoversMethod(AdapterInterfaceDelegator::class, '__invoke')] final class AdapterInterfaceDelegatorTest extends TestCase { - public function testDelegatorWithPluginManager(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delegatorWithPluginManager(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -74,11 +75,11 @@ public function validate(mixed $instance): void {} $options, ); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); - $this->assertSame($options, $result->getOptions()); + static::assertSame($options, $result->getOptions()); } /** @@ -86,7 +87,8 @@ public function validate(mixed $instance): void {} * @throws NotFoundExceptionInterface * @throws Exception */ - public function testDelegatorWithServiceManager(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delegatorWithServiceManager(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -110,7 +112,7 @@ public function testDelegatorWithServiceManager(): void $result = $container->get(ConcreteAdapterAwareObject::class); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -121,7 +123,8 @@ public function testDelegatorWithServiceManager(): void * @throws NotFoundExceptionInterface * @throws Exception */ - public function testDelegatorWithServiceManagerAndCustomAdapterName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delegatorWithServiceManagerAndCustomAdapterName(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -145,13 +148,14 @@ public function testDelegatorWithServiceManagerAndCustomAdapterName(): void $result = $container->get(ConcreteAdapterAwareObject::class); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); } - public function testInvokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -171,14 +175,15 @@ public function testInvokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): voi $callback, ); - self::assertInstanceOf(ConcreteAdapterAwareObject::class, $result); - self::assertNull($result->getAdapter()); + static::assertInstanceOf(ConcreteAdapterAwareObject::class, $result); + static::assertNull($result->getAdapter()); } /** * @throws Exception */ - public function testSetAdapterShouldBeCalledForExistingAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAdapterShouldBeCalledForExistingAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -199,7 +204,7 @@ public function testSetAdapterShouldBeCalledForExistingAdapter(): void $callback, ); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -208,7 +213,8 @@ public function testSetAdapterShouldBeCalledForExistingAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAdapterShouldBeCalledForOnlyConcreteAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -230,7 +236,7 @@ public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void $callback, ); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -239,7 +245,8 @@ public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldNotBeCalledForMissingAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAdapterShouldNotBeCalledForMissingAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -264,7 +271,8 @@ public function testSetAdapterShouldNotBeCalledForMissingAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldNotBeCalledForWrongClassInstance(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAdapterShouldNotBeCalledForWrongClassInstance(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::never()) @@ -286,11 +294,12 @@ public function testSetAdapterShouldNotBeCalledForWrongClassInstance(): void ); } - public function testSetStateWithCustomAdapterName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setStateWithCustomAdapterName(): void { $delegator = AdapterInterfaceDelegator::__set_state(['adapterName' => 'custom']); - self::assertInstanceOf(AdapterInterfaceDelegator::class, $delegator); + static::assertInstanceOf(AdapterInterfaceDelegator::class, $delegator); $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -308,10 +317,11 @@ public function testSetStateWithCustomAdapterName(): void ); } - public function testSetStateWithDefaultAdapterName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setStateWithDefaultAdapterName(): void { $delegator = AdapterInterfaceDelegator::__set_state([]); - self::assertInstanceOf(AdapterInterfaceDelegator::class, $delegator); + static::assertInstanceOf(AdapterInterfaceDelegator::class, $delegator); } } diff --git a/test/unit/Adapter/Driver/AbstractConnectionTest.php b/test/unit/Adapter/Driver/AbstractConnectionTest.php index bd0429c1..f8aa87c2 100644 --- a/test/unit/Adapter/Driver/AbstractConnectionTest.php +++ b/test/unit/Adapter/Driver/AbstractConnectionTest.php @@ -22,93 +22,103 @@ #[Group('unit')] final class AbstractConnectionTest extends TestCase { - public function testDisconnectIsNoOpWhenNotConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function disconnectIsNoOpWhenNotConnected(): void { $connection = new TestConnection(); $result = $connection->disconnect(); - self::assertSame($connection, $result); + static::assertSame($connection, $result); } - public function testDisconnectNullsResourceWhenConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function disconnectNullsResourceWhenConnected(): void { $connection = new TestConnection(); $connection->connect(); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); $connection->disconnect(); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); } - public function testGetConnectionParametersReturnsEmptyByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getConnectionParametersReturnsEmptyByDefault(): void { $connection = new TestConnection(); - self::assertSame([], $connection->getConnectionParameters()); + static::assertSame([], $connection->getConnectionParameters()); } - public function testGetDriverNameReturnsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDriverNameReturnsNullByDefault(): void { $connection = new TestConnection(); - self::assertNull($connection->getDriverName()); + static::assertNull($connection->getDriverName()); } - public function testGetDriverNameReturnsValueWhenSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDriverNameReturnsValueWhenSet(): void { $connection = new TestConnection('sqlite'); - self::assertSame('sqlite', $connection->getDriverName()); + static::assertSame('sqlite', $connection->getDriverName()); } - public function testGetProfilerReturnsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getProfilerReturnsNullByDefault(): void { $connection = new TestConnection(); - self::assertNull($connection->getProfiler()); + static::assertNull($connection->getProfiler()); } - public function testGetResourceAutoConnectsWhenNotConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getResourceAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); $resource = $connection->getResource(); - self::assertTrue($connection->isConnected()); - self::assertSame('fake-resource', $resource); + static::assertTrue($connection->isConnected()); + static::assertSame('fake-resource', $resource); } - public function testInTransactionReturnsFalseByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function inTransactionReturnsFalseByDefault(): void { $connection = new TestConnection(); - self::assertFalse($connection->inTransaction()); + static::assertFalse($connection->inTransaction()); } - public function testSetConnectionParametersStoresAndReturnsConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setConnectionParametersStoresAndReturnsConnection(): void { $connection = new TestConnection(); $params = ['host' => 'localhost', 'port' => 3306]; $result = $connection->setConnectionParameters($params); - self::assertSame($connection, $result); - self::assertSame($params, $connection->getConnectionParameters()); + static::assertSame($connection, $result); + static::assertSame($params, $connection->getConnectionParameters()); } - public function testSetProfilerStoresAndReturnsProfiler(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setProfilerStoresAndReturnsProfiler(): void { $connection = new TestConnection(); $profiler = $this->createMock(ProfilerInterface::class); $result = $connection->setProfiler($profiler); - self::assertSame($connection, $result); - self::assertSame($profiler, $connection->getProfiler()); + static::assertSame($connection, $result); + static::assertSame($profiler, $connection->getProfiler()); } } diff --git a/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php b/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php index f0839b2d..2a2b35dc 100644 --- a/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php +++ b/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php @@ -16,14 +16,15 @@ #[CoversMethod(AbstractFeature::class, 'setDriver')] final class AbstractFeatureTest extends TestCase { - public function testSetDriverStoresDriverAndReturnsInstance(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDriverStoresDriverAndReturnsInstance(): void { $feature = new TestDriverFeature(); $driver = $this->createMock(DriverInterface::class); $result = $feature->setDriver($driver); - self::assertInstanceOf(DriverFeatureInterface::class, $result); - self::assertSame($feature, $result); + static::assertInstanceOf(DriverFeatureInterface::class, $result); + static::assertSame($feature, $result); } } diff --git a/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php b/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php index ef473075..ee56381e 100644 --- a/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php +++ b/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php @@ -22,7 +22,8 @@ #[CoversMethod(DriverFeatureProviderTrait::class, 'getFeature')] final class DriverFeatureProviderTraitTest extends TestCase { - public function testAddFeaturesAddsMultipleFeatures(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addFeaturesAddsMultipleFeatures(): void { $driver = new TestFeatureDriver(); $feature1 = $this->createMock(DriverFeatureInterface::class); @@ -30,10 +31,11 @@ public function testAddFeaturesAddsMultipleFeatures(): void $driver->addFeatures([$feature1, $feature2]); - self::assertNotFalse($driver->getFeature($feature1::class)); + static::assertNotFalse($driver->getFeature($feature1::class)); } - public function testAddFeatureSetsDriverAndStoresFeature(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addFeatureSetsDriverAndStoresFeature(): void { $driver = new TestFeatureDriver(); $feature = $this->createMock(DriverFeatureInterface::class); @@ -41,10 +43,11 @@ public function testAddFeatureSetsDriverAndStoresFeature(): void $driver->addFeature($feature); - self::assertSame($feature, $driver->getFeature($feature::class)); + static::assertSame($feature, $driver->getFeature($feature::class)); } - public function testAddFeatureThrowsWhenUsedOutsideDriverInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addFeatureThrowsWhenUsedOutsideDriverInterface(): void { $nonDriver = new class implements DriverFeatureProviderInterface { use DriverFeatureProviderTrait; @@ -62,20 +65,22 @@ public function testAddFeatureThrowsWhenUsedOutsideDriverInterface(): void $nonDriver->addFeature($feature); } - public function testGetFeatureReturnsFalseWhenNotFound(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFeatureReturnsFalseWhenNotFound(): void { $driver = new TestFeatureDriver(); - self::assertFalse($driver->getFeature('NonExistent')); + static::assertFalse($driver->getFeature('NonExistent')); } - public function testGetFeatureReturnsFeatureByClassName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFeatureReturnsFeatureByClassName(): void { $driver = new TestFeatureDriver(); $feature = $this->createMock(DriverFeatureInterface::class); $driver->addFeature($feature); - self::assertSame($feature, $driver->getFeature($feature::class)); + static::assertSame($feature, $driver->getFeature($feature::class)); } } diff --git a/test/unit/Adapter/Driver/Pdo/ConnectionTest.php b/test/unit/Adapter/Driver/Pdo/ConnectionTest.php index 8f876d09..673651eb 100644 --- a/test/unit/Adapter/Driver/Pdo/ConnectionTest.php +++ b/test/unit/Adapter/Driver/Pdo/ConnectionTest.php @@ -36,60 +36,66 @@ final class ConnectionTest extends TestCase { protected TestConnection $connection; - public function testBeginTransactionAutoConnectsWhenNotConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function beginTransactionAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); $connection->beginTransaction(); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); } - public function testCommitAutoConnectsWhenNotConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function commitAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $connection->beginTransaction(); $connection->beginTransaction(); $connection->disconnect(); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); $connection->commit(); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); } - public function testConstructorWithArraySetsConnectionParameters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithArraySetsConnectionParameters(): void { $params = ['dsn' => 'sqlite::memory:', 'username' => 'user']; $connection = new TestConnection($params); - self::assertSame($params, $connection->getConnectionParameters()); + static::assertSame($params, $connection->getConnectionParameters()); } - public function testConstructorWithPdoResourceSetsConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithPdoResourceSetsConnected(): void { $pdo = new SqliteMemoryPdo(); $connection = new TestConnection($pdo); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); } - public function testExecuteAutoConnectsWhenNotConnected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); $driver = new TestPdo($connection); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); $connection->execute('SELECT 1'); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); } - public function testExecuteCallsProfilerFinishBeforeThrowingOnError(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeCallsProfilerFinishBeforeThrowingOnError(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -105,7 +111,8 @@ public function testExecuteCallsProfilerFinishBeforeThrowingOnError(): void @$connection->execute('INVALID SQL STATEMENT HERE %%%'); } - public function testExecuteCallsProfilerStartAndFinish(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeCallsProfilerStartAndFinish(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -119,19 +126,21 @@ public function testExecuteCallsProfilerStartAndFinish(): void $connection->execute('SELECT 1'); } - public function testFluentSetDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fluentSetDriver(): void { $driver = $this->createMock(PdoDriverInterface::class); $result = $this->connection->setDriver($driver); - self::assertSame($this->connection, $result); + static::assertSame($this->connection, $result); } /** * Test getConnectedDsn returns a DSN string if it has been set */ - public function testGetDsnReturnsDsnAfterConnect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDsnReturnsDsnAfterConnect(): void { $dsn = 'sqlite::memory:'; $this->connection->setConnectionParameters(['dsn' => $dsn]); @@ -141,10 +150,11 @@ public function testGetDsnReturnsDsnAfterConnect(): void } $responseString = $this->connection->getDsn(); - self::assertEquals($dsn, $responseString); + static::assertEquals($dsn, $responseString); } - public function testGetDsnThrowsWhenDsnIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDsnThrowsWhenDsnIsNull(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); $connection->connect(); @@ -158,35 +168,38 @@ public function testGetDsnThrowsWhenDsnIsNull(): void $connection->getDsn(); } - public function testPrepareAutoConnectsAndReturnsStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareAutoConnectsAndReturnsStatement(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); $driver = new TestPdo($connection); - self::assertFalse($connection->isConnected()); + static::assertFalse($connection->isConnected()); $statement = $connection->prepare('SELECT 1'); - self::assertTrue($connection->isConnected()); - self::assertInstanceOf(Statement::class, $statement); + static::assertTrue($connection->isConnected()); + static::assertInstanceOf(Statement::class, $statement); } /** * Test getResource method tries to connect to the database, it should never return null */ - public function testResource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resource(): void { $resource = $this->connection->getResource(); - self::assertNotNull($resource); + static::assertNotNull($resource); } - public function testSetConnectionParametersStoresParams(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setConnectionParametersStoresParams(): void { $params = ['dsn' => 'sqlite::memory:', 'username' => 'test']; $this->connection->setConnectionParameters($params); - self::assertSame($params, $this->connection->getConnectionParameters()); + static::assertSame($params, $this->connection->getConnectionParameters()); } /** diff --git a/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php b/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php index 65d9cc27..eb83add0 100644 --- a/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php +++ b/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php @@ -27,88 +27,96 @@ final class ConnectionTransactionsTest extends TestCase { protected ConnectionWrapper $wrapper; - public function testBeginTransactionReturnsInstanceOfConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function beginTransactionReturnsInstanceOfConnection(): void { - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->beginTransaction()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->beginTransaction()); } - public function testBeginTransactionSetsInTransactionAtTrue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function beginTransactionSetsInTransactionAtTrue(): void { $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); + static::assertTrue($this->wrapper->inTransaction()); } - public function testCommitReturnsInstanceOfConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function commitReturnsInstanceOfConnection(): void { $this->wrapper->beginTransaction(); - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); } - public function testCommitSetsInTransactionAtFalse(): void + #[\PHPUnit\Framework\Attributes\Test] + public function commitSetsInTransactionAtFalse(): void { $this->wrapper->beginTransaction(); $this->wrapper->commit(); - self::assertFalse($this->wrapper->inTransaction()); + static::assertFalse($this->wrapper->inTransaction()); } /** * Standalone commit after a SET autocommit=0; */ - public function testCommitWithoutBeginReturnsInstanceOfConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function commitWithoutBeginReturnsInstanceOfConnection(): void { - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); } - public function testNestedTransactionsCommit(): void + #[\PHPUnit\Framework\Attributes\Test] + public function nestedTransactionsCommit(): void { $nested = 0; - self::assertFalse($this->wrapper->inTransaction()); + static::assertFalse($this->wrapper->inTransaction()); // 1st transaction $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); - self::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertTrue($this->wrapper->inTransaction()); + static::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); // 2nd transaction $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); - self::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertTrue($this->wrapper->inTransaction()); + static::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); // 1st commit $this->wrapper->commit(); - self::assertTrue($this->wrapper->inTransaction()); - self::assertSame(--$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertTrue($this->wrapper->inTransaction()); + static::assertSame(--$nested, $this->wrapper->getNestedTransactionsCount()); // 2nd commit $this->wrapper->commit(); - self::assertFalse($this->wrapper->inTransaction()); - self::assertSame(--$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertFalse($this->wrapper->inTransaction()); + static::assertSame(--$nested, $this->wrapper->getNestedTransactionsCount()); } - public function testNestedTransactionsRollback(): void + #[\PHPUnit\Framework\Attributes\Test] + public function nestedTransactionsRollback(): void { $nested = 0; - self::assertFalse($this->wrapper->inTransaction()); + static::assertFalse($this->wrapper->inTransaction()); // 1st transaction $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); - self::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertTrue($this->wrapper->inTransaction()); + static::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); // 2nd transaction $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); - self::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); + static::assertTrue($this->wrapper->inTransaction()); + static::assertSame(++$nested, $this->wrapper->getNestedTransactionsCount()); // Rollback $this->wrapper->rollback(); - self::assertFalse($this->wrapper->inTransaction()); - self::assertSame(0, $this->wrapper->getNestedTransactionsCount()); + static::assertFalse($this->wrapper->inTransaction()); + static::assertSame(0, $this->wrapper->getNestedTransactionsCount()); } - public function testRollbackDisconnectedThrowsException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rollbackDisconnectedThrowsException(): void { $this->wrapper->disconnect(); @@ -117,20 +125,23 @@ public function testRollbackDisconnectedThrowsException(): void $this->wrapper->rollback(); } - public function testRollbackReturnsInstanceOfConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rollbackReturnsInstanceOfConnection(): void { $this->wrapper->beginTransaction(); - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->rollback()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->rollback()); } - public function testRollbackSetsInTransactionAtFalse(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rollbackSetsInTransactionAtFalse(): void { $this->wrapper->beginTransaction(); $this->wrapper->rollback(); - self::assertFalse($this->wrapper->inTransaction()); + static::assertFalse($this->wrapper->inTransaction()); } - public function testRollbackWithoutBeginThrowsException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rollbackWithoutBeginThrowsException(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::ROLLBACK_WITHOUT_TRANSACTION); @@ -140,15 +151,16 @@ public function testRollbackWithoutBeginThrowsException(): void /** * Standalone commit after a SET autocommit=0; */ - public function testStandaloneCommit(): void + #[\PHPUnit\Framework\Attributes\Test] + public function standaloneCommit(): void { - self::assertFalse($this->wrapper->inTransaction()); - self::assertSame(0, $this->wrapper->getNestedTransactionsCount()); + static::assertFalse($this->wrapper->inTransaction()); + static::assertSame(0, $this->wrapper->getNestedTransactionsCount()); $this->wrapper->commit(); - self::assertFalse($this->wrapper->inTransaction()); - self::assertSame(0, $this->wrapper->getNestedTransactionsCount()); + static::assertFalse($this->wrapper->inTransaction()); + static::assertSame(0, $this->wrapper->getNestedTransactionsCount()); } /** diff --git a/test/unit/Adapter/Driver/Pdo/PdoTest.php b/test/unit/Adapter/Driver/Pdo/PdoTest.php index 05bd2a20..874e819d 100644 --- a/test/unit/Adapter/Driver/Pdo/PdoTest.php +++ b/test/unit/Adapter/Driver/Pdo/PdoTest.php @@ -66,40 +66,45 @@ public static function getParamsAndType(): array ]; } - public function testCheckEnvironmentReturnsTrue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function checkEnvironmentReturnsTrue(): void { - self::assertTrue($this->pdo->checkEnvironment()); + static::assertTrue($this->pdo->checkEnvironment()); } - public function testConstructorAddsFeaturesWhenDriverSupportsFeatures(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorAddsFeaturesWhenDriverSupportsFeatures(): void { $feature = $this->createMock(DriverFeatureInterface::class); $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdoWithFeatures($connection, features: [$feature]); - self::assertSame($feature, $pdo->getFeature($feature::class)); + static::assertSame($feature, $pdo->getFeature($feature::class)); } - public function testConstructorSetsDriverOnConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorSetsDriverOnConnection(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdo($connection); - self::assertSame($connection, $pdo->getConnection()); + static::assertSame($connection, $pdo->getConnection()); } - public function testCreateStatementWithNullConnectsAndInitializes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createStatementWithNullConnectsAndInitializes(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); $pdo = new TestPdo($connection); $statement = $pdo->createStatement(); - self::assertInstanceOf(Statement::class, $statement); + static::assertInstanceOf(Statement::class, $statement); } - public function testCreateStatementWithPdoStatementResource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createStatementWithPdoStatementResource(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdo($connection); @@ -107,72 +112,81 @@ public function testCreateStatementWithPdoStatementResource(): void $pdoStmt = $this->createMock(PDOStatement::class); $statement = $pdo->createStatement($pdoStmt); - self::assertInstanceOf(Statement::class, $statement); - self::assertSame($pdoStmt, $statement->getResource()); + static::assertInstanceOf(Statement::class, $statement); + static::assertSame($pdoStmt, $statement->getResource()); } - public function testCreateStatementWithSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createStatementWithSqlString(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdo($connection); $statement = $pdo->createStatement('SELECT 1'); - self::assertInstanceOf(Statement::class, $statement); - self::assertSame('SELECT 1', $statement->getSql()); + static::assertInstanceOf(Statement::class, $statement); + static::assertSame('SELECT 1', $statement->getSql()); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('getParamsAndType')] - public function testFormatParameterNameFormatsCorrectly(int|string $name, ?string $type, string $expected): void + public function formatParameterNameFormatsCorrectly(int|string $name, ?string $type, string $expected): void { $result = $this->pdo->formatParameterName($name, $type); - $this->assertEquals($expected, $result); + static::assertEquals($expected, $result); } - public function testFormatParameterNameReturnsQuestionMarkForNumericWithoutType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function formatParameterNameReturnsQuestionMarkForNumericWithoutType(): void { - self::assertSame('?', $this->pdo->formatParameterName(42)); + static::assertSame('?', $this->pdo->formatParameterName(42)); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('getInvalidParamName')] - public function testFormatParameterNameWithInvalidCharacters(string $name): void + public function formatParameterNameWithInvalidCharacters(string $name): void { $this->expectException(RuntimeException::class); $this->pdo->formatParameterName($name); } - public function testGetConnectionReturnsConnectionInstance(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getConnectionReturnsConnectionInstance(): void { $connection = $this->pdo->getConnection(); - self::assertInstanceOf(TestConnection::class, $connection); + static::assertInstanceOf(TestConnection::class, $connection); } - public function testGetLastGeneratedValueDelegatesToConnection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLastGeneratedValueDelegatesToConnection(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdo($connection); $value = $pdo->getLastGeneratedValue(); - self::assertSame('0', $value); + static::assertSame('0', $value); } - public function testGetPrepareTypeReturnsNamed(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getPrepareTypeReturnsNamed(): void { - self::assertSame(DriverInterface::PARAMETERIZATION_NAMED, $this->pdo->getPrepareType()); + static::assertSame(DriverInterface::PARAMETERIZATION_NAMED, $this->pdo->getPrepareType()); } - public function testGetProfilerReturnsSetProfiler(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getProfilerReturnsSetProfiler(): void { $profiler = $this->createMock(ProfilerInterface::class); $this->pdo->setProfiler($profiler); - self::assertSame($profiler, $this->pdo->getProfiler()); + static::assertSame($profiler, $this->pdo->getProfiler()); } - public function testGetProfilerThrowsWhenNotInitialized(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getProfilerThrowsWhenNotInitialized(): void { $pdo = new TestPdo([]); @@ -181,14 +195,16 @@ public function testGetProfilerThrowsWhenNotInitialized(): void $unused = $pdo->getProfiler(); } - public function testGetResultPrototypeReturnsResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getResultPrototypeReturnsResult(): void { $resultPrototype = $this->pdo->getResultPrototype(); - self::assertInstanceOf(Result::class, $resultPrototype); + static::assertInstanceOf(Result::class, $resultPrototype); } - public function testSetProfilerPropagatesProfilerToConnectionAndStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setProfilerPropagatesProfilerToConnectionAndStatement(): void { $profiler = $this->createMock(ProfilerInterface::class); $connection = new TestConnection(new SqliteMemoryPdo()); @@ -197,9 +213,9 @@ public function testSetProfilerPropagatesProfilerToConnectionAndStatement(): voi $pdo->setProfiler($profiler); - self::assertSame($profiler, $pdo->getProfiler()); - self::assertSame($profiler, $connection->getProfiler()); - self::assertSame($profiler, $statement->getProfiler()); + static::assertSame($profiler, $pdo->getProfiler()); + static::assertSame($profiler, $connection->getProfiler()); + static::assertSame($profiler, $statement->getProfiler()); } /** diff --git a/test/unit/Adapter/Driver/Pdo/ResultTest.php b/test/unit/Adapter/Driver/Pdo/ResultTest.php index 73f5b277..1da02c86 100644 --- a/test/unit/Adapter/Driver/Pdo/ResultTest.php +++ b/test/unit/Adapter/Driver/Pdo/ResultTest.php @@ -42,15 +42,17 @@ #[Group('unit')] final class ResultTest extends TestCase { - public function testBufferIsCallableWithNoEffect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bufferIsCallableWithNoEffect(): void { $result = new Result(); $result->buffer(); - self::assertFalse($result->isBuffered()); + static::assertFalse($result->isBuffered()); } - public function testCountCachesResultFromClosure(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countCachesResultFromClosure(): void { $callCount = 0; $rowCount = static function () use (&$callCount): int { @@ -66,10 +68,11 @@ public function testCountCachesResultFromClosure(): void $result->count(); $result->count(); - self::assertSame(1, $callCount); + static::assertSame(1, $callCount); } - public function testCountCachesResultFromStatementRowCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countCachesResultFromStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->once())->method('rowCount')->willReturn(3); @@ -80,10 +83,11 @@ public function testCountCachesResultFromStatementRowCount(): void $result->count(); $result->count(); - self::assertSame(3, $result->count()); + static::assertSame(3, $result->count()); } - public function testCountWithClosureInvokesClosureAndReturnsValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countWithClosureInvokesClosureAndReturnsValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->never())->method('rowCount'); @@ -93,10 +97,11 @@ public function testCountWithClosureInvokesClosureAndReturnsValue(): void $result = new Result(); $result->initialize($stub, null, $rowCount); - self::assertSame(42, $result->count()); + static::assertSame(42, $result->count()); } - public function testCountWithIntReturnsProvidedValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countWithIntReturnsProvidedValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->never())->method('rowCount'); @@ -104,10 +109,11 @@ public function testCountWithIntReturnsProvidedValue(): void $result = new Result(); $result->initialize($stub, null, 10); - self::assertSame(10, $result->count()); + static::assertSame(10, $result->count()); } - public function testCountWithNoRowCountFallsBackToStatementRowCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countWithNoRowCountFallsBackToStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->once()) @@ -117,13 +123,14 @@ public function testCountWithNoRowCountFallsBackToStatementRowCount(): void $result = new Result(); $result->initialize($stub, null); - self::assertSame(5, $result->count()); + static::assertSame(5, $result->count()); } /** * Tests current method returns same data on consecutive calls. */ - public function testCurrentReturnsSameDataOnConsecutiveCalls(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsSameDataOnConsecutiveCalls(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -133,13 +140,14 @@ public function testCurrentReturnsSameDataOnConsecutiveCalls(): void $result = new Result(); $result->initialize($stub, null); - self::assertEquals($result->current(), $result->current()); + static::assertEquals($result->current(), $result->current()); } /** * Tests whether the fetch mode has a broader range */ - public function testFetchModeAcceptsNamedMode(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fetchModeAcceptsNamedMode(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -148,14 +156,15 @@ public function testFetchModeAcceptsNamedMode(): void $result = new Result(); $result->initialize($stub, null); $result->setFetchMode(PDO::FETCH_NAMED); - self::assertEquals(11, $result->getFetchMode()); - self::assertInstanceOf('stdClass', $result->current()); + static::assertSame(11, $result->getFetchMode()); + static::assertInstanceOf('stdClass', $result->current()); } /** * Tests whether the fetch mode was set properly and */ - public function testFetchModeObjReturnsStdClass(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fetchModeObjReturnsStdClass(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -166,11 +175,12 @@ public function testFetchModeObjReturnsStdClass(): void $result->initialize($stub, null); $result->setFetchMode(PDO::FETCH_OBJ); - self::assertEquals(5, $result->getFetchMode()); - self::assertInstanceOf('stdClass', $result->current()); + static::assertSame(5, $result->getFetchMode()); + static::assertInstanceOf('stdClass', $result->current()); } - public function testGetAffectedRowsDelegatesToRowCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getAffectedRowsDelegatesToRowCount(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('rowCount')->willReturn(5); @@ -178,17 +188,19 @@ public function testGetAffectedRowsDelegatesToRowCount(): void $result = new Result(); $result->initialize($stub, null); - self::assertSame(5, $result->getAffectedRows()); + static::assertSame(5, $result->getAffectedRows()); } - public function testGetFetchModeDefaultIsAssoc(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFetchModeDefaultIsAssoc(): void { $result = new Result(); - self::assertSame(PDO::FETCH_ASSOC, $result->getFetchMode()); + static::assertSame(PDO::FETCH_ASSOC, $result->getFetchMode()); } - public function testGetFieldCountDelegatesToColumnCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCountDelegatesToColumnCount(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -196,26 +208,29 @@ public function testGetFieldCountDelegatesToColumnCount(): void $result = new Result(); $result->initialize($stub, null); - self::assertSame(3, $result->getFieldCount()); + static::assertSame(3, $result->getFieldCount()); } - public function testGetGeneratedValueReturnsInitializedValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getGeneratedValueReturnsInitializedValue(): void { $stub = $this->createMock(PDOStatement::class); $result = new Result(); $result->initialize($stub, 42); - self::assertSame(42, $result->getGeneratedValue()); + static::assertSame(42, $result->getGeneratedValue()); } - public function testGetGeneratedValueReturnsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getGeneratedValueReturnsNullByDefault(): void { $result = new Result(); - self::assertNull($result->getGeneratedValue()); + static::assertNull($result->getGeneratedValue()); } - public function testGetQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -226,11 +241,12 @@ public function testGetQueryResultClonesGivenPrototypeRatherThanMutatingIt(): vo $returned = $result->getQueryResult($prototype); - self::assertInstanceOf(TemporaryResultSet::class, $returned); - self::assertNotSame($prototype, $returned); + static::assertInstanceOf(TemporaryResultSet::class, $returned); + static::assertNotSame($prototype, $returned); } - public function testGetQueryResultInitializesReturnedResultSetWithThisResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQueryResultInitializesReturnedResultSetWithThisResult(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -238,10 +254,11 @@ public function testGetQueryResultInitializesReturnedResultSetWithThisResult(): $result = new Result(); $result->initialize($stub, null); - self::assertSame($result->getFieldCount(), $result->getQueryResult()->getFieldCount()); + static::assertSame($result->getFieldCount(), $result->getQueryResult()->getFieldCount()); } - public function testGetQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -249,10 +266,11 @@ public function testGetQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven( $result = new Result(); $result->initialize($stub, null); - self::assertInstanceOf(ResultSet::class, $result->getQueryResult()); + static::assertInstanceOf(ResultSet::class, $result->getQueryResult()); } - public function testGetQueryResultThrowsWhenResultIsNotAQueryResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQueryResultThrowsWhenResultIsNotAQueryResult(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(0); @@ -264,34 +282,38 @@ public function testGetQueryResultThrowsWhenResultIsNotAQueryResult(): void $result->getQueryResult(); } - public function testGetResourceReturnsPdoStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getResourceReturnsPdoStatement(): void { $stub = $this->createMock(PDOStatement::class); $result = new Result(); $result->initialize($stub, null); - self::assertSame($stub, $result->getResource()); + static::assertSame($stub, $result->getResource()); } - public function testInitializeStoresResourceAndValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeStoresResourceAndValues(): void { $stub = $this->createMock(PDOStatement::class); $result = new Result(); $result->initialize($stub, 42, 5); - self::assertSame(42, $result->getGeneratedValue()); - self::assertSame(5, $result->count()); + static::assertSame(42, $result->getGeneratedValue()); + static::assertSame(5, $result->count()); } - public function testIsBufferedReturnsFalse(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isBufferedReturnsFalse(): void { $result = new Result(); - self::assertFalse($result->isBuffered()); + static::assertFalse($result->isBuffered()); } - public function testIsQueryResultReturnsFalseWhenNoColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isQueryResultReturnsFalseWhenNoColumns(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(0); @@ -299,10 +321,11 @@ public function testIsQueryResultReturnsFalseWhenNoColumns(): void $result = new Result(); $result->initialize($stub, null); - self::assertFalse($result->isQueryResult()); + static::assertFalse($result->isQueryResult()); } - public function testIsQueryResultReturnsTrueWhenColumnsExist(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isQueryResultReturnsTrueWhenColumnsExist(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -310,10 +333,11 @@ public function testIsQueryResultReturnsTrueWhenColumnsExist(): void $result = new Result(); $result->initialize($stub, null); - self::assertTrue($result->isQueryResult()); + static::assertTrue($result->isQueryResult()); } - public function testNextAdvancesPositionAndFetchesData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function nextAdvancesPositionAndFetchesData(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['name' => 'test']); @@ -322,13 +346,14 @@ public function testNextAdvancesPositionAndFetchesData(): void $result->initialize($stub, null); $result->rewind(); - self::assertSame(0, $result->key()); + static::assertSame(0, $result->key()); $result->next(); - self::assertSame(1, $result->key()); + static::assertSame(1, $result->key()); } - public function testRewindResetsIterationToStart(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rewindResetsIterationToStart(): void { $data = [ ['test' => 1], @@ -349,17 +374,18 @@ public function testRewindResetsIterationToStart(): void $result->rewind(); $result->rewind(); - $this->assertEquals(0, $result->key()); - $this->assertEquals(1, $position); - $this->assertEquals($data[0], $result->current()); + static::assertSame(0, $result->key()); + static::assertSame(1, $position); + static::assertEquals($data[0], $result->current()); $result->next(); - $this->assertEquals(1, $result->key()); - $this->assertEquals(2, $position); - $this->assertEquals($data[1], $result->current()); + static::assertSame(1, $result->key()); + static::assertSame(2, $position); + static::assertEquals($data[1], $result->current()); } - public function testRewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['id' => 1]); @@ -375,15 +401,17 @@ public function testRewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void $result->rewind(); } - public function testSetFetchModeStoresValidMode(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setFetchModeStoresValidMode(): void { $result = new Result(); $result->setFetchMode(PDO::FETCH_NUM); - self::assertSame(PDO::FETCH_NUM, $result->getFetchMode()); + static::assertSame(PDO::FETCH_NUM, $result->getFetchMode()); } - public function testSetFetchModeThrowsOnInvalidFetchMode(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setFetchModeThrowsOnInvalidFetchMode(): void { $result = new Result(); @@ -393,7 +421,8 @@ public function testSetFetchModeThrowsOnInvalidFetchMode(): void $result->setFetchMode(9999); } - public function testSetFetchModeThrowsOnInvalidMode(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setFetchModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -401,7 +430,8 @@ public function testSetFetchModeThrowsOnInvalidMode(): void $result->setFetchMode(13); } - public function testSetStatementModeThrowsOnInvalidMode(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setStatementModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -409,25 +439,28 @@ public function testSetStatementModeThrowsOnInvalidMode(): void $result->setStatementMode('invalid'); } - public function testSetStatementModeToForward(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setStatementModeToForward(): void { $result = new Result(); $result->setStatementMode(Result::STATEMENT_MODE_FORWARD); - self::assertSame(Result::STATEMENT_MODE_FORWARD, $result->getStatementMode()); + static::assertSame(Result::STATEMENT_MODE_FORWARD, $result->getStatementMode()); } - public function testSetStatementModeToScrollable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setStatementModeToScrollable(): void { $result = new Result(); $result->setStatementMode(Result::STATEMENT_MODE_SCROLLABLE); - self::assertSame(Result::STATEMENT_MODE_SCROLLABLE, $result->getStatementMode()); + static::assertSame(Result::STATEMENT_MODE_SCROLLABLE, $result->getStatementMode()); } - public function testValidReturnsFalseWhenCurrentDataIsFalse(): void + #[\PHPUnit\Framework\Attributes\Test] + public function validReturnsFalseWhenCurrentDataIsFalse(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(false); @@ -436,10 +469,11 @@ public function testValidReturnsFalseWhenCurrentDataIsFalse(): void $result->initialize($stub, null); $result->rewind(); - self::assertFalse($result->valid()); + static::assertFalse($result->valid()); } - public function testValidReturnsTrueWhenCurrentDataExists(): void + #[\PHPUnit\Framework\Attributes\Test] + public function validReturnsTrueWhenCurrentDataExists(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['id' => 1]); @@ -448,6 +482,6 @@ public function testValidReturnsTrueWhenCurrentDataExists(): void $result->initialize($stub, null); $result->rewind(); - self::assertTrue($result->valid()); + static::assertTrue($result->valid()); } } diff --git a/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php b/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php index 7b789e55..8dcbb5fb 100644 --- a/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php +++ b/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php @@ -18,54 +18,58 @@ final class StatementIntegrationTest extends TestCase protected PDOStatement|MockObject $pdoStatementMock; - public function testStatementExecuteWillConvertPhpBoolToPdoBoolWhenBinding(): void + #[\PHPUnit\Framework\Attributes\Test] + public function statementExecuteWillConvertPhpBoolToPdoBoolWhenBinding(): void { $this->pdoStatementMock ->expects($this->any()) ->method('bindParam') ->with( - $this->equalTo(':foo'), - $this->equalTo(false), - $this->equalTo(PDO::PARAM_BOOL), + static::equalTo(':foo'), + static::equalTo(false), + static::equalTo(PDO::PARAM_BOOL), ); $this->statement->execute(['foo' => false]); } - public function testStatementExecuteWillUsePdoIntForIntWhenBinding(): void + #[\PHPUnit\Framework\Attributes\Test] + public function statementExecuteWillUsePdoIntForIntWhenBinding(): void { $this->pdoStatementMock ->expects($this->any()) ->method('bindParam') ->with( - $this->equalTo(':foo'), - $this->equalTo(123), - $this->equalTo(PDO::PARAM_INT), + static::equalTo(':foo'), + static::equalTo(123), + static::equalTo(PDO::PARAM_INT), ); $this->statement->execute(['foo' => 123]); } - public function testStatementExecuteWillUsePdoStrByDefaultWhenBinding(): void + #[\PHPUnit\Framework\Attributes\Test] + public function statementExecuteWillUsePdoStrByDefaultWhenBinding(): void { $this->pdoStatementMock ->expects($this->any()) ->method('bindParam') ->with( - $this->equalTo(':foo'), - $this->equalTo('bar'), - $this->equalTo(PDO::PARAM_STR), + static::equalTo(':foo'), + static::equalTo('bar'), + static::equalTo(PDO::PARAM_STR), ); $this->statement->execute(['foo' => 'bar']); } - public function testStatementExecuteWillUsePdoStrForStringIntegerWhenBinding(): void + #[\PHPUnit\Framework\Attributes\Test] + public function statementExecuteWillUsePdoStrForStringIntegerWhenBinding(): void { $this->pdoStatementMock ->expects($this->any()) ->method('bindParam') ->with( - $this->equalTo(':foo'), - $this->equalTo('123'), - $this->equalTo(PDO::PARAM_STR), + static::equalTo(':foo'), + static::equalTo('123'), + static::equalTo(PDO::PARAM_STR), ); $this->statement->execute(['foo' => '123']); } diff --git a/test/unit/Adapter/Driver/Pdo/StatementTest.php b/test/unit/Adapter/Driver/Pdo/StatementTest.php index 5b3eb200..fda6a7e9 100644 --- a/test/unit/Adapter/Driver/Pdo/StatementTest.php +++ b/test/unit/Adapter/Driver/Pdo/StatementTest.php @@ -59,7 +59,8 @@ public static function invalidParameterNameProvider(): array ]; } - public function testBindParametersDetectsBooleanValueType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersDetectsBooleanValueType(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -72,10 +73,11 @@ public function testBindParametersDetectsBooleanValueType(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersDetectsNullValueType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersDetectsNullValueType(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -88,10 +90,11 @@ public function testBindParametersDetectsNullValueType(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersFromContainerSkipsWhenAlreadyBound(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersFromContainerSkipsWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -100,10 +103,11 @@ public function testBindParametersFromContainerSkipsWhenAlreadyBound(): void $this->statement->setParameterContainer(new ParameterContainer(['val' => 'first'])); $result1 = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result1); + static::assertInstanceOf(Result::class, $result1); } - public function testBindParametersWithErrataTypeDefaultsToString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersWithErrataTypeDefaultsToString(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -116,10 +120,11 @@ public function testBindParametersWithErrataTypeDefaultsToString(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeInteger(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersWithErrataTypeInteger(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -132,10 +137,11 @@ public function testBindParametersWithErrataTypeInteger(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeLob(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersWithErrataTypeLob(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -148,10 +154,11 @@ public function testBindParametersWithErrataTypeLob(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersWithErrataTypeNull(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -164,10 +171,11 @@ public function testBindParametersWithErrataTypeNull(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithPositionalIntegers(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bindParametersWithPositionalIntegers(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -182,21 +190,23 @@ public function testBindParametersWithPositionalIntegers(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testCloneClonesParameterContainerWhenSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneClonesParameterContainerWhenSet(): void { $container = new ParameterContainer(['key' => 'value']); $statement = new Statement($container); $clone = clone $statement; - self::assertNotSame($container, $clone->getParameterContainer()); - self::assertSame('value', $clone->getParameterContainer()->offsetGet('key')); + static::assertNotSame($container, $clone->getParameterContainer()); + static::assertSame('value', $clone->getParameterContainer()->offsetGet('key')); } - public function testCloneResetsState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneResetsState(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -206,38 +216,41 @@ public function testCloneResetsState(): void $clone = clone $this->statement; - self::assertFalse($clone->isPrepared()); - self::assertNull($clone->getResource()); - self::assertNotSame( + static::assertFalse($clone->isPrepared()); + static::assertNull($clone->getResource()); + static::assertNotSame( $this->statement->getParameterContainer(), $clone->getParameterContainer(), ); } - public function testConstructorAcceptsParameterContainerAndOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorAcceptsParameterContainerAndOptions(): void { $container = new ParameterContainer(['key' => 'value']); $statement = new Statement($container, ['option' => true]); - self::assertSame($container, $statement->getParameterContainer()); + static::assertSame($container, $statement->getParameterContainer()); } - public function testExecuteAutoPrepares(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeAutoPrepares(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); $this->statement->initialize($pdo); $this->statement->setSql('SELECT 1'); - self::assertFalse($this->statement->isPrepared()); + static::assertFalse($this->statement->isPrepared()); $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); - self::assertTrue($this->statement->isPrepared()); + static::assertInstanceOf(Result::class, $result); + static::assertTrue($this->statement->isPrepared()); } - public function testExecuteCallsProfilerFinishOnFailure(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeCallsProfilerFinishOnFailure(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -261,7 +274,8 @@ public function testExecuteCallsProfilerFinishOnFailure(): void $this->statement->execute(); } - public function testExecuteCallsProfilerOnSuccess(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeCallsProfilerOnSuccess(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -276,7 +290,8 @@ public function testExecuteCallsProfilerOnSuccess(): void $this->statement->execute(); } - public function testExecuteCastsNonIntErrorCodeToZero(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeCastsNonIntErrorCodeToZero(): void { $pdoException = new PDOException('fail'); $ref = new ReflectionProperty($pdoException, 'code'); @@ -297,21 +312,23 @@ public function testExecuteCastsNonIntErrorCodeToZero(): void try { $this->statement->execute(); - self::fail('Expected InvalidQueryException'); + static::fail('Expected InvalidQueryException'); } catch (InvalidQueryException $e) { - self::assertSame(0, $e->getCode()); + static::assertSame(0, $e->getCode()); } } - public function testExecuteReturnsResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeReturnsResult(): void { $this->statement->setDriver(new TestPdo(new TestConnection($pdo = new SqliteMemoryPdo()))); $this->statement->initialize($pdo); $this->statement->prepare('SELECT 1'); - self::assertInstanceOf(Result::class, $this->statement->execute()); + static::assertInstanceOf(Result::class, $this->statement->execute()); } - public function testExecuteThrowsInvalidQueryExceptionOnPdoException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeThrowsInvalidQueryExceptionOnPdoException(): void { $pdoStmt = $this->createMock(PDOStatement::class); $pdoStmt->method('execute')->willThrowException(new PDOException('execute failed')); @@ -330,8 +347,9 @@ public function testExecuteThrowsInvalidQueryExceptionOnPdoException(): void $this->statement->execute(); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidParameterNameProvider')] - public function testExecuteThrowsOnInvalidParameterName(string $name): void + public function executeThrowsOnInvalidParameterName(string $name): void { $this->statement->setDriver(new TestPdo(new TestConnection($pdo = new SqliteMemoryPdo()))); $this->statement->initialize($pdo); @@ -342,7 +360,8 @@ public function testExecuteThrowsOnInvalidParameterName(string $name): void $this->statement->execute([$name => 'value']); } - public function testExecuteWithArrayParametersMergesIntoContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeWithArrayParametersMergesIntoContainer(): void { $pdo = new SqliteMemoryPdo(); $statement = new Statement(); @@ -352,10 +371,11 @@ public function testExecuteWithArrayParametersMergesIntoContainer(): void $result = $statement->execute(['name' => 'test']); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testExecuteWithParameterContainerSetsContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeWithParameterContainerSetsContainer(): void { $pdo = new SqliteMemoryPdo(); $statement = new Statement(); @@ -368,56 +388,64 @@ public function testExecuteWithParameterContainerSetsContainer(): void $result = $statement->execute($container); - self::assertInstanceOf(Result::class, $result); - self::assertSame($container, $statement->getParameterContainer()); + static::assertInstanceOf(Result::class, $result); + static::assertSame($container, $statement->getParameterContainer()); } - public function testFluentPrepare(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fluentPrepare(): void { $this->statement->initialize(new SqliteMemoryPdo()); $result = $this->statement->prepare('SELECT 1'); - self::assertInstanceOf(Statement::class, $result); - self::assertSame($this->statement, $result); + static::assertInstanceOf(Statement::class, $result); + static::assertSame($this->statement, $result); } - public function testFluentSetDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fluentSetDriver(): void { - self::assertEquals($this->statement, $this->statement->setDriver(new TestPdo([]))); + static::assertEquals($this->statement, $this->statement->setDriver(new TestPdo([]))); } - public function testFluentSetParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fluentSetParameterContainer(): void { - self::assertSame($this->statement, $this->statement->setParameterContainer(new ParameterContainer())); + static::assertSame($this->statement, $this->statement->setParameterContainer(new ParameterContainer())); } - public function testGetParameterContainerReturnsContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getParameterContainerReturnsContainer(): void { $container = new ParameterContainer(); $this->statement->setParameterContainer($container); - self::assertSame($container, $this->statement->getParameterContainer()); + static::assertSame($container, $this->statement->getParameterContainer()); } - public function testGetProfilerReturnsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getProfilerReturnsNullByDefault(): void { - self::assertNull($this->statement->getProfiler()); + static::assertNull($this->statement->getProfiler()); } - public function testGetResourceReturnsPdoStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getResourceReturnsPdoStatement(): void { $pdo = new SqliteMemoryPdo(); $stmt = $pdo->prepare('SELECT 1'); $this->statement->setResource($stmt); - self::assertSame($stmt, $this->statement->getResource()); + static::assertSame($stmt, $this->statement->getResource()); } - public function testGetSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSql(): void { $this->statement->setSql('SELECT 1'); - self::assertEquals('SELECT 1', $this->statement->getSql()); + static::assertSame('SELECT 1', $this->statement->getSql()); } - public function testInitializeSetsPdoResource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeSetsPdoResource(): void { $pdo = new SqliteMemoryPdo(); @@ -425,18 +453,20 @@ public function testInitializeSetsPdoResource(): void $this->statement->setSql('SELECT 1'); $this->statement->prepare(); - self::assertTrue($this->statement->isPrepared()); + static::assertTrue($this->statement->isPrepared()); } - public function testIsPreparedReturnsTrueAfterPrepare(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isPreparedReturnsTrueAfterPrepare(): void { - self::assertFalse($this->statement->isPrepared()); + static::assertFalse($this->statement->isPrepared()); $this->statement->initialize(new SqliteMemoryPdo()); $this->statement->prepare('SELECT 1'); - self::assertTrue($this->statement->isPrepared()); + static::assertTrue($this->statement->isPrepared()); } - public function testPrepareThrowsRuntimeExceptionOnPdoFailure(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareThrowsRuntimeExceptionOnPdoFailure(): void { $pdo = $this->createMock(PDO::class); $pdo->method('prepare')->willReturn(false); @@ -449,7 +479,8 @@ public function testPrepareThrowsRuntimeExceptionOnPdoFailure(): void $this->statement->prepare(); } - public function testPrepareThrowsWhenAlreadyPrepared(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareThrowsWhenAlreadyPrepared(): void { $this->statement->initialize(new SqliteMemoryPdo()); $this->statement->prepare('SELECT 1'); @@ -460,7 +491,8 @@ public function testPrepareThrowsWhenAlreadyPrepared(): void $this->statement->prepare('SELECT 2'); } - public function testSecondExecuteSkipsBindingWhenAlreadyBound(): void + #[\PHPUnit\Framework\Attributes\Test] + public function secondExecuteSkipsBindingWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -469,34 +501,37 @@ public function testSecondExecuteSkipsBindingWhenAlreadyBound(): void $this->statement->setParameterContainer(new ParameterContainer(['val' => 'test'])); $result1 = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result1); + static::assertInstanceOf(Result::class, $result1); $result2 = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result2); + static::assertInstanceOf(Result::class, $result2); } - public function testSetProfilerStoresProfiler(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setProfilerStoresProfiler(): void { $profiler = $this->createMock(ProfilerInterface::class); $this->statement->setProfiler($profiler); - self::assertSame($profiler, $this->statement->getProfiler()); + static::assertSame($profiler, $this->statement->getProfiler()); } - public function testSetResourceStoresPdoStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setResourceStoresPdoStatement(): void { $pdoStmt = $this->createMock(PDOStatement::class); $this->statement->setResource($pdoStmt); - self::assertSame($pdoStmt, $this->statement->getResource()); + static::assertSame($pdoStmt, $this->statement->getResource()); } - public function testSetSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setSql(): void { $this->statement->setSql('SELECT 1'); - self::assertEquals('SELECT 1', $this->statement->getSql()); + static::assertSame('SELECT 1', $this->statement->getSql()); } /** diff --git a/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php b/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php index 023c5836..33c50913 100644 --- a/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php +++ b/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php @@ -13,10 +13,11 @@ #[CoversMethod(InvalidConnectionParametersException::class, '__construct')] final class InvalidConnectionParametersExceptionTest extends TestCase { - public function testConstructorStoresMessageAndParameters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorStoresMessageAndParameters(): void { $exception = new InvalidConnectionParametersException('msg', ['host', 'port']); - self::assertSame('msg', $exception->getMessage()); + static::assertSame('msg', $exception->getMessage()); } } diff --git a/test/unit/Adapter/ParameterContainerTest.php b/test/unit/Adapter/ParameterContainerTest.php index 4c391040..8b5ce4c6 100644 --- a/test/unit/Adapter/ParameterContainerTest.php +++ b/test/unit/Adapter/ParameterContainerTest.php @@ -42,108 +42,122 @@ final class ParameterContainerTest extends TestCase { protected ParameterContainer $parameterContainer; - public function testConstructorWithDataPopulatesContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithDataPopulatesContainer(): void { $container = new ParameterContainer(['a' => 1, 'b' => 2]); - self::assertSame(2, $container->count()); - self::assertSame(1, $container->offsetGet('a')); - self::assertSame(2, $container->offsetGet('b')); + static::assertSame(2, $container->count()); + static::assertSame(1, $container->offsetGet('a')); + static::assertSame(2, $container->offsetGet('b')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test count() returns the proper count')] - public function testCount(): void + public function countsStoredParameters(): void { - self::assertEquals(1, $this->parameterContainer->count()); + static::assertSame(1, $this->parameterContainer->count()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test current() returns the current element when used as an iterator')] - public function testCurrent(): void + public function current(): void { $value = $this->parameterContainer->current(); - self::assertEquals('bar', $value); + static::assertSame('bar', $value); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getErrataIterator() will return an iterator for the errata data')] - public function testGetErrataIterator(): void + public function getErrataIterator(): void { $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); $data = $this->parameterContainer->getErrataIterator(); - self::assertInstanceOf('ArrayIterator', $data); + static::assertInstanceOf('ArrayIterator', $data); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getMaxLengthIterator() will return an iterator for the errata data')] - public function testGetMaxLengthIterator(): void + public function getMaxLengthIterator(): void { $this->parameterContainer->offsetSetMaxLength('foo', 100); $data = $this->parameterContainer->getMaxLengthIterator(); - self::assertInstanceOf('ArrayIterator', $data); + static::assertInstanceOf('ArrayIterator', $data); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test getNamedArray()')] - public function testGetNamedArray(): void + public function getNamedArray(): void { $data = $this->parameterContainer->getNamedArray(); - self::assertEquals(['foo' => 'bar'], $data); + static::assertEquals(['foo' => 'bar'], $data); } - public function testGetPositionalArrayReturnsValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getPositionalArrayReturnsValues(): void { $container = new ParameterContainer(['a' => 1, 'b' => 2, 'c' => 3]); - self::assertSame([1, 2, 3], $container->getPositionalArray()); + static::assertSame([1, 2, 3], $container->getPositionalArray()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox("unit test: Test key() returns the name of the current item's name")] - public function testKey(): void + public function key(): void { - self::assertEquals('foo', $this->parameterContainer->key()); + static::assertSame('foo', $this->parameterContainer->key()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test next() increases the pointer when used as an iterator')] - public function testNext(): void + public function next(): void { $this->parameterContainer['bar'] = 'baz'; $this->parameterContainer->next(); - self::assertEquals('baz', $this->parameterContainer->current()); + static::assertSame('baz', $this->parameterContainer->current()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetExists() returns proper values via method call and isset()')] - public function testOffsetExists(): void + public function offsetExists(): void { - self::assertTrue($this->parameterContainer->offsetExists('foo')); - self::assertTrue(isset($this->parameterContainer['foo'])); - self::assertFalse($this->parameterContainer->offsetExists('bar')); - self::assertFalse(isset($this->parameterContainer['bar'])); + static::assertTrue($this->parameterContainer->offsetExists('foo')); + static::assertTrue(isset($this->parameterContainer['foo'])); + static::assertFalse($this->parameterContainer->offsetExists('bar')); + static::assertFalse(isset($this->parameterContainer['bar'])); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetGet() returns proper values via method call and array access')] - public function testOffsetGet(): void + public function offsetGet(): void { - self::assertEquals('bar', $this->parameterContainer->offsetGet('foo')); - self::assertEquals('bar', $this->parameterContainer['foo']); + static::assertSame('bar', $this->parameterContainer->offsetGet('foo')); + static::assertSame('bar', $this->parameterContainer['foo']); - self::assertNull($this->parameterContainer->offsetGet('bar')); + static::assertNull($this->parameterContainer->offsetGet('bar')); // @todo determine what should come back here } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetGetErrata() return persisted errata data, if it exists')] - public function testOffsetGetErrata(): void + public function offsetGetErrata(): void { $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); - self::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); + static::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); } - public function testOffsetGetErrataByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetGetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); - self::assertSame(ParameterContainer::TYPE_INTEGER, $container->offsetGetErrata(0)); + static::assertSame(ParameterContainer::TYPE_INTEGER, $container->offsetGetErrata(0)); } - public function testOffsetGetErrataThrowsWhenNameDoesNotExist(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetGetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -153,15 +167,17 @@ public function testOffsetGetErrataThrowsWhenNameDoesNotExist(): void $container->offsetGetErrata('nonexistent'); } - public function testOffsetGetMaxLengthByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetGetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetMaxLength('foo', 50); - self::assertSame(50, $container->offsetGetMaxLength(0)); + static::assertSame(50, $container->offsetGetMaxLength(0)); } - public function testOffsetGetMaxLengthThrowsWhenNameDoesNotExist(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetGetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -171,59 +187,64 @@ public function testOffsetGetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetGetMaxLength('nonexistent'); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetHasErrata() will check if errata exists for a particular key')] - public function testOffsetHasErrata(): void + public function offsetHasErrata(): void { $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); - self::assertTrue($this->parameterContainer->offsetHasErrata('foo')); + static::assertTrue($this->parameterContainer->offsetHasErrata('foo')); } - public function testOffsetHasErrataByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetHasErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetErrata('foo', ParameterContainer::TYPE_STRING); - self::assertTrue($container->offsetHasErrata(0)); + static::assertTrue($container->offsetHasErrata(0)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetHasMaxLength() will check if errata exists for a particular key')] - public function testOffsetHasMaxLength(): void + public function offsetHasMaxLength(): void { $this->parameterContainer->offsetSetMaxLength('foo', 100); - self::assertTrue($this->parameterContainer->offsetHasMaxLength('foo')); + static::assertTrue($this->parameterContainer->offsetHasMaxLength('foo')); } - public function testOffsetHasMaxLengthByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetHasMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetMaxLength('foo', 50); - self::assertTrue($container->offsetHasMaxLength(0)); + static::assertTrue($container->offsetHasMaxLength(0)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetSet() works via method call and array access')] - public function testOffsetSet(): void + public function offsetSet(): void { $this->parameterContainer->offsetSet('boo', 'baz'); - self::assertEquals('baz', $this->parameterContainer->offsetGet('boo')); + static::assertSame('baz', $this->parameterContainer->offsetGet('boo')); $this->parameterContainer->offsetSet('1', 'book', ParameterContainer::TYPE_STRING, 4); - self::assertEquals( + static::assertEquals( ['foo' => 'bar', 'boo' => 'baz', '1' => 'book'], $this->parameterContainer->getNamedArray(), ); - self::assertEquals('string', $this->parameterContainer->offsetGetErrata('1')); - self::assertEquals(4, $this->parameterContainer->offsetGetMaxLength('1')); + static::assertSame('string', $this->parameterContainer->offsetGetErrata('1')); + static::assertSame(4, $this->parameterContainer->offsetGetMaxLength('1')); // test that setting an index applies to correct named parameter $this->parameterContainer[0] = 'Zero'; $this->parameterContainer[1] = 'One'; - self::assertEquals( + static::assertEquals( ['foo' => 'Zero', 'boo' => 'One', '1' => 'book'], $this->parameterContainer->getNamedArray(), ); - self::assertEquals( + static::assertEquals( [0 => 'Zero', 1 => 'One', 2 => 'book'], $this->parameterContainer->getPositionalArray(), ); @@ -232,7 +253,7 @@ public function testOffsetSet(): void $this->parameterContainer['buffer'] = 'A buffer Element'; $this->parameterContainer[] = 'Second To Last'; $this->parameterContainer[] = 'Last'; - self::assertEquals( + static::assertEquals( [ 'foo' => 'Zero', 'boo' => 'One', @@ -243,54 +264,60 @@ public function testOffsetSet(): void ], $this->parameterContainer->getNamedArray(), ); - self::assertEquals( + static::assertEquals( [0 => 'Zero', 1 => 'One', 2 => 'book', 3 => 'A buffer Element', 4 => 'Second To Last', 5 => 'Last'], $this->parameterContainer->getPositionalArray(), ); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(' unit test: Test offsetSetMaxLength() will persist errata data unit test: Test offsetGetMaxLength() return persisted errata data, if it exists ')] - public function testOffsetSetAndGetMaxLength(): void + public function offsetSetAndGetMaxLength(): void { $this->parameterContainer->offsetSetMaxLength('foo', 100); - self::assertEquals(100, $this->parameterContainer->offsetGetMaxLength('foo')); + static::assertSame(100, $this->parameterContainer->offsetGetMaxLength('foo')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetSetErrata() will persist errata data')] - public function testOffsetSetErrata(): void + public function offsetSetErrata(): void { $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); - self::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); + static::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); } - public function testOffsetSetErrataByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetErrata(0, ParameterContainer::TYPE_STRING); - self::assertSame(ParameterContainer::TYPE_STRING, $container->offsetGetErrata('foo')); + static::assertSame(ParameterContainer::TYPE_STRING, $container->offsetGetErrata('foo')); } - public function testOffsetSetMaxLengthByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetMaxLength(0, 50); - self::assertSame(50, $container->offsetGetMaxLength('foo')); + static::assertSame(50, $container->offsetGetMaxLength('foo')); } - public function testOffsetSetReferenceCreatesReference(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetReferenceCreatesReference(): void { $container = new ParameterContainer(['source' => 'original']); $container->offsetSetReference('alias', 'source'); - self::assertSame('original', $container->offsetGet('alias')); + static::assertSame('original', $container->offsetGet('alias')); } - public function testOffsetSetThrowsOnInvalidKeyType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetThrowsOnInvalidKeyType(): void { $container = new ParameterContainer(); @@ -300,60 +327,67 @@ public function testOffsetSetThrowsOnInvalidKeyType(): void $container->offsetSet(1.5, 'value'); } - public function testOffsetSetWithIntNotInPositionsCastsToString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetWithIntNotInPositionsCastsToString(): void { $container = new ParameterContainer(); $container->offsetSet(5, 'value'); - self::assertSame('value', $container->offsetGet('5')); + static::assertSame('value', $container->offsetGet('5')); } - public function testOffsetSetWithNameMappingMatchForNonColonName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSetWithNameMappingMatchForNonColonName(): void { $container = new ParameterContainer(); $container->offsetSet('c_0', ':myparam'); $container->offsetSet('myparam', 'updated'); - self::assertSame('updated', $container->offsetGet('c_0')); + static::assertSame('updated', $container->offsetGet('c_0')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetUnset() works via method call and array access')] - public function testOffsetUnset(): void + public function offsetUnset(): void { $this->parameterContainer->offsetSet('boo', 'baz'); - self::assertTrue($this->parameterContainer->offsetExists('boo')); + static::assertTrue($this->parameterContainer->offsetExists('boo')); $this->parameterContainer->offsetUnset('boo'); - self::assertFalse($this->parameterContainer->offsetExists('boo')); + static::assertFalse($this->parameterContainer->offsetExists('boo')); } - public function testOffsetUnsetByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnsetByPositionalIndex(): void { $container = new ParameterContainer(['a' => 'one', 'b' => 'two']); $container->offsetUnset(0); - self::assertFalse($container->offsetExists('a')); - self::assertTrue($container->offsetExists('b')); + static::assertFalse($container->offsetExists('a')); + static::assertTrue($container->offsetExists('b')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetUnsetErrata() will unset data for a particular key')] - public function testOffsetUnsetErrata(): void + public function offsetUnsetErrata(): void { $this->parameterContainer->offsetSetErrata('foo', ParameterContainer::TYPE_INTEGER); $this->parameterContainer->offsetUnsetErrata('foo'); - self::assertNull($this->parameterContainer->offsetGetErrata('foo')); + static::assertNull($this->parameterContainer->offsetGetErrata('foo')); } - public function testOffsetUnsetErrataByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnsetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetErrata('foo', ParameterContainer::TYPE_STRING); $container->offsetUnsetErrata(0); - self::assertNull($container->offsetGetErrata('foo')); + static::assertNull($container->offsetGetErrata('foo')); } - public function testOffsetUnsetErrataThrowsWhenNameDoesNotExist(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnsetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -363,24 +397,27 @@ public function testOffsetUnsetErrataThrowsWhenNameDoesNotExist(): void $container->offsetUnsetErrata('foo'); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test offsetUnsetMaxLength() will unset data for a particular key')] - public function testOffsetUnsetMaxLength(): void + public function offsetUnsetMaxLength(): void { $this->parameterContainer->offsetSetMaxLength('foo', 100); $this->parameterContainer->offsetUnsetMaxLength('foo'); - self::assertNull($this->parameterContainer->offsetGetMaxLength('foo')); + static::assertNull($this->parameterContainer->offsetGetMaxLength('foo')); } - public function testOffsetUnsetMaxLengthByPositionalIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnsetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetMaxLength('foo', 50); $container->offsetUnsetMaxLength(0); - self::assertNull($container->offsetGetMaxLength('foo')); + static::assertNull($container->offsetGetMaxLength('foo')); } - public function testOffsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -390,21 +427,23 @@ public function testOffsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetUnsetMaxLength('foo'); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test rewind() resets the iterators pointer')] - public function testRewind(): void + public function rewind(): void { $this->parameterContainer->offsetSet('bar', 'baz'); $this->parameterContainer->next(); - self::assertEquals('bar', $this->parameterContainer->key()); + static::assertSame('bar', $this->parameterContainer->key()); $this->parameterContainer->rewind(); - self::assertEquals('foo', $this->parameterContainer->key()); + static::assertSame('foo', $this->parameterContainer->key()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test setFromArray() will populate the container')] - public function testSetFromArray(): void + public function setFromArray(): void { $this->parameterContainer->setFromArray(['bar' => 'baz']); - self::assertEquals('baz', $this->parameterContainer['bar']); + static::assertSame('baz', $this->parameterContainer['bar']); } /** @@ -412,20 +451,22 @@ public function testSetFromArray(): void * * @see Insert::procesInsert as example */ - public function testSetFromArrayNamed(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setFromArrayNamed(): void { $this->parameterContainer->offsetSet('c_0', ':myparam'); $this->parameterContainer->setFromArray([':myparam' => 'baz']); - self::assertEquals('baz', $this->parameterContainer['c_0']); - self::assertEquals('baz', $this->parameterContainer[':myparam']); + static::assertSame('baz', $this->parameterContainer['c_0']); + static::assertSame('baz', $this->parameterContainer[':myparam']); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test valid() returns whether the iterators current position is valid')] - public function testValid(): void + public function valid(): void { - self::assertTrue($this->parameterContainer->valid()); + static::assertTrue($this->parameterContainer->valid()); $this->parameterContainer->next(); - self::assertFalse($this->parameterContainer->valid()); + static::assertFalse($this->parameterContainer->valid()); } /** diff --git a/test/unit/Adapter/Platform/Sql92Test.php b/test/unit/Adapter/Platform/Sql92Test.php index 1b11b20e..55d8cf44 100644 --- a/test/unit/Adapter/Platform/Sql92Test.php +++ b/test/unit/Adapter/Platform/Sql92Test.php @@ -39,14 +39,16 @@ final class Sql92Test extends TestCase { protected Sql92 $platform; - public function testAbstractPlatformQuoteValueEscapesWithDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function abstractPlatformQuoteValueEscapesWithDriver(): void { $platform = new TestPlatform($this->createStub(DriverInterface::class)); - self::assertSame("'test\\'value'", $platform->quoteValue("test'value")); + static::assertSame("'test\\'value'", $platform->quoteValue("test'value")); } - public function testAbstractPlatformQuoteValueThrowsWithoutDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function abstractPlatformQuoteValueThrowsWithoutDriver(): void { $platform = new TestPlatform(); @@ -54,51 +56,58 @@ public function testAbstractPlatformQuoteValueThrowsWithoutDriver(): void $platform->quoteValue('value'); } - public function testGetIdentifierSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getIdentifierSeparator(): void { - self::assertEquals('.', $this->platform->getIdentifierSeparator()); + static::assertSame('.', $this->platform->getIdentifierSeparator()); } - public function testGetName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getName(): void { - self::assertEquals('SQL92', $this->platform->getName()); + static::assertSame('SQL92', $this->platform->getName()); } - public function testGetQuoteIdentifierSymbol(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQuoteIdentifierSymbol(): void { - self::assertEquals('"', $this->platform->getQuoteIdentifierSymbol()); + static::assertSame('"', $this->platform->getQuoteIdentifierSymbol()); } - public function testGetQuoteValueSymbol(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getQuoteValueSymbol(): void { - self::assertEquals("'", $this->platform->getQuoteValueSymbol()); + static::assertSame("'", $this->platform->getQuoteValueSymbol()); } - public function testQuoteIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteIdentifier(): void { - self::assertEquals('"identifier"', $this->platform->quoteIdentifier('identifier')); + static::assertSame('"identifier"', $this->platform->quoteIdentifier('identifier')); } - public function testQuoteIdentifierChain(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteIdentifierChain(): void { - self::assertEquals('"identifier"', $this->platform->quoteIdentifierChain('identifier')); - self::assertEquals('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); - self::assertEquals('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); + static::assertSame('"identifier"', $this->platform->quoteIdentifierChain('identifier')); + static::assertSame('"identifier"', $this->platform->quoteIdentifierChain(['identifier'])); + static::assertSame('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); } - public function testQuoteIdentifierInFragment(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteIdentifierInFragment(): void { - self::assertEquals('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar')); - self::assertEquals('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); + static::assertSame('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar')); + static::assertSame('"foo" as "bar"', $this->platform->quoteIdentifierInFragment('foo as bar')); // single char words - self::assertEquals( + static::assertSame( '("foo"."bar" = "boo"."baz")', $this->platform->quoteIdentifierInFragment('(foo.bar = boo.baz)', ['(', ')', '=']), ); // case insensitive safe words - self::assertEquals( + static::assertSame( '("foo"."bar" = "boo"."baz") AND ("foo"."baz" = "boo"."baz")', $this->platform->quoteIdentifierInFragment( '(foo.bar = boo.baz) AND (foo.baz = boo.baz)', @@ -107,7 +116,7 @@ public function testQuoteIdentifierInFragment(): void ); // case insensitive safe words in field - self::assertEquals( + static::assertSame( '("foo"."bar" = "boo".baz) AND ("foo".baz = "boo".baz)', $this->platform->quoteIdentifierInFragment( '(foo.bar = boo.baz) AND (foo.baz = boo.baz)', @@ -116,69 +125,76 @@ public function testQuoteIdentifierInFragment(): void ); } - public function testQuoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled(): void { $platform = new TestSql92Platform(quoteIdentifiers: false); - self::assertSame('foo.bar', $platform->quoteIdentifierInFragment('foo.bar')); + static::assertSame('foo.bar', $platform->quoteIdentifierInFragment('foo.bar')); } - public function testQuoteIdentifierReturnsUnquotedWhenQuotingDisabled(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteIdentifierReturnsUnquotedWhenQuotingDisabled(): void { $platform = new TestSql92Platform(quoteIdentifiers: false); - self::assertSame('test', $platform->quoteIdentifier('test')); + static::assertSame('test', $platform->quoteIdentifier('test')); } - public function testQuoteTrustedValueEscapesSpecialCharacters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteTrustedValueEscapesSpecialCharacters(): void { - self::assertEquals("'value'", $this->platform->quoteTrustedValue('value')); - self::assertEquals("'Foo O\\'Bar'", $this->platform->quoteTrustedValue("Foo O'Bar")); - self::assertEquals( + static::assertSame("'value'", $this->platform->quoteTrustedValue('value')); + static::assertSame("'Foo O\\'Bar'", $this->platform->quoteTrustedValue("Foo O'Bar")); + static::assertSame( '\'\\\'; DELETE FROM some_table; -- \'', $this->platform->quoteTrustedValue("'; DELETE FROM some_table; -- "), ); // '\\\'; DELETE FROM some_table; -- ' <- actual below - self::assertEquals( + static::assertSame( "'\\\\\\'; DELETE FROM some_table; -- '", $this->platform->quoteTrustedValue('\\\'; DELETE FROM some_table; -- '), ); } - public function testQuoteValueEscapesSpecialCharacters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteValueEscapesSpecialCharacters(): void { $platform = new TestSql92Platform(driver: $this->createStub(DriverInterface::class)); $quoted = $platform->quoteValue("test'value"); - self::assertStringContainsString('test', $quoted); - self::assertStringStartsWith("'", $quoted); - self::assertStringEndsWith("'", $quoted); + static::assertStringContainsString('test', $quoted); + static::assertStringStartsWith("'", $quoted); + static::assertStringEndsWith("'", $quoted); } - public function testQuoteValueListThrowsWithoutDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteValueListThrowsWithoutDriver(): void { $this->expectException(RuntimeException::class); - self::assertEquals("'Foo O\\'Bar'", $this->platform->quoteValueList("Foo O'Bar")); + static::assertSame("'Foo O\\'Bar'", $this->platform->quoteValueList("Foo O'Bar")); } - public function testQuoteValueRaisesNoticeWithoutPlatformSupport(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteValueRaisesNoticeWithoutPlatformSupport(): void { $this->expectException(RuntimeException::class); $this->platform->quoteValue('value'); } - public function testQuoteValueThrowsWithoutDriver(): void + #[\PHPUnit\Framework\Attributes\Test] + public function quoteValueThrowsWithoutDriver(): void { $this->expectException(RuntimeException::class); - self::assertEquals("'value'", @$this->platform->quoteValue('value')); - self::assertEquals("'Foo O\\'Bar'", @$this->platform->quoteValue("Foo O'Bar")); - self::assertEquals( + static::assertSame("'value'", @$this->platform->quoteValue('value')); + static::assertSame("'Foo O\\'Bar'", @$this->platform->quoteValue("Foo O'Bar")); + static::assertSame( '\'\\\'; DELETE FROM some_table; -- \'', @$this->platform->quoteValue("'; DELETE FROM some_table; -- "), ); - self::assertEquals( + static::assertSame( "'\\\\\\'; DELETE FROM some_table; -- '", @$this->platform->quoteValue('\\\'; DELETE FROM some_table; -- '), ); diff --git a/test/unit/Adapter/Profiler/ProfilerTest.php b/test/unit/Adapter/Profiler/ProfilerTest.php index ff1d6117..a794e9bd 100644 --- a/test/unit/Adapter/Profiler/ProfilerTest.php +++ b/test/unit/Adapter/Profiler/ProfilerTest.php @@ -24,33 +24,36 @@ final class ProfilerTest extends TestCase { protected Profiler $profiler; - public function testGetLastProfileReturnsSqlAndTimings(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLastProfileReturnsSqlAndTimings(): void { $this->profiler->profilerStart('SELECT * FROM FOO'); $this->profiler->profilerFinish(); $profile = $this->profiler->getLastProfile(); - self::assertEquals('SELECT * FROM FOO', $profile['sql']); - self::assertNull($profile['parameters']); - self::assertIsFloat($profile['start']); - self::assertIsFloat($profile['end']); - self::assertIsFloat($profile['elapse']); + static::assertSame('SELECT * FROM FOO', $profile['sql']); + static::assertNull($profile['parameters']); + static::assertIsFloat($profile['start']); + static::assertIsFloat($profile['end']); + static::assertIsFloat($profile['elapse']); } - public function testGetProfilesReturnsAllRecordedProfiles(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getProfilesReturnsAllRecordedProfiles(): void { $this->profiler->profilerStart('SELECT * FROM FOO1'); $this->profiler->profilerFinish(); $this->profiler->profilerStart('SELECT * FROM FOO2'); $this->profiler->profilerFinish(); - self::assertCount(2, $this->profiler->getProfiles()); + static::assertCount(2, $this->profiler->getProfiles()); } - public function testProfilerFinishThrowsWithoutStart(): void + #[\PHPUnit\Framework\Attributes\Test] + public function profilerFinishThrowsWithoutStart(): void { $this->profiler->profilerStart('SELECT * FROM FOO'); $ret = $this->profiler->profilerFinish(); - self::assertSame($this->profiler, $ret); + static::assertSame($this->profiler, $ret); $profiler = new Profiler(); self::expectException(RuntimeException::class); @@ -58,7 +61,8 @@ public function testProfilerFinishThrowsWithoutStart(): void $profiler->profilerFinish(); } - public function testProfilerStartClonesParameterContainerFromStatementContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function profilerStartClonesParameterContainerFromStatementContainer(): void { $parameterContainer = new ParameterContainer(['key' => 'value']); $statementContainer = new StatementContainer('SELECT ?', $parameterContainer); @@ -68,21 +72,23 @@ public function testProfilerStartClonesParameterContainerFromStatementContainer( $profile = $this->profiler->getLastProfile(); - self::assertSame('SELECT ?', $profile['sql']); - self::assertInstanceOf(ParameterContainer::class, $profile['parameters']); - self::assertNotSame($parameterContainer, $profile['parameters']); + static::assertSame('SELECT ?', $profile['sql']); + static::assertInstanceOf(ParameterContainer::class, $profile['parameters']); + static::assertNotSame($parameterContainer, $profile['parameters']); } - public function testProfilerStartWithStatementContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function profilerStartWithStatementContainer(): void { $ret = $this->profiler->profilerStart(new StatementContainer()); - self::assertSame($this->profiler, $ret); + static::assertSame($this->profiler, $ret); } - public function testProfilerStartWithString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function profilerStartWithString(): void { $ret = $this->profiler->profilerStart('SELECT * FROM FOO'); - self::assertSame($this->profiler, $ret); + static::assertSame($this->profiler, $ret); } /** diff --git a/test/unit/Adapter/StatementContainerTest.php b/test/unit/Adapter/StatementContainerTest.php index 9436bc08..3aacd102 100644 --- a/test/unit/Adapter/StatementContainerTest.php +++ b/test/unit/Adapter/StatementContainerTest.php @@ -18,38 +18,42 @@ #[CoversMethod(StatementContainer::class, 'getParameterContainer')] final class StatementContainerTest extends TestCase { - public function testConstructorWithoutSqlDoesNotSetSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithoutSqlDoesNotSetSql(): void { $container = new StatementContainer(); - self::assertSame('', $container->getSql()); + static::assertSame('', $container->getSql()); } - public function testConstructorWithSqlSetsSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSqlSetsSql(): void { $container = new StatementContainer('SELECT 1'); - self::assertSame('SELECT 1', $container->getSql()); + static::assertSame('SELECT 1', $container->getSql()); } - public function testSetAndGetParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAndGetParameterContainer(): void { $container = new StatementContainer(); $parameterContainer = new ParameterContainer(['a' => 1]); $result = $container->setParameterContainer($parameterContainer); - self::assertSame($container, $result); - self::assertSame($parameterContainer, $container->getParameterContainer()); + static::assertSame($container, $result); + static::assertSame($parameterContainer, $container->getParameterContainer()); } - public function testSetAndGetSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAndGetSql(): void { $container = new StatementContainer(); $result = $container->setSql('test'); - self::assertSame($container, $result); - self::assertSame('test', $container->getSql()); + static::assertSame($container, $result); + static::assertSame('test', $container->getSql()); } } diff --git a/test/unit/ConfigProviderTest.php b/test/unit/ConfigProviderTest.php index 8d3b7eb3..3639c7e4 100644 --- a/test/unit/ConfigProviderTest.php +++ b/test/unit/ConfigProviderTest.php @@ -47,8 +47,9 @@ public function getDependenciesIsCallableAsPartOfThePublicApi(): void static::assertEquals($this->config['dependencies'], (new ConfigProvider())->getDependencies()); } - public function testInvocationProvidesDependencyConfiguration(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invocationProvidesDependencyConfiguration(): void { - self::assertEquals($this->config, (new ConfigProvider())()); + static::assertEquals($this->config, (new ConfigProvider())()); } } diff --git a/test/unit/Container/AdapterInterfaceFactoryTest.php b/test/unit/Container/AdapterInterfaceFactoryTest.php index 29dc54c5..a8d7a40d 100644 --- a/test/unit/Container/AdapterInterfaceFactoryTest.php +++ b/test/unit/Container/AdapterInterfaceFactoryTest.php @@ -22,7 +22,8 @@ #[CoversMethod(AdapterInterfaceFactory::class, '__invoke')] final class AdapterInterfaceFactoryTest extends TestCase { - public function testInvokeCreatesAdapterWithAllDependencies(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesAdapterWithAllDependencies(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -46,10 +47,11 @@ public function testInvokeCreatesAdapterWithAllDependencies(): void $factory = new AdapterInterfaceFactory(); $adapter = $factory($container, AdapterInterface::class); - self::assertInstanceOf(Adapter::class, $adapter); + static::assertInstanceOf(Adapter::class, $adapter); } - public function testInvokeCreatesAdapterWithDefaultResultSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesAdapterWithDefaultResultSet(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -69,10 +71,11 @@ public function testInvokeCreatesAdapterWithDefaultResultSet(): void $factory = new AdapterInterfaceFactory(); $adapter = $factory($container, AdapterInterface::class); - self::assertInstanceOf(ResultSet::class, $adapter->getQueryResultSetPrototype()); + static::assertInstanceOf(ResultSet::class, $adapter->getQueryResultSetPrototype()); } - public function testInvokeCreatesAdapterWithoutOptionalProfiler(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesAdapterWithoutOptionalProfiler(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -92,11 +95,12 @@ public function testInvokeCreatesAdapterWithoutOptionalProfiler(): void $factory = new AdapterInterfaceFactory(); $adapter = $factory($container, AdapterInterface::class); - self::assertInstanceOf(Adapter::class, $adapter); - self::assertNull($adapter->getProfiler()); + static::assertInstanceOf(Adapter::class, $adapter); + static::assertNull($adapter->getProfiler()); } - public function testInvokeThrowsWhenAdapterConfigIsEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeThrowsWhenAdapterConfigIsEmpty(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -116,7 +120,8 @@ public function testInvokeThrowsWhenAdapterConfigIsEmpty(): void $factory($container, AdapterInterface::class); } - public function testInvokeThrowsWhenContainerHasNoConfig(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeThrowsWhenContainerHasNoConfig(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); diff --git a/test/unit/Container/TableIdentifierFactoryFactoryTest.php b/test/unit/Container/TableIdentifierFactoryFactoryTest.php index af57a627..02cd881c 100644 --- a/test/unit/Container/TableIdentifierFactoryFactoryTest.php +++ b/test/unit/Container/TableIdentifierFactoryFactoryTest.php @@ -17,7 +17,8 @@ #[CoversMethod(TableIdentifierFactoryFactory::class, '__invoke')] final class TableIdentifierFactoryFactoryTest extends TestCase { - public function testInvokeCreatesFactoryWithConfiguredPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithConfiguredPrefix(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -29,10 +30,11 @@ public function testInvokeCreatesFactoryWithConfiguredPrefix(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertSame('backup', $result->getPrefix()); + static::assertSame('backup', $result->getPrefix()); } - public function testInvokeCreatesFactoryWithConfiguredSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithConfiguredSeparator(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -45,10 +47,11 @@ public function testInvokeCreatesFactoryWithConfiguredSeparator(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertSame('__', $result->getSeparator()); + static::assertSame('__', $result->getSeparator()); } - public function testInvokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -60,11 +63,12 @@ public function testInvokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); - self::assertSame('__', $result->getSeparator()); + static::assertNull($result->getPrefix()); + static::assertSame('__', $result->getSeparator()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void { $container = new ServiceManager(); $container->setService('config', []); @@ -72,10 +76,11 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void { $container = $this->createMock(ContainerInterface::class); $container->method('has')->with('config')->willReturn(true); @@ -84,20 +89,22 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig(): void { $container = new ServiceManager(); $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -107,10 +114,11 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): vo $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeRejectsEmptyStringSeparatorFromConfig(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeRejectsEmptyStringSeparatorFromConfig(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -126,7 +134,8 @@ public function testInvokeRejectsEmptyStringSeparatorFromConfig(): void $factory($container); } - public function testInvokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function invokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -138,6 +147,6 @@ public function testInvokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertSame('_', $result->getSeparator()); + static::assertSame('_', $result->getSeparator()); } } diff --git a/test/unit/DeprecatedAssertionsTrait.php b/test/unit/DeprecatedAssertionsTrait.php index 7e0b2c0c..0b3d0eea 100644 --- a/test/unit/DeprecatedAssertionsTrait.php +++ b/test/unit/DeprecatedAssertionsTrait.php @@ -27,6 +27,19 @@ public static function assertAttributeEquals( Assert::assertEquals($expected, $r->getValue($instance), $message); } + /** + * @throws ReflectionException + */ + public static function assertAttributeSame( + mixed $expected, + string $attribute, + object $instance, + string $message = '', + ): void { + $r = new ReflectionProperty($instance, $attribute); + Assert::assertSame($expected, $r->getValue($instance), $message); + } + /** * @throws ReflectionException */ diff --git a/test/unit/ResultSet/AbstractResultSetIntegrationTest.php b/test/unit/ResultSet/AbstractResultSetIntegrationTest.php index df7045cb..c810f213 100644 --- a/test/unit/ResultSet/AbstractResultSetIntegrationTest.php +++ b/test/unit/ResultSet/AbstractResultSetIntegrationTest.php @@ -20,7 +20,8 @@ final class AbstractResultSetIntegrationTest extends TestCase /** * @throws \Exception */ - public function testCurrentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); $this->resultSet->initialize($result); @@ -29,13 +30,14 @@ public function testCurrentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): voi $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); - self::assertEquals($value1, $value2); + static::assertEquals($value1, $value2); } /** * @throws \Exception */ - public function testCurrentCallsDataSourceCurrentOnceWithBuffer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentCallsDataSourceCurrentOnceWithBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); $this->resultSet->buffer(); @@ -45,7 +47,7 @@ public function testCurrentCallsDataSourceCurrentOnceWithBuffer(): void $value1 = $this->resultSet->current(); $value2 = $this->resultSet->current(); $this->resultSet->current(); - self::assertEquals($value1, $value2); + static::assertEquals($value1, $value2); } /** diff --git a/test/unit/ResultSet/AbstractResultSetTest.php b/test/unit/ResultSet/AbstractResultSetTest.php index 93d5fd4b..14ce51ca 100644 --- a/test/unit/ResultSet/AbstractResultSetTest.php +++ b/test/unit/ResultSet/AbstractResultSetTest.php @@ -42,11 +42,12 @@ final class AbstractResultSetTest extends TestCase /** * @throws Exception */ - public function testBuffer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function buffer(): void { $resultSet = $this->createResultSetMock(); // Verify buffer() returns fluent interface - self::assertSame($resultSet, $resultSet->buffer()); + static::assertSame($resultSet, $resultSet->buffer()); $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -66,8 +67,9 @@ public function testBuffer(): void * * @throws Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('issue-6845')] - public function testBufferIterations(): void + public function bufferIterations(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -79,39 +81,25 @@ public function testBufferIterations(): void // Iterate through rows and verify data $data = $resultSet->current(); - self::assertEquals(1, $data['id']); + static::assertSame(1, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(2, $data['id']); + static::assertSame(2, $data['id']); // Rewind and iterate again to verify buffering allows rewind $resultSet->rewind(); $data = $resultSet->current(); - self::assertEquals(1, $data['id']); + static::assertSame(1, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(2, $data['id']); + static::assertSame(2, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(3, $data['id']); + static::assertSame(3, $data['id']); } - /** - * @throws Exception - */ - public function testCount(): void - { - $resultSet = $this->createResultSetMock(); - $resultSet->initialize(new ArrayIterator([ - ['id' => 1, 'name' => 'one'], - ['id' => 2, 'name' => 'two'], - ['id' => 3, 'name' => 'three'], - ])); - // Verify count() returns total number of rows - self::assertEquals(3, $resultSet->count()); - } - - public function testCountReturnsCachedResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countReturnsCachedResult(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize([['id' => 1], ['id' => 2]]); @@ -119,23 +107,41 @@ public function testCountReturnsCachedResult(): void $first = $resultSet->count(); $second = $resultSet->count(); - self::assertSame(2, $first); - self::assertSame($first, $second); + static::assertSame(2, $first); + static::assertSame($first, $second); } - public function testCountReturnsNullForUncountableDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countReturnsNullForUncountableDataSource(): void { $resultSet = $this->createResultSetMock(); $iterator = new NoRewindIterator(new ArrayIterator([['id' => 1]])); $resultSet->initialize($iterator); - self::assertNull($resultSet->count()); + static::assertNull($resultSet->count()); } /** * @throws Exception */ - public function testCurrent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countsRowsInDataSource(): void + { + $resultSet = $this->createResultSetMock(); + $resultSet->initialize(new ArrayIterator([ + ['id' => 1, 'name' => 'one'], + ['id' => 2, 'name' => 'two'], + ['id' => 3, 'name' => 'three'], + ])); + // Verify count() returns total number of rows + static::assertSame(3, $resultSet->count()); + } + + /** + * @throws Exception + */ + #[\PHPUnit\Framework\Attributes\Test] + public function current(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -144,10 +150,11 @@ public function testCurrent(): void ['id' => 3, 'name' => 'three'], ])); // Verify current() returns the current row - self::assertEquals(['id' => 1, 'name' => 'one'], $resultSet->current()); + static::assertEquals(['id' => 1, 'name' => 'one'], $resultSet->current()); } - public function testCurrentReturnsBufferedDataOnSecondPass(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsBufferedDataOnSecondPass(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -168,13 +175,14 @@ public function testCurrentReturnsBufferedDataOnSecondPass(): void $secondPass[] = $row; } - self::assertEquals($firstPass, $secondPass); + static::assertEquals($firstPass, $secondPass); } /** * @throws Exception */ - public function testGetDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDataSource(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -183,23 +191,25 @@ public function testGetDataSource(): void ['id' => 3, 'name' => 'three'], ])); // Verify getDataSource() returns the initialized iterator - self::assertInstanceOf(ArrayIterator::class, $resultSet->getDataSource()); + static::assertInstanceOf(ArrayIterator::class, $resultSet->getDataSource()); } /** * @throws Exception */ - public function testGetFieldCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCount(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ ['id' => 1, 'name' => 'one'], ])); // Verify getFieldCount() returns number of columns in current row - self::assertEquals(2, $resultSet->getFieldCount()); + static::assertSame(2, $resultSet->getFieldCount()); } - public function testGetFieldCountReturnsCachedValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCountReturnsCachedValue(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize([['a' => 1, 'b' => 2]]); @@ -207,42 +217,46 @@ public function testGetFieldCountReturnsCachedValue(): void $first = $resultSet->getFieldCount(); $second = $resultSet->getFieldCount(); - self::assertSame(2, $first); - self::assertSame($first, $second); + static::assertSame(2, $first); + static::assertSame($first, $second); } - public function testGetFieldCountReturnsZeroForEmptyIterator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCountReturnsZeroForEmptyIterator(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([])); - self::assertSame(0, $resultSet->getFieldCount()); + static::assertSame(0, $resultSet->getFieldCount()); } - public function testGetFieldCountReturnsZeroWithNoDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCountReturnsZeroWithNoDataSource(): void { $resultSet = $this->createResultSetMock(); - self::assertSame(0, $resultSet->getFieldCount()); + static::assertSame(0, $resultSet->getFieldCount()); } - public function testGetFieldCountWithCountableRow(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFieldCountWithCountableRow(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([new ArrayObject(['a' => 1, 'b' => 2, 'c' => 3])])); - self::assertSame(3, $resultSet->getFieldCount()); + static::assertSame(3, $resultSet->getFieldCount()); } /** * @throws Exception */ - public function testInitialize(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initialize(): void { $resultSet = $this->createResultSetMock(); // Verify initialize() accepts array data and returns fluent interface - self::assertSame($resultSet, $resultSet->initialize([ + static::assertSame($resultSet, $resultSet->initialize([ ['id' => 1, 'name' => 'one'], ['id' => 2, 'name' => 'two'], ['id' => 3, 'name' => 'three'], @@ -257,7 +271,8 @@ public function testInitialize(): void /** * @throws Exception */ - public function testInitializeDoesNotCallCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeDoesNotCallCount(): void { $resultSet = $this->createResultSetMock(); $result = $this->getMockBuilder(ResultInterface::class)->onlyMethods([])->getMock(); @@ -269,7 +284,8 @@ public function testInitializeDoesNotCallCount(): void /** * @throws Exception */ - public function testInitializeResetsBufferWhenAlreadyBuffered(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeResetsBufferWhenAlreadyBuffered(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([['id' => 1]])); @@ -277,10 +293,11 @@ public function testInitializeResetsBufferWhenAlreadyBuffered(): void $resultSet->initialize(new ArrayIterator([['id' => 2]])); - self::assertSame(2, $resultSet->current()['id']); + static::assertSame(2, $resultSet->current()['id']); } - public function testInitializeWithBufferedResultInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeWithBufferedResultInterface(): void { $result = $this->createMock(ResultInterface::class); $result->method('isBuffered')->willReturn(true); @@ -289,23 +306,25 @@ public function testInitializeWithBufferedResultInterface(): void $resultSet = $this->createResultSetMock(); $resultSet->initialize($result); - self::assertTrue($resultSet->isBuffered()); + static::assertTrue($resultSet->isBuffered()); } /** * @throws Exception */ - public function testInitializeWithEmptyArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeWithEmptyArray(): void { $resultSet = $this->createResultSetMock(); // Verify initialize() accepts empty array - self::assertSame($resultSet, $resultSet->initialize([])); + static::assertSame($resultSet, $resultSet->initialize([])); } /** * @throws Exception */ - public function testInitializeWithIteratorAggregate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeWithIteratorAggregate(): void { $resultSet = $this->createResultSetMock(); $aggregate = new class implements IteratorAggregate { @@ -317,13 +336,14 @@ public function getIterator(): ArrayIterator $resultSet->initialize($aggregate); - self::assertSame(1, $resultSet->current()['id']); + static::assertSame(1, $resultSet->current()['id']); } /** * @throws Exception */ - public function testInitializeWithResultInterfaceRewindsWhenBuffered(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeWithResultInterfaceRewindsWhenBuffered(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([['id' => 1]])); @@ -337,20 +357,22 @@ public function testInitializeWithResultInterfaceRewindsWhenBuffered(): void $resultSet->initialize($result); } - public function testIsBuffered(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isBuffered(): void { $resultSet = $this->createResultSetMock(); // Verify buffering is disabled by default - self::assertFalse($resultSet->isBuffered()); + static::assertFalse($resultSet->isBuffered()); $resultSet->buffer(); // Verify buffering is enabled after buffer() call - self::assertTrue($resultSet->isBuffered()); + static::assertTrue($resultSet->isBuffered()); } /** * @throws Exception */ - public function testKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function key(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -360,11 +382,11 @@ public function testKey(): void ])); // Verify key() returns current iterator position $resultSet->next(); - self::assertEquals(1, $resultSet->key()); + static::assertSame(1, $resultSet->key()); $resultSet->next(); - self::assertEquals(2, $resultSet->key()); + static::assertSame(2, $resultSet->key()); $resultSet->next(); - self::assertEquals(3, $resultSet->key()); + static::assertSame(3, $resultSet->key()); } /** @@ -372,8 +394,9 @@ public function testKey(): void * * @throws Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('issue-6845')] - public function testMultipleRewindBufferIterations(): void + public function multipleRewindBufferIterations(): void { $resultSet = $this->createResultSetMock(); $result = new Result(); @@ -386,7 +409,7 @@ public function testMultipleRewindBufferIterations(): void assert($stub instanceof PDOStatement); // to suppress IDE type warnings $stub->expects($this->any()) ->method('fetch') - ->willReturnCallback(function () use ($data) { + ->willReturnCallback(static function () use ($data) { $r = $data->current(); $data->next(); return $r; @@ -402,29 +425,30 @@ public function testMultipleRewindBufferIterations(): void // Iterate through rows $data = $resultSet->current(); - self::assertEquals(1, $data['id']); + static::assertSame(1, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(2, $data['id']); + static::assertSame(2, $data['id']); // Rewind multiple times and iterate again to verify buffering handles multiple rewinds $resultSet->rewind(); $resultSet->rewind(); $data = $resultSet->current(); - self::assertEquals(1, $data['id']); + static::assertSame(1, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(2, $data['id']); + static::assertSame(2, $data['id']); $resultSet->next(); $data = $resultSet->current(); - self::assertEquals(3, $data['id']); + static::assertSame(3, $data['id']); } /** * @throws Exception */ - public function testNext(): void + #[\PHPUnit\Framework\Attributes\Test] + public function next(): void { $rows = [ ['id' => 1, 'name' => 'one'], @@ -436,15 +460,16 @@ public function testNext(): void $resultSet->initialize(new ArrayIterator($rows)); // Verify next() advances iterator position - self::assertSame(0, $resultSet->key()); + static::assertSame(0, $resultSet->key()); $resultSet->next(); - self::assertSame(1, $resultSet->key()); + static::assertSame(1, $resultSet->key()); } /** * @throws Exception */ - public function testRewindResetsIteratorPosition(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rewindResetsIteratorPosition(): void { $rows = [ ['id' => 1, 'name' => 'one'], @@ -456,15 +481,16 @@ public function testRewindResetsIteratorPosition(): void // Move forward to ensure position changes $this->resultSet->next(); - self::assertSame(1, $this->resultSet->key()); + static::assertSame(1, $this->resultSet->key()); // Verify rewind() resets iterator position and current row $this->resultSet->rewind(); - self::assertSame(0, $this->resultSet->key()); - self::assertEquals($rows[0], $this->resultSet->current()); + static::assertSame(0, $this->resultSet->key()); + static::assertEquals($rows[0], $this->resultSet->current()); } - public function testRewindWithNonIteratorDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rewindWithNonIteratorDataSource(): void { $resultSet = $this->createResultSetMock(); $aggregate = new class implements IteratorAggregate { @@ -478,13 +504,14 @@ public function getIterator(): ArrayIterator $resultSet->next(); $resultSet->rewind(); - self::assertSame(0, $resultSet->key()); + static::assertSame(0, $resultSet->key()); } /** * @throws Exception */ - public function testValid(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valid(): void { $resultSet = $this->createResultSetMock(); $resultSet->initialize(new ArrayIterator([ @@ -493,40 +520,12 @@ public function testValid(): void ['id' => 3, 'name' => 'three'], ])); // Verify valid() returns true when iterator is at valid position - self::assertTrue($resultSet->valid()); + static::assertTrue($resultSet->valid()); $resultSet->next(); $resultSet->next(); $resultSet->next(); // Verify valid() returns false after iterating past last element - self::assertFalse($resultSet->valid()); - } - - public function testValidReturnsFalseAfterLastElement(): void - { - $resultSet = $this->createResultSetMock(); - $resultSet->initialize(new ArrayIterator([ - ['id' => 1], - ])); - - self::assertTrue($resultSet->valid()); - $resultSet->next(); - self::assertFalse($resultSet->valid()); - } - - public function testValidWithNonIteratorDataSource(): void - { - $resultSet = $this->createResultSetMock(); - $aggregate = new class implements IteratorAggregate { - public function getIterator(): ArrayIterator - { - return new ArrayIterator([['id' => 1]]); - } - }; - - $resultSet->initialize($aggregate); - $resultSet->rewind(); - - self::assertTrue($resultSet->valid()); + static::assertFalse($resultSet->valid()); } /** @@ -546,6 +545,19 @@ public function validAnswersFromTheBufferAfterTheDataSourceIsExhausted(): void static::assertTrue($resultSet->valid()); } + #[\PHPUnit\Framework\Attributes\Test] + public function validReturnsFalseAfterLastElement(): void + { + $resultSet = $this->createResultSetMock(); + $resultSet->initialize(new ArrayIterator([ + ['id' => 1], + ])); + + static::assertTrue($resultSet->valid()); + $resultSet->next(); + static::assertFalse($resultSet->valid()); + } + /** * @throws Exception */ @@ -558,6 +570,23 @@ public function validReturnsFalseBeyondTheEndOfTheBuffer(): void static::assertFalse($resultSet->valid()); } + #[\PHPUnit\Framework\Attributes\Test] + public function validWithNonIteratorDataSource(): void + { + $resultSet = $this->createResultSetMock(); + $aggregate = new class implements IteratorAggregate { + public function getIterator(): ArrayIterator + { + return new ArrayIterator([['id' => 1]]); + } + }; + + $resultSet->initialize($aggregate); + $resultSet->rewind(); + + static::assertTrue($resultSet->valid()); + } + /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. diff --git a/test/unit/ResultSet/HydratingResultSetIntegrationTest.php b/test/unit/ResultSet/HydratingResultSetIntegrationTest.php index 1a093833..4d8676e7 100644 --- a/test/unit/ResultSet/HydratingResultSetIntegrationTest.php +++ b/test/unit/ResultSet/HydratingResultSetIntegrationTest.php @@ -16,7 +16,8 @@ class HydratingResultSetIntegrationTest extends TestCase /** * @throws Exception */ - public function testCurrentWillReturnBufferedRow(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentWillReturnBufferedRow(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -29,6 +30,6 @@ public function testCurrentWillReturnBufferedRow(): void $obj1 = $hydratingRs->current(); $hydratingRs->rewind(); $obj2 = $hydratingRs->current(); - self::assertSame($obj1, $obj2); + static::assertSame($obj1, $obj2); } } diff --git a/test/unit/ResultSet/HydratingResultSetTest.php b/test/unit/ResultSet/HydratingResultSetTest.php index bc0d56f7..c5729679 100644 --- a/test/unit/ResultSet/HydratingResultSetTest.php +++ b/test/unit/ResultSet/HydratingResultSetTest.php @@ -33,14 +33,16 @@ final class HydratingResultSetTest extends TestCase private string $classMethodsHydratorClass; - public function testConstructorDefaultsToArraySerializableHydrator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorDefaultsToArraySerializableHydrator(): void { $hydratingRs = new HydratingResultSet(); - self::assertInstanceOf(ArraySerializableHydrator::class, $hydratingRs->getHydrator()); + static::assertInstanceOf(ArraySerializableHydrator::class, $hydratingRs->getHydrator()); } - public function testCurrentDisablesBufferingImplicitly(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentDisablesBufferingImplicitly(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -56,20 +58,22 @@ public function testCurrentDisablesBufferingImplicitly(): void /** * @throws Exception */ - public function testCurrentDoesnotHasData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentDoesnotHasData(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([]); // Verify current() returns null when no data exists $result = $hydratingRs->current(); - self::assertNull($result); + static::assertNull($result); } /** * @throws Exception */ - public function testCurrentHasData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentHasData(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -77,10 +81,11 @@ public function testCurrentHasData(): void ]); // Verify current() returns hydrated object when data exists $obj = $hydratingRs->current(); - self::assertInstanceOf('ArrayObject', $obj); + static::assertInstanceOf('ArrayObject', $obj); } - public function testCurrentWithBufferReturnsBufferedObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentWithBufferReturnsBufferedObject(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -93,31 +98,35 @@ public function testCurrentWithBufferReturnsBufferedObject(): void $hydratingRs->rewind(); $buffered = $hydratingRs->current(); - self::assertSame($first, $buffered); + static::assertSame($first, $buffered); } - public function testGetHydrator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getHydrator(): void { $hydratingRs = new HydratingResultSet(); // Verify getHydrator() returns default ArraySerializable hydrator - self::assertInstanceOf($this->arraySerializableHydratorClass, $hydratingRs->getHydrator()); + static::assertInstanceOf($this->arraySerializableHydratorClass, $hydratingRs->getHydrator()); } - public function testGetObjectPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getObjectPrototype(): void { $hydratingRs = new HydratingResultSet(); // Verify getObjectPrototype() returns default ArrayObject prototype - self::assertInstanceOf('ArrayObject', $hydratingRs->getObjectPrototype()); + static::assertInstanceOf('ArrayObject', $hydratingRs->getObjectPrototype()); } - public function testGetRowPrototypeReturnsDefaultArrayObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRowPrototypeReturnsDefaultArrayObject(): void { $hydratingRs = new HydratingResultSet(); - self::assertInstanceOf(ArrayObject::class, $hydratingRs->getRowPrototype()); + static::assertInstanceOf(ArrayObject::class, $hydratingRs->getRowPrototype()); } - public function testSetHydrator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setHydrator(): void { $hydratingRs = new HydratingResultSet(); $hydratorClass1 = $this->classMethodsHydratorClass; @@ -130,20 +139,21 @@ public function testSetHydrator(): void $result = $hydratingRs->setHydrator($hydrator1); // Verify fluent interface - self::assertSame($hydratingRs, $result); + static::assertSame($hydratingRs, $result); // Verify the first mutation occurred - self::assertSame($hydrator1, $hydratingRs->getHydrator()); + static::assertSame($hydrator1, $hydratingRs->getHydrator()); // Second mutation to verify mutability $hydratingRs->setHydrator($hydrator2); // Verify the instance was actually mutated - self::assertSame($hydrator2, $hydratingRs->getHydrator()); - self::assertNotSame($hydrator1, $hydratingRs->getHydrator()); + static::assertSame($hydrator2, $hydratingRs->getHydrator()); + static::assertNotSame($hydrator1, $hydratingRs->getHydrator()); } - public function testSetObjectPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setObjectPrototype(): void { $prototype1 = new stdClass(); $prototype1->property1 = 'value1'; @@ -155,35 +165,37 @@ public function testSetObjectPrototype(): void $result = $hydratingRs->setObjectPrototype($prototype1); // Verify fluent interface - self::assertSame($hydratingRs, $result); + static::assertSame($hydratingRs, $result); // Verify the first mutation occurred - self::assertSame($prototype1, $hydratingRs->getObjectPrototype()); + static::assertSame($prototype1, $hydratingRs->getObjectPrototype()); // Second mutation to verify mutability $hydratingRs->setObjectPrototype($prototype2); // Verify the instance was actually mutated - self::assertSame($prototype2, $hydratingRs->getObjectPrototype()); - self::assertNotSame($prototype1, $hydratingRs->getObjectPrototype()); + static::assertSame($prototype2, $hydratingRs->getObjectPrototype()); + static::assertNotSame($prototype1, $hydratingRs->getObjectPrototype()); } - public function testSetRowPrototypeStoresPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setRowPrototypeStoresPrototype(): void { $hydratingRs = new HydratingResultSet(); $prototype = new stdClass(); $result = $hydratingRs->setRowPrototype($prototype); - self::assertSame($hydratingRs, $result); - self::assertSame($prototype, $hydratingRs->getRowPrototype()); + static::assertSame($hydratingRs, $result); + static::assertSame($prototype, $hydratingRs->getRowPrototype()); } /** * @throws Exception * @todo Implement testToArray(). */ - public function testToArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function toArray(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -191,10 +203,11 @@ public function testToArray(): void ]); // Verify toArray() returns array of hydrated objects $obj = $hydratingRs->toArray(); - self::assertIsArray($obj); + static::assertIsArray($obj); } - public function testToArrayUsesHydratorExtract(): void + #[\PHPUnit\Framework\Attributes\Test] + public function toArrayUsesHydratorExtract(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -203,9 +216,9 @@ public function testToArrayUsesHydratorExtract(): void $result = $hydratingRs->toArray(); - self::assertCount(1, $result); - self::assertArrayHasKey('id', $result[0]); - self::assertSame(1, $result[0]['id']); + static::assertCount(1, $result); + static::assertArrayHasKey('id', $result[0]); + static::assertSame(1, $result[0]['id']); } #[Override] diff --git a/test/unit/ResultSet/ResultSetIntegrationTest.php b/test/unit/ResultSet/ResultSetIntegrationTest.php index f25fd173..83c7e7e4 100644 --- a/test/unit/ResultSet/ResultSetIntegrationTest.php +++ b/test/unit/ResultSet/ResultSetIntegrationTest.php @@ -54,24 +54,12 @@ public static function invalidReturnTypes(): array ]; } - public function getArrayDataSource(int $count): ArrayIterator - { - $array = []; - for ($i = 0; $i < $count; $i++) { - $array[] = [ - 'id' => $i, - 'title' => 'title ' . $i, - ]; - } - - return new ArrayIterator($array); - } - /** * @throws Exception * @throws \Exception */ - public function testBufferCalledAfterIterationThrowsException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function bufferCalledAfterIterationThrowsException(): void { $this->resultSet->initialize($this->createMock(ResultInterface::class)); $this->resultSet->current(); @@ -85,26 +73,28 @@ public function testBufferCalledAfterIterationThrowsException(): void /** * @throws \Exception */ - public function testCanProvideArrayAsDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canProvideArrayAsDataSource(): void { $dataSource = [['foo']]; // Initialize with array data source and verify current row $this->resultSet->initialize($dataSource); - $this->assertEquals($dataSource[0], (array) $this->resultSet->current()); + static::assertEquals($dataSource[0], (array) $this->resultSet->current()); $returnType = new ArrayObject([], ArrayObject::ARRAY_AS_PROPS); $dataSource = [$returnType]; // Test with custom ArrayObject prototype $this->resultSet->setArrayObjectPrototype($returnType); $this->resultSet->initialize($dataSource); - $this->assertEquals($dataSource[0], $this->resultSet->current()); - $this->assertContains($dataSource[0], $this->resultSet); + static::assertEquals($dataSource[0], $this->resultSet->current()); + static::assertContains($dataSource[0], $this->resultSet); } /** * @throws \Exception */ - public function testCanProvideIteratorAggregateAsDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canProvideIteratorAggregateAsDataSource(): void { $iteratorAggregate = $this->getMockBuilder('IteratorAggregate') ->onlyMethods(['getIterator']) @@ -112,34 +102,37 @@ public function testCanProvideIteratorAggregateAsDataSource(): void $iteratorAggregate->expects($this->any())->method('getIterator')->willReturn($iteratorAggregate); // Initialize with IteratorAggregate and verify its iterator is used $this->resultSet->initialize($iteratorAggregate); - self::assertSame($iteratorAggregate->getIterator(), $this->resultSet->getDataSource()); + static::assertSame($iteratorAggregate->getIterator(), $this->resultSet->getDataSource()); } /** * @throws \Exception */ - public function testCanProvideIteratorAsDataSource(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canProvideIteratorAsDataSource(): void { $it = new SplStack(); // Initialize with iterator and verify it is stored as data source $this->resultSet->initialize($it); - self::assertSame($it, $this->resultSet->getDataSource()); + static::assertSame($it, $this->resultSet->getDataSource()); } /** * @throws RandomException * @throws \Exception */ - public function testCountReturnsCountOfRows(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countReturnsCountOfRows(): void { $count = random_int(3, 75); $dataSource = $this->getArrayDataSource($count); // Verify count() returns correct number of rows $this->resultSet->initialize($dataSource); - self::assertEquals($count, $this->resultSet->count()); + static::assertEquals($count, $this->resultSet->count()); } - public function testCurrentClonesRowPrototypeOnEachCall(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentClonesRowPrototypeOnEachCall(): void { $resultSet = new ResultSet(ResultSetReturnType::ArrayObject); $resultSet->initialize([ @@ -151,36 +144,39 @@ public function testCurrentClonesRowPrototypeOnEachCall(): void $resultSet->next(); $second = $resultSet->current(); - self::assertNotSame($first, $second); + static::assertNotSame($first, $second); } - public function testCurrentReturnsArrayObjectWhenReturnTypeIsArrayObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsArrayObjectWhenReturnTypeIsArrayObject(): void { $resultSet = new ResultSet(ResultSetReturnType::ArrayObject); $resultSet->initialize([['id' => 1, 'name' => 'one']]); $current = $resultSet->current(); - self::assertInstanceOf(ArrayObject::class, $current); - self::assertSame(1, $current['id']); + static::assertInstanceOf(ArrayObject::class, $current); + static::assertSame(1, $current['id']); } - public function testCurrentReturnsArrayWhenReturnTypeIsArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsArrayWhenReturnTypeIsArray(): void { $resultSet = new ResultSet(ResultSetReturnType::Array); $resultSet->initialize([['id' => 1, 'name' => 'one']]); $current = $resultSet->current(); - self::assertIsArray($current); - self::assertSame(1, $current['id']); + static::assertIsArray($current); + static::assertSame(1, $current['id']); } /** * @throws Exception * @throws \Exception */ - public function testCurrentReturnsNullForNonExistingValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsNullForNonExistingValues(): void { $mockResult = $this->createMock(ResultInterface::class); $mockResult->expects($this->once())->method('current')->willReturn('Not an Array'); @@ -189,13 +185,14 @@ public function testCurrentReturnsNullForNonExistingValues(): void $this->resultSet->buffer(); // Verify current() returns null when data source returns non-array value - self::assertNull($this->resultSet->current()); + static::assertNull($this->resultSet->current()); } /** * @throws \Exception */ - public function testCurrentWithBufferingCallsDataSourceCurrentOnce(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentWithBufferingCallsDataSourceCurrentOnce(): void { $mockResult = $this->getMockBuilder(ResultInterface::class)->getMock(); $mockResult->expects($this->once())->method('current')->willReturn(['foo' => 'bar']); @@ -209,50 +206,69 @@ public function testCurrentWithBufferingCallsDataSourceCurrentOnce(): void $this->resultSet->current(); } - public function testDataSourceIsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function dataSourceIsNullByDefault(): void { // Verify data source is null before initialization - self::assertNull($this->resultSet->getDataSource()); + static::assertNull($this->resultSet->getDataSource()); } - public function testFieldCountIsZeroWithNoDataSourcePresent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fieldCountIsZeroWithNoDataSourcePresent(): void { // Verify field count is 0 when no data source is set - self::assertEquals(0, $this->resultSet->getFieldCount()); + static::assertSame(0, $this->resultSet->getFieldCount()); } /** * @throws \Exception */ - public function testFieldCountRepresentsNumberOfFieldsInARowOfData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fieldCountRepresentsNumberOfFieldsInARowOfData(): void { $resultSet = new ResultSet(ResultSet::TYPE_ARRAY); $dataSource = $this->getArrayDataSource(10); // Verify field count matches number of columns in row data $resultSet->initialize($dataSource); - self::assertEquals(2, $resultSet->getFieldCount()); + static::assertSame(2, $resultSet->getFieldCount()); + } + + public function getArrayDataSource(int $count): ArrayIterator + { + $array = []; + for ($i = 0; $i < $count; $i++) { + $array[] = [ + 'id' => $i, + 'title' => "title {$i}", + ]; + } + + return new ArrayIterator($array); } - public function testGetArrayObjectPrototypeDelegatesToGetRowPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getArrayObjectPrototypeDelegatesToGetRowPrototype(): void { - self::assertSame( + static::assertSame( $this->resultSet->getRowPrototype(), $this->resultSet->getArrayObjectPrototype(), ); } - public function testGetReturnTypeReturnsArrayWhenSetToArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getReturnTypeReturnsArrayWhenSetToArray(): void { $resultSet = new ResultSet(ResultSetReturnType::Array); - self::assertSame(ResultSetReturnType::Array, $resultSet->getReturnType()); + static::assertSame(ResultSetReturnType::Array, $resultSet->getReturnType()); } /** * @throws \Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidReturnTypes')] - public function testInvalidDataSourceRaisesException(mixed $dataSource): void + public function invalidDataSourceRaisesException(mixed $dataSource): void { if (is_array($dataSource)) { $this->expectNotToPerformAssertions(); @@ -265,13 +281,15 @@ public function testInvalidDataSourceRaisesException(mixed $dataSource): void $this->resultSet->initialize($dataSource); } - public function testReturnTypeIsObjectByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function returnTypeIsObjectByDefault(): void { // Verify default return type is ArrayObject - self::assertEquals(ResultSetReturnType::ArrayObject, $this->resultSet->getReturnType()); + static::assertEquals(ResultSetReturnType::ArrayObject, $this->resultSet->getReturnType()); } - public function testRowObjectPrototypeIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rowObjectPrototypeIsMutable(): void { $row1 = new ArrayObject(['test1' => 'value1']); $row2 = new ArrayObject(['test2' => 'value2']); @@ -280,33 +298,36 @@ public function testRowObjectPrototypeIsMutable(): void $this->resultSet->setArrayObjectPrototype($row1); // Verify the first mutation occurred - self::assertSame($row1, $this->resultSet->getArrayObjectPrototype()); + static::assertSame($row1, $this->resultSet->getArrayObjectPrototype()); // Second mutation to verify mutability $this->resultSet->setArrayObjectPrototype($row2); // Verify the instance was actually mutated - self::assertSame($row2, $this->resultSet->getArrayObjectPrototype()); - self::assertNotSame($row1, $this->resultSet->getArrayObjectPrototype()); + static::assertSame($row2, $this->resultSet->getArrayObjectPrototype()); + static::assertNotSame($row1, $this->resultSet->getArrayObjectPrototype()); } - public function testRowObjectPrototypeIsPopulatedByRowObjectByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rowObjectPrototypeIsPopulatedByRowObjectByDefault(): void { // Verify default row object prototype is ArrayObject $row = $this->resultSet->getArrayObjectPrototype(); - self::assertInstanceOf('ArrayObject', $row); + static::assertInstanceOf('ArrayObject', $row); } - public function testRowObjectPrototypeMayBePassedToConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rowObjectPrototypeMayBePassedToConstructor(): void { $row = new ArrayObject(); // Verify prototype can be passed to constructor $resultSet = new ResultSet(ResultSet::TYPE_ARRAYOBJECT, $row); - self::assertSame($row, $resultSet->getArrayObjectPrototype()); + static::assertSame($row, $resultSet->getArrayObjectPrototype()); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidReturnTypes')] - public function testSettingInvalidReturnTypeRaisesException(mixed $type): void + public function settingInvalidReturnTypeRaisesException(mixed $type): void { // Verify invalid return type throws TypeError self::expectException(TypeError::class); @@ -317,41 +338,44 @@ public function testSettingInvalidReturnTypeRaisesException(mixed $type): void * @throws RandomException * @throws \Exception */ - public function testToArrayCreatesArrayOfArraysRepresentingRows(): void + #[\PHPUnit\Framework\Attributes\Test] + public function toArrayCreatesArrayOfArraysRepresentingRows(): void { $count = random_int(3, 75); $dataSource = $this->getArrayDataSource($count); // Verify toArray() returns array representation of all rows $this->resultSet->initialize($dataSource); $test = $this->resultSet->toArray(); - self::assertEquals($dataSource->getArrayCopy(), $test, var_export($test, true)); + static::assertEquals($dataSource->getArrayCopy(), $test, var_export($test, true)); } /** * @throws \Exception */ - public function testWhenReturnTypeIsArrayThenIterationReturnsArrays(): void + #[\PHPUnit\Framework\Attributes\Test] + public function whenReturnTypeIsArrayThenIterationReturnsArrays(): void { $resultSet = new ResultSet(ResultSet::TYPE_ARRAY); $dataSource = $this->getArrayDataSource(10); $resultSet->initialize($dataSource); // Iterate and verify each row is returned as array foreach ($resultSet as $index => $row) { - self::assertEquals($dataSource[$index], $row); + static::assertEquals($dataSource[$index], $row); } } /** * @throws \Exception */ - public function testWhenReturnTypeIsObjectThenIterationReturnsRowObjects(): void + #[\PHPUnit\Framework\Attributes\Test] + public function whenReturnTypeIsObjectThenIterationReturnsRowObjects(): void { $dataSource = $this->getArrayDataSource(10); $this->resultSet->initialize($dataSource); // Iterate and verify each row is returned as ArrayObject foreach ($this->resultSet as $index => $row) { - self::assertInstanceOf('ArrayObject', $row); - self::assertEquals($dataSource[$index], $row->getArrayCopy()); + static::assertInstanceOf('ArrayObject', $row); + static::assertEquals($dataSource[$index], $row->getArrayCopy()); } } diff --git a/test/unit/RowGateway/AbstractRowGatewayTest.php b/test/unit/RowGateway/AbstractRowGatewayTest.php index 8a6fc57c..ed1ceb94 100644 --- a/test/unit/RowGateway/AbstractRowGatewayTest.php +++ b/test/unit/RowGateway/AbstractRowGatewayTest.php @@ -57,37 +57,41 @@ final class AbstractRowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - public function testCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function countsPopulatedColumns(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); - self::assertEquals(2, $this->rowGateway->count()); + static::assertSame(2, $this->rowGateway->count()); } - public function testDelete(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delete(): void { $this->rowGateway->foo = 'bar'; $affectedRows = $this->rowGateway->delete(); - self::assertFalse($this->rowGateway->rowExistsInDatabase()); - self::assertEquals(1, $affectedRows); + static::assertFalse($this->rowGateway->rowExistsInDatabase()); + static::assertSame(1, $affectedRows); } - public function testExchangeArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function exchangeArray(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); - self::assertEquals(['id' => 5, 'name' => 'foo'], $this->rowGateway->toArray()); + static::assertEquals(['id' => 5, 'name' => 'foo'], $this->rowGateway->toArray()); $oldData = $this->rowGateway->exchangeArray(['id' => 10, 'name' => 'bar']); /** @phpstan-ignore staticMethod.alreadyNarrowedType */ - self::assertIsArray($oldData); - self::assertEquals(['id' => 5, 'name' => 'foo'], $oldData); + static::assertIsArray($oldData); + static::assertEquals(['id' => 5, 'name' => 'foo'], $oldData); - self::assertEquals(10, $this->rowGateway['id']); - self::assertEquals('bar', $this->rowGateway['name']); - self::assertTrue($this->rowGateway->rowExistsInDatabase()); + static::assertSame(10, $this->rowGateway['id']); + static::assertSame('bar', $this->rowGateway['name']); + static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - public function testInitializeCreatesFeatureSetIfNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeCreatesFeatureSetIfNotSet(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -103,14 +107,15 @@ public function testInitializeCreatesFeatureSetIfNotSet(): void $sqlProp->setValue($rowGateway, new Sql($this->mockAdapter)); $featureSetProp = $refRowGateway->getProperty('featureSet'); - self::assertNull($featureSetProp->getValue($rowGateway)); + static::assertNull($featureSetProp->getValue($rowGateway)); $rowGateway->populate(['id' => 1, 'name' => 'test'], true); - self::assertInstanceOf(FeatureSet::class, $featureSetProp->getValue($rowGateway)); + static::assertInstanceOf(FeatureSet::class, $featureSetProp->getValue($rowGateway)); } - public function testInitializeEarlyReturnWhenAlreadyInitialized(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeEarlyReturnWhenAlreadyInitialized(): void { $rowGateway = new RowGateway('id', 'test_table', $this->mockAdapter); @@ -119,28 +124,30 @@ public function testInitializeEarlyReturnWhenAlreadyInitialized(): void $originalFeatureSet = $featureSetProp->getValue($rowGateway); $isInitializedProp = $refRowGateway->getProperty('isInitialized'); - self::assertTrue($isInitializedProp->getValue($rowGateway)); + static::assertTrue($isInitializedProp->getValue($rowGateway)); $rowGateway->populate(['id' => 2, 'name' => 'bar'], true); - self::assertSame($originalFeatureSet, $featureSetProp->getValue($rowGateway)); + static::assertSame($originalFeatureSet, $featureSetProp->getValue($rowGateway)); } - public function testInitializeOnlyRunsOnce(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeOnlyRunsOnce(): void { $this->rowGateway->populate(['id' => 1, 'name' => 'foo'], true); $refRowGateway = new ReflectionObject($this->rowGateway); $isInitializedProp = $refRowGateway->getProperty('isInitialized'); - self::assertTrue($isInitializedProp->getValue($this->rowGateway)); + static::assertTrue($isInitializedProp->getValue($this->rowGateway)); $this->rowGateway->populate(['id' => 2, 'name' => 'bar'], true); - self::assertEquals(2, $this->rowGateway['id']); - self::assertEquals('bar', $this->rowGateway['name']); + static::assertSame(2, $this->rowGateway['id']); + static::assertSame('bar', $this->rowGateway['name']); } - public function testInitializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -158,7 +165,8 @@ public function testInitializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testInitializeThrowsExceptionWhenSqlIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsExceptionWhenSqlIsNull(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_SQL_OBJECT); @@ -176,7 +184,8 @@ public function testInitializeThrowsExceptionWhenSqlIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testInitializeThrowsExceptionWhenTableIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsExceptionWhenTableIsNull(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_TABLE); @@ -193,14 +202,16 @@ public function testInitializeThrowsExceptionWhenTableIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testMagicGetReturnsTheColumnValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsTheColumnValue(): void { $this->rowGateway->testColumn = 'test'; - self::assertEquals('test', $this->rowGateway->testColumn); - self::assertEquals('test', $this->rowGateway['testColumn']); + static::assertSame('test', $this->rowGateway->testColumn); + static::assertSame('test', $this->rowGateway['testColumn']); } - public function testMagicGetThrowsForUnknownColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetThrowsForUnknownColumn(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(sprintf(InvalidArgumentException::INVALID_COLUMN, 'nonExistentColumn')); @@ -209,71 +220,80 @@ public function testMagicGetThrowsForUnknownColumn(): void $this->rowGateway->nonExistentColumn; } - public function testMagicIssetReportsWhetherAColumnIsSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicIssetReportsWhetherAColumnIsSet(): void { - self::assertFalse(isset($this->rowGateway->foo)); + static::assertFalse(isset($this->rowGateway->foo)); $this->rowGateway->foo = 'bar'; - self::assertTrue(isset($this->rowGateway->foo)); + static::assertTrue(isset($this->rowGateway->foo)); } - public function testMagicSetAssignsTheColumnValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicSetAssignsTheColumnValue(): void { $this->rowGateway->testColumn = 'test'; - self::assertEquals('test', $this->rowGateway->testColumn); - self::assertEquals('test', $this->rowGateway['testColumn']); + static::assertSame('test', $this->rowGateway->testColumn); + static::assertSame('test', $this->rowGateway['testColumn']); } - public function testMagicUnsetClearsTheColumnValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicUnsetClearsTheColumnValue(): void { $this->rowGateway->foo = 'bar'; - self::assertEquals('bar', $this->rowGateway->foo); + static::assertSame('bar', $this->rowGateway->foo); unset($this->rowGateway->foo); - self::assertEmpty($this->rowGateway->foo); - self::assertEmpty($this->rowGateway['foo']); + static::assertEmpty($this->rowGateway->foo); + static::assertEmpty($this->rowGateway['foo']); } - public function testOffsetExists(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetExists(): void { - self::assertFalse(isset($this->rowGateway['foo'])); + static::assertFalse(isset($this->rowGateway['foo'])); $this->rowGateway['foo'] = 'bar'; - self::assertTrue(isset($this->rowGateway['foo'])); + static::assertTrue(isset($this->rowGateway['foo'])); } - public function testOffsetGet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetGet(): void { $this->rowGateway['testColumn'] = 'test'; - self::assertEquals('test', $this->rowGateway->testColumn); - self::assertEquals('test', $this->rowGateway['testColumn']); + static::assertSame('test', $this->rowGateway->testColumn); + static::assertSame('test', $this->rowGateway['testColumn']); } - public function testOffsetSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetSet(): void { $this->rowGateway['testColumn'] = 'test'; - self::assertEquals('test', $this->rowGateway->testColumn); - self::assertEquals('test', $this->rowGateway['testColumn']); + static::assertSame('test', $this->rowGateway->testColumn); + static::assertSame('test', $this->rowGateway['testColumn']); } - public function testOffsetUnset(): void + #[\PHPUnit\Framework\Attributes\Test] + public function offsetUnset(): void { $this->rowGateway['foo'] = 'bar'; - self::assertEquals('bar', $this->rowGateway['foo']); + static::assertSame('bar', $this->rowGateway['foo']); unset($this->rowGateway['foo']); - self::assertEmpty($this->rowGateway->foo); - self::assertEmpty($this->rowGateway['foo']); + static::assertEmpty($this->rowGateway->foo); + static::assertEmpty($this->rowGateway['foo']); } - public function testPopulate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function populate(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo']); - self::assertEquals(5, $this->rowGateway['id']); - self::assertEquals('foo', $this->rowGateway['name']); - self::assertFalse($this->rowGateway->rowExistsInDatabase()); + static::assertSame(5, $this->rowGateway['id']); + static::assertSame('foo', $this->rowGateway['name']); + static::assertFalse($this->rowGateway->rowExistsInDatabase()); $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); - self::assertTrue($this->rowGateway->rowExistsInDatabase()); + static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - public function testProcessPrimaryKeyData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processPrimaryKeyData(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); @@ -282,34 +302,38 @@ public function testProcessPrimaryKeyData(): void $this->rowGateway->populate(['boo' => 5, 'name' => 'foo'], true); } - public function testRowExistsInDatabaseReturnsFalseWhenNew(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rowExistsInDatabaseReturnsFalseWhenNew(): void { $this->rowGateway->populate(['name' => 'foo']); - self::assertFalse($this->rowGateway->rowExistsInDatabase()); + static::assertFalse($this->rowGateway->rowExistsInDatabase()); } - public function testRowExistsInDatabaseReturnsTrueAfterPopulateWithTrue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rowExistsInDatabaseReturnsTrueAfterPopulateWithTrue(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); - self::assertTrue($this->rowGateway->rowExistsInDatabase()); + static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - public function testSaveInsert(): void + #[\PHPUnit\Framework\Attributes\Test] + public function saveInsert(): void { $this->mockResult->expects($this->any())->method('current')->willReturn(['id' => 5, 'name' => 'foo']); $this->mockResult->expects($this->any())->method('getGeneratedValue')->willReturn(5); $this->rowGateway->populate(['name' => 'foo']); $this->rowGateway->save(); - self::assertEquals(5, $this->rowGateway->id); - self::assertEquals(5, $this->rowGateway['id']); + static::assertSame(5, $this->rowGateway->id); + static::assertSame(5, $this->rowGateway['id']); } /** * @throws ReflectionException * @throws Exception */ + #[\PHPUnit\Framework\Attributes\Test] #[RequiresPhp('<= 8.6')] - public function testSaveInsertMultiKey(): void + public function saveInsertMultiKey(): void { $this->rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -334,29 +358,31 @@ public function testSaveInsertMultiKey(): void $this->rowGateway->populate(['one' => 'foo', 'two' => 'bar']); - self::assertNull($refRowGatewayProp->getValue($this->rowGateway)); + static::assertNull($refRowGatewayProp->getValue($this->rowGateway)); $this->rowGateway->save(); - self::assertEquals(['one' => 'foo', 'two' => 'bar'], $refRowGatewayProp->getValue($this->rowGateway)); + static::assertEquals(['one' => 'foo', 'two' => 'bar'], $refRowGatewayProp->getValue($this->rowGateway)); } - public function testSaveUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function saveUpdate(): void { $this->mockResult->expects($this->any())->method('current')->willReturn(['id' => 6, 'name' => 'foo']); $this->rowGateway->populate(['id' => 6, 'name' => 'foo'], true); $this->rowGateway->save(); - self::assertEquals(6, $this->rowGateway['id']); + static::assertSame(6, $this->rowGateway['id']); } - public function testSaveUpdateChangingPrimaryKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function saveUpdateChangingPrimaryKey(): void { $selectMock = $this->getMockBuilder(Select::class) ->onlyMethods(['where']) ->getMock(); $selectMock->expects($this->once()) ->method('where') - ->with($this->equalTo(['id' => 7])) + ->with(static::equalTo(['id' => 7])) ->willReturn($selectMock); $sqlMock = $this->getMockBuilder(Sql::class) @@ -377,13 +403,14 @@ public function testSaveUpdateChangingPrimaryKey(): void $this->rowGateway->populate(['id' => 6, 'name' => 'foo'], true); $this->rowGateway->id = 7; $this->rowGateway->save(); - self::assertEquals(['id' => 7, 'name' => 'fooUpdated'], $this->rowGateway->toArray()); + static::assertEquals(['id' => 7, 'name' => 'fooUpdated'], $this->rowGateway->toArray()); } - public function testToArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function toArray(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); - self::assertEquals(['id' => 5, 'name' => 'foo'], $this->rowGateway->toArray()); + static::assertEquals(['id' => 5, 'name' => 'foo'], $this->rowGateway->toArray()); } /** diff --git a/test/unit/RowGateway/RowGatewayTest.php b/test/unit/RowGateway/RowGatewayTest.php index 7a05a4d2..eb2bef3d 100644 --- a/test/unit/RowGateway/RowGatewayTest.php +++ b/test/unit/RowGateway/RowGatewayTest.php @@ -30,7 +30,8 @@ final class RowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -40,18 +41,20 @@ public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new RowGateway('id', 'foo', $sql); } - public function testConstructorWithArrayPrimaryKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithArrayPrimaryKey(): void { $rowGateway = new RowGateway(['id', 'name'], 'foo', $this->mockAdapter); $tableProp = new ReflectionProperty(RowGateway::class, 'table'); - self::assertEquals('foo', $tableProp->getValue($rowGateway)); + static::assertSame('foo', $tableProp->getValue($rowGateway)); $pkProp = new ReflectionProperty(RowGateway::class, 'primaryKeyColumn'); - self::assertEquals(['id', 'name'], $pkProp->getValue($rowGateway)); + static::assertEquals(['id', 'name'], $pkProp->getValue($rowGateway)); } - public function testConstructorWithNullPrimaryKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithNullPrimaryKey(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_PRIMARY_KEY_COLUMN); @@ -59,7 +62,8 @@ public function testConstructorWithNullPrimaryKey(): void new RowGateway(null, 'foo', $this->mockAdapter); } - public function testConstructorWithSqlObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSqlObject(): void { $sql = new Sql($this->mockAdapter, 'foo'); $rowGateway = new RowGateway('id', 'foo', $sql); @@ -67,50 +71,55 @@ public function testConstructorWithSqlObject(): void $sqlProp = new ReflectionProperty(RowGateway::class, 'sql'); $tableProp = new ReflectionProperty(RowGateway::class, 'table'); - self::assertSame($sql, $sqlProp->getValue($rowGateway)); - self::assertEquals('foo', $tableProp->getValue($rowGateway)); + static::assertSame($sql, $sqlProp->getValue($rowGateway)); + static::assertSame('foo', $tableProp->getValue($rowGateway)); } - public function testConstructorWithStringPrimaryKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithStringPrimaryKey(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); $tableProp = new ReflectionProperty(RowGateway::class, 'table'); $sqlProp = new ReflectionProperty(RowGateway::class, 'sql'); - self::assertEquals('foo', $tableProp->getValue($rowGateway)); - self::assertInstanceOf(Sql::class, $sqlProp->getValue($rowGateway)); + static::assertSame('foo', $tableProp->getValue($rowGateway)); + static::assertInstanceOf(Sql::class, $sqlProp->getValue($rowGateway)); } - public function testConstructorWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'schema'); $rowGateway = new RowGateway('id', $tableIdentifier, $this->mockAdapter); $tableProp = new ReflectionProperty(RowGateway::class, 'table'); - self::assertSame($tableIdentifier, $tableProp->getValue($rowGateway)); + static::assertSame($tableIdentifier, $tableProp->getValue($rowGateway)); } - public function testEmptyPrimaryKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyPrimaryKey(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_PRIMARY_KEY_COLUMN); $this->rowGateway = new RowGateway('', 'foo', $this->mockAdapter); } - public function testInitializeReturnsEarlyWhenAlreadyInitialized(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeReturnsEarlyWhenAlreadyInitialized(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); $isInitializedProp = new ReflectionProperty(RowGateway::class, 'isInitialized'); - self::assertTrue($isInitializedProp->getValue($rowGateway)); + static::assertTrue($isInitializedProp->getValue($rowGateway)); $rowGateway->initialize(); - self::assertTrue($isInitializedProp->getValue($rowGateway)); + static::assertTrue($isInitializedProp->getValue($rowGateway)); } - public function testInitializeThrowsWhenSqlIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsWhenSqlIsNull(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); @@ -126,7 +135,8 @@ public function testInitializeThrowsWhenSqlIsNull(): void $rowGateway->initialize(); } - public function testInitializeThrowsWhenTableIsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsWhenTableIsNull(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); diff --git a/test/unit/Sql/AbstractSqlFunctionalTestCase.php b/test/unit/Sql/AbstractSqlFunctionalTestCase.php index ea1fd69a..c895d96d 100644 --- a/test/unit/Sql/AbstractSqlFunctionalTestCase.php +++ b/test/unit/Sql/AbstractSqlFunctionalTestCase.php @@ -289,6 +289,7 @@ protected static function update(string|TableIdentifier|null $sqlString): Sql\Up return new Sql\Update($sqlString); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('dataProvider')] public function test(PreparableSqlInterface|SqlInterface $sqlObject, string $platform, string|array $expected): void { @@ -351,7 +352,7 @@ protected function resolveAdapter(string $platformName): Adapter\Adapter }); $mockStatement->expects($this->any()) ->method('getSql') - ->willReturnCallback(static fn(): ?string => $container->getSql()); + ->willReturnCallback($container->getSql(...)); $mockStatement->expects($this->any()) ->method('setParameterContainer') ->willReturnCallback( @@ -362,7 +363,7 @@ static function (ParameterContainer $params) use ($container, $mockStatement): M ); $mockStatement->expects($this->any()) ->method('getParameterContainer') - ->willReturnCallback(static fn(): ?ParameterContainer => $container->getParameterContainer()); + ->willReturnCallback($container->getParameterContainer(...)); return $mockStatement; }); diff --git a/test/unit/Sql/AbstractSqlTest.php b/test/unit/Sql/AbstractSqlTest.php index f4676d54..94ae0f86 100644 --- a/test/unit/Sql/AbstractSqlTest.php +++ b/test/unit/Sql/AbstractSqlTest.php @@ -68,7 +68,8 @@ final class AbstractSqlTest extends TestCase /** * @throws ReflectionException */ - public function testCreateSqlFromSpecificationThrowsOnParameterCountMismatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createSqlFromSpecificationThrowsOnParameterCountMismatch(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -87,7 +88,8 @@ public function testCreateSqlFromSpecificationThrowsOnParameterCountMismatch(): /** * @throws ReflectionException */ - public function testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -106,7 +108,8 @@ public function testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): vo /** * @throws ReflectionException */ - public function testCreateSqlFromSpecWithCombinedByScalarParam(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createSqlFromSpecWithCombinedByScalarParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -120,13 +123,14 @@ public function testCreateSqlFromSpecWithCombinedByScalarParam(): void $result = $method->invoke($this->abstractSql, $spec, $params); - self::assertSame('SELECT col1 FROM table1', $result); + static::assertSame('SELECT col1 FROM table1', $result); } /** * @throws ReflectionException */ - public function testCreateSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -146,7 +150,8 @@ public function testCreateSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): v /** * @throws ReflectionException */ - public function testCreateSqlFromSpecWithNonCombinedByParam(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createSqlFromSpecWithNonCombinedByParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -159,20 +164,22 @@ public function testCreateSqlFromSpecWithNonCombinedByParam(): void $result = $method->invoke($this->abstractSql, $spec, $params); - self::assertSame('FROM my_table', $result); + static::assertSame('FROM my_table', $result); } - public function testFlattenExpressionValuesViaInPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function flattenExpressionValuesViaInPredicate(): void { $select = new Select('users'); $select->where(new Predicate\In('id', [1, 2, 3])); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString("\"id\" IN ('1', '2', '3')", $sql); + static::assertStringContainsString("\"id\" IN ('1', '2', '3')", $sql); } - public function testFlattenExpressionValuesViaInPredicateWithParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function flattenExpressionValuesViaInPredicateWithParameterContainer(): void { $select = new Select('users'); $select->where(new Predicate\In('id', [1, 2, 3])); @@ -193,10 +200,11 @@ public function testFlattenExpressionValuesViaInPredicateWithParameterContainer( $select->prepareStatement($adapter, $mockStatement); - self::assertSame(3, $parameterContainer->count()); + static::assertSame(3, $parameterContainer->count()); } - public function testLocalizeVariablesCopiesSubjectProperties(): void + #[\PHPUnit\Framework\Attributes\Test] + public function localizeVariablesCopiesSubjectProperties(): void { $decorator = new SelectDecorator(); $select = new Select('users'); @@ -205,11 +213,12 @@ public function testLocalizeVariablesCopiesSubjectProperties(): void $sql = $decorator->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('"users"', $sql); - self::assertStringContainsString('"id"', $sql); + static::assertStringContainsString('"users"', $sql); + static::assertStringContainsString('"id"', $sql); } - public function testProcessExpressionThrowsOnUnknownArgumentType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionThrowsOnUnknownArgumentType(): void { $unknownArg = new class implements ArgumentInterface { public function getSpecification(): string @@ -238,7 +247,8 @@ public function getValue(): string /** * @throws ReflectionException */ - public function testProcessExpressionWithIdentifiersArgument(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWithIdentifiersArgument(): void { $expression = new Expression('? IN (SELECT col1, col2 FROM bar)', [ Argument::identifiers(['col1', 'col2']), @@ -246,25 +256,27 @@ public function testProcessExpressionWithIdentifiersArgument(): void $sqlAndParams = $this->invokeProcessExpressionMethod($expression); - self::assertStringContainsString('"col1"', $sqlAndParams); - self::assertStringContainsString('"col2"', $sqlAndParams); + static::assertStringContainsString('"col1"', $sqlAndParams); + static::assertStringContainsString('"col2"', $sqlAndParams); } /** * @throws ReflectionException */ - public function testProcessExpressionWithoutParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWithoutParameterContainer(): void { $expression = new Expression('? > ? AND y < ?', [new Identifier('x'), 5, 10]); $sqlAndParams = $this->invokeProcessExpressionMethod($expression); - self::assertEquals("\"x\" > '5' AND y < '10'", $sqlAndParams); + static::assertSame("\"x\" > '5' AND y < '10'", $sqlAndParams); } /** * @throws ReflectionException */ - public function testProcessExpressionWithParameterContainerAndParameterizationTypeNamed(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWithParameterContainerAndParameterizationTypeNamed(): void { $parameterContainer = new ParameterContainer(); $expression = new Expression('? > ? AND y < ?', [new Identifier('x'), 5, 10]); @@ -273,17 +285,17 @@ public function testProcessExpressionWithParameterContainerAndParameterizationTy $parameters = $parameterContainer->getNamedArray(); // Verify SQL uses named parameters - self::assertMatchesRegularExpression('#"x" > :expr\d+Param1 AND y < :expr\d+Param2#', $sqlAndParams); + static::assertMatchesRegularExpression('#"x" > :expr\d+Param1 AND y < :expr\d+Param2#', $sqlAndParams); // Verify parameter names and values preg_match('#expr(\d+)Param1#', key($parameters), $matches); $expressionNumber = $matches[1]; - self::assertMatchesRegularExpression('#expr\d+Param1#', key($parameters)); - self::assertEquals(5, current($parameters)); + static::assertMatchesRegularExpression('#expr\d+Param1#', key($parameters)); + static::assertSame(5, current($parameters)); next($parameters); - self::assertMatchesRegularExpression('#expr\d+Param2#', key($parameters)); - self::assertEquals(10, current($parameters)); + static::assertMatchesRegularExpression('#expr\d+Param2#', key($parameters)); + static::assertSame(10, current($parameters)); // Verify next invocation increments expression number $parameterContainer = new ParameterContainer(); @@ -294,13 +306,14 @@ public function testProcessExpressionWithParameterContainerAndParameterizationTy preg_match('#expr(\d+)Param1#', key($parameters), $matches); $expressionNumberNext = $matches[1]; - self::assertEquals(1, (int) $expressionNumberNext - (int) $expressionNumber); + static::assertSame(1, (int) $expressionNumberNext - (int) $expressionNumber); } /** * @throws ReflectionException */ - public function testProcessExpressionWithValuesArgument(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWithValuesArgument(): void { $expression = new Expression( '? IN (?, ?, ?)', @@ -314,16 +327,17 @@ public function testProcessExpressionWithValuesArgument(): void $sqlAndParams = $this->invokeProcessExpressionMethod($expression); - self::assertStringContainsString("'1'", $sqlAndParams); - self::assertStringContainsString("'2'", $sqlAndParams); - self::assertStringContainsString("'3'", $sqlAndParams); - self::assertStringContainsString('"id"', $sqlAndParams); + static::assertStringContainsString("'1'", $sqlAndParams); + static::assertStringContainsString("'2'", $sqlAndParams); + static::assertStringContainsString("'3'", $sqlAndParams); + static::assertStringContainsString('"id"', $sqlAndParams); } /** * @throws ReflectionException */ - public function testProcessExpressionWorksWithExpressionContainingExpressionObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWorksWithExpressionContainingExpressionObject(): void { $expression = new Predicate\Operator( 'release_date', @@ -332,13 +346,14 @@ public function testProcessExpressionWorksWithExpressionContainingExpressionObje ); $sqlAndParams = $this->invokeProcessExpressionMethod($expression); - self::assertEquals('"release_date" = FROM_UNIXTIME(\'100000000\')', $sqlAndParams); + static::assertSame('"release_date" = FROM_UNIXTIME(\'100000000\')', $sqlAndParams); } /** * @throws ReflectionException */ - public function testProcessExpressionWorksWithExpressionContainingSelectObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWorksWithExpressionContainingSelectObject(): void { $select = new Select(); $select->from('x')->where->like('bar', 'Foo%'); @@ -347,65 +362,70 @@ public function testProcessExpressionWorksWithExpressionContainingSelectObject() $predicateSet = new Predicate\PredicateSet([new Predicate\PredicateSet([$expression])]); $sqlAndParams = $this->invokeProcessExpressionMethod($predicateSet); - self::assertEquals('("x" IN (SELECT "x".* FROM "x" WHERE "bar" LIKE \'Foo%\'))', $sqlAndParams); + static::assertSame('("x" IN (SELECT "x".* FROM "x" WHERE "bar" LIKE \'Foo%\'))', $sqlAndParams); } /** * @throws ReflectionException */ - public function testProcessExpressionWorksWithExpressionContainingStringParts(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWorksWithExpressionContainingStringParts(): void { $expression = new Predicate\Expression('x = ?', 5); $predicateSet = new Predicate\PredicateSet([new Predicate\PredicateSet([$expression])]); $sqlAndParams = $this->invokeProcessExpressionMethod($predicateSet); - self::assertEquals("(x = '5')", $sqlAndParams); + static::assertSame("(x = '5')", $sqlAndParams); } /** * @throws ReflectionException */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('7407')] - public function testProcessExpressionWorksWithExpressionObjectWithPercentageSigns(): void + public function processExpressionWorksWithExpressionObjectWithPercentageSigns(): void { $expressionString = 'FROM_UNIXTIME(date, "%Y-%m")'; $expression = new Expression($expressionString); $sqlString = $this->invokeProcessExpressionMethod($expression); - self::assertSame($expressionString, $sqlString); + static::assertSame($expressionString, $sqlString); } /** * @throws ReflectionException */ - public function testProcessExpressionWorksWithNamedParameterPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWorksWithNamedParameterPrefix(): void { $parameterContainer = new ParameterContainer(); $namedParameterPrefix = uniqid(); $expression = new Expression('FROM_UNIXTIME(?)', [10_000_000]); $this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix); - self::assertSame("{$namedParameterPrefix}1", (string) key($parameterContainer->getNamedArray())); + static::assertSame("{$namedParameterPrefix}1", (string) key($parameterContainer->getNamedArray())); } /** * @throws ReflectionException */ - public function testProcessExpressionWorksWithNamedParameterPrefixContainingWhitespace(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processExpressionWorksWithNamedParameterPrefixContainingWhitespace(): void { $parameterContainer = new ParameterContainer(); $namedParameterPrefix = "string\ncontaining white space"; $expression = new Expression('FROM_UNIXTIME(?)', [10_000_000]); $this->invokeProcessExpressionMethod($expression, $parameterContainer, $namedParameterPrefix); - self::assertSame('string__containing__white__space1', key($parameterContainer->getNamedArray())); + static::assertSame('string__containing__white__space1', key($parameterContainer->getNamedArray())); } /** * @throws ReflectionException */ - public function testProcessJoinReturnsNullWhenEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinReturnsNullWhenEmpty(): void { $method = new ReflectionMethod($this->abstractSql, 'processJoin'); $result = $method->invoke( @@ -416,13 +436,14 @@ public function testProcessJoinReturnsNullWhenEmpty(): void null, ); - self::assertNull($result); + static::assertNull($result); } /** * @throws ReflectionException */ - public function testProcessJoinWithArrayAlias(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinWithArrayAlias(): void { $join = new Join(); $join->join(['b' => 'bar'], 'foo.id = b.foo_id'); @@ -436,14 +457,15 @@ public function testProcessJoinWithArrayAlias(): void null, ); - self::assertNotNull($result); - self::assertStringContainsString('AS', $result[0][0][1]); + static::assertNotNull($result); + static::assertStringContainsString('AS', $result[0][0][1]); } /** * @throws ReflectionException */ - public function testProcessJoinWithExpressionNameViaArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinWithExpressionNameViaArray(): void { $join = new Join(); $join->join(['x' => new Expression('LATERAL(SELECT 1)')], 'true'); @@ -457,13 +479,14 @@ public function testProcessJoinWithExpressionNameViaArray(): void null, ); - self::assertStringContainsString('LATERAL(SELECT 1)', $result[0][0][1]); + static::assertStringContainsString('LATERAL(SELECT 1)', $result[0][0][1]); } /** * @throws ReflectionException */ - public function testProcessJoinWithPredicateExpressionOnClause(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinWithPredicateExpressionOnClause(): void { $join = new Join(); $join->join('bar', new Predicate\Expression('foo.id = bar.foo_id AND bar.active = 1')); @@ -477,14 +500,15 @@ public function testProcessJoinWithPredicateExpressionOnClause(): void null, ); - self::assertNotNull($result); - self::assertStringContainsString('foo.id = bar.foo_id', $result[0][0][2]); + static::assertNotNull($result); + static::assertStringContainsString('foo.id = bar.foo_id', $result[0][0][2]); } /** * @throws ReflectionException */ - public function testProcessJoinWithSelectSubqueryViaArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinWithSelectSubqueryViaArray(): void { $subselect = new Select('bar'); $join = new Join(); @@ -499,14 +523,15 @@ public function testProcessJoinWithSelectSubqueryViaArray(): void null, ); - self::assertStringContainsString('SELECT', $result[0][0][1]); - self::assertStringContainsString('AS', $result[0][0][1]); + static::assertStringContainsString('SELECT', $result[0][0][1]); + static::assertStringContainsString('AS', $result[0][0][1]); } /** * @throws ReflectionException */ - public function testProcessJoinWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processJoinWithTableIdentifier(): void { $join = new Join(); $join->join(new TableIdentifier('bar', 'myschema'), 'foo.id = bar.foo_id'); @@ -520,12 +545,13 @@ public function testProcessJoinWithTableIdentifier(): void null, ); - self::assertNotNull($result); - self::assertStringContainsString('"myschema"', $result[0][0][1]); - self::assertStringContainsString('"bar"', $result[0][0][1]); + static::assertNotNull($result); + static::assertStringContainsString('"myschema"', $result[0][0][1]); + static::assertStringContainsString('"bar"', $result[0][0][1]); } - public function testProcessSubSelectUsesDecoratorWhenPlatformDecorator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processSubSelectUsesDecoratorWhenPlatformDecorator(): void { $decorator = new SelectDecorator(); $outer = new Select('foo'); @@ -535,14 +561,15 @@ public function testProcessSubSelectUsesDecoratorWhenPlatformDecorator(): void $sql = $decorator->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('SELECT "bar"', $sql); - self::assertStringContainsString('SELECT "foo"', $sql); + static::assertStringContainsString('SELECT "bar"', $sql); + static::assertStringContainsString('SELECT "foo"', $sql); } /** * @throws ReflectionException */ - public function testProcessSubSelectWithoutParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processSubSelectWithoutParameterContainer(): void { $select = new Select('foo'); @@ -556,13 +583,14 @@ public function testProcessSubSelectWithoutParameterContainer(): void null, ); - self::assertStringContainsString('SELECT', $result); + static::assertStringContainsString('SELECT', $result); } /** * @throws ReflectionException */ - public function testProcessSubSelectWithParameterContainer(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processSubSelectWithParameterContainer(): void { $select = new Select('foo'); $select->where(['id' => 5]); @@ -578,25 +606,27 @@ public function testProcessSubSelectWithParameterContainer(): void $parameterContainer, ); - self::assertStringContainsString('SELECT', $result); - self::assertGreaterThan(0, count($parameterContainer->getNamedArray())); + static::assertStringContainsString('SELECT', $result); + static::assertGreaterThan(0, count($parameterContainer->getNamedArray())); } /** * @throws ReflectionException */ - public function testRenderTableWithAlias(): void + #[\PHPUnit\Framework\Attributes\Test] + public function renderTableWithAlias(): void { $method = new ReflectionMethod($this->abstractSql, 'renderTable'); $result = $method->invoke($this->abstractSql, '"foo"', '"f"'); - self::assertSame('"foo" AS "f"', $result); + static::assertSame('"foo" AS "f"', $result); } /** * @throws ReflectionException */ - public function testResolveColumnValueWithArrayAndFromTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveColumnValueWithArrayAndFromTable(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -613,11 +643,12 @@ public function testResolveColumnValueWithArrayAndFromTable(): void null, ); - self::assertStringContainsString('table.', $result); - self::assertStringContainsString('id', $result); + static::assertStringContainsString('table.', $result); + static::assertStringContainsString('id', $result); } - public function testResolveColumnValueWithNamedParameterPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveColumnValueWithNamedParameterPrefix(): void { $select = new Select('users'); $select->columns(['id']); @@ -640,13 +671,14 @@ public function testResolveColumnValueWithNamedParameterPrefix(): void $select->prepareStatement($adapter, $mockStatement); - self::assertGreaterThanOrEqual(2, $parameterContainer->count()); + static::assertGreaterThanOrEqual(2, $parameterContainer->count()); } /** * @throws ReflectionException */ - public function testResolveColumnValueWithNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveColumnValueWithNull(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -659,13 +691,14 @@ public function testResolveColumnValueWithNull(): void null, ); - self::assertEquals('NULL', $result); + static::assertSame('NULL', $result); } /** * @throws ReflectionException */ - public function testResolveColumnValueWithSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveColumnValueWithSelect(): void { $select = new Select('foo'); $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -679,15 +712,16 @@ public function testResolveColumnValueWithSelect(): void null, ); - self::assertStringContainsString('SELECT', $result); - self::assertStringStartsWith('(', $result); - self::assertStringEndsWith(')', $result); + static::assertStringContainsString('SELECT', $result); + static::assertStringStartsWith('(', $result); + static::assertStringEndsWith(')', $result); } /** * @throws ReflectionException */ - public function testResolveTableWithSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveTableWithSelect(): void { $select = new Select('foo'); $method = new ReflectionMethod($this->abstractSql, 'resolveTable'); @@ -700,15 +734,16 @@ public function testResolveTableWithSelect(): void null, ); - self::assertStringStartsWith('(', $result); - self::assertStringEndsWith(')', $result); - self::assertStringContainsString('SELECT', $result); + static::assertStringStartsWith('(', $result); + static::assertStringEndsWith(')', $result); + static::assertStringContainsString('SELECT', $result); } /** * @throws ReflectionException */ - public function testResolveTableWithTableIdentifierAndSchema(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveTableWithTableIdentifierAndSchema(): void { $table = new TableIdentifier('users', 'public'); $method = new ReflectionMethod($this->abstractSql, 'resolveTable'); @@ -721,8 +756,8 @@ public function testResolveTableWithTableIdentifierAndSchema(): void null, ); - self::assertStringContainsString('public', $result); - self::assertStringContainsString('users', $result); + static::assertStringContainsString('public', $result); + static::assertStringContainsString('users', $result); } /** diff --git a/test/unit/Sql/Argument/LiteralTest.php b/test/unit/Sql/Argument/LiteralTest.php index bd142104..1ab98e27 100644 --- a/test/unit/Sql/Argument/LiteralTest.php +++ b/test/unit/Sql/Argument/LiteralTest.php @@ -17,24 +17,27 @@ #[CoversMethod(Literal::class, 'getSpecification')] final class LiteralTest extends TestCase { - public function testGetSpecificationReturnsPlaceholder(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSpecificationReturnsPlaceholder(): void { $literal = new Literal('test'); - self::assertSame('%s', $literal->getSpecification()); + static::assertSame('%s', $literal->getSpecification()); } - public function testGetTypeReturnsLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeReturnsLiteral(): void { $literal = new Literal('test'); - self::assertSame(ArgumentType::Literal, $literal->getType()); + static::assertSame(ArgumentType::Literal, $literal->getType()); } - public function testGetValueReturnsLiteralString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getValueReturnsLiteralString(): void { $literal = new Literal('NOW()'); - self::assertSame('NOW()', $literal->getValue()); + static::assertSame('NOW()', $literal->getValue()); } } diff --git a/test/unit/Sql/ArgumentTest.php b/test/unit/Sql/ArgumentTest.php index f5f6737f..043a7146 100644 --- a/test/unit/Sql/ArgumentTest.php +++ b/test/unit/Sql/ArgumentTest.php @@ -22,7 +22,8 @@ #[CoversMethod(Argument::class, 'select')] final class ArgumentTest extends TestCase { - public function testConstructorThrowsExceptionForInvalidSelectType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorThrowsExceptionForInvalidSelectType(): void { self::expectException(TypeError::class); /** @noinspection PhpParamsInspection */ @@ -30,105 +31,118 @@ public function testConstructorThrowsExceptionForInvalidSelectType(): void new ArgumentSelect('simple_value'); /** @phpstan-ignore-line */ } - public function testConstructorWithArrayContainingArgumentType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithArrayContainingArgumentType(): void { $argument = new Identifier('column'); - self::assertEquals('column', $argument->getValue()); - self::assertEquals(ArgumentType::Identifier, $argument->getType()); + static::assertSame('column', $argument->getValue()); + static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - public function testConstructorWithBooleanValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithBooleanValue(): void { $argument = new Value(true); - self::assertTrue($argument->getValue()); - self::assertEquals(ArgumentType::Value, $argument->getType()); + static::assertTrue($argument->getValue()); + static::assertEquals(ArgumentType::Value, $argument->getType()); } - public function testConstructorWithExplicitType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithExplicitType(): void { $argument = new Identifier('column_name'); - self::assertEquals('column_name', $argument->getValue()); - self::assertEquals(ArgumentType::Identifier, $argument->getType()); + static::assertSame('column_name', $argument->getValue()); + static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - public function testConstructorWithExpressionInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithExpressionInterface(): void { $expression = new Expression('NOW()'); $argument = new ArgumentSelect($expression); - self::assertSame($expression, $argument->getValue()); - self::assertEquals(ArgumentType::Select, $argument->getType()); + static::assertSame($expression, $argument->getValue()); + static::assertEquals(ArgumentType::Select, $argument->getType()); } - public function testConstructorWithFloatValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithFloatValue(): void { $argument = new Value(3.14); - self::assertEquals(3.14, $argument->getValue()); - self::assertEquals(ArgumentType::Value, $argument->getType()); + static::assertSame(3.14, $argument->getValue()); + static::assertEquals(ArgumentType::Value, $argument->getType()); } - public function testConstructorWithNullValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithNullValue(): void { $argument = new Value(null); - self::assertNull($argument->getValue()); - self::assertEquals(ArgumentType::Value, $argument->getType()); + static::assertNull($argument->getValue()); + static::assertEquals(ArgumentType::Value, $argument->getType()); } - public function testConstructorWithSimpleArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSimpleArray(): void { $argument = new Values([1, 2, 3]); - self::assertEquals([1, 2, 3], $argument->getValue()); - self::assertEquals(ArgumentType::Values, $argument->getType()); + static::assertEquals([1, 2, 3], $argument->getValue()); + static::assertEquals(ArgumentType::Values, $argument->getType()); } - public function testConstructorWithSimpleValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSimpleValue(): void { $argument = new Value('test'); - self::assertEquals('test', $argument->getValue()); - self::assertEquals(ArgumentType::Value, $argument->getType()); + static::assertSame('test', $argument->getValue()); + static::assertEquals(ArgumentType::Value, $argument->getType()); } - public function testConstructorWithSqlInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSqlInterface(): void { $select = new Select(); $argument = new ArgumentSelect($select); - self::assertSame($select, $argument->getValue()); - self::assertEquals(ArgumentType::Select, $argument->getType()); + static::assertSame($select, $argument->getValue()); + static::assertEquals(ArgumentType::Select, $argument->getType()); } - public function testStaticIdentifierMethod(): void + #[\PHPUnit\Framework\Attributes\Test] + public function staticIdentifierMethod(): void { $argument = Argument::identifier('column_name'); - self::assertEquals('column_name', $argument->getValue()); - self::assertEquals(ArgumentType::Identifier, $argument->getType()); + static::assertSame('column_name', $argument->getValue()); + static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - public function testStaticLiteralMethod(): void + #[\PHPUnit\Framework\Attributes\Test] + public function staticLiteralMethod(): void { $argument = Argument::literal('LITERAL_VALUE'); - self::assertEquals('LITERAL_VALUE', $argument->getValue()); - self::assertEquals(ArgumentType::Literal, $argument->getType()); + static::assertSame('LITERAL_VALUE', $argument->getValue()); + static::assertEquals(ArgumentType::Literal, $argument->getType()); } - public function testStaticSelectMethodCreatesSelectArgument(): void + #[\PHPUnit\Framework\Attributes\Test] + public function staticSelectMethodCreatesSelectArgument(): void { $select = new Select(); $argument = Argument::select($select); - self::assertSame($select, $argument->getValue()); - self::assertEquals(ArgumentType::Select, $argument->getType()); + static::assertSame($select, $argument->getValue()); + static::assertEquals(ArgumentType::Select, $argument->getType()); } - public function testStaticValueMethod(): void + #[\PHPUnit\Framework\Attributes\Test] + public function staticValueMethod(): void { $argument = Argument::value('test_value'); - self::assertEquals('test_value', $argument->getValue()); - self::assertEquals(ArgumentType::Value, $argument->getType()); + static::assertSame('test_value', $argument->getValue()); + static::assertEquals(ArgumentType::Value, $argument->getType()); } } diff --git a/test/unit/Sql/CombineTest.php b/test/unit/Sql/CombineTest.php index a44595d1..f7e94a97 100644 --- a/test/unit/Sql/CombineTest.php +++ b/test/unit/Sql/CombineTest.php @@ -34,7 +34,8 @@ final class CombineTest extends TestCase protected Combine $combine; - public function testAlignColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function alignColumns(): void { $select1 = new Select('t1'); $select1->columns([ @@ -52,7 +53,7 @@ public function testAlignColumns(): void ->alignColumns(); // Verify first select has NULL for missing c2 - self::assertEquals( + static::assertEquals( [ 'c0' => 'c0', 'c1' => 'c1', @@ -62,7 +63,7 @@ public function testAlignColumns(): void ); // Verify second select has NULL for missing c0 - self::assertEquals( + static::assertEquals( [ 'c0' => new Expression('NULL'), 'c1' => 'c1', @@ -72,7 +73,8 @@ public function testAlignColumns(): void ); } - public function testAlignColumnsAppendsNullExpressionsForMissingColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function alignColumnsAppendsNullExpressionsForMissingColumns(): void { $select1 = new Select('t1'); $select1->columns(['a' => 'a']); @@ -83,47 +85,51 @@ public function testAlignColumnsAppendsNullExpressionsForMissingColumns(): void $this->combine->union([$select1, $select2])->alignColumns(); $columns1 = $select1->getRawState('columns'); - self::assertArrayHasKey('b', $columns1); - self::assertInstanceOf(Expression::class, $columns1['b']); + static::assertArrayHasKey('b', $columns1); + static::assertInstanceOf(Expression::class, $columns1['b']); } - public function testAlignColumnsReturnsEarlyWhenEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function alignColumnsReturnsEarlyWhenEmpty(): void { $combine = new Combine(); $result = $combine->alignColumns(); - self::assertSame($combine, $result); + static::assertSame($combine, $result); } - public function testCombineWithArrayOfSelectAndModifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function combineWithArrayOfSelectAndModifier(): void { $this->combine->combine([ [new Select('t1'), 'UNION', 'ALL'], [new Select('t2'), 'INTERSECT'], ]); - self::assertEquals( + static::assertSame( '(SELECT "t1".* FROM "t1") INTERSECT (SELECT "t2".* FROM "t2")', $this->combine->getSqlString(), ); } - public function testConstructorWithSelectDelegatesToCombine(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSelectDelegatesToCombine(): void { $select = new Select('foo'); $combine = new Combine($select, Combine::COMBINE_EXCEPT, 'ALL'); $rawState = $combine->getRawState(); - self::assertCount(1, $rawState['combine']); - self::assertSame('except', $rawState['combine'][0]['type']); - self::assertSame('ALL', $rawState['combine'][0]['modifier']); + static::assertCount(1, $rawState['combine']); + static::assertSame('except', $rawState['combine'][0]['type']); + static::assertSame('ALL', $rawState['combine'][0]['modifier']); } - public function testGetRawState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawState(): void { $select = new Select('t1'); $this->combine->combine($select); - self::assertSame( + static::assertSame( [ 'combine' => [ [ @@ -140,7 +146,8 @@ public function testGetRawState(): void ); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $this->combine ->union(new Select('t1')) @@ -148,7 +155,7 @@ public function testGetSqlString(): void ->except(new Select('t3')) ->union(new Select('t4')); - self::assertEquals( + static::assertSame( // @codingStandardsIgnoreStart '(SELECT "t1".* FROM "t1") INTERSECT (SELECT "t2".* FROM "t2") EXCEPT (SELECT "t3".* FROM "t3") UNION (SELECT "t4".* FROM "t4")', // @codingStandardsIgnoreEnd @@ -156,12 +163,14 @@ public function testGetSqlString(): void ); } - public function testGetSqlStringEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringEmpty(): void { - self::assertEmpty($this->combine->getSqlString()); + static::assertEmpty($this->combine->getSqlString()); } - public function testGetSqlStringFromArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringFromArray(): void { $this->combine->combine([ [new Select('t1')], @@ -169,7 +178,7 @@ public function testGetSqlStringFromArray(): void [new Select('t3'), Combine::COMBINE_EXCEPT], ]); - self::assertEquals( + static::assertSame( '(SELECT "t1".* FROM "t1") INTERSECT ALL (SELECT "t2".* FROM "t2") EXCEPT (SELECT "t3".* FROM "t3")', $this->combine->getSqlString(), ); @@ -181,25 +190,27 @@ public function testGetSqlStringFromArray(): void new Select('t3'), ]); - self::assertEquals( + static::assertSame( '(SELECT "t1".* FROM "t1") UNION (SELECT "t2".* FROM "t2") UNION (SELECT "t3".* FROM "t3")', $this->combine->getSqlString(), ); } - public function testGetSqlStringWithModifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithModifier(): void { $this->combine ->union(new Select('t1')) ->union(new Select('t2'), 'ALL'); - self::assertEquals( + static::assertSame( '(SELECT "t1".* FROM "t1") UNION ALL (SELECT "t2".* FROM "t2")', $this->combine->getSqlString(), ); } - public function testPrepareStatementWithModifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementWithModifier(): void { $select1 = new Select('t1'); $select1->where(['x1' => 10]); @@ -215,14 +226,15 @@ public function testPrepareStatementWithModifier(): void $adapter = $this->getMockAdapter(); $statement = $this->combine->prepareStatement($adapter, new StatementContainer()); - self::assertInstanceOf(StatementContainerInterface::class, $statement); - self::assertEquals( + static::assertInstanceOf(StatementContainerInterface::class, $statement); + static::assertSame( '(SELECT "t1".* FROM "t1" WHERE "x1" = ?) UNION (SELECT "t2".* FROM "t2" WHERE "x2" = ?)', $statement->getSql(), ); } - public function testRejectsInvalidStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsInvalidStatement(): void { self::expectException(TypeError::class); diff --git a/test/unit/Sql/Ddl/AlterTableTest.php b/test/unit/Sql/Ddl/AlterTableTest.php index c1bb71f5..698059a8 100644 --- a/test/unit/Sql/Ddl/AlterTableTest.php +++ b/test/unit/Sql/Ddl/AlterTableTest.php @@ -38,37 +38,41 @@ #[CoversMethod(AlterTable::class, 'processTableOptions')] class AlterTableTest extends TestCase { - public function testAddColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addColumn(): void { $at = new AlterTable(); /** @var ColumnInterface $colMock */ $colMock = $this->getMockBuilder(ColumnInterface::class)->getMock(); - self::assertSame($at, $at->addColumn($colMock)); - self::assertEquals([$colMock], $at->getRawState(AlterTable::ADD_COLUMNS)); + static::assertSame($at, $at->addColumn($colMock)); + static::assertEquals([$colMock], $at->getRawState(AlterTable::ADD_COLUMNS)); } - public function testAddConstraint(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addConstraint(): void { $at = new AlterTable(); /** @var ConstraintInterface $conMock */ $conMock = $this->getMockBuilder(ConstraintInterface::class)->getMock(); - self::assertSame($at, $at->addConstraint($conMock)); - self::assertEquals([$conMock], $at->getRawState(AlterTable::ADD_CONSTRAINTS)); + static::assertSame($at, $at->addConstraint($conMock)); + static::assertEquals([$conMock], $at->getRawState(AlterTable::ADD_CONSTRAINTS)); } - public function testAddConstraintGeneratesCorrectSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addConstraintGeneratesCorrectSql(): void { $at = new AlterTable('orders'); $fk = new Constraint\ForeignKey('fk_user', 'user_id', 'users', 'id'); $at->addConstraint($fk); $sql = $at->getSqlString(); - self::assertStringContainsString('ADD CONSTRAINT', $sql); - self::assertStringContainsString('"fk_user"', $sql); - self::assertStringContainsString('FOREIGN KEY', $sql); + static::assertStringContainsString('ADD CONSTRAINT', $sql); + static::assertStringContainsString('"fk_user"', $sql); + static::assertStringContainsString('FOREIGN KEY', $sql); } - public function testChainedOperations(): void + #[\PHPUnit\Framework\Attributes\Test] + public function chainedOperations(): void { $at = new AlterTable(); $col = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -81,101 +85,113 @@ public function testChainedOperations(): void ->dropConstraint('old_fk') ->dropIndex('old_idx'); - self::assertSame($at, $result); - self::assertEquals('test', $at->getRawState(AlterTable::TABLE)); + static::assertSame($at, $result); + static::assertSame('test', $at->getRawState(AlterTable::TABLE)); } - public function testChangeColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function changeColumn(): void { $at = new AlterTable(); /** @var ColumnInterface $colMock */ $colMock = $this->getMockBuilder(ColumnInterface::class)->getMock(); - self::assertSame($at, $at->changeColumn('newname', $colMock)); - self::assertEquals(['newname' => $colMock], $at->getRawState(AlterTable::CHANGE_COLUMNS)); + static::assertSame($at, $at->changeColumn('newname', $colMock)); + static::assertEquals(['newname' => $colMock], $at->getRawState(AlterTable::CHANGE_COLUMNS)); } - public function testChangeColumnGeneratesCorrectSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function changeColumnGeneratesCorrectSql(): void { $at = new AlterTable('users'); $at->changeColumn('old_name', new Column\Varchar('new_name', 100)); $sql = $at->getSqlString(); - self::assertStringContainsString('CHANGE COLUMN', $sql); - self::assertStringContainsString('"old_name"', $sql); - self::assertStringContainsString('"new_name"', $sql); - self::assertStringContainsString('VARCHAR(100)', $sql); + static::assertStringContainsString('CHANGE COLUMN', $sql); + static::assertStringContainsString('"old_name"', $sql); + static::assertStringContainsString('"new_name"', $sql); + static::assertStringContainsString('VARCHAR(100)', $sql); } - public function testConstructorWithEmptyTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithEmptyTable(): void { $at = new AlterTable(); - self::assertEquals('', $at->getRawState('table')); + static::assertSame('', $at->getRawState('table')); } - public function testConstructorWithTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTable(): void { $at = new AlterTable('test_table'); - self::assertEquals('test_table', $at->getRawState('table')); + static::assertSame('test_table', $at->getRawState('table')); } - public function testConstructorWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTableIdentifier(): void { $tableId = new TableIdentifier('bar', 'foo'); $at = new AlterTable($tableId); // Get full raw state to avoid type issue with getRawState('table') $rawState = $at->getRawState(); - self::assertSame($tableId, $rawState['table']); + static::assertSame($tableId, $rawState['table']); } - public function testDropColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function dropColumn(): void { $at = new AlterTable(); - self::assertSame($at, $at->dropColumn('foo')); - self::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_COLUMNS)); + static::assertSame($at, $at->dropColumn('foo')); + static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_COLUMNS)); } - public function testDropConstraint(): void + #[\PHPUnit\Framework\Attributes\Test] + public function dropConstraint(): void { $at = new AlterTable(); - self::assertSame($at, $at->dropConstraint('foo')); - self::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_CONSTRAINTS)); + static::assertSame($at, $at->dropConstraint('foo')); + static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_CONSTRAINTS)); } - public function testDropIndex(): void + #[\PHPUnit\Framework\Attributes\Test] + public function dropIndex(): void { $at = new AlterTable(); - self::assertSame($at, $at->dropIndex('foo')); - self::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_INDEXES)); + static::assertSame($at, $at->dropIndex('foo')); + static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_INDEXES)); } - public function testEmptyAlterTableGeneratesMinimalSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyAlterTableGeneratesMinimalSql(): void { $at = new AlterTable('test_table'); $sql = $at->getSqlString(); // Should have ALTER TABLE but no operations - self::assertStringContainsString('ALTER TABLE "test_table"', $sql); + static::assertStringContainsString('ALTER TABLE "test_table"', $sql); } - public function testGetOptionsReturnsEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getOptionsReturnsEmpty(): void { $at = new AlterTable('foo'); - self::assertEquals([], $at->getOptions()); + static::assertEquals([], $at->getOptions()); } - public function testGetRawStateIncludesTableOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateIncludesTableOptions(): void { $at = new AlterTable('foo'); $at->setOption('engine', new Literal('InnoDB')); $rawState = $at->getRawState(); - self::assertArrayHasKey(AlterTable::TABLE_OPTIONS, $rawState); - self::assertEquals(['engine' => new Literal('InnoDB')], $rawState[AlterTable::TABLE_OPTIONS]); + static::assertArrayHasKey(AlterTable::TABLE_OPTIONS, $rawState); + static::assertEquals(['engine' => new Literal('InnoDB')], $rawState[AlterTable::TABLE_OPTIONS]); } - public function testGetRawStateReturnsAllState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateReturnsAllState(): void { $at = new AlterTable('test'); $colMock = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -190,49 +206,52 @@ public function testGetRawStateReturnsAllState(): void $rawState = $at->getRawState(); - self::assertIsArray($rawState); - self::assertArrayHasKey(AlterTable::TABLE, $rawState); - self::assertArrayHasKey(AlterTable::ADD_COLUMNS, $rawState); - self::assertArrayHasKey(AlterTable::CHANGE_COLUMNS, $rawState); - self::assertArrayHasKey(AlterTable::DROP_COLUMNS, $rawState); - self::assertArrayHasKey(AlterTable::ADD_CONSTRAINTS, $rawState); - self::assertArrayHasKey(AlterTable::DROP_CONSTRAINTS, $rawState); - self::assertArrayHasKey(AlterTable::DROP_INDEXES, $rawState); + static::assertIsArray($rawState); + static::assertArrayHasKey(AlterTable::TABLE, $rawState); + static::assertArrayHasKey(AlterTable::ADD_COLUMNS, $rawState); + static::assertArrayHasKey(AlterTable::CHANGE_COLUMNS, $rawState); + static::assertArrayHasKey(AlterTable::DROP_COLUMNS, $rawState); + static::assertArrayHasKey(AlterTable::ADD_CONSTRAINTS, $rawState); + static::assertArrayHasKey(AlterTable::DROP_CONSTRAINTS, $rawState); + static::assertArrayHasKey(AlterTable::DROP_INDEXES, $rawState); - self::assertEquals('test', $rawState[AlterTable::TABLE]); - self::assertEquals([$colMock], $rawState[AlterTable::ADD_COLUMNS]); - self::assertEquals(['old_col' => $colMock], $rawState[AlterTable::CHANGE_COLUMNS]); - self::assertEquals(['drop_col'], $rawState[AlterTable::DROP_COLUMNS]); - self::assertEquals([$conMock], $rawState[AlterTable::ADD_CONSTRAINTS]); - self::assertEquals(['drop_con'], $rawState[AlterTable::DROP_CONSTRAINTS]); - self::assertEquals(['drop_idx'], $rawState[AlterTable::DROP_INDEXES]); + static::assertSame('test', $rawState[AlterTable::TABLE]); + static::assertEquals([$colMock], $rawState[AlterTable::ADD_COLUMNS]); + static::assertEquals(['old_col' => $colMock], $rawState[AlterTable::CHANGE_COLUMNS]); + static::assertEquals(['drop_col'], $rawState[AlterTable::DROP_COLUMNS]); + static::assertEquals([$conMock], $rawState[AlterTable::ADD_CONSTRAINTS]); + static::assertEquals(['drop_con'], $rawState[AlterTable::DROP_CONSTRAINTS]); + static::assertEquals(['drop_idx'], $rawState[AlterTable::DROP_INDEXES]); } - public function testGetRawStateWithInvalidKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateWithInvalidKey(): void { $at = new AlterTable('test'); $result = $at->getRawState('invalid_key'); // Should return full array when key doesn't exist - self::assertIsArray($result); - self::assertArrayHasKey(AlterTable::TABLE, $result); + static::assertIsArray($result); + static::assertArrayHasKey(AlterTable::TABLE, $result); } - public function testGetRawStateWithSpecificKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateWithSpecificKey(): void { $at = new AlterTable('my_table'); $at->dropColumn('col1'); $at->dropColumn('col2'); - self::assertEquals('my_table', $at->getRawState(AlterTable::TABLE)); - self::assertEquals(['col1', 'col2'], $at->getRawState(AlterTable::DROP_COLUMNS)); - self::assertEquals([], $at->getRawState(AlterTable::ADD_COLUMNS)); + static::assertSame('my_table', $at->getRawState(AlterTable::TABLE)); + static::assertEquals(['col1', 'col2'], $at->getRawState(AlterTable::DROP_COLUMNS)); + static::assertEquals([], $at->getRawState(AlterTable::ADD_COLUMNS)); } /** * @todo Implement testGetSqlString(). */ - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $at = new AlterTable('foo'); $at->addColumn(new Column\Varchar('another', 255)); @@ -253,80 +272,87 @@ public function testGetSqlString(): void EOS; $actual = $at->getSqlString(); - self::assertEquals( + static::assertEquals( str_replace(["\r", "\n"], '', $expected), str_replace(["\r", "\n"], '', $actual), ); $at = new AlterTable(new TableIdentifier('foo')); $at->addColumn(new Column\Column('bar')); - $this->assertEquals("ALTER TABLE \"foo\"\n ADD COLUMN \"bar\" INTEGER NOT NULL", $at->getSqlString()); + static::assertSame("ALTER TABLE \"foo\"\n ADD COLUMN \"bar\" INTEGER NOT NULL", $at->getSqlString()); $at = new AlterTable(new TableIdentifier('bar', 'foo')); $at->addColumn(new Column\Column('baz')); - $this->assertEquals("ALTER TABLE \"foo\".\"bar\"\n ADD COLUMN \"baz\" INTEGER NOT NULL", $at->getSqlString()); + static::assertSame("ALTER TABLE \"foo\".\"bar\"\n ADD COLUMN \"baz\" INTEGER NOT NULL", $at->getSqlString()); } - public function testGetSqlStringWithBoolOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithBoolOption(): void { $at = new AlterTable('foo'); $at->setOption('pack_keys', true); $sql = $at->getSqlString(); - self::assertStringContainsString('PACK_KEYS = 1', $sql); + static::assertStringContainsString('PACK_KEYS = 1', $sql); } - public function testGetSqlStringWithColumnAndEngineOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithColumnAndEngineOption(): void { $at = new AlterTable('foo'); $at->addColumn(new Column\Column('bar')); $at->setOption('engine', new Literal('InnoDB')); $sql = $at->getSqlString(); - self::assertStringContainsString('ADD COLUMN "bar" INTEGER NOT NULL', $sql); - self::assertStringContainsString('ENGINE = InnoDB', $sql); + static::assertStringContainsString('ADD COLUMN "bar" INTEGER NOT NULL', $sql); + static::assertStringContainsString('ENGINE = InnoDB', $sql); } - public function testGetSqlStringWithEngineOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithEngineOption(): void { $at = new AlterTable('foo'); $at->setOption('engine', new Literal('InnoDB')); $sql = $at->getSqlString(); - self::assertStringContainsString('ALTER TABLE "foo"', $sql); - self::assertStringContainsString('ENGINE = InnoDB', $sql); + static::assertStringContainsString('ALTER TABLE "foo"', $sql); + static::assertStringContainsString('ENGINE = InnoDB', $sql); } - public function testGetSqlStringWithIntOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithIntOption(): void { $at = new AlterTable('foo'); $at->setOption('auto_increment', 100); $sql = $at->getSqlString(); - self::assertStringContainsString('AUTO_INCREMENT = 100', $sql); + static::assertStringContainsString('AUTO_INCREMENT = 100', $sql); } - public function testGetSqlStringWithMultipleOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithMultipleOptions(): void { $at = new AlterTable('foo'); $at->setOption('engine', new Literal('InnoDB')); $at->setOption('auto_increment', 100); $sql = $at->getSqlString(); - self::assertStringContainsString('ENGINE = InnoDB', $sql); - self::assertStringContainsString('AUTO_INCREMENT = 100', $sql); + static::assertStringContainsString('ENGINE = InnoDB', $sql); + static::assertStringContainsString('AUTO_INCREMENT = 100', $sql); } - public function testGetSqlStringWithStringOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithStringOption(): void { $at = new AlterTable('foo'); $at->setOption('comment', 'My table'); $sql = $at->getSqlString(); - self::assertStringContainsString('COMMENT = \'My table\'', $sql); + static::assertStringContainsString('COMMENT = \'My table\'', $sql); } - public function testMixedOperationsInCorrectOrder(): void + #[\PHPUnit\Framework\Attributes\Test] + public function mixedOperationsInCorrectOrder(): void { $at = new AlterTable('complex_table'); @@ -341,26 +367,28 @@ public function testMixedOperationsInCorrectOrder(): void $sql = $at->getSqlString(); // Verify all operations are present - self::assertStringContainsString('ADD COLUMN "new_col"', $sql); - self::assertStringContainsString('CHANGE COLUMN "existing"', $sql); - self::assertStringContainsString('DROP COLUMN "old_col"', $sql); - self::assertStringContainsString('ADD CONSTRAINT "fk_test"', $sql); - self::assertStringContainsString('DROP CONSTRAINT "old_constraint"', $sql); - self::assertStringContainsString('DROP INDEX "old_index"', $sql); + static::assertStringContainsString('ADD COLUMN "new_col"', $sql); + static::assertStringContainsString('CHANGE COLUMN "existing"', $sql); + static::assertStringContainsString('DROP COLUMN "old_col"', $sql); + static::assertStringContainsString('ADD CONSTRAINT "fk_test"', $sql); + static::assertStringContainsString('DROP CONSTRAINT "old_constraint"', $sql); + static::assertStringContainsString('DROP INDEX "old_index"', $sql); } - public function testMultipleChangeColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleChangeColumns(): void { $at = new AlterTable('products'); $at->changeColumn('price', new Column\Decimal('cost', 10, 2)); $at->changeColumn('name', new Column\Varchar('title', 200)); $sql = $at->getSqlString(); - self::assertStringContainsString('CHANGE COLUMN "price" "cost"', $sql); - self::assertStringContainsString('CHANGE COLUMN "name" "title"', $sql); + static::assertStringContainsString('CHANGE COLUMN "price" "cost"', $sql); + static::assertStringContainsString('CHANGE COLUMN "name" "title"', $sql); } - public function testMultipleColumnsAndConstraints(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleColumnsAndConstraints(): void { $at = new AlterTable('users'); @@ -372,15 +400,16 @@ public function testMultipleColumnsAndConstraints(): void $at->addColumn($col2); $at->addColumn($col3); - self::assertCount(3, $at->getRawState(AlterTable::ADD_COLUMNS)); + static::assertCount(3, $at->getRawState(AlterTable::ADD_COLUMNS)); $sql = $at->getSqlString(); - self::assertStringContainsString('ADD COLUMN "email"', $sql); - self::assertStringContainsString('ADD COLUMN "age"', $sql); - self::assertStringContainsString('ADD COLUMN "bio"', $sql); + static::assertStringContainsString('ADD COLUMN "email"', $sql); + static::assertStringContainsString('ADD COLUMN "age"', $sql); + static::assertStringContainsString('ADD COLUMN "bio"', $sql); } - public function testMultipleConstraints(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleConstraints(): void { $at = new AlterTable('orders'); $fk1 = new Constraint\ForeignKey('fk_user', 'user_id', 'users', 'id'); @@ -390,11 +419,12 @@ public function testMultipleConstraints(): void $at->addConstraint($fk2); $sql = $at->getSqlString(); - self::assertStringContainsString('"fk_user"', $sql); - self::assertStringContainsString('"fk_product"', $sql); + static::assertStringContainsString('"fk_user"', $sql); + static::assertStringContainsString('"fk_product"', $sql); } - public function testMultipleDropOperations(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleDropOperations(): void { $at = new AlterTable('products'); @@ -404,46 +434,50 @@ public function testMultipleDropOperations(): void $at->dropIndex('old_idx'); $sql = $at->getSqlString(); - self::assertStringContainsString('DROP COLUMN "old_col1"', $sql); - self::assertStringContainsString('DROP COLUMN "old_col2"', $sql); - self::assertStringContainsString('DROP CONSTRAINT "old_fk"', $sql); - self::assertStringContainsString('DROP INDEX "old_idx"', $sql); + static::assertStringContainsString('DROP COLUMN "old_col1"', $sql); + static::assertStringContainsString('DROP COLUMN "old_col2"', $sql); + static::assertStringContainsString('DROP CONSTRAINT "old_fk"', $sql); + static::assertStringContainsString('DROP INDEX "old_idx"', $sql); } - public function testSetOptionFluentInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOptionFluentInterface(): void { $at = new AlterTable('foo'); $result = $at->setOption('engine', new Literal('InnoDB')); - self::assertSame($at, $result); - self::assertEquals(['engine' => new Literal('InnoDB')], $at->getOptions()); + static::assertSame($at, $result); + static::assertEquals(['engine' => new Literal('InnoDB')], $at->getOptions()); } - public function testSetOptionsReplacesAll(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOptionsReplacesAll(): void { $at = new AlterTable('foo'); $at->setOption('engine', new Literal('InnoDB')); $at->setOptions(['charset' => new Literal('utf8mb4')]); - self::assertEquals(['charset' => new Literal('utf8mb4')], $at->getOptions()); + static::assertEquals(['charset' => new Literal('utf8mb4')], $at->getOptions()); } - public function testSetTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTable(): void { $at = new AlterTable(); - self::assertEquals('', $at->getRawState('table')); - self::assertSame($at, $at->setTable('test')); - self::assertEquals('test', $at->getRawState('table')); + static::assertSame('', $at->getRawState('table')); + static::assertSame($at, $at->setTable('test')); + static::assertSame('test', $at->getRawState('table')); } - public function testTableIdentifierInChangeColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function tableIdentifierInChangeColumn(): void { $at = new AlterTable(new TableIdentifier('table', 'schema')); $at->changeColumn('col1', new Column\Integer('col1_new')); $sql = $at->getSqlString(); - self::assertStringContainsString('"schema"."table"', $sql); - self::assertStringContainsString('CHANGE COLUMN "col1" "col1_new"', $sql); + static::assertStringContainsString('"schema"."table"', $sql); + static::assertStringContainsString('CHANGE COLUMN "col1" "col1_new"', $sql); } } diff --git a/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php b/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php index 8cc511a2..c991141f 100644 --- a/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php +++ b/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php @@ -24,6 +24,30 @@ final class AbstractLengthColumnTest extends TestCase { use ColumnAssertionsTrait; + /** + * @throws Exception + */ + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = $this->getMockBuilder(AbstractLengthColumn::class) + ->setConstructorArgs(['foo', 4]) + ->onlyMethods([]) + ->getMock(); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + new Identifier('foo'), + new Literal('INTEGER'), + new Literal('4'), + ], + $expressionData['values'], + ); + } + /** * The length is inserted directly after the type. Values contributed by a default and * by a constraint sit after that point, so they must be pushed along rather than @@ -80,93 +104,72 @@ public function getExpressionDataOmitsLengthPlaceholderWhenLengthIsNotSet(): voi /** * @throws Exception */ - #[Test] - public function rendersLengthDirectlyAfterType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLength(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) - ->setConstructorArgs(['foo', 4, true]) + ->setConstructorArgs(['foo', 55]) ->onlyMethods([]) ->getMock(); - - static::assertColumnRenders('"foo" INTEGER(4) NULL DEFAULT NULL', $column); + static::assertSame(55, $column->getLength()); } /** * @throws Exception */ #[Test] - public function rendersWithoutParenthesesWhenLengthIsNotSet(): void + public function rendersLengthDirectlyAfterType(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) - ->setConstructorArgs(['foo']) + ->setConstructorArgs(['foo', 4, true]) ->onlyMethods([]) ->getMock(); - static::assertColumnRenders('"foo" INTEGER NOT NULL', $column); + static::assertColumnRenders('"foo" INTEGER(4) NULL DEFAULT NULL', $column); } /** * @throws Exception */ #[Test] - public function setLengthWithoutAnArgumentResetsTheLengthToZero(): void - { - $column = $this->getMockBuilder(AbstractLengthColumn::class) - ->setConstructorArgs(['foo', 55]) - ->onlyMethods([]) - ->getMock(); - - $column->setLength(); - - static::assertSame(0, $column->getLength()); - } - - /** - * @throws Exception - */ - public function testGetExpressionData(): void + public function rendersWithoutParenthesesWhenLengthIsNotSet(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) - ->setConstructorArgs(['foo', 4]) + ->setConstructorArgs(['foo']) ->onlyMethods([]) ->getMock(); - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - new Identifier('foo'), - new Literal('INTEGER'), - new Literal('4'), - ], - $expressionData['values'], - ); + static::assertColumnRenders('"foo" INTEGER NOT NULL', $column); } /** * @throws Exception */ - public function testGetLength(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setLength(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) ->setConstructorArgs(['foo', 55]) ->onlyMethods([]) ->getMock(); - self::assertEquals(55, $column->getLength()); + static::assertSame(55, $column->getLength()); + static::assertSame($column, $column->setLength(20)); + static::assertSame(20, $column->getLength()); } /** * @throws Exception */ - public function testSetLength(): void + #[Test] + public function setLengthWithoutAnArgumentResetsTheLengthToZero(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) ->setConstructorArgs(['foo', 55]) ->onlyMethods([]) ->getMock(); - self::assertEquals(55, $column->getLength()); - self::assertSame($column, $column->setLength(20)); - self::assertEquals(20, $column->getLength()); + + $column->setLength(); + + static::assertSame(0, $column->getLength()); } } diff --git a/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php b/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php index 26c831aa..ccdbda0c 100644 --- a/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php +++ b/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php @@ -27,36 +27,39 @@ final class AbstractPrecisionColumnTest extends TestCase /** * @throws Exception */ - #[Test] - public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDecimal(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) - ->setConstructorArgs(['foo']) + ->setConstructorArgs(['foo', 10, 5]) ->onlyMethods([]) ->getMock(); - - $expressionData = $column->getExpressionData(); - - static::assertSame('%s %s NOT NULL', $expressionData['spec']); - static::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('INTEGER'), - ], - $expressionData['values'], - ); + static::assertSame(5, $column->getDecimal()); } /** * @throws Exception */ - #[Test] - public function getExpressionDataUsesDigitsOnlyWhenDecimalIsNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDigits(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) ->setConstructorArgs(['foo', 10]) ->onlyMethods([]) ->getMock(); + static::assertSame(10, $column->getDigits()); + } + + /** + * @throws Exception + */ + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = $this->getMockBuilder(AbstractPrecisionColumn::class) + ->setConstructorArgs(['foo', 10, 5]) + ->onlyMethods([]) + ->getMock(); $expressionData = $column->getExpressionData(); @@ -65,7 +68,7 @@ public function getExpressionDataUsesDigitsOnlyWhenDecimalIsNotSet(): void [ Argument::identifier('foo'), Argument::literal('INTEGER'), - Argument::literal('10'), + Argument::literal('10,5'), ], $expressionData['values'], ); @@ -74,45 +77,45 @@ public function getExpressionDataUsesDigitsOnlyWhenDecimalIsNotSet(): void /** * @throws Exception */ - public function testGetDecimal(): void + #[Test] + public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) - ->setConstructorArgs(['foo', 10, 5]) + ->setConstructorArgs(['foo']) ->onlyMethods([]) ->getMock(); - self::assertEquals(5, $column->getDecimal()); - } - /** - * @throws Exception - */ - public function testGetDigits(): void - { - $column = $this->getMockBuilder(AbstractPrecisionColumn::class) - ->setConstructorArgs(['foo', 10]) - ->onlyMethods([]) - ->getMock(); - self::assertEquals(10, $column->getDigits()); + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('INTEGER'), + ], + $expressionData['values'], + ); } /** * @throws Exception */ - public function testGetExpressionData(): void + #[Test] + public function getExpressionDataUsesDigitsOnlyWhenDecimalIsNotSet(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) - ->setConstructorArgs(['foo', 10, 5]) + ->setConstructorArgs(['foo', 10]) ->onlyMethods([]) ->getMock(); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('INTEGER'), - Argument::literal('10,5'), + Argument::literal('10'), ], $expressionData['values'], ); @@ -121,29 +124,31 @@ public function testGetExpressionData(): void /** * @throws Exception */ - public function testSetDecimal(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDecimal(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) ->setConstructorArgs(['foo', 10, 5]) ->onlyMethods([]) ->getMock(); - self::assertEquals(5, $column->getDecimal()); - self::assertSame($column, $column->setDecimal(2)); - self::assertEquals(2, $column->getDecimal()); + static::assertSame(5, $column->getDecimal()); + static::assertSame($column, $column->setDecimal(2)); + static::assertSame(2, $column->getDecimal()); } /** * @throws Exception */ - public function testSetDigits(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDigits(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) ->setConstructorArgs(['foo', 10]) ->onlyMethods([]) ->getMock(); - self::assertEquals(10, $column->getDigits()); - self::assertSame($column, $column->setDigits(12)); - self::assertEquals(12, $column->getDigits()); + static::assertSame(10, $column->getDigits()); + static::assertSame($column, $column->setDigits(12)); + static::assertSame(12, $column->getDigits()); } /** diff --git a/test/unit/Sql/Ddl/Column/BigIntegerTest.php b/test/unit/Sql/Ddl/Column/BigIntegerTest.php index 3fc7959b..c0ebbcbc 100644 --- a/test/unit/Sql/Ddl/Column/BigIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/BigIntegerTest.php @@ -20,26 +20,18 @@ #[Group('unit')] final class BigIntegerTest extends TestCase { - #[Test] - public function rendersLengthDirectlyAfterType(): void - { - $createTable = new CreateTable('t'); - $createTable->addColumn(new BigInteger('i', false, null, ['length' => 20])); - - static::assertSame("CREATE TABLE \"t\" ( \n \"i\" BIGINT(20) NOT NULL \n)", $createTable->getSqlString()); - } - - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new BigInteger('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals( + static::assertSame( '%s %s NOT NULL', $expressionData['spec'], ); - self::assertEquals( + static::assertEquals( [ Argument::Identifier('foo'), Argument::Literal('BIGINT'), @@ -48,9 +40,19 @@ public function testGetExpressionData(): void ); } - public function testObjectConstruction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function objectConstruction(): void { $integer = new BigInteger('foo'); - self::assertEquals('foo', $integer->getName()); + static::assertSame('foo', $integer->getName()); + } + + #[Test] + public function rendersLengthDirectlyAfterType(): void + { + $createTable = new CreateTable('t'); + $createTable->addColumn(new BigInteger('i', false, null, ['length' => 20])); + + static::assertSame("CREATE TABLE \"t\" ( \n \"i\" BIGINT(20) NOT NULL \n)", $createTable->getSqlString()); } } diff --git a/test/unit/Sql/Ddl/Column/BinaryTest.php b/test/unit/Sql/Ddl/Column/BinaryTest.php index 6677118d..53724fc1 100644 --- a/test/unit/Sql/Ddl/Column/BinaryTest.php +++ b/test/unit/Sql/Ddl/Column/BinaryTest.php @@ -20,6 +20,24 @@ final class BinaryTest extends TestCase { use ColumnAssertionsTrait; + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Binary('foo', 10_000_000); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('BINARY'), + Argument::literal('10000000'), + ], + $expressionData['values'], + ); + } + #[Test] public function getExpressionDataOmitsLengthPlaceholderWhenLengthIsNotSet(): void { @@ -47,21 +65,4 @@ public function rendersWithoutParenthesesWhenLengthIsNotSet(?int $length): void { static::assertColumnRenders('"hash" BINARY NOT NULL', new Binary('hash', $length)); } - - public function testGetExpressionData(): void - { - $column = new Binary('foo', 10_000_000); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('BINARY'), - Argument::literal('10000000'), - ], - $expressionData['values'], - ); - } } diff --git a/test/unit/Sql/Ddl/Column/BlobTest.php b/test/unit/Sql/Ddl/Column/BlobTest.php index 5e6dfee3..ce4e81b6 100644 --- a/test/unit/Sql/Ddl/Column/BlobTest.php +++ b/test/unit/Sql/Ddl/Column/BlobTest.php @@ -19,10 +19,12 @@ final class BlobTest extends TestCase { use ColumnAssertionsTrait; - #[Test] - public function getExpressionDataOmitsConfiguredLength(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { - $expressionData = (new Blob('foo', 16_777_215))->getExpressionData(); + $column = new Blob('foo'); + + $expressionData = $column->getExpressionData(); static::assertSame('%s %s NOT NULL', $expressionData['spec']); static::assertEquals( @@ -35,19 +37,12 @@ public function getExpressionDataOmitsConfiguredLength(): void } #[Test] - public function rendersWithoutConfiguredLength(): void - { - static::assertColumnRenders('"foo" BLOB NOT NULL', new Blob('foo', 16_777_215)); - } - - public function testGetExpressionData(): void + public function getExpressionDataOmitsConfiguredLength(): void { - $column = new Blob('foo'); - - $expressionData = $column->getExpressionData(); + $expressionData = (new Blob('foo', 16_777_215))->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ new Identifier('foo'), new Literal('BLOB'), @@ -55,4 +50,10 @@ public function testGetExpressionData(): void $expressionData['values'], ); } + + #[Test] + public function rendersWithoutConfiguredLength(): void + { + static::assertColumnRenders('"foo" BLOB NOT NULL', new Blob('foo', 16_777_215)); + } } diff --git a/test/unit/Sql/Ddl/Column/BooleanTest.php b/test/unit/Sql/Ddl/Column/BooleanTest.php index 417bd959..b2394e9a 100644 --- a/test/unit/Sql/Ddl/Column/BooleanTest.php +++ b/test/unit/Sql/Ddl/Column/BooleanTest.php @@ -15,14 +15,15 @@ #[CoversClass(Boolean::class)] final class BooleanTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Boolean('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('BOOLEAN'), @@ -31,15 +32,16 @@ public function testGetExpressionData(): void ); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6257')] - public function testIsAlwaysNotNullable(): void + public function isAlwaysNotNullable(): void { $column = new Boolean('foo', true); - self::assertFalse($column->isNullable()); + static::assertFalse($column->isNullable()); $column->setNullable(true); - self::assertFalse($column->isNullable()); + static::assertFalse($column->isNullable()); } } diff --git a/test/unit/Sql/Ddl/Column/CharTest.php b/test/unit/Sql/Ddl/Column/CharTest.php index d6ff2f43..6aaba5a5 100644 --- a/test/unit/Sql/Ddl/Column/CharTest.php +++ b/test/unit/Sql/Ddl/Column/CharTest.php @@ -21,6 +21,24 @@ final class CharTest extends TestCase { use ColumnAssertionsTrait; + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Char('foo', 20); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + new Identifier('foo'), + new Literal('CHAR'), + new Literal('20'), + ], + $expressionData['values'], + ); + } + #[Test] public function getExpressionDataOmitsLengthPlaceholderWhenLengthIsNotSet(): void { @@ -48,21 +66,4 @@ public function rendersWithoutParenthesesWhenLengthIsNotSet(?int $length): void { static::assertColumnRenders('"code" CHAR NOT NULL', new Char('code', $length)); } - - public function testGetExpressionData(): void - { - $column = new Char('foo', 20); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - new Identifier('foo'), - new Literal('CHAR'), - new Literal('20'), - ], - $expressionData['values'], - ); - } } diff --git a/test/unit/Sql/Ddl/Column/ColumnTest.php b/test/unit/Sql/Ddl/Column/ColumnTest.php index 0e496f88..de97144a 100644 --- a/test/unit/Sql/Ddl/Column/ColumnTest.php +++ b/test/unit/Sql/Ddl/Column/ColumnTest.php @@ -29,44 +29,36 @@ #[Group('unit')] final class ColumnTest extends TestCase { - #[Test] - public function setOptionAcceptsIntegerValue(): void - { - $column = new Column(); - - $result = $column->setOption('length', 11); - - static::assertSame($column, $result); - static::assertSame(['length' => 11], $column->getOptions()); - } - - public function testAddConstraintAppendsConstraintToColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addConstraintAppendsConstraintToColumn(): void { $column = new Column('id'); $result = $column->addConstraint(new PrimaryKey()); - self::assertSame($column, $result); + static::assertSame($column, $result); } - public function testConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructor(): void { $column = new Column('test_col', true, 'default_val', ['option1' => 'value1']); - self::assertEquals('test_col', $column->getName()); - self::assertTrue($column->isNullable()); - self::assertEquals('default_val', $column->getDefault()); - self::assertEquals(['option1' => 'value1'], $column->getOptions()); + static::assertSame('test_col', $column->getName()); + static::assertTrue($column->isNullable()); + static::assertSame('default_val', $column->getDefault()); + static::assertEquals(['option1' => 'value1'], $column->getOptions()); } - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Column(); $column->setName('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('INTEGER'), @@ -78,8 +70,8 @@ public function testGetExpressionData(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NULL DEFAULT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NULL DEFAULT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('INTEGER'), @@ -91,8 +83,8 @@ public function testGetExpressionData(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('INTEGER'), @@ -102,27 +94,30 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataIncludesConstraints(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataIncludesConstraints(): void { $column = new Column('id'); $column->addConstraint(new PrimaryKey()); $expressionData = $column->getExpressionData(); - self::assertStringContainsString('PRIMARY KEY', $expressionData['spec']); + static::assertStringContainsString('PRIMARY KEY', $expressionData['spec']); } - public function testGetExpressionDataIncludesConstraintValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataIncludesConstraintValues(): void { $column = new Column('id'); $column->addConstraint(new PrimaryKey('id', 'pk_id')); $expressionData = $column->getExpressionData(); - self::assertNotEmpty($expressionData['values']); + static::assertNotEmpty($expressionData['values']); } - public function testGetExpressionDataWithBoolDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithBoolDefault(): void { $column = new Column(); $column->setName('is_active'); @@ -130,8 +125,8 @@ public function testGetExpressionDataWithBoolDefault(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('is_active'), Argument::literal('INTEGER'), @@ -141,7 +136,8 @@ public function testGetExpressionDataWithBoolDefault(): void ); } - public function testGetExpressionDataWithFloatDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithFloatDefault(): void { $column = new Column(); $column->setName('rate'); @@ -149,8 +145,8 @@ public function testGetExpressionDataWithFloatDefault(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('rate'), Argument::literal('INTEGER'), @@ -160,7 +156,8 @@ public function testGetExpressionDataWithFloatDefault(): void ); } - public function testGetExpressionDataWithLiteralDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithLiteralDefault(): void { $column = new Column(); $column->setName('created_at'); @@ -168,8 +165,8 @@ public function testGetExpressionDataWithLiteralDefault(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('created_at'), Argument::literal('INTEGER'), @@ -179,7 +176,8 @@ public function testGetExpressionDataWithLiteralDefault(): void ); } - public function testGetExpressionDataWithValueDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithValueDefault(): void { $column = new Column(); $column->setName('score'); @@ -187,8 +185,8 @@ public function testGetExpressionDataWithValueDefault(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('score'), Argument::literal('INTEGER'), @@ -198,7 +196,8 @@ public function testGetExpressionDataWithValueDefault(): void ); } - public function testSetDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDefault(): void { $column = new Column(); @@ -206,41 +205,44 @@ public function testSetDefault(): void $result = $column->setDefault('foo bar'); // Verify fluent interface - self::assertSame($column, $result); + static::assertSame($column, $result); // Verify the first mutation occurred - self::assertEquals('foo bar', $column->getDefault()); + static::assertSame('foo bar', $column->getDefault()); // Second mutation to verify mutability $column->setDefault('baz qux'); // Verify the instance was actually mutated - self::assertEquals('baz qux', $column->getDefault()); + static::assertSame('baz qux', $column->getDefault()); } - public function testSetDefaultWithBool(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDefaultWithBool(): void { $column = new Column(); $column->setName('is_active'); $result = $column->setDefault(true); - self::assertSame($column, $result); - self::assertTrue($column->getDefault()); + static::assertSame($column, $result); + static::assertTrue($column->getDefault()); } - public function testSetDefaultWithFloat(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDefaultWithFloat(): void { $column = new Column(); $column->setName('rate'); $result = $column->setDefault(3.14); - self::assertSame($column, $result); - self::assertSame(3.14, $column->getDefault()); + static::assertSame($column, $result); + static::assertSame(3.14, $column->getDefault()); } - public function testSetDefaultWithLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDefaultWithLiteral(): void { $column = new Column(); $column->setName('created_at'); @@ -248,11 +250,12 @@ public function testSetDefaultWithLiteral(): void $literal = new Literal('CURRENT_TIMESTAMP'); $result = $column->setDefault($literal); - self::assertSame($column, $result); - self::assertSame($literal, $column->getDefault()); + static::assertSame($column, $result); + static::assertSame($literal, $column->getDefault()); } - public function testSetDefaultWithValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDefaultWithValue(): void { $column = new Column(); $column->setName('score'); @@ -260,11 +263,12 @@ public function testSetDefaultWithValue(): void $value = new Value(99); $result = $column->setDefault($value); - self::assertSame($column, $result); - self::assertSame($value, $column->getDefault()); + static::assertSame($column, $result); + static::assertSame($value, $column->getDefault()); } - public function testSetName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setName(): void { $column = new Column(); @@ -272,19 +276,20 @@ public function testSetName(): void $result = $column->setName('foo'); // Verify fluent interface - self::assertSame($column, $result); + static::assertSame($column, $result); // Verify the first mutation occurred - self::assertEquals('foo', $column->getName()); + static::assertSame('foo', $column->getName()); // Second mutation to verify mutability $column->setName('bar'); // Verify the instance was actually mutated - self::assertEquals('bar', $column->getName()); + static::assertSame('bar', $column->getName()); } - public function testSetNullable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setNullable(): void { $column = new Column(); @@ -292,19 +297,20 @@ public function testSetNullable(): void $result = $column->setNullable(true); // Verify fluent interface - self::assertSame($column, $result); + static::assertSame($column, $result); // Verify the first mutation occurred - self::assertTrue($column->isNullable()); + static::assertTrue($column->isNullable()); // Second mutation to verify mutability $column->setNullable(false); // Verify the instance was actually mutated - self::assertFalse($column->isNullable()); + static::assertFalse($column->isNullable()); } - public function testSetOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOption(): void { $column = new Column(); @@ -312,19 +318,31 @@ public function testSetOption(): void $result = $column->setOption('primary', true); // Verify fluent interface - self::assertSame($column, $result); + static::assertSame($column, $result); // Verify the first mutation occurred - self::assertEquals(['primary' => true], $column->getOptions()); + static::assertEquals(['primary' => true], $column->getOptions()); // Second mutation to verify mutability $column->setOption('unsigned', true); // Verify the instance was actually mutated - self::assertEquals(['primary' => true, 'unsigned' => true], $column->getOptions()); + static::assertEquals(['primary' => true, 'unsigned' => true], $column->getOptions()); + } + + #[Test] + public function setOptionAcceptsIntegerValue(): void + { + $column = new Column(); + + $result = $column->setOption('length', 11); + + static::assertSame($column, $result); + static::assertSame(['length' => 11], $column->getOptions()); } - public function testSetOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOptions(): void { $column = new Column(); @@ -332,15 +350,15 @@ public function testSetOptions(): void $result = $column->setOptions(['autoincrement' => true]); // Verify fluent interface - self::assertSame($column, $result); + static::assertSame($column, $result); // Verify the first mutation occurred - self::assertEquals(['autoincrement' => true], $column->getOptions()); + static::assertEquals(['autoincrement' => true], $column->getOptions()); // Second mutation to verify mutability $column->setOptions(['primary' => true, 'unsigned' => true]); // Verify the instance was actually mutated - self::assertEquals(['primary' => true, 'unsigned' => true], $column->getOptions()); + static::assertEquals(['primary' => true, 'unsigned' => true], $column->getOptions()); } } diff --git a/test/unit/Sql/Ddl/Column/DateTest.php b/test/unit/Sql/Ddl/Column/DateTest.php index 9050935c..12c9fd00 100644 --- a/test/unit/Sql/Ddl/Column/DateTest.php +++ b/test/unit/Sql/Ddl/Column/DateTest.php @@ -12,14 +12,15 @@ #[CoversMethod(Date::class, 'getExpressionData')] final class DateTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Date('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('DATE'), diff --git a/test/unit/Sql/Ddl/Column/DatetimeTest.php b/test/unit/Sql/Ddl/Column/DatetimeTest.php index 89aa5300..b99ed2d0 100644 --- a/test/unit/Sql/Ddl/Column/DatetimeTest.php +++ b/test/unit/Sql/Ddl/Column/DatetimeTest.php @@ -12,14 +12,15 @@ #[CoversMethod(Datetime::class, 'getExpressionData')] final class DatetimeTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Datetime('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('DATETIME'), diff --git a/test/unit/Sql/Ddl/Column/DecimalTest.php b/test/unit/Sql/Ddl/Column/DecimalTest.php index adae7968..05c4730f 100644 --- a/test/unit/Sql/Ddl/Column/DecimalTest.php +++ b/test/unit/Sql/Ddl/Column/DecimalTest.php @@ -29,65 +29,50 @@ final class DecimalTest extends TestCase { use ColumnAssertionsTrait; - #[Test] - public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorSetsDigitsAndDecimal(): void { - $expressionData = (new Decimal('amount'))->getExpressionData(); + $column = new Decimal('price', 10, 2); - static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertSame(10, $column->getDigits()); + static::assertSame(2, $column->getDecimal()); + } + + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Decimal('foo', 10, 5); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); static::assertEquals( [ - Argument::identifier('amount'), + Argument::identifier('foo'), Argument::literal('DECIMAL'), + Argument::literal('10,5'), ], $expressionData['values'], ); } #[Test] - public function rendersDigitsAndDecimalDirectlyAfterType(): void - { - static::assertColumnRenders('"price" DECIMAL(10,2) NOT NULL', new Decimal('price', 10, 2)); - } - - #[Test] - public function rendersDigitsOnlyWhenDecimalIsNotSet(): void - { - static::assertColumnRenders('"price" DECIMAL(10) NOT NULL', new Decimal('price', 10)); - } - - #[Test] - public function rendersWithoutParenthesesWhenPrecisionIsNotSet(): void - { - static::assertColumnRenders('"price" DECIMAL NOT NULL', new Decimal('price')); - } - - public function testConstructorSetsDigitsAndDecimal(): void - { - $column = new Decimal('price', 10, 2); - - self::assertEquals(10, $column->getDigits()); - self::assertEquals(2, $column->getDecimal()); - } - - public function testGetExpressionData(): void + public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void { - $column = new Decimal('foo', 10, 5); - - $expressionData = $column->getExpressionData(); + $expressionData = (new Decimal('amount'))->getExpressionData(); - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ - Argument::identifier('foo'), + Argument::identifier('amount'), Argument::literal('DECIMAL'), - Argument::literal('10,5'), ], $expressionData['values'], ); } - public function testGetExpressionDataWithNullDecimal(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithNullDecimal(): void { $column = new Decimal('amount', 10); $column->setDecimal(null); @@ -96,35 +81,56 @@ public function testGetExpressionDataWithNullDecimal(): void // Without decimal, length expression should be just the digits (as string) $values = $expressionData['values']; - self::assertCount(3, $values); - self::assertEquals(Argument::identifier('amount'), $values[0]); - self::assertEquals(Argument::literal('DECIMAL'), $values[1]); + static::assertCount(3, $values); + static::assertEquals(Argument::identifier('amount'), $values[0]); + static::assertEquals(Argument::literal('DECIMAL'), $values[1]); // The third value should be "10" (string representation) - self::assertEquals(Argument::literal((string) 10), $values[2]); + static::assertEquals(Argument::literal((string) 10), $values[2]); } - public function testInheritanceFromAbstractPrecisionColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function inheritanceFromAbstractPrecisionColumn(): void { $column = new Decimal('test'); - self::assertInstanceOf(AbstractPrecisionColumn::class, $column); + static::assertInstanceOf(AbstractPrecisionColumn::class, $column); + } + + #[Test] + public function rendersDigitsAndDecimalDirectlyAfterType(): void + { + static::assertColumnRenders('"price" DECIMAL(10,2) NOT NULL', new Decimal('price', 10, 2)); + } + + #[Test] + public function rendersDigitsOnlyWhenDecimalIsNotSet(): void + { + static::assertColumnRenders('"price" DECIMAL(10) NOT NULL', new Decimal('price', 10)); + } + + #[Test] + public function rendersWithoutParenthesesWhenPrecisionIsNotSet(): void + { + static::assertColumnRenders('"price" DECIMAL NOT NULL', new Decimal('price')); } - public function testSetDecimalAndGetDecimal(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDecimalAndGetDecimal(): void { $column = new Decimal('value'); $result = $column->setDecimal(4); - self::assertSame($column, $result); // Fluent interface - self::assertEquals(4, $column->getDecimal()); + static::assertSame($column, $result); // Fluent interface + static::assertSame(4, $column->getDecimal()); } - public function testSetDigitsAndGetDigits(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setDigitsAndGetDigits(): void { $column = new Decimal('amount'); $result = $column->setDigits(15); - self::assertSame($column, $result); // Fluent interface - self::assertEquals(15, $column->getDigits()); + static::assertSame($column, $result); // Fluent interface + static::assertSame(15, $column->getDigits()); } #[Test] diff --git a/test/unit/Sql/Ddl/Column/DoubleTest.php b/test/unit/Sql/Ddl/Column/DoubleTest.php index f361ca50..93d6b7d2 100644 --- a/test/unit/Sql/Ddl/Column/DoubleTest.php +++ b/test/unit/Sql/Ddl/Column/DoubleTest.php @@ -24,6 +24,24 @@ final class DoubleTest extends TestCase { use ColumnAssertionsTrait; + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Double('foo', 10, 5); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('DOUBLE'), + Argument::literal('10,5'), + ], + $expressionData['values'], + ); + } + #[Test] public function rendersDigitsAndDecimalDirectlyAfterType(): void { @@ -42,23 +60,6 @@ public function rendersWithoutParenthesesWhenPrecisionIsNotSet(): void static::assertColumnRenders('"f" DOUBLE NOT NULL', new Double('f')); } - public function testGetExpressionData(): void - { - $column = new Double('foo', 10, 5); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('DOUBLE'), - Argument::literal('10,5'), - ], - $expressionData['values'], - ); - } - #[Test] public function throwsWhenDecimalIsSetWithoutDigits(): void { diff --git a/test/unit/Sql/Ddl/Column/FloatingTest.php b/test/unit/Sql/Ddl/Column/FloatingTest.php index 9d405f63..adc9bc92 100644 --- a/test/unit/Sql/Ddl/Column/FloatingTest.php +++ b/test/unit/Sql/Ddl/Column/FloatingTest.php @@ -24,6 +24,24 @@ final class FloatingTest extends TestCase { use ColumnAssertionsTrait; + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Floating('foo', 10, 5); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('FLOAT'), + Argument::literal('10,5'), + ], + $expressionData['values'], + ); + } + #[Test] public function rendersDigitsAndDecimalDirectlyAfterType(): void { @@ -42,23 +60,6 @@ public function rendersWithoutParenthesesWhenPrecisionIsNotSet(): void static::assertColumnRenders('"f" FLOAT NOT NULL', new Floating('f')); } - public function testGetExpressionData(): void - { - $column = new Floating('foo', 10, 5); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('FLOAT'), - Argument::literal('10,5'), - ], - $expressionData['values'], - ); - } - #[Test] public function throwsWhenDecimalIsSetWithoutDigits(): void { diff --git a/test/unit/Sql/Ddl/Column/IntegerTest.php b/test/unit/Sql/Ddl/Column/IntegerTest.php index bc3e3176..aee21743 100644 --- a/test/unit/Sql/Ddl/Column/IntegerTest.php +++ b/test/unit/Sql/Ddl/Column/IntegerTest.php @@ -53,6 +53,66 @@ private static function assertColumnRenders(string $expected, ColumnInterface $c ); } + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $column = new Integer('foo'); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('INTEGER'), + ], + $expressionData['values'], + ); + + $column = new Integer('foo'); + $column->addConstraint(new PrimaryKey()); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s NOT NULL PRIMARY KEY', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('INTEGER'), + ], + $expressionData['values'], + ); + } + + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataExcludesLengthWhenNotSet(): void + { + $column = new Integer('id'); + + $expressionData = $column->getExpressionData(); + + static::assertStringNotContainsString('(', $expressionData['spec']); + } + + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataIncludesLengthWhenOptionSet(): void + { + $column = new Integer('id'); + $column->setOption('length', '11'); + + $expressionData = $column->getExpressionData(); + + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('id'), + Argument::literal('INTEGER'), + Argument::literal('11'), + ], + $expressionData['values'], + ); + } + /** * The display width is inserted directly after the type. Values contributed by a * default and by a named constraint sit after that point, so they must be pushed @@ -94,6 +154,13 @@ public function getExpressionDataPlacesLengthDirectlyAfterType(): void ); } + #[\PHPUnit\Framework\Attributes\Test] + public function objectConstruction(): void + { + $integer = new Integer('foo'); + static::assertSame('foo', $integer->getName()); + } + /** * Zero is a non-negative integer, so it is a width like any other rather than a * rejected value. @@ -128,69 +195,6 @@ public function rendersLengthSetAsIntegerOption(): void static::assertColumnRenders('"i" INTEGER(11) NOT NULL', $column); } - public function testGetExpressionData(): void - { - $column = new Integer('foo'); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('INTEGER'), - ], - $expressionData['values'], - ); - - $column = new Integer('foo'); - $column->addConstraint(new PrimaryKey()); - - $expressionData = $column->getExpressionData(); - - self::assertEquals('%s %s NOT NULL PRIMARY KEY', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('INTEGER'), - ], - $expressionData['values'], - ); - } - - public function testGetExpressionDataExcludesLengthWhenNotSet(): void - { - $column = new Integer('id'); - - $expressionData = $column->getExpressionData(); - - self::assertStringNotContainsString('(', $expressionData['spec']); - } - - public function testGetExpressionDataIncludesLengthWhenOptionSet(): void - { - $column = new Integer('id'); - $column->setOption('length', '11'); - - $expressionData = $column->getExpressionData(); - - static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); - static::assertEquals( - [ - Argument::identifier('id'), - Argument::literal('INTEGER'), - Argument::literal('11'), - ], - $expressionData['values'], - ); - } - - public function testObjectConstruction(): void - { - $integer = new Integer('foo'); - self::assertEquals('foo', $integer->getName()); - } - #[Test] #[DataProvider('invalidLengthProvider')] public function throwsWhenLengthOptionIsNotANonNegativeInteger(bool|int|string $length): void diff --git a/test/unit/Sql/Ddl/Column/JsonTest.php b/test/unit/Sql/Ddl/Column/JsonTest.php index 0af7d7ee..cbd1e9f0 100644 --- a/test/unit/Sql/Ddl/Column/JsonTest.php +++ b/test/unit/Sql/Ddl/Column/JsonTest.php @@ -12,14 +12,15 @@ #[CoversMethod(Json::class, 'getExpressionData')] final class JsonTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Json('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('JSON'), diff --git a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php index 1218b4da..267daef1 100644 --- a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php @@ -20,26 +20,18 @@ #[Group('unit')] final class SmallIntegerTest extends TestCase { - #[Test] - public function rendersLengthDirectlyAfterType(): void - { - $createTable = new CreateTable('t'); - $createTable->addColumn(new SmallInteger('i', false, null, ['length' => 6])); - - static::assertSame("CREATE TABLE \"t\" ( \n \"i\" SMALLINT(6) NOT NULL \n)", $createTable->getSqlString()); - } - - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new SmallInteger('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals( + static::assertSame( '%s %s NOT NULL', $expressionData['spec'], ); - self::assertEquals( + static::assertEquals( [ Argument::Identifier('foo'), Argument::Literal('SMALLINT'), @@ -48,9 +40,19 @@ public function testGetExpressionData(): void ); } - public function testObjectConstruction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function objectConstruction(): void { $integer = new SmallInteger('foo'); - self::assertEquals('foo', $integer->getName()); + static::assertSame('foo', $integer->getName()); + } + + #[Test] + public function rendersLengthDirectlyAfterType(): void + { + $createTable = new CreateTable('t'); + $createTable->addColumn(new SmallInteger('i', false, null, ['length' => 6])); + + static::assertSame("CREATE TABLE \"t\" ( \n \"i\" SMALLINT(6) NOT NULL \n)", $createTable->getSqlString()); } } diff --git a/test/unit/Sql/Ddl/Column/TextTest.php b/test/unit/Sql/Ddl/Column/TextTest.php index f718c3b9..834a7e51 100644 --- a/test/unit/Sql/Ddl/Column/TextTest.php +++ b/test/unit/Sql/Ddl/Column/TextTest.php @@ -18,10 +18,12 @@ final class TextTest extends TestCase { use ColumnAssertionsTrait; - #[Test] - public function getExpressionDataOmitsConfiguredLength(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { - $expressionData = (new Text('foo', 65_535))->getExpressionData(); + $column = new Text('foo'); + + $expressionData = $column->getExpressionData(); static::assertSame('%s %s NOT NULL', $expressionData['spec']); static::assertEquals( @@ -34,19 +36,12 @@ public function getExpressionDataOmitsConfiguredLength(): void } #[Test] - public function rendersWithoutConfiguredLength(): void - { - static::assertColumnRenders('"foo" TEXT NOT NULL', new Text('foo', 65_535)); - } - - public function testGetExpressionData(): void + public function getExpressionDataOmitsConfiguredLength(): void { - $column = new Text('foo'); - - $expressionData = $column->getExpressionData(); + $expressionData = (new Text('foo', 65_535))->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('TEXT'), @@ -54,4 +49,10 @@ public function testGetExpressionData(): void $expressionData['values'], ); } + + #[Test] + public function rendersWithoutConfiguredLength(): void + { + static::assertColumnRenders('"foo" TEXT NOT NULL', new Text('foo', 65_535)); + } } diff --git a/test/unit/Sql/Ddl/Column/TimeTest.php b/test/unit/Sql/Ddl/Column/TimeTest.php index 3c0a9520..b7517635 100644 --- a/test/unit/Sql/Ddl/Column/TimeTest.php +++ b/test/unit/Sql/Ddl/Column/TimeTest.php @@ -13,14 +13,15 @@ #[CoversMethod(Time::class, 'getExpressionData')] final class TimeTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Time('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ new Identifier('foo'), new Literal('TIME'), diff --git a/test/unit/Sql/Ddl/Column/TimestampTest.php b/test/unit/Sql/Ddl/Column/TimestampTest.php index 94dcd506..f68fa929 100644 --- a/test/unit/Sql/Ddl/Column/TimestampTest.php +++ b/test/unit/Sql/Ddl/Column/TimestampTest.php @@ -17,14 +17,15 @@ #[CoversMethod(AbstractTimestampColumn::class, 'getExpressionData')] final class TimestampTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Timestamp('foo'); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL', $expressionData['spec']); + static::assertEquals( [ new Identifier('foo'), new Literal('TIMESTAMP'), @@ -33,15 +34,16 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataWithCurrentTimestampDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithCurrentTimestampDefault(): void { $column = new Timestamp('created_at'); $column->setDefault(new Literal('CURRENT_TIMESTAMP')); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('created_at'), new Literal('TIMESTAMP'), @@ -51,7 +53,8 @@ public function testGetExpressionDataWithCurrentTimestampDefault(): void ); } - public function testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void { $column = new Timestamp('updated_at'); $column->setDefault(new Literal('CURRENT_TIMESTAMP')); @@ -59,8 +62,8 @@ public function testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): v $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s NOT NULL DEFAULT %s %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s NOT NULL DEFAULT %s %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('updated_at'), new Literal('TIMESTAMP'), @@ -71,7 +74,8 @@ public function testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): v ); } - public function testGetExpressionDataWithOnUpdateOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithOnUpdateOption(): void { $column = new Timestamp('created_at'); $column->setOption('on_update', true); @@ -80,22 +84,23 @@ public function testGetExpressionDataWithOnUpdateOption(): void // Verify specification includes ON UPDATE $spec = $expressionData['spec']; - self::assertEquals('%s %s NOT NULL %s', $spec); + static::assertSame('%s %s NOT NULL %s', $spec); $values = $expressionData['values']; // Should have 3 values: identifier, type, and ON UPDATE argument - self::assertCount(3, $values); - self::assertEquals(new Identifier('created_at'), $values[0]); - self::assertEquals(new Literal('TIMESTAMP'), $values[1]); + static::assertCount(3, $values); + static::assertEquals(new Identifier('created_at'), $values[0]); + static::assertEquals(new Literal('TIMESTAMP'), $values[1]); // Third value should be the ON UPDATE argument - self::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); // Verify it equals the expected Argument using factory method for consistency - self::assertEquals(new Literal('ON UPDATE CURRENT_TIMESTAMP'), $values[2]); + static::assertEquals(new Literal('ON UPDATE CURRENT_TIMESTAMP'), $values[2]); } - public function testGetExpressionDataWithoutOnUpdateOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithoutOnUpdateOption(): void { $column = new Timestamp('updated_at'); @@ -103,14 +108,15 @@ public function testGetExpressionDataWithoutOnUpdateOption(): void // Should have 2 values: identifier and type (no ON UPDATE) $values = $expressionData['values']; - self::assertCount(2, $values); - self::assertEquals(new Identifier('updated_at'), $values[0]); - self::assertEquals(Argument::literal('TIMESTAMP'), $values[1]); + static::assertCount(2, $values); + static::assertEquals(new Identifier('updated_at'), $values[0]); + static::assertEquals(Argument::literal('TIMESTAMP'), $values[1]); } - public function testInheritanceFromAbstractTimestampColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function inheritanceFromAbstractTimestampColumn(): void { $column = new Timestamp('test'); - self::assertInstanceOf(AbstractTimestampColumn::class, $column); + static::assertInstanceOf(AbstractTimestampColumn::class, $column); } } diff --git a/test/unit/Sql/Ddl/Column/VarbinaryTest.php b/test/unit/Sql/Ddl/Column/VarbinaryTest.php index 7c1ccf58..02567993 100644 --- a/test/unit/Sql/Ddl/Column/VarbinaryTest.php +++ b/test/unit/Sql/Ddl/Column/VarbinaryTest.php @@ -23,20 +23,15 @@ final class VarbinaryTest extends TestCase { use ColumnAssertionsTrait; - #[Test] - public function rendersLengthDirectlyAfterType(): void - { - static::assertColumnRenders('"data" VARBINARY(20) NOT NULL', new Varbinary('data', 20)); - } - - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Varbinary('foo', 20); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('VARBINARY'), @@ -46,6 +41,12 @@ public function testGetExpressionData(): void ); } + #[Test] + public function rendersLengthDirectlyAfterType(): void + { + static::assertColumnRenders('"data" VARBINARY(20) NOT NULL', new Varbinary('data', 20)); + } + #[Test] #[DataProvider('missingLengthProvider')] public function throwsWhenRenderedWithoutLength(?int $length): void diff --git a/test/unit/Sql/Ddl/Column/VarcharTest.php b/test/unit/Sql/Ddl/Column/VarcharTest.php index c63bbdf3..8cfb9662 100644 --- a/test/unit/Sql/Ddl/Column/VarcharTest.php +++ b/test/unit/Sql/Ddl/Column/VarcharTest.php @@ -27,26 +27,15 @@ final class VarcharTest extends TestCase { use ColumnAssertionsTrait; - #[Test] - public function rendersLengthBeforeNullabilityAndDefault(): void - { - static::assertColumnRenders('"name" VARCHAR(20) NULL DEFAULT NULL', new Varchar('name', 20, true)); - } - - #[Test] - public function rendersLengthDirectlyAfterType(): void - { - static::assertColumnRenders('"name" VARCHAR(20) NOT NULL', new Varchar('name', 20)); - } - - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $column = new Varchar('foo', 20); $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s(%s) NOT NULL', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s(%s) NOT NULL', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('VARCHAR'), @@ -59,8 +48,8 @@ public function testGetExpressionData(): void $expressionData = $column->getExpressionData(); - self::assertEquals('%s %s(%s) NOT NULL DEFAULT %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s %s(%s) NOT NULL DEFAULT %s', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), Argument::literal('VARCHAR'), @@ -71,19 +60,33 @@ public function testGetExpressionData(): void ); } - public function testInheritanceFromAbstractLengthColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function inheritanceFromAbstractLengthColumn(): void { $column = new Varchar('test'); - self::assertInstanceOf(AbstractLengthColumn::class, $column); + static::assertInstanceOf(AbstractLengthColumn::class, $column); + } + + #[Test] + public function rendersLengthBeforeNullabilityAndDefault(): void + { + static::assertColumnRenders('"name" VARCHAR(20) NULL DEFAULT NULL', new Varchar('name', 20, true)); + } + + #[Test] + public function rendersLengthDirectlyAfterType(): void + { + static::assertColumnRenders('"name" VARCHAR(20) NOT NULL', new Varchar('name', 20)); } - public function testSetLengthAndGetLength(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setLengthAndGetLength(): void { $column = new Varchar('name'); $result = $column->setLength(100); - self::assertSame($column, $result); // Fluent interface - self::assertEquals(100, $column->getLength()); + static::assertSame($column, $result); // Fluent interface + static::assertSame(100, $column->getLength()); } #[Test] diff --git a/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php b/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php index 464148cf..866acfcf 100644 --- a/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php +++ b/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php @@ -18,22 +18,25 @@ final class AbstractConstraintTest extends TestCase { protected MockObject $ac; - public function testAddColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addColumn(): void { - self::assertSame($this->ac, $this->ac->addColumn('foo')); - self::assertEquals(['foo'], $this->ac->getColumns()); + static::assertSame($this->ac, $this->ac->addColumn('foo')); + static::assertEquals(['foo'], $this->ac->getColumns()); } - public function testGetColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getColumns(): void { $this->ac->setColumns(['foo', 'bar']); - self::assertEquals(['foo', 'bar'], $this->ac->getColumns()); + static::assertEquals(['foo', 'bar'], $this->ac->getColumns()); } - public function testSetColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setColumns(): void { - self::assertSame($this->ac, $this->ac->setColumns(['foo', 'bar'])); - self::assertEquals(['foo', 'bar'], $this->ac->getColumns()); + static::assertSame($this->ac, $this->ac->setColumns(['foo', 'bar'])); + static::assertEquals(['foo', 'bar'], $this->ac->getColumns()); } /** diff --git a/test/unit/Sql/Ddl/Constraint/CheckTest.php b/test/unit/Sql/Ddl/Constraint/CheckTest.php index 38a98273..17929cfc 100644 --- a/test/unit/Sql/Ddl/Constraint/CheckTest.php +++ b/test/unit/Sql/Ddl/Constraint/CheckTest.php @@ -37,6 +37,23 @@ private static function assertConstraintRenders(string $expected, ConstraintInte ); } + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void + { + $check = new Check('id>0', 'foo'); + + $expressionData = $check->getExpressionData(); + + static::assertSame('CONSTRAINT %s CHECK (%s)', $expressionData['spec']); + static::assertEquals( + [ + Argument::identifier('foo'), + Argument::literal('id>0'), + ], + $expressionData['values'], + ); + } + #[Test] public function getExpressionDataMergesExpressionSpecAndValues(): void { @@ -107,22 +124,6 @@ public function rendersWithoutConstraintClauseWhenUnnamed(): void static::assertConstraintRenders('CHECK (id > 0)', new Check('id > 0')); } - public function testGetExpressionData(): void - { - $check = new Check('id>0', 'foo'); - - $expressionData = $check->getExpressionData(); - - self::assertEquals('CONSTRAINT %s CHECK (%s)', $expressionData['spec']); - self::assertEquals( - [ - Argument::identifier('foo'), - Argument::literal('id>0'), - ], - $expressionData['values'], - ); - } - #[Test] public function throwsWhenExpressionIsEmpty(): void { diff --git a/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php b/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php index 57260c18..d1535a4f 100644 --- a/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php @@ -32,54 +32,56 @@ #[CoversMethod(ForeignKey::class, 'getExpressionData')] final class ForeignKeyTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam', 'CASCADE', 'SET NULL'); $expressionData = $fk->getExpressionData(); // Verify specification - self::assertEquals( + static::assertSame( 'CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s) ON DELETE %s ON UPDATE %s', $expressionData['spec'], ); // Verify expression values $values = $expressionData['values']; - self::assertCount(6, $values); + static::assertCount(6, $values); // Verify constraint name - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify column name - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('bar', $values[1]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('bar', $values[1]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); // Verify reference table - self::assertInstanceOf(ArgumentInterface::class, $values[2]); - self::assertEquals('baz', $values[2]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertSame('baz', $values[2]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[2]->getType()); // Verify reference column - self::assertInstanceOf(ArgumentInterface::class, $values[3]); - self::assertEquals('bam', $values[3]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[3]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[3]); + static::assertSame('bam', $values[3]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[3]->getType()); // Verify on delete rule - self::assertInstanceOf(ArgumentInterface::class, $values[4]); - self::assertEquals('CASCADE', $values[4]->getValue()); - self::assertEquals(ArgumentType::Literal, $values[4]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[4]); + static::assertSame('CASCADE', $values[4]->getValue()); + static::assertEquals(ArgumentType::Literal, $values[4]->getType()); // Verify on update rule - self::assertInstanceOf(ArgumentInterface::class, $values[5]); - self::assertEquals('SET NULL', $values[5]->getValue()); - self::assertEquals(ArgumentType::Literal, $values[5]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[5]); + static::assertSame('SET NULL', $values[5]->getValue()); + static::assertEquals(ArgumentType::Literal, $values[5]->getType()); } - public function testSetName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setName(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -87,19 +89,20 @@ public function testSetName(): void $result = $fk->setName('xxxx'); // Verify fluent interface - self::assertSame($fk, $result); + static::assertSame($fk, $result); // Verify the first mutation occurred - self::assertEquals('xxxx', $fk->getName()); + static::assertSame('xxxx', $fk->getName()); // Second mutation to verify mutability $fk->setName('yyyy'); // Verify the instance was actually mutated - self::assertEquals('yyyy', $fk->getName()); + static::assertSame('yyyy', $fk->getName()); } - public function testSetOnDeleteRule(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOnDeleteRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -107,19 +110,20 @@ public function testSetOnDeleteRule(): void $result = $fk->setOnDeleteRule('CASCADE'); // Verify fluent interface - self::assertSame($fk, $result); + static::assertSame($fk, $result); // Verify the first mutation occurred - self::assertEquals('CASCADE', $fk->getOnDeleteRule()); + static::assertSame('CASCADE', $fk->getOnDeleteRule()); // Second mutation to verify mutability $fk->setOnDeleteRule('SET NULL'); // Verify the instance was actually mutated - self::assertEquals('SET NULL', $fk->getOnDeleteRule()); + static::assertSame('SET NULL', $fk->getOnDeleteRule()); } - public function testSetOnUpdateRule(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOnUpdateRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -127,19 +131,20 @@ public function testSetOnUpdateRule(): void $result = $fk->setOnUpdateRule('CASCADE'); // Verify fluent interface - self::assertSame($fk, $result); + static::assertSame($fk, $result); // Verify the first mutation occurred - self::assertEquals('CASCADE', $fk->getOnUpdateRule()); + static::assertSame('CASCADE', $fk->getOnUpdateRule()); // Second mutation to verify mutability $fk->setOnUpdateRule('RESTRICT'); // Verify the instance was actually mutated - self::assertEquals('RESTRICT', $fk->getOnUpdateRule()); + static::assertSame('RESTRICT', $fk->getOnUpdateRule()); } - public function testSetReferenceColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setReferenceColumn(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -147,19 +152,20 @@ public function testSetReferenceColumn(): void $result = $fk->setReferenceColumn('xxxx'); // Verify fluent interface - self::assertSame($fk, $result); + static::assertSame($fk, $result); // Verify the first mutation occurred - self::assertEquals(['xxxx'], $fk->getReferenceColumn()); + static::assertEquals(['xxxx'], $fk->getReferenceColumn()); // Second mutation to verify mutability $fk->setReferenceColumn('yyyy'); // Verify the instance was actually mutated - self::assertEquals(['yyyy'], $fk->getReferenceColumn()); + static::assertEquals(['yyyy'], $fk->getReferenceColumn()); } - public function testSetReferenceTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setReferenceTable(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -167,15 +173,15 @@ public function testSetReferenceTable(): void $result = $fk->setReferenceTable('xxxx'); // Verify fluent interface - self::assertSame($fk, $result); + static::assertSame($fk, $result); // Verify the first mutation occurred - self::assertEquals('xxxx', $fk->getReferenceTable()); + static::assertSame('xxxx', $fk->getReferenceTable()); // Second mutation to verify mutability $fk->setReferenceTable('yyyy'); // Verify the instance was actually mutated - self::assertEquals('yyyy', $fk->getReferenceTable()); + static::assertSame('yyyy', $fk->getReferenceTable()); } } diff --git a/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php b/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php index 51669b9a..a4d3db91 100644 --- a/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php @@ -12,14 +12,15 @@ #[CoversMethod(PrimaryKey::class, 'getExpressionData')] final class PrimaryKeyTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $pk = new PrimaryKey('foo'); $expressionData = $pk->getExpressionData(); - self::assertEquals('PRIMARY KEY (%s)', $expressionData['spec']); - self::assertEquals( + static::assertSame('PRIMARY KEY (%s)', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('foo'), ], diff --git a/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php b/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php index 59e30fbe..0d0e8696 100644 --- a/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php @@ -12,14 +12,15 @@ #[CoversMethod(UniqueKey::class, 'getExpressionData')] final class UniqueKeyTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $uk = new UniqueKey('foo', 'my_uk'); $expressionData = $uk->getExpressionData(); - self::assertEquals('CONSTRAINT %s UNIQUE (%s)', $expressionData['spec']); - self::assertEquals( + static::assertSame('CONSTRAINT %s UNIQUE (%s)', $expressionData['spec']); + static::assertEquals( [ Argument::identifier('my_uk'), Argument::identifier('foo'), diff --git a/test/unit/Sql/Ddl/CreateTableTest.php b/test/unit/Sql/Ddl/CreateTableTest.php index cd3bdb0e..d7feeb02 100644 --- a/test/unit/Sql/Ddl/CreateTableTest.php +++ b/test/unit/Sql/Ddl/CreateTableTest.php @@ -35,7 +35,8 @@ #[CoversMethod(CreateTable::class, 'processTableOptions')] class CreateTableTest extends TestCase { - public function testAddColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addColumn(): void { $column = $this->getMockBuilder(ColumnInterface::class)->getMock(); $ct = new CreateTable(); @@ -44,13 +45,13 @@ public function testAddColumn(): void $result = $ct->addColumn($column); // Verify fluent interface - self::assertSame($ct, $result); + static::assertSame($ct, $result); // Verify the first mutation occurred $state = $ct->getRawState('columns'); - self::assertIsArray($state); - self::assertCount(1, $state); - self::assertInstanceOf(ColumnInterface::class, $state[0]); + static::assertIsArray($state); + static::assertCount(1, $state); + static::assertInstanceOf(ColumnInterface::class, $state[0]); // Second mutation to verify mutability (columns accumulate) $column2 = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -58,11 +59,12 @@ public function testAddColumn(): void // Verify the instance was actually mutated $state2 = $ct->getRawState('columns'); - self::assertCount(2, $state2); - self::assertInstanceOf(ColumnInterface::class, $state2[1]); + static::assertCount(2, $state2); + static::assertInstanceOf(ColumnInterface::class, $state2[1]); } - public function testAddConstraint(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addConstraint(): void { $constraint = $this->getMockBuilder(ConstraintInterface::class)->getMock(); $ct = new CreateTable(); @@ -71,13 +73,13 @@ public function testAddConstraint(): void $result = $ct->addConstraint($constraint); // Verify fluent interface - self::assertSame($ct, $result); + static::assertSame($ct, $result); // Verify the first mutation occurred $state = $ct->getRawState('constraints'); - self::assertIsArray($state); - self::assertCount(1, $state); - self::assertInstanceOf(ConstraintInterface::class, $state[0]); + static::assertIsArray($state); + static::assertCount(1, $state); + static::assertInstanceOf(ConstraintInterface::class, $state[0]); // Second mutation to verify mutability (constraints accumulate) $constraint2 = $this->getMockBuilder(ConstraintInterface::class)->getMock(); @@ -85,11 +87,12 @@ public function testAddConstraint(): void // Verify the instance was actually mutated $state2 = $ct->getRawState('constraints'); - self::assertCount(2, $state2); - self::assertInstanceOf(ConstraintInterface::class, $state2[1]); + static::assertCount(2, $state2); + static::assertInstanceOf(ConstraintInterface::class, $state2[1]); } - public function testChainedOperations(): void + #[\PHPUnit\Framework\Attributes\Test] + public function chainedOperations(): void { $ct = new CreateTable(); $col1 = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -102,59 +105,65 @@ public function testChainedOperations(): void ->addColumn($col2) ->addConstraint($con); - self::assertSame($ct, $result); - self::assertEquals('products', $ct->getRawState(CreateTable::TABLE)); - self::assertTrue($ct->isTemporary()); - self::assertCount(2, $ct->getRawState(CreateTable::COLUMNS)); - self::assertCount(1, $ct->getRawState(CreateTable::CONSTRAINTS)); + static::assertSame($ct, $result); + static::assertSame('products', $ct->getRawState(CreateTable::TABLE)); + static::assertTrue($ct->isTemporary()); + static::assertCount(2, $ct->getRawState(CreateTable::COLUMNS)); + static::assertCount(1, $ct->getRawState(CreateTable::CONSTRAINTS)); } - public function testConstructorWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTableIdentifier(): void { $tableId = new TableIdentifier('bar', 'foo'); $ct = new CreateTable($tableId); $rawState = $ct->getRawState(); - self::assertSame($tableId, $rawState[CreateTable::TABLE]); + static::assertSame($tableId, $rawState[CreateTable::TABLE]); } - public function testConstructorWithTemporaryFlag(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTemporaryFlag(): void { $ct = new CreateTable('test', true); - self::assertTrue($ct->isTemporary()); - self::assertEquals('test', $ct->getRawState(CreateTable::TABLE)); + static::assertTrue($ct->isTemporary()); + static::assertSame('test', $ct->getRawState(CreateTable::TABLE)); $ct2 = new CreateTable('test', false); - self::assertFalse($ct2->isTemporary()); + static::assertFalse($ct2->isTemporary()); } - public function testEmptyTableConstruction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyTableConstruction(): void { $ct = new CreateTable(); - self::assertEquals('', $ct->getRawState(CreateTable::TABLE)); - self::assertFalse($ct->isTemporary()); - self::assertEmpty($ct->getRawState(CreateTable::COLUMNS)); - self::assertEmpty($ct->getRawState(CreateTable::CONSTRAINTS)); + static::assertSame('', $ct->getRawState(CreateTable::TABLE)); + static::assertFalse($ct->isTemporary()); + static::assertEmpty($ct->getRawState(CreateTable::COLUMNS)); + static::assertEmpty($ct->getRawState(CreateTable::CONSTRAINTS)); } - public function testGetOptionsReturnsEmpty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getOptionsReturnsEmpty(): void { $ct = new CreateTable('foo'); - self::assertEquals([], $ct->getOptions()); + static::assertEquals([], $ct->getOptions()); } - public function testGetRawStateIncludesTableOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateIncludesTableOptions(): void { $ct = new CreateTable('foo'); $ct->setOption('engine', new Literal('InnoDB')); $rawState = $ct->getRawState(); - self::assertArrayHasKey(CreateTable::TABLE_OPTIONS, $rawState); - self::assertEquals(['engine' => new Literal('InnoDB')], $rawState[CreateTable::TABLE_OPTIONS]); + static::assertArrayHasKey(CreateTable::TABLE_OPTIONS, $rawState); + static::assertEquals(['engine' => new Literal('InnoDB')], $rawState[CreateTable::TABLE_OPTIONS]); } - public function testGetRawStateReturnsAllState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateReturnsAllState(): void { $ct = new CreateTable('users'); $col = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -165,47 +174,49 @@ public function testGetRawStateReturnsAllState(): void $rawState = $ct->getRawState(); - self::assertIsArray($rawState); - self::assertArrayHasKey(CreateTable::TABLE, $rawState); - self::assertArrayHasKey(CreateTable::COLUMNS, $rawState); - self::assertArrayHasKey(CreateTable::CONSTRAINTS, $rawState); + static::assertIsArray($rawState); + static::assertArrayHasKey(CreateTable::TABLE, $rawState); + static::assertArrayHasKey(CreateTable::COLUMNS, $rawState); + static::assertArrayHasKey(CreateTable::CONSTRAINTS, $rawState); - self::assertEquals('users', $rawState[CreateTable::TABLE]); - self::assertEquals([$col], $rawState[CreateTable::COLUMNS]); - self::assertEquals([$con], $rawState[CreateTable::CONSTRAINTS]); + static::assertSame('users', $rawState[CreateTable::TABLE]); + static::assertEquals([$col], $rawState[CreateTable::COLUMNS]); + static::assertEquals([$con], $rawState[CreateTable::CONSTRAINTS]); } - public function testGetRawStateWithInvalidKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateWithInvalidKey(): void { $ct = new CreateTable('test'); $ct->addColumn($this->getMockBuilder(ColumnInterface::class)->getMock()); // Non-existent key should return full array $rawState = $ct->getRawState('invalid_key'); - self::assertIsArray($rawState); - self::assertArrayHasKey(CreateTable::TABLE, $rawState); + static::assertIsArray($rawState); + static::assertArrayHasKey(CreateTable::TABLE, $rawState); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $ct = new CreateTable('foo'); - self::assertEquals("CREATE TABLE \"foo\" ( \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE \"foo\" ( \n)", $ct->getSqlString()); $ct = new CreateTable('foo', true); - self::assertEquals("CREATE TEMPORARY TABLE \"foo\" ( \n)", $ct->getSqlString()); + static::assertSame("CREATE TEMPORARY TABLE \"foo\" ( \n)", $ct->getSqlString()); $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); - self::assertEquals("CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); $ct = new CreateTable('foo', true); $ct->addColumn(new Column('bar')); - self::assertEquals("CREATE TEMPORARY TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); + static::assertSame("CREATE TEMPORARY TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); $ct = new CreateTable('foo', true); $ct->addColumn(new Column('bar')); $ct->addColumn(new Column('baz')); - self::assertEquals( + static::assertSame( "CREATE TEMPORARY TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL,\n \"baz\" INTEGER NOT NULL \n)", $ct->getSqlString(), ); @@ -213,7 +224,7 @@ public function testGetSqlString(): void $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->addConstraint(new Constraint\PrimaryKey('bat')); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL , \n PRIMARY KEY (\"bat\") \n)", $ct->getSqlString(), ); @@ -221,133 +232,144 @@ public function testGetSqlString(): void $ct = new CreateTable('foo'); $ct->addConstraint(new Constraint\PrimaryKey('bar')); $ct->addConstraint(new Constraint\PrimaryKey('bat')); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n PRIMARY KEY (\"bar\"),\n PRIMARY KEY (\"bat\") \n)", $ct->getSqlString(), ); $ct = new CreateTable(new TableIdentifier('foo')); $ct->addColumn(new Column('bar')); - self::assertEquals("CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString()); $ct = new CreateTable(new TableIdentifier('bar', 'foo')); $ct->addColumn(new Column('baz')); - self::assertEquals("CREATE TABLE \"foo\".\"bar\" ( \n \"baz\" INTEGER NOT NULL \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE \"foo\".\"bar\" ( \n \"baz\" INTEGER NOT NULL \n)", $ct->getSqlString()); } - public function testGetSqlStringWithBoolOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithBoolOption(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->setOption('pack_keys', true); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n) PACK_KEYS = 1", $ct->getSqlString(), ); } - public function testGetSqlStringWithIntOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithIntOption(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->setOption('auto_increment', 100); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n) AUTO_INCREMENT = 100", $ct->getSqlString(), ); } - public function testGetSqlStringWithLiteralOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithLiteralOption(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->setOption('engine', new Literal('InnoDB')); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n) ENGINE = InnoDB", $ct->getSqlString(), ); } - public function testGetSqlStringWithMultipleOptions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithMultipleOptions(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->setOption('engine', new Literal('InnoDB')); $ct->setOption('auto_increment', 100); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n) ENGINE = InnoDB AUTO_INCREMENT = 100", $ct->getSqlString(), ); } - public function testGetSqlStringWithNoOptionsUnchanged(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithNoOptionsUnchanged(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n)", $ct->getSqlString(), ); } - public function testGetSqlStringWithStringOption(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithStringOption(): void { $ct = new CreateTable('foo'); $ct->addColumn(new Column('bar')); $ct->setOption('comment', 'My table'); - self::assertEquals( + static::assertSame( "CREATE TABLE \"foo\" ( \n \"bar\" INTEGER NOT NULL \n) COMMENT = 'My table'", $ct->getSqlString(), ); } - public function testIfNotExists(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifNotExists(): void { $ct = new CreateTable('foo'); - self::assertFalse($ct->getIfNotExists()); + static::assertFalse($ct->getIfNotExists()); $result = $ct->ifNotExists(); - self::assertSame($ct, $result); - self::assertTrue($ct->getIfNotExists()); + static::assertSame($ct, $result); + static::assertTrue($ct->getIfNotExists()); - self::assertEquals("CREATE TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); } - public function testIfNotExistsCombinedWithTemporary(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifNotExistsCombinedWithTemporary(): void { $ct = new CreateTable('foo', true); $ct->ifNotExists(); - self::assertEquals("CREATE TEMPORARY TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); + static::assertSame("CREATE TEMPORARY TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); } - public function testIfNotExistsDisable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifNotExistsDisable(): void { $ct = new CreateTable('foo'); $ct->ifNotExists(); - self::assertTrue($ct->getIfNotExists()); + static::assertTrue($ct->getIfNotExists()); $ct->ifNotExists(false); - self::assertFalse($ct->getIfNotExists()); + static::assertFalse($ct->getIfNotExists()); - self::assertEquals("CREATE TABLE \"foo\" ( \n)", $ct->getSqlString()); + static::assertSame("CREATE TABLE \"foo\" ( \n)", $ct->getSqlString()); } - public function testIsTemporary(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isTemporary(): void { $ct = new CreateTable(); - self::assertFalse($ct->isTemporary()); + static::assertFalse($ct->isTemporary()); $ct->setTemporary(true); - self::assertTrue($ct->isTemporary()); + static::assertTrue($ct->isTemporary()); } - public function testMultipleColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleColumns(): void { $ct = new CreateTable('users'); $ct->addColumn(new Column('id')); @@ -355,104 +377,111 @@ public function testMultipleColumns(): void $ct->addColumn(new Column('email')); $columns = $ct->getRawState(CreateTable::COLUMNS); - self::assertCount(3, $columns); + static::assertCount(3, $columns); $sql = $ct->getSqlString(); - self::assertStringContainsString('"id"', $sql); - self::assertStringContainsString('"name"', $sql); - self::assertStringContainsString('"email"', $sql); + static::assertStringContainsString('"id"', $sql); + static::assertStringContainsString('"name"', $sql); + static::assertStringContainsString('"email"', $sql); } - public function testMultipleConstraints(): void + #[\PHPUnit\Framework\Attributes\Test] + public function multipleConstraints(): void { $ct = new CreateTable('orders'); $ct->addConstraint(new Constraint\PrimaryKey('id')); $ct->addConstraint(new Constraint\UniqueKey('order_number')); $constraints = $ct->getRawState(CreateTable::CONSTRAINTS); - self::assertCount(2, $constraints); + static::assertCount(2, $constraints); $sql = $ct->getSqlString(); - self::assertStringContainsString('PRIMARY KEY', $sql); - self::assertStringContainsString('UNIQUE', $sql); + static::assertStringContainsString('PRIMARY KEY', $sql); + static::assertStringContainsString('UNIQUE', $sql); } /** * test object construction */ - public function testObjectConstruction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function objectConstruction(): void { $ct = new CreateTable('foo', true); - self::assertEquals('foo', $ct->getRawState(CreateTable::TABLE)); - self::assertTrue($ct->isTemporary()); + static::assertSame('foo', $ct->getRawState(CreateTable::TABLE)); + static::assertTrue($ct->isTemporary()); } - public function testSetOptionFluentInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOptionFluentInterface(): void { $ct = new CreateTable('foo'); $result = $ct->setOption('engine', new Literal('InnoDB')); - self::assertSame($ct, $result); - self::assertEquals(['engine' => new Literal('InnoDB')], $ct->getOptions()); + static::assertSame($ct, $result); + static::assertEquals(['engine' => new Literal('InnoDB')], $ct->getOptions()); } - public function testSetOptionsReplacesAll(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setOptionsReplacesAll(): void { $ct = new CreateTable('foo'); $ct->setOption('engine', new Literal('InnoDB')); $ct->setOptions(['charset' => new Literal('utf8mb4')]); - self::assertEquals(['charset' => new Literal('utf8mb4')], $ct->getOptions()); + static::assertEquals(['charset' => new Literal('utf8mb4')], $ct->getOptions()); } - public function testSetTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTable(): void { $ct = new CreateTable(); // Verify initial state - self::assertEquals('', $ct->getRawState('table')); + static::assertSame('', $ct->getRawState('table')); // First mutation $result = $ct->setTable('test'); // Verify fluent interface - self::assertSame($ct, $result); + static::assertSame($ct, $result); // Verify the first mutation occurred - self::assertEquals('test', $ct->getRawState('table')); + static::assertSame('test', $ct->getRawState('table')); // Second mutation to verify mutability $ct->setTable('another_table'); // Verify the instance was actually mutated - self::assertEquals('another_table', $ct->getRawState('table')); + static::assertSame('another_table', $ct->getRawState('table')); } - public function testSetTableAfterConstruction(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTableAfterConstruction(): void { $ct = new CreateTable(); - self::assertEquals('', $ct->getRawState(CreateTable::TABLE)); + static::assertSame('', $ct->getRawState(CreateTable::TABLE)); $ct->setTable('new_table'); - self::assertEquals('new_table', $ct->getRawState(CreateTable::TABLE)); + static::assertSame('new_table', $ct->getRawState(CreateTable::TABLE)); // Test that setTable is chainable $result = $ct->setTable('another_table'); - self::assertSame($ct, $result); - self::assertEquals('another_table', $ct->getRawState(CreateTable::TABLE)); + static::assertSame($ct, $result); + static::assertSame('another_table', $ct->getRawState(CreateTable::TABLE)); } - public function testSetTemporary(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTemporary(): void { $ct = new CreateTable(); - self::assertSame($ct, $ct->setTemporary(false)); - self::assertFalse($ct->isTemporary()); + static::assertSame($ct, $ct->setTemporary(false)); + static::assertFalse($ct->isTemporary()); $ct->setTemporary(true); - self::assertTrue($ct->isTemporary()); + static::assertTrue($ct->isTemporary()); $ct->setTemporary('yes'); - self::assertTrue($ct->isTemporary()); + static::assertTrue($ct->isTemporary()); - self::assertStringStartsWith('CREATE TEMPORARY TABLE', $ct->getSqlString()); + static::assertStringStartsWith('CREATE TEMPORARY TABLE', $ct->getSqlString()); } } diff --git a/test/unit/Sql/Ddl/DropTableTest.php b/test/unit/Sql/Ddl/DropTableTest.php index 12198591..0f5dcd33 100644 --- a/test/unit/Sql/Ddl/DropTableTest.php +++ b/test/unit/Sql/Ddl/DropTableTest.php @@ -16,47 +16,51 @@ #[CoversMethod(DropTable::class, 'processTable')] class DropTableTest extends TestCase { - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $dt = new DropTable('foo'); - self::assertEquals('DROP TABLE "foo"', $dt->getSqlString()); + static::assertSame('DROP TABLE "foo"', $dt->getSqlString()); $dt = new DropTable(new TableIdentifier('foo')); - self::assertEquals('DROP TABLE "foo"', $dt->getSqlString()); + static::assertSame('DROP TABLE "foo"', $dt->getSqlString()); $dt = new DropTable(new TableIdentifier('bar', 'foo')); - self::assertEquals('DROP TABLE "foo"."bar"', $dt->getSqlString()); + static::assertSame('DROP TABLE "foo"."bar"', $dt->getSqlString()); } - public function testIfExists(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifExists(): void { $dt = new DropTable('foo'); - self::assertFalse($dt->getIfExists()); + static::assertFalse($dt->getIfExists()); $result = $dt->ifExists(); - self::assertSame($dt, $result); - self::assertTrue($dt->getIfExists()); + static::assertSame($dt, $result); + static::assertTrue($dt->getIfExists()); - self::assertEquals('DROP TABLE IF EXISTS "foo"', $dt->getSqlString()); + static::assertSame('DROP TABLE IF EXISTS "foo"', $dt->getSqlString()); } - public function testIfExistsDisable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifExistsDisable(): void { $dt = new DropTable('foo'); $dt->ifExists(); - self::assertTrue($dt->getIfExists()); + static::assertTrue($dt->getIfExists()); $dt->ifExists(false); - self::assertFalse($dt->getIfExists()); + static::assertFalse($dt->getIfExists()); - self::assertEquals('DROP TABLE "foo"', $dt->getSqlString()); + static::assertSame('DROP TABLE "foo"', $dt->getSqlString()); } - public function testIfExistsWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function ifExistsWithTableIdentifier(): void { $dt = new DropTable(new TableIdentifier('bar', 'foo')); $dt->ifExists(); - self::assertEquals('DROP TABLE IF EXISTS "foo"."bar"', $dt->getSqlString()); + static::assertSame('DROP TABLE IF EXISTS "foo"."bar"', $dt->getSqlString()); } } diff --git a/test/unit/Sql/Ddl/Index/IndexTest.php b/test/unit/Sql/Ddl/Index/IndexTest.php index 1e5fa73f..59a718bf 100644 --- a/test/unit/Sql/Ddl/Index/IndexTest.php +++ b/test/unit/Sql/Ddl/Index/IndexTest.php @@ -16,14 +16,15 @@ #[CoversMethod(Index::class, 'getExpressionData')] final class IndexTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $uk = new Index('foo', 'my_uk'); $expressionData = $uk->getExpressionData(); - self::assertEquals('INDEX %s(%s)', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s)', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_uk'), new Identifier('foo'), @@ -32,15 +33,16 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataWithBtreeType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithBtreeType(): void { $index = new Index('foo', 'my_idx'); $index->setType('BTREE'); $expressionData = $index->getExpressionData(); - self::assertEquals('INDEX %s(%s) USING %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s) USING %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_idx'), new Identifier('foo'), @@ -50,15 +52,16 @@ public function testGetExpressionDataWithBtreeType(): void ); } - public function testGetExpressionDataWithHashType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithHashType(): void { $index = new Index('foo', 'my_idx'); $index->setType('HASH'); $expressionData = $index->getExpressionData(); - self::assertEquals('INDEX %s(%s) USING %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s) USING %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_idx'), new Identifier('foo'), @@ -68,14 +71,15 @@ public function testGetExpressionDataWithHashType(): void ); } - public function testGetExpressionDataWithLength(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithLength(): void { $key = new Index(['foo', 'bar'], 'my_uk', [10, 5]); $expressionData = $key->getExpressionData(); - self::assertEquals('INDEX %s(%s(10), %s(5))', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s(10), %s(5))', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_uk'), new Identifier('foo'), @@ -85,14 +89,15 @@ public function testGetExpressionDataWithLength(): void ); } - public function testGetExpressionDataWithLengthUnmatched(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithLengthUnmatched(): void { $key = new Index(['foo', 'bar'], 'my_uk', [10]); $expressionData = $key->getExpressionData(); - self::assertEquals('INDEX %s(%s(10), %s)', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s(10), %s)', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_uk'), new Identifier('foo'), @@ -102,15 +107,16 @@ public function testGetExpressionDataWithLengthUnmatched(): void ); } - public function testGetExpressionDataWithTypeAndLengths(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithTypeAndLengths(): void { $index = new Index(['foo', 'bar'], 'my_idx', [10, 5]); $index->setType('BTREE'); $expressionData = $index->getExpressionData(); - self::assertEquals('INDEX %s(%s(10), %s(5)) USING %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('INDEX %s(%s(10), %s(5)) USING %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('my_idx'), new Identifier('foo'), @@ -121,13 +127,14 @@ public function testGetExpressionDataWithTypeAndLengths(): void ); } - public function testSetTypeAndGetType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTypeAndGetType(): void { $index = new Index('foo', 'my_idx'); - self::assertNull($index->getType()); + static::assertNull($index->getType()); $result = $index->setType('BTREE'); - self::assertSame($index, $result); - self::assertEquals('BTREE', $index->getType()); + static::assertSame($index, $result); + static::assertSame('BTREE', $index->getType()); } } diff --git a/test/unit/Sql/DeleteTest.php b/test/unit/Sql/DeleteTest.php index 487e40b1..4a3c081a 100644 --- a/test/unit/Sql/DeleteTest.php +++ b/test/unit/Sql/DeleteTest.php @@ -47,91 +47,101 @@ final class DeleteTest extends TestCase protected Delete $delete; - public function testConstructorWithTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTable(): void { $delete = new Delete('foo'); - self::assertEquals('foo', $delete->getRawState('table')); + static::assertSame('foo', $delete->getRawState('table')); } - public function testConstructorWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); $delete = new Delete($tableIdentifier); - self::assertEquals($tableIdentifier, $delete->getRawState('table')); + static::assertEquals($tableIdentifier, $delete->getRawState('table')); } /** * @throws ReflectionException */ - public function testFrom(): void + #[\PHPUnit\Framework\Attributes\Test] + public function from(): void { // Set table with string $this->delete->from('foo'); - self::assertEquals('foo', $this->readAttribute($this->delete, 'table')); + static::assertSame('foo', static::readAttribute($this->delete, 'table')); // Set table with TableIdentifier $tableIdentifier = new TableIdentifier('foo', 'bar'); $this->delete->from($tableIdentifier); - self::assertEquals($tableIdentifier, $this->readAttribute($this->delete, 'table')); + static::assertEquals($tableIdentifier, static::readAttribute($this->delete, 'table')); } - public function testGetRawState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawState(): void { $this->delete->from('foo')->where('x = y'); $rawState = $this->delete->getRawState(); - self::assertIsArray($rawState); - self::assertArrayHasKey('table', $rawState); - self::assertArrayHasKey('where', $rawState); - self::assertArrayHasKey('emptyWhereProtection', $rawState); + static::assertIsArray($rawState); + static::assertArrayHasKey('table', $rawState); + static::assertArrayHasKey('where', $rawState); + static::assertArrayHasKey('emptyWhereProtection', $rawState); - self::assertEquals('foo', $rawState['table']); - self::assertInstanceOf(Where::class, $rawState['where']); - self::assertTrue($rawState['emptyWhereProtection']); + static::assertSame('foo', $rawState['table']); + static::assertInstanceOf(Where::class, $rawState['where']); + static::assertTrue($rawState['emptyWhereProtection']); } - public function testGetRawStateWithKey(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateWithKey(): void { $this->delete->from('foo'); - self::assertEquals('foo', $this->delete->getRawState('table')); - self::assertInstanceOf(Where::class, $this->delete->getRawState('where')); - self::assertTrue($this->delete->getRawState('emptyWhereProtection')); + static::assertSame('foo', $this->delete->getRawState('table')); + static::assertInstanceOf(Where::class, $this->delete->getRawState('where')); + static::assertTrue($this->delete->getRawState('emptyWhereProtection')); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $this->delete->from('foo')->where('x = y'); - self::assertEquals('DELETE FROM "foo" WHERE x = y', $this->delete->getSqlString()); + static::assertSame('DELETE FROM "foo" WHERE x = y', $this->delete->getSqlString()); // Test with TableIdentifier $this->delete = new Delete(); $this->delete->from(new TableIdentifier('foo', 'sch'))->where('x = y'); - self::assertEquals('DELETE FROM "sch"."foo" WHERE x = y', $this->delete->getSqlString()); + static::assertSame('DELETE FROM "sch"."foo" WHERE x = y', $this->delete->getSqlString()); } - public function testGetSqlStringWithEmptyWhere(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithEmptyWhere(): void { $this->delete->from('foo'); // Empty where should not add WHERE clause - self::assertEquals('DELETE FROM "foo"', $this->delete->getSqlString()); + static::assertSame('DELETE FROM "foo"', $this->delete->getSqlString()); } - public function testMagicGetReturnsNullForUnknownProperty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsNullForUnknownProperty(): void { /** @noinspection PhpUndefinedFieldInspection */ - self::assertNull($this->delete->unknown); // @phpstan-ignore-line - self::assertNull($this->delete->table); // @phpstan-ignore-line + static::assertNull($this->delete->unknown); // @phpstan-ignore-line + static::assertNull($this->delete->table); // @phpstan-ignore-line } - public function testMagicGetReturnsWhereClause(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsWhereClause(): void { $where = $this->delete->where; - self::assertInstanceOf(Where::class, $where); + static::assertInstanceOf(Where::class, $where); } - public function testPrepareStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockAdapter = $this->createMockAdapter($mockDriver); @@ -139,7 +149,7 @@ public function testPrepareStatement(): void $mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('DELETE FROM "foo" WHERE x = y')); + ->with(static::equalTo('DELETE FROM "foo" WHERE x = y')); $this->delete->from('foo')->where('x = y'); @@ -154,31 +164,33 @@ public function testPrepareStatement(): void $mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('DELETE FROM "sch"."foo" WHERE x = y')); + ->with(static::equalTo('DELETE FROM "sch"."foo" WHERE x = y')); $this->delete->from(new TableIdentifier('foo', 'sch'))->where('x = y'); $this->delete->prepareStatement($mockAdapter, $mockStatement); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void + public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $deleteIgnore = new DeleteIgnore(); $deleteIgnore->from('foo') ->where('x = y'); - self::assertEquals('DELETE IGNORE FROM "foo" WHERE x = y', $deleteIgnore->getSqlString()); + static::assertSame('DELETE IGNORE FROM "foo" WHERE x = y', $deleteIgnore->getSqlString()); // with TableIdentifier $deleteIgnore = new DeleteIgnore(); $deleteIgnore->from(new TableIdentifier('foo', 'sch')) ->where('x = y'); - self::assertEquals('DELETE IGNORE FROM "sch"."foo" WHERE x = y', $deleteIgnore->getSqlString()); + static::assertSame('DELETE IGNORE FROM "sch"."foo" WHERE x = y', $deleteIgnore->getSqlString()); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $deleteIgnore = new DeleteIgnore(); @@ -188,7 +200,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('DELETE IGNORE FROM "foo" WHERE x = y')); + ->with(static::equalTo('DELETE IGNORE FROM "foo" WHERE x = y')); $deleteIgnore->from('foo') ->where('x = y'); @@ -204,7 +216,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('DELETE IGNORE FROM "sch"."foo" WHERE x = y')); + ->with(static::equalTo('DELETE IGNORE FROM "sch"."foo" WHERE x = y')); $deleteIgnore->from(new TableIdentifier('foo', 'sch')) ->where('x = y'); @@ -216,7 +228,8 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt * @throws ReflectionException * @todo REMOVE THIS IN 3.x */ - public function testWhere(): void + #[\PHPUnit\Framework\Attributes\Test] + public function where(): void { $this->delete->where('x = y'); $this->delete->where(['foo > ?' => 5]); @@ -229,45 +242,46 @@ public function testWhere(): void $where = $this->delete->where; - $predicates = $this->readAttribute($where, 'predicates'); - self::assertEquals('AND', $predicates[0][0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); + $predicates = static::readAttribute($where, 'predicates'); + static::assertSame('AND', $predicates[0][0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); - self::assertEquals('AND', $predicates[1][0]); - self::assertInstanceOf(Expression::class, $predicates[1][1]); + static::assertSame('AND', $predicates[1][0]); + static::assertInstanceOf(Expression::class, $predicates[1][1]); - self::assertEquals('AND', $predicates[2][0]); - self::assertInstanceOf(Operator::class, $predicates[2][1]); + static::assertSame('AND', $predicates[2][0]); + static::assertInstanceOf(Operator::class, $predicates[2][1]); - self::assertEquals('OR', $predicates[3][0]); - self::assertInstanceOf(Literal::class, $predicates[3][1]); + static::assertSame('OR', $predicates[3][0]); + static::assertInstanceOf(Literal::class, $predicates[3][1]); - self::assertEquals('AND', $predicates[4][0]); - self::assertInstanceOf(IsNull::class, $predicates[4][1]); + static::assertSame('AND', $predicates[4][0]); + static::assertInstanceOf(IsNull::class, $predicates[4][1]); - self::assertEquals('AND', $predicates[5][0]); - self::assertInstanceOf(In::class, $predicates[5][1]); + static::assertSame('AND', $predicates[5][0]); + static::assertInstanceOf(In::class, $predicates[5][1]); - self::assertEquals('AND', $predicates[6][0]); - self::assertInstanceOf(IsNotNull::class, $predicates[6][1]); + static::assertSame('AND', $predicates[6][0]); + static::assertInstanceOf(IsNotNull::class, $predicates[6][1]); - self::assertEquals('AND', $predicates[7][0]); - self::assertInstanceOf(Operator::class, $predicates[7][1]); + static::assertSame('AND', $predicates[7][0]); + static::assertInstanceOf(Operator::class, $predicates[7][1]); - self::assertEquals('AND', $predicates[8][0]); - self::assertInstanceOf(Operator::class, $predicates[8][1]); + static::assertSame('AND', $predicates[8][0]); + static::assertInstanceOf(Operator::class, $predicates[8][1]); $where = new Where(); $this->delete->where($where); - self::assertSame($where, $this->delete->where); + static::assertSame($where, $this->delete->where); $this->delete->where(static function ($what) use ($where): void { self::assertSame($where, $what); }); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] - public function testWhereAcceptsExpressionInterface(): void + public function whereAcceptsExpressionInterface(): void { $this->delete ->from('foo') @@ -276,8 +290,8 @@ public function testWhereAcceptsExpressionInterface(): void ]); $where = $this->delete->getRawState('where'); - self::assertInstanceOf(Where::class, $where); - self::assertEquals(1, $where->count()); + static::assertInstanceOf(Where::class, $where); + static::assertSame(1, $where->count()); } /** diff --git a/test/unit/Sql/ExpressionTest.php b/test/unit/Sql/ExpressionTest.php index 2900869f..04c31ddd 100644 --- a/test/unit/Sql/ExpressionTest.php +++ b/test/unit/Sql/ExpressionTest.php @@ -43,37 +43,41 @@ public static function falsyExpressionParametersProvider(): array ]; } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('falsyExpressionParametersProvider')] - public function testConstructorWithFalsyValidParameters(mixed $falsyParameter): void + public function constructorWithFalsyValidParameters(mixed $falsyParameter): void { $expression = new Expression('?', $falsyParameter); $falsyValue = Argument::value($falsyParameter); $expressionData = $expression->getExpressionData(); - self::assertEquals([$falsyValue], $expressionData['values']); + static::assertEquals([$falsyValue], $expressionData['values']); } - public function testConstructorWithInvalidParameter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithInvalidParameter(): void { self::expectException(TypeError::class); new Expression('?', (object) []); } - public function testConstructorWithLiteralZero(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithLiteralZero(): void { $expression = new Expression('0'); - self::assertSame('0', $expression->getExpression()); + static::assertSame('0', $expression->getExpression()); } - public function testConstructorWithMultipleArguments(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithMultipleArguments(): void { $expression = new Expression('? + ? - ?', 1, 2, 3); $expressionData = $expression->getExpressionData(); - self::assertEquals('%s + %s - %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('%s + %s - %s', $expressionData['spec']); + static::assertEquals( [ Argument::value(1), Argument::value(2), @@ -83,7 +87,8 @@ public function testConstructorWithMultipleArguments(): void ); } - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $expression = new Expression( 'X SAME AS ? AND Y = ? BUT LITERALLY ?', @@ -96,8 +101,8 @@ public function testGetExpressionData(): void $expressionData = $expression->getExpressionData(); - self::assertEquals('X SAME AS %s AND Y = %s BUT LITERALLY %s', $expressionData['spec']); - self::assertEquals( + static::assertSame('X SAME AS %s AND Y = %s BUT LITERALLY %s', $expressionData['spec']); + static::assertEquals( [ new Identifier('foo'), new Value(5), @@ -107,7 +112,8 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataThrowsExceptionWhenParameterCountMismatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenParameterCountMismatch(): void { $expression = new Expression('? AND ?', [1]); // Two placeholders but only one parameter @@ -118,52 +124,57 @@ public function testGetExpressionDataThrowsExceptionWhenParameterCountMismatch() $expression->getExpressionData(); } - public function testGetExpressionDataUsesRegexWhenPlaceholderCountMismatches(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataUsesRegexWhenPlaceholderCountMismatches(): void { $expression = new Expression('uf.user_id = :user_id OR uf.friend_id = :user_id', ['user_id' => 1]); $expressionData = $expression->getExpressionData(); - self::assertEquals( + static::assertSame( 'uf.user_id = :user_id OR uf.friend_id = :user_id', $expressionData['spec'], ); - self::assertCount(1, $expressionData['values']); + static::assertCount(1, $expressionData['values']); } - public function testGetExpressionDataWillEscapePercent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWillEscapePercent(): void { $expression = new Expression('X LIKE "foo%"'); $expressionData = $expression->getExpressionData(); - self::assertEquals('X LIKE "foo%%"', $expressionData['spec']); + static::assertSame('X LIKE "foo%%"', $expressionData['spec']); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('7407')] - public function testGetExpressionPreservesPercentageSignInFromUnixtime(): void + public function getExpressionPreservesPercentageSignInFromUnixtime(): void { $expressionString = 'FROM_UNIXTIME(date, "%Y-%m")'; $expression = new Expression($expressionString); - self::assertSame($expressionString, $expression->getExpression()); + static::assertSame($expressionString, $expression->getExpression()); } - public function testNumberOfReplacementsConsidersWhenSameVariableIsUsedManyTimes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function numberOfReplacementsConsidersWhenSameVariableIsUsedManyTimes(): void { $expression = new Expression('uf.user_id = :user_id OR uf.friend_id = :user_id', ['user_id' => 1]); $value = new Value(1); $expressionData = $expression->getExpressionData(); - self::assertEquals( + static::assertSame( 'uf.user_id = :user_id OR uf.friend_id = :user_id', $expressionData['spec'], ); - self::assertEquals([$value], $expressionData['values']); + static::assertEquals([$value], $expressionData['values']); } - public function testNumberOfReplacementsForExpressionWithParameters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function numberOfReplacementsForExpressionWithParameters(): void { $expression = new Expression(':a + :b', ['a' => 1, 'b' => 2]); $value1 = Argument::value(1); @@ -171,11 +182,12 @@ public function testNumberOfReplacementsForExpressionWithParameters(): void $expressionData = $expression->getExpressionData(); - self::assertEquals(':a + :b', $expressionData['spec']); - self::assertEquals([$value1, $value2], $expressionData['values']); + static::assertSame(':a + :b', $expressionData['spec']); + static::assertEquals([$value1, $value2], $expressionData['values']); } - public function testSetExpression(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setExpression(): void { $expression = new Expression(); @@ -183,19 +195,20 @@ public function testSetExpression(): void $result = $expression->setExpression('Foo Bar'); // Verify fluent interface - self::assertSame($expression, $result); + static::assertSame($expression, $result); // Verify the first mutation occurred - self::assertEquals('Foo Bar', $expression->getExpression()); + static::assertSame('Foo Bar', $expression->getExpression()); // Second mutation to verify mutability $expression->setExpression('Baz Qux'); // Verify the instance was actually mutated - self::assertEquals('Baz Qux', $expression->getExpression()); + static::assertSame('Baz Qux', $expression->getExpression()); } - public function testSetExpressionException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setExpressionException(): void { $expression = new Expression(); self::expectException(TypeError::class); @@ -208,7 +221,8 @@ public function testSetExpressionException(): void $expression->setExpression(''); } - public function testSetExpressionThrowsOnEmptyString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setExpressionThrowsOnEmptyString(): void { $expression = new Expression(); @@ -216,7 +230,8 @@ public function testSetExpressionThrowsOnEmptyString(): void $expression->setExpression(''); } - public function testSetParameters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setParameters(): void { $expression = new Expression(); @@ -224,25 +239,26 @@ public function testSetParameters(): void $result = $expression->setParameters('foo'); // Verify fluent interface - self::assertSame($expression, $result); + static::assertSame($expression, $result); // Verify the first mutation occurred - self::assertEquals([new Value('foo')], $expression->getParameters()); + static::assertEquals([new Value('foo')], $expression->getParameters()); // Second mutation to verify mutability (setParameters appends) $expression->setParameters('bar'); // Verify the instance was actually mutated (now has both parameters) - self::assertEquals([new Value('foo'), new Value('bar')], $expression->getParameters()); + static::assertEquals([new Value('foo'), new Value('bar')], $expression->getParameters()); } - public function testSetParametersWrapsArrayInValuesArgument(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setParametersWrapsArrayInValuesArgument(): void { $expression = new Expression('? IN (?)', [Argument::identifier('id'), [1, 2, 3]]); $data = $expression->getExpressionData(); - self::assertCount(2, $data['values']); - self::assertInstanceOf(Argument\Values::class, $data['values'][1]); + static::assertCount(2, $data['values']); + static::assertInstanceOf(Argument\Values::class, $data['values'][1]); } } diff --git a/test/unit/Sql/InsertIgnoreTest.php b/test/unit/Sql/InsertIgnoreTest.php index 151bc997..593104b7 100644 --- a/test/unit/Sql/InsertIgnoreTest.php +++ b/test/unit/Sql/InsertIgnoreTest.php @@ -36,78 +36,85 @@ final class InsertIgnoreTest extends TestCase protected InsertIgnore $insert; // @codingStandardsIgnoreStart - public function test__get(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _get(): void { // @codingStandardsIgnoreEnd $this->insert->foo = 'bar'; - self::assertEquals('bar', $this->insert->foo); + static::assertSame('bar', $this->insert->foo); $this->insert->foo = null; - self::assertNull($this->insert->foo); + static::assertNull($this->insert->foo); } // @codingStandardsIgnoreStart - public function test__isset(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _isset(): void { // @codingStandardsIgnoreEnd $this->insert->foo = 'bar'; - self::assertTrue(isset($this->insert->foo)); + static::assertTrue(isset($this->insert->foo)); $this->insert->foo = null; - self::assertTrue(isset($this->insert->foo)); + static::assertTrue(isset($this->insert->foo)); } // @codingStandardsIgnoreStart - public function test__set(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _set(): void { // @codingStandardsIgnoreEnd $this->insert->foo = 'bar'; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); } // @codingStandardsIgnoreStart - public function test__unset(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _unset(): void { // @codingStandardsIgnoreEnd $this->insert->foo = 'bar'; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); unset($this->insert->foo); - self::assertEquals([], $this->insert->getRawState('columns')); - self::assertEquals([], $this->insert->getRawState('values')); + static::assertEquals([], $this->insert->getRawState('columns')); + static::assertEquals([], $this->insert->getRawState('values')); $this->insert->foo = null; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals([null], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals([null], $this->insert->getRawState('values')); unset($this->insert->foo); - self::assertEquals([], $this->insert->getRawState('columns')); - self::assertEquals([], $this->insert->getRawState('values')); + static::assertEquals([], $this->insert->getRawState('columns')); + static::assertEquals([], $this->insert->getRawState('values')); } - public function testColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function columns(): void { $columns = ['foo', 'bar']; $this->insert->columns($columns); - self::assertEquals($columns, $this->insert->getRawState('columns')); + static::assertEquals($columns, $this->insert->getRawState('columns')); } /** * @throws ReflectionException */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-4926')] - public function testEmptyArrayValues(): void + public function emptyArrayValues(): void { $this->insert->values([]); - self::assertEquals([], $this->readAttribute($this->insert, 'columns')); + static::assertEquals([], static::readAttribute($this->insert, 'columns')); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()), ); @@ -118,7 +125,7 @@ public function testGetSqlString(): void ->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()), ); @@ -128,43 +135,46 @@ public function testGetSqlString(): void $select = new Select(); $this->insert->into('foo')->select($select->from('bar')); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()), ); // with Select and columns $this->insert->columns(['col1', 'col2']); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" ("col1", "col2") SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testGetSqlStringUsingColumnsAndValuesMethods(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringUsingColumnsAndValuesMethods(): void { // With columns() and values() $this->insert ->into('foo') ->columns(['col1', 'col2', 'col3']) ->values(['val1', 'val2', 'val3']); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" ("col1", "col2", "col3") VALUES (\'val1\', \'val2\', \'val3\')', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testInto(): void + #[\PHPUnit\Framework\Attributes\Test] + public function into(): void { $this->insert->into('table'); - self::assertEquals('table', $this->insert->getRawState('table')); + static::assertSame('table', $this->insert->getRawState('table')); $tableIdentifier = new TableIdentifier('table', 'schema'); $this->insert->into($tableIdentifier); - self::assertEquals($tableIdentifier, $this->insert->getRawState('table')); + static::assertEquals($tableIdentifier, $this->insert->getRawState('table')); } - public function testPrepareStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -176,7 +186,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('INSERT IGNORE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('INSERT IGNORE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -195,7 +205,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('INSERT IGNORE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('INSERT IGNORE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert ->into(new TableIdentifier('foo', 'sch')) @@ -204,7 +214,8 @@ public function testPrepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - public function testPrepareStatementWithSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -220,21 +231,22 @@ public function testPrepareStatementWithSelect(): void ->select($select->where(['x' => 5])) ->prepareStatement($mockAdapter, $mockStatement); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" ("col1") SELECT "bar".* FROM "bar" WHERE "x" = ?', $mockStatement->getSql(), ); $parameters = $mockStatement->getParameterContainer()->getNamedArray(); - self::assertSame(['subselect1where1' => 5], $parameters); + static::assertSame(['subselect1where1' => 5], $parameters); } - public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $replace = new Replace(); $replace->into('foo') ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'REPLACE INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform()), ); @@ -244,13 +256,14 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr $replace->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'REPLACE INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform()), ); } - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $replace = new Replace(); @@ -264,7 +277,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('REPLACE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('REPLACE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into('foo') ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -284,7 +297,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('REPLACE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('REPLACE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -292,37 +305,40 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $replace->prepareStatement($mockAdapter, $mockStatement); } - public function testValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function values(): void { $this->insert->values(['foo' => 'bar']); - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); // test will merge cols and values of previously set stuff $this->insert->values(['foo' => 'bax'], Insert::VALUES_MERGE); $this->insert->values(['boom' => 'bam'], Insert::VALUES_MERGE); - self::assertEquals(['foo', 'boom'], $this->insert->getRawState('columns')); - self::assertEquals(['bax', 'bam'], $this->insert->getRawState('values')); + static::assertEquals(['foo', 'boom'], $this->insert->getRawState('columns')); + static::assertEquals(['bax', 'bam'], $this->insert->getRawState('values')); $this->insert->values(['foo' => 'bax']); - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bax'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bax'], $this->insert->getRawState('values')); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-536')] - public function testValuesMerge(): void + public function valuesMerge(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->insert->into('foo') ->values(['qux' => 100], Insert::VALUES_MERGE); - self::assertEquals( + static::assertSame( 'INSERT IGNORE INTO "foo" ("bar", "boo", "bam", "qux") VALUES (\'baz\', NOW(), NULL, \'100\')', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -334,13 +350,15 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - public function testValuesThrowsExceptionWhenNotArrayOrSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); $this->insert->values(5); } - public function testValuesThrowsExceptionWhenSelectMergeOverArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenSelectMergeOverArray(): void { $this->insert->values(['foo' => 'bar']); diff --git a/test/unit/Sql/InsertTest.php b/test/unit/Sql/InsertTest.php index a06e1ccc..f1204f74 100644 --- a/test/unit/Sql/InsertTest.php +++ b/test/unit/Sql/InsertTest.php @@ -54,87 +54,94 @@ final class InsertTest extends TestCase protected Insert $insert; // @codingStandardsIgnoreStart - public function test__get(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _get(): void { // @codingStandardsIgnoreEnd /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = 'bar'; - self::assertEquals('bar', $this->insert->foo); + static::assertSame('bar', $this->insert->foo); /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = null; - self::assertNull($this->insert->foo); + static::assertNull($this->insert->foo); } // @codingStandardsIgnoreStart - public function test__isset(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _isset(): void { // @codingStandardsIgnoreEnd /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = 'bar'; /** @psalm-suppress RedundantCondition */ - self::assertTrue(isset($this->insert->foo)); + static::assertTrue(isset($this->insert->foo)); /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = null; /** @psalm-suppress TypeDoesNotContainType */ - self::assertTrue(isset($this->insert->foo)); + static::assertTrue(isset($this->insert->foo)); } // @codingStandardsIgnoreStart - public function test__set(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _set(): void { // @codingStandardsIgnoreEnd /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = 'bar'; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); } // @codingStandardsIgnoreStart - public function test__unset(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _unset(): void { // @codingStandardsIgnoreEnd /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = 'bar'; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); unset($this->insert->foo); - self::assertEquals([], $this->insert->getRawState('columns')); - self::assertEquals([], $this->insert->getRawState('values')); + static::assertEquals([], $this->insert->getRawState('columns')); + static::assertEquals([], $this->insert->getRawState('values')); /** @psalm-suppress UndefinedMagicPropertyAssignment */ $this->insert->foo = null; - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals([null], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals([null], $this->insert->getRawState('values')); unset($this->insert->foo); - self::assertEquals([], $this->insert->getRawState('columns')); - self::assertEquals([], $this->insert->getRawState('values')); + static::assertEquals([], $this->insert->getRawState('columns')); + static::assertEquals([], $this->insert->getRawState('values')); } - public function testColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function columns(): void { $columns = ['foo', 'bar']; $this->insert->columns($columns); - self::assertEquals($columns, $this->insert->getRawState('columns')); + static::assertEquals($columns, $this->insert->getRawState('columns')); } /** * @throws ReflectionException */ + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-4926')] - public function testEmptyArrayValues(): void + public function emptyArrayValues(): void { $this->insert->values([]); - self::assertEquals([], $this->readAttribute($this->insert, 'columns')); + static::assertEquals([], static::readAttribute($this->insert, 'columns')); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()), ); @@ -145,7 +152,7 @@ public function testGetSqlString(): void ->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'INSERT INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $this->insert->getSqlString(new TrustingSql92Platform()), ); @@ -155,20 +162,21 @@ public function testGetSqlString(): void $select = new Select(); $this->insert->into('foo')->select($select->from('bar')); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()), ); // with Select and columns $this->insert->columns(['col1', 'col2']); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" ("col1", "col2") SELECT "bar".* FROM "bar"', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testGetSqlStringThrowsExceptionWhenNoValuesOrSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringThrowsExceptionWhenNoValuesOrSelect(): void { $this->insert->into('foo'); @@ -177,37 +185,41 @@ public function testGetSqlStringThrowsExceptionWhenNoValuesOrSelect(): void $this->insert->getSqlString(new TrustingSql92Platform()); } - public function testGetSqlStringUsingColumnsAndValuesMethods(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringUsingColumnsAndValuesMethods(): void { // With columns() and values() $this->insert ->into('foo') ->columns(['col1', 'col2', 'col3']) ->values(['val1', 'val2', 'val3']); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" ("col1", "col2", "col3") VALUES (\'val1\', \'val2\', \'val3\')', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testGetThrowsExceptionForNonExistentColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getThrowsExceptionForNonExistentColumn(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(sprintf(InvalidArgumentException::UNKNOWN_COLUMN_KEY, 'nonexistent')); $value = $this->insert->nonexistent; } - public function testInto(): void + #[\PHPUnit\Framework\Attributes\Test] + public function into(): void { $this->insert->into('table'); - self::assertEquals('table', $this->insert->getRawState('table')); + static::assertSame('table', $this->insert->getRawState('table')); $tableIdentifier = new TableIdentifier('table', 'schema'); $this->insert->into($tableIdentifier); - self::assertEquals($tableIdentifier, $this->insert->getRawState('table')); + static::assertEquals($tableIdentifier, $this->insert->getRawState('table')); } - public function testPrepareStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -219,7 +231,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('INSERT INTO "foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('INSERT INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -238,7 +250,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('INSERT INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('INSERT INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $this->insert ->into(new TableIdentifier('foo', 'sch')) @@ -247,7 +259,8 @@ public function testPrepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - public function testPrepareStatementCreatesParameterContainerWhenNotPresent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementCreatesParameterContainerWhenNotPresent(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -260,21 +273,22 @@ public function testPrepareStatementCreatesParameterContainerWhenNotPresent(): v ->willReturn(null); $mockStatement->expects($this->once()) ->method('setParameterContainer') - ->with($this->isInstanceOf(ParameterContainer::class)) + ->with(static::isInstanceOf(ParameterContainer::class)) ->willReturnSelf(); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->stringContains('INSERT INTO')) + ->with(static::stringContains('INSERT INTO')) ->willReturnSelf(); $this->insert->into('foo')->values(['bar' => 'baz']); $result = $this->insert->prepareStatement($mockAdapter, $mockStatement); - self::assertSame($mockStatement, $result); + static::assertSame($mockStatement, $result); } - public function testPrepareStatementWithSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -290,18 +304,19 @@ public function testPrepareStatementWithSelect(): void ->select($select->where(['x' => 5])) ->prepareStatement($mockAdapter, $mockStatement); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" ("col1") SELECT "bar".* FROM "bar" WHERE "x" = ?', $mockStatement->getSql(), ); $parameters = $mockStatement->getParameterContainer(); - $this->assertInstanceOf(ParameterContainer::class, $parameters); + static::assertInstanceOf(ParameterContainer::class, $parameters); $namedArray = $parameters->getNamedArray(); - self::assertSame(['subselect1where1' => 5], $namedArray); + static::assertSame(['subselect1where1' => 5], $namedArray); } - public function testProcessInsertWithPdoDriverUsesDriverColumnQuoting(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processInsertWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -317,18 +332,19 @@ public function testProcessInsertWithPdoDriverUsesDriverColumnQuoting(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); $sql = $mockStatement->getSql(); - self::assertStringContainsString(':c_0', $sql); - self::assertStringContainsString(':c_1', $sql); + static::assertStringContainsString(':c_0', $sql); + static::assertStringContainsString(':c_1', $sql); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void + public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $replace = new Replace(); $replace->into('foo') ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'REPLACE INTO "foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform()), ); @@ -338,14 +354,15 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr $replace->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); - self::assertEquals( + static::assertSame( 'REPLACE INTO "sch"."foo" ("bar", "boo", "bam") VALUES (\'baz\', NOW(), NULL)', $replace->getSqlString(new TrustingSql92Platform()), ); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $replace = new Replace(); @@ -359,7 +376,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('REPLACE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('REPLACE INTO "foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into('foo') ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -379,7 +396,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($pContainer); $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('REPLACE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); + ->with(static::equalTo('REPLACE INTO "sch"."foo" ("bar", "boo") VALUES (?, NOW())')); $replace->into(new TableIdentifier('foo', 'sch')) ->values(['bar' => 'baz', 'boo' => new Expression('NOW()')]); @@ -387,44 +404,48 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $replace->prepareStatement($mockAdapter, $mockStatement); } - public function testUnsetThrowsExceptionForNonExistentColumn(): void + #[\PHPUnit\Framework\Attributes\Test] + public function unsetThrowsExceptionForNonExistentColumn(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(sprintf(InvalidArgumentException::UNKNOWN_COLUMN_KEY, 'nonexistent')); unset($this->insert->nonexistent); } - public function testValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function values(): void { $this->insert->values(['foo' => 'bar']); - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bar'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bar'], $this->insert->getRawState('values')); // test will merge cols and values of previously set stuff $this->insert->values(['foo' => 'bax'], Insert::VALUES_MERGE); $this->insert->values(['boom' => 'bam'], Insert::VALUES_MERGE); - self::assertEquals(['foo', 'boom'], $this->insert->getRawState('columns')); - self::assertEquals(['bax', 'bam'], $this->insert->getRawState('values')); + static::assertEquals(['foo', 'boom'], $this->insert->getRawState('columns')); + static::assertEquals(['bax', 'bam'], $this->insert->getRawState('values')); $this->insert->values(['foo' => 'bax']); - self::assertEquals(['foo'], $this->insert->getRawState('columns')); - self::assertEquals(['bax'], $this->insert->getRawState('values')); + static::assertEquals(['foo'], $this->insert->getRawState('columns')); + static::assertEquals(['bax'], $this->insert->getRawState('values')); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-536')] - public function testValuesMerge(): void + public function valuesMerge(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); $this->insert->into('foo') ->values(['qux' => 100], Insert::VALUES_MERGE); - self::assertEquals( + static::assertSame( 'INSERT INTO "foo" ("bar", "boo", "bam", "qux") VALUES (\'baz\', NOW(), NULL, \'100\')', $this->insert->getSqlString(new TrustingSql92Platform()), ); } - public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -436,14 +457,16 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - public function testValuesThrowsExceptionWhenNotArrayOrSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); /** @psalm-suppress InvalidArgument */ $this->insert->values(5); } - public function testValuesThrowsExceptionWhenSelectMergeOverArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valuesThrowsExceptionWhenSelectMergeOverArray(): void { $this->insert->values(['foo' => 'bar']); diff --git a/test/unit/Sql/JoinTest.php b/test/unit/Sql/JoinTest.php index f7066c34..15160bc5 100644 --- a/test/unit/Sql/JoinTest.php +++ b/test/unit/Sql/JoinTest.php @@ -31,18 +31,20 @@ class JoinTest extends TestCase { use DeprecatedAssertionsTrait; + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test count() returns correct count')] - public function testCount(): void + public function countsJoinedTables(): void { $join = new Join(); $join->join('baz', 'foo.fooId = baz.fooId', Join::JOIN_LEFT); $join->join('bar', 'foo.fooId = bar.fooId', Join::JOIN_LEFT); - self::assertEquals(2, $join->count()); - self::assertCount($join->count(), $join->getJoins()); + static::assertSame(2, $join->count()); + static::assertCount($join->count(), $join->getJoins()); } - public function testCurrentReturnsTheCurrentJoinSpecification(): void + #[\PHPUnit\Framework\Attributes\Test] + public function currentReturnsTheCurrentJoinSpecification(): void { $name = 'baz'; $on = 'foo.id = baz.id'; @@ -57,35 +59,39 @@ public function testCurrentReturnsTheCurrentJoinSpecification(): void 'type' => Join::JOIN_INNER, ]; - self::assertEquals($expectedSpecification, $join->current()); + static::assertEquals($expectedSpecification, $join->current()); } /** * @throws ReflectionException */ - public function testInitialPositionIsZero(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initialPositionIsZero(): void { $join = new Join(); - self::assertAttributeEquals(0, 'position', $join); + static::assertAttributeSame(0, 'position', $join); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test join() returns Join object (is chainable)')] - public function testJoin(): void + public function join(): void { $join = new Join(); $return = $join->join('baz', 'foo.fooId = baz.fooId', Join::JOIN_LEFT); - self::assertSame($join, $return); + static::assertSame($join, $return); } - public function testJoinFullOuter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function joinFullOuter(): void { $join = new Join(); $return = $join->join('baz', 'foo.fooId = baz.fooId', Join::JOIN_FULL_OUTER); - self::assertSame($join, $return); + static::assertSame($join, $return); } - public function testJoinThrowsOnInvalidMultiElementArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function joinThrowsOnInvalidMultiElementArray(): void { $join = new Join(); @@ -94,7 +100,8 @@ public function testJoinThrowsOnInvalidMultiElementArray(): void $join->join(['a' => 'b', 'c' => 'd'], 'on'); } - public function testJoinWillThrowAnExceptionIfNameIsNoValid(): void + #[\PHPUnit\Framework\Attributes\Test] + public function joinWillThrowAnExceptionIfNameIsNoValid(): void { $join = new Join(); @@ -103,7 +110,8 @@ public function testJoinWillThrowAnExceptionIfNameIsNoValid(): void $join->join([], false); } - public function testKeyReturnsTheCurrentPosition(): void + #[\PHPUnit\Framework\Attributes\Test] + public function keyReturnsTheCurrentPosition(): void { $join = new Join(); @@ -111,56 +119,60 @@ public function testKeyReturnsTheCurrentPosition(): void $join->next(); $join->next(); - self::assertEquals(3, $join->key()); + static::assertSame(3, $join->key()); } /** * @throws ReflectionException */ - public function testNextIncrementsThePosition(): void + #[\PHPUnit\Framework\Attributes\Test] + public function nextIncrementsThePosition(): void { $join = new Join(); $join->next(); - self::assertAttributeEquals(1, 'position', $join); + static::assertAttributeSame(1, 'position', $join); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test reset() resets the joins')] - public function testReset(): void + public function reset(): void { $join = new Join(); $join->join('baz', 'foo.fooId = baz.fooId', Join::JOIN_LEFT); $join->join('bar', 'foo.fooId = bar.fooId', Join::JOIN_LEFT); $join->reset(); - self::assertEquals(0, $join->count()); + static::assertSame(0, $join->count()); } /** * @throws ReflectionException */ - public function testRewindResetsPositionToZero(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rewindResetsPositionToZero(): void { $join = new Join(); $join->next(); $join->next(); - self::assertAttributeEquals(2, 'position', $join); + static::assertAttributeSame(2, 'position', $join); $join->rewind(); - self::assertAttributeEquals(0, 'position', $join); + static::assertAttributeSame(0, 'position', $join); } - public function testValidReturnsTrueIfTheIteratorIsAtAValidPositionAndFalseIfNot(): void + #[\PHPUnit\Framework\Attributes\Test] + public function validReturnsTrueIfTheIteratorIsAtAValidPositionAndFalseIfNot(): void { $join = new Join(); $join->join('baz', 'foo.id = baz.id'); - self::assertTrue($join->valid()); + static::assertTrue($join->valid()); $join->next(); - self::assertFalse($join->valid()); + static::assertFalse($join->valid()); } } diff --git a/test/unit/Sql/LiteralTest.php b/test/unit/Sql/LiteralTest.php index 5d105311..104e8870 100644 --- a/test/unit/Sql/LiteralTest.php +++ b/test/unit/Sql/LiteralTest.php @@ -9,45 +9,49 @@ class LiteralTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $literal = new Literal('bar'); $expressionData = $literal->getExpressionData(); - self::assertEquals( + static::assertSame( 'bar', $expressionData['spec'], ); - self::assertEquals( + static::assertEquals( [], $expressionData['values'], ); } - public function testGetExpressionDataWillEscapePercent(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWillEscapePercent(): void { $literal = new Literal('X LIKE "foo%"'); $expressionData = $literal->getExpressionData(); - self::assertEquals( + static::assertSame( 'X LIKE "foo%%"', $expressionData['spec'], ); - self::assertEquals( + static::assertEquals( [], $expressionData['values'], ); } - public function testGetLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLiteral(): void { $literal = new Literal('bar'); - self::assertEquals('bar', $literal->getLiteral()); + static::assertSame('bar', $literal->getLiteral()); } - public function testSetLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setLiteral(): void { $literal = new Literal('bar'); @@ -55,15 +59,15 @@ public function testSetLiteral(): void $result = $literal->setLiteral('foo'); // Verify fluent interface - self::assertSame($literal, $result); + static::assertSame($literal, $result); // Verify the first mutation occurred - self::assertEquals('foo', $literal->getLiteral()); + static::assertSame('foo', $literal->getLiteral()); // Second mutation to verify mutability $literal->setLiteral('baz'); // Verify the instance was actually mutated - self::assertEquals('baz', $literal->getLiteral()); + static::assertSame('baz', $literal->getLiteral()); } } diff --git a/test/unit/Sql/Platform/AbstractPlatformTest.php b/test/unit/Sql/Platform/AbstractPlatformTest.php index f62d5ab8..1f150629 100644 --- a/test/unit/Sql/Platform/AbstractPlatformTest.php +++ b/test/unit/Sql/Platform/AbstractPlatformTest.php @@ -31,18 +31,20 @@ final class AbstractPlatformTest extends TestCase { private AbstractPlatform $platform; - public function testGetSqlStringDelegatesToDecoratorSubject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringDelegatesToDecoratorSubject(): void { $select = new Select('foo'); $this->platform->setSubject($select); $sql = $this->platform->getSqlString(); - self::assertStringContainsString('SELECT', $sql); - self::assertStringContainsString('"foo"', $sql); + static::assertStringContainsString('SELECT', $sql); + static::assertStringContainsString('"foo"', $sql); } - public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $subject = $this->createMock(PreparableSqlInterface::class); $this->platform->setSubject($subject); @@ -56,7 +58,8 @@ public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void $this->platform->getSqlString(); } - public function testGetTypeDecoratorLoopMatchesByInstanceof(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorLoopMatchesByInstanceof(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $decorator->method('setSubject')->willReturnSelf(); @@ -66,19 +69,21 @@ public function testGetTypeDecoratorLoopMatchesByInstanceof(): void $subject = new Select('foo'); $result = $this->platform->getTypeDecorator($subject); - self::assertSame($decorator, $result); + static::assertSame($decorator, $result); } - public function testGetTypeDecoratorReturnsSubjectWhenNoMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorReturnsSubjectWhenNoMatch(): void { $subject = $this->createMock(SqlInterface::class); $result = $this->platform->getTypeDecorator($subject); - self::assertSame($subject, $result); + static::assertSame($subject, $result); } - public function testPrepareStatementDelegatesToDecoratorSubject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementDelegatesToDecoratorSubject(): void { $select = new Select('foo'); $select->where(['id' => 1]); @@ -100,11 +105,12 @@ public function testPrepareStatementDelegatesToDecoratorSubject(): void $statement = new StatementContainer(); $result = $this->platform->prepareStatement($adapter, $statement); - self::assertSame($statement, $result); - self::assertStringContainsString('SELECT', $statement->getSql()); + static::assertSame($statement, $result); + static::assertStringContainsString('SELECT', $statement->getSql()); } - public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $subject = $this->createMock(SqlInterface::class); $this->platform->setSubject($subject); @@ -121,23 +127,25 @@ public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void $this->platform->prepareStatement($adapter, $statement); } - public function testSetAndGetTypeDecorator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setAndGetTypeDecorator(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $this->platform->setTypeDecorator(Select::class, $decorator); $decorators = $this->platform->getDecorators(); - self::assertArrayHasKey(Select::class, $decorators); - self::assertSame($decorator, $decorators[Select::class]); + static::assertArrayHasKey(Select::class, $decorators); + static::assertSame($decorator, $decorators[Select::class]); } - public function testSetSubjectReturnsStatic(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setSubjectReturnsStatic(): void { $subject = $this->createMock(SqlInterface::class); $result = $this->platform->setSubject($subject); - self::assertSame($this->platform, $result); + static::assertSame($this->platform, $result); } protected function setUp(): void diff --git a/test/unit/Sql/Platform/PlatformTest.php b/test/unit/Sql/Platform/PlatformTest.php index c2112b11..92501828 100644 --- a/test/unit/Sql/Platform/PlatformTest.php +++ b/test/unit/Sql/Platform/PlatformTest.php @@ -40,7 +40,8 @@ #[CoversMethod(Platform::class, 'getDefaultPlatform')] class PlatformTest extends TestCase { - public function testGetDefaultPlatformReturnsInstance(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDefaultPlatformReturnsInstance(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -48,10 +49,11 @@ public function testGetDefaultPlatformReturnsInstance(): void $reflectionMethod = new ReflectionMethod($platform, 'getDefaultPlatform'); $result = $reflectionMethod->invoke($platform); - self::assertSame($adapterPlatform, $result); + static::assertSame($adapterPlatform, $result); } - public function testGetSqlStringDelegatesToTypeDecorator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringDelegatesToTypeDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -61,11 +63,12 @@ public function testGetSqlStringDelegatesToTypeDecorator(): void $sql = $platform->getSqlString($adapterPlatform); - self::assertStringContainsString('SELECT', $sql); - self::assertStringContainsString('"foo"', $sql); + static::assertStringContainsString('SELECT', $sql); + static::assertStringContainsString('"foo"', $sql); } - public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -77,7 +80,8 @@ public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void $platform->getSqlString($adapterPlatform); } - public function testGetTypeDecoratorFallsThroughWhenNoMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorFallsThroughWhenNoMatch(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -88,10 +92,11 @@ public function testGetTypeDecoratorFallsThroughWhenNoMatch(): void $select = new Select('foo'); $result = $platform->getTypeDecorator($select); - self::assertSame($select, $result); + static::assertSame($select, $result); } - public function testGetTypeDecoratorMatchesByInstanceofLoop(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorMatchesByInstanceofLoop(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -102,10 +107,11 @@ public function testGetTypeDecoratorMatchesByInstanceofLoop(): void $select = new Select('foo'); $result = $platform->getTypeDecorator($select); - self::assertSame($innerPlatform, $result); + static::assertSame($innerPlatform, $result); } - public function testGetTypeDecoratorMatchesExactClass(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorMatchesExactClass(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -117,10 +123,11 @@ public function testGetTypeDecoratorMatchesExactClass(): void $select = new Select('foo'); $result = $platform->getTypeDecorator($select); - self::assertSame($decorator, $result); + static::assertSame($decorator, $result); } - public function testGetTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -128,10 +135,11 @@ public function testGetTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): v $select = new Select('foo'); $result = $platform->getTypeDecorator($select); - self::assertSame($select, $result); + static::assertSame($select, $result); } - public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -149,38 +157,41 @@ public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void /** * @throws ReflectionException */ - public function testResolveDefaultPlatform(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolveDefaultPlatform(): void { $adapter = $this->resolveAdapter('sql92'); $platform = new Platform($adapter->getPlatform()); $reflectionMethod = new ReflectionMethod($platform, 'resolvePlatform'); - self::assertEquals($adapter->getPlatform(), $reflectionMethod->invoke($platform, null)); + static::assertEquals($adapter->getPlatform(), $reflectionMethod->invoke($platform, null)); } /** * @throws ReflectionException */ - public function testResolvePlatformName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolvePlatformName(): void { $platform = new Platform($this->resolveAdapter('sql92')->getPlatform()); $reflectionMethod = new ReflectionMethod($platform, 'resolvePlatformName'); - self::assertEquals('mysql', $reflectionMethod->invoke($platform, new TestAsset\TrustingMysqlPlatform())); - self::assertEquals('sqlserver', $reflectionMethod->invoke( + static::assertSame('mysql', $reflectionMethod->invoke($platform, new TestAsset\TrustingMysqlPlatform())); + static::assertSame('sqlserver', $reflectionMethod->invoke( $platform, new TestAsset\TrustingSqlServerPlatform(), )); - self::assertEquals('oracle', $reflectionMethod->invoke($platform, new TestAsset\TrustingOraclePlatform())); - self::assertEquals('sql92', $reflectionMethod->invoke($platform, new TestAsset\TrustingSql92Platform())); + static::assertSame('oracle', $reflectionMethod->invoke($platform, new TestAsset\TrustingOraclePlatform())); + static::assertSame('sql92', $reflectionMethod->invoke($platform, new TestAsset\TrustingSql92Platform())); } /** * @throws ReflectionException */ - public function testResolvePlatformNameCachesResult(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolvePlatformNameCachesResult(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -190,11 +201,12 @@ public function testResolvePlatformNameCachesResult(): void $first = $reflectionMethod->invoke($platform, null); $second = $reflectionMethod->invoke($platform, null); - self::assertEquals($first, $second); - self::assertEquals('sql92', $first); + static::assertEquals($first, $second); + static::assertSame('sql92', $first); } - public function testResolvePlatformWithAdapterInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolvePlatformWithAdapterInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -208,10 +220,11 @@ public function testResolvePlatformWithAdapterInterface(): void $reflectionMethod = new ReflectionMethod($platform, 'resolvePlatform'); $result = $reflectionMethod->invoke($platform, $mockAdapter); - self::assertSame($mockPlatform, $result); + static::assertSame($mockPlatform, $result); } - public function testResolvePlatformWithPlatformInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resolvePlatformWithPlatformInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -221,10 +234,11 @@ public function testResolvePlatformWithPlatformInterface(): void $reflectionMethod = new ReflectionMethod($platform, 'resolvePlatform'); $result = $reflectionMethod->invoke($platform, $mockPlatform); - self::assertSame($mockPlatform, $result); + static::assertSame($mockPlatform, $result); } - public function testSetTypeDecoratorRegistersDecorator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setTypeDecoratorRegistersDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -233,8 +247,8 @@ public function testSetTypeDecoratorRegistersDecorator(): void $platform->setTypeDecorator(Select::class, $decorator); $decorators = $platform->getDecorators(); - self::assertArrayHasKey(Select::class, $decorators); - self::assertSame($decorator, $decorators[Select::class]); + static::assertArrayHasKey(Select::class, $decorators); + static::assertSame($decorator, $decorators[Select::class]); } protected function resolveAdapter(string $platformName): Adapter diff --git a/test/unit/Sql/Predicate/BetweenTest.php b/test/unit/Sql/Predicate/BetweenTest.php index d59b97ab..c9ebc8a1 100644 --- a/test/unit/Sql/Predicate/BetweenTest.php +++ b/test/unit/Sql/Predicate/BetweenTest.php @@ -28,81 +28,84 @@ final class BetweenTest extends TestCase { protected Between $between; - /** - * A custom specification replaces the generated one rather than sitting unused - * behind it. - */ - #[Test] - public function getExpressionDataPrefersACustomSpecification(): void - { - $between = new Between('foo.bar', 1, 10); - $between->setSpecification('%1$s IS INBETWEEN %2$s AND %3$s'); - - static::assertSame('%1$s IS INBETWEEN %2$s AND %3$s', $between->getExpressionData()['spec']); - } - - public function testConstructorCanPassIdentifierMinimumAndMaximumValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorCanPassIdentifierMinimumAndMaximumValues(): void { $between = new Between('foo.bar', 1, 300); $identifier = $between->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); $minValue = $between->getMinValue(); - self::assertInstanceOf(ArgumentInterface::class, $minValue); - self::assertEquals(1, $minValue->getValue()); - self::assertEquals(ArgumentType::Value, $minValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $minValue); + static::assertSame(1, $minValue->getValue()); + static::assertEquals(ArgumentType::Value, $minValue->getType()); $maxValue = $between->getMaxValue(); - self::assertInstanceOf(ArgumentInterface::class, $maxValue); - self::assertEquals(300, $maxValue->getValue()); - self::assertEquals(ArgumentType::Value, $maxValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $maxValue); + static::assertSame(300, $maxValue->getValue()); + static::assertEquals(ArgumentType::Value, $maxValue->getType()); $between = new Between('foo.bar', 0, 1); $identifier = $between->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); $minValue = $between->getMinValue(); - self::assertInstanceOf(ArgumentInterface::class, $minValue); - self::assertEquals(0, $minValue->getValue()); - self::assertEquals(ArgumentType::Value, $minValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $minValue); + static::assertSame(0, $minValue->getValue()); + static::assertEquals(ArgumentType::Value, $minValue->getType()); $maxValue = $between->getMaxValue(); - self::assertInstanceOf(ArgumentInterface::class, $maxValue); - self::assertEquals(1, $maxValue->getValue()); - self::assertEquals(ArgumentType::Value, $maxValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $maxValue); + static::assertSame(1, $maxValue->getValue()); + static::assertEquals(ArgumentType::Value, $maxValue->getType()); $between = new Between('foo.bar', -1, 0); $identifier = $between->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); $minValue = $between->getMinValue(); - self::assertInstanceOf(ArgumentInterface::class, $minValue); - self::assertEquals(-1, $minValue->getValue()); - self::assertEquals(ArgumentType::Value, $minValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $minValue); + static::assertEquals(-1, $minValue->getValue()); + static::assertEquals(ArgumentType::Value, $minValue->getType()); $maxValue = $between->getMaxValue(); - self::assertInstanceOf(ArgumentInterface::class, $maxValue); - self::assertEquals(0, $maxValue->getValue()); - self::assertEquals(ArgumentType::Value, $maxValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $maxValue); + static::assertSame(0, $maxValue->getValue()); + static::assertEquals(ArgumentType::Value, $maxValue->getType()); } - public function testConstructorYieldsNullIdentifierMinimumAndMaximumValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorYieldsNullIdentifierMinimumAndMaximumValues(): void { - self::assertNull($this->between->getIdentifier()); - self::assertNull($this->between->getMinValue()); - self::assertNull($this->between->getMaxValue()); + static::assertNull($this->between->getIdentifier()); + static::assertNull($this->between->getMinValue()); + static::assertNull($this->between->getMaxValue()); + } + + /** + * A custom specification replaces the generated one rather than sitting unused + * behind it. + */ + #[Test] + public function getExpressionDataPrefersACustomSpecification(): void + { + $between = new Between('foo.bar', 1, 10); + $between->setSpecification('%1$s IS INBETWEEN %2$s AND %3$s'); + + static::assertSame('%1$s IS INBETWEEN %2$s AND %3$s', $between->getExpressionData()['spec']); } - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $between = new Between(); $between->setMinValue(1)->setMaxValue(10); @@ -112,7 +115,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $between->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenMaxValueNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenMaxValueNotSet(): void { $between = new Between(); $between->setIdentifier('foo')->setMinValue(1); @@ -122,7 +126,8 @@ public function testGetExpressionDataThrowsExceptionWhenMaxValueNotSet(): void $between->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenMinValueNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenMinValueNotSet(): void { $between = new Between(); $between->setIdentifier('foo')->setMaxValue(10); @@ -132,79 +137,83 @@ public function testGetExpressionDataThrowsExceptionWhenMinValueNotSet(): void $between->getExpressionData(); } - public function testIdentifierIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function identifierIsMutable(): void { // First mutation $result = $this->between->setIdentifier('foo.bar'); // Verify fluent interface - self::assertSame($this->between, $result); + static::assertSame($this->between, $result); // Verify the first mutation occurred $identifier1 = $this->between->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier1); - self::assertEquals('foo.bar', $identifier1->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier1); + static::assertSame('foo.bar', $identifier1->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier1->getType()); // Second mutation with different data to verify mutability $this->between->setIdentifier('baz.qux'); // Verify the instance was actually mutated $identifier2 = $this->between->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier2); - self::assertEquals('baz.qux', $identifier2->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier2); + static::assertSame('baz.qux', $identifier2->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - public function testMaxValueIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function maxValueIsMutable(): void { // First mutation $result = $this->between->setMaxValue(10); // Verify fluent interface - self::assertSame($this->between, $result); + static::assertSame($this->between, $result); // Verify the first mutation occurred $maxValue1 = $this->between->getMaxValue(); - self::assertInstanceOf(ArgumentInterface::class, $maxValue1); - self::assertEquals(10, $maxValue1->getValue()); - self::assertEquals(ArgumentType::Value, $maxValue1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $maxValue1); + static::assertSame(10, $maxValue1->getValue()); + static::assertEquals(ArgumentType::Value, $maxValue1->getType()); // Second mutation with different data to verify mutability $this->between->setMaxValue(30); // Verify the instance was actually mutated $maxValue2 = $this->between->getMaxValue(); - self::assertInstanceOf(ArgumentInterface::class, $maxValue2); - self::assertEquals(30, $maxValue2->getValue()); - self::assertEquals(ArgumentType::Value, $maxValue2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $maxValue2); + static::assertSame(30, $maxValue2->getValue()); + static::assertEquals(ArgumentType::Value, $maxValue2->getType()); } - public function testMinValueIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function minValueIsMutable(): void { // First mutation $result = $this->between->setMinValue(10); // Verify fluent interface - self::assertSame($this->between, $result); + static::assertSame($this->between, $result); // Verify the first mutation occurred $minValue1 = $this->between->getMinValue(); - self::assertInstanceOf(ArgumentInterface::class, $minValue1); - self::assertEquals(10, $minValue1->getValue()); - self::assertEquals(ArgumentType::Value, $minValue1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $minValue1); + static::assertSame(10, $minValue1->getValue()); + static::assertEquals(ArgumentType::Value, $minValue1->getType()); // Second mutation with different data to verify mutability $this->between->setMinValue(20); // Verify the instance was actually mutated $minValue2 = $this->between->getMinValue(); - self::assertInstanceOf(ArgumentInterface::class, $minValue2); - self::assertEquals(20, $minValue2->getValue()); - self::assertEquals(ArgumentType::Value, $minValue2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $minValue2); + static::assertSame(20, $minValue2->getValue()); + static::assertEquals(ArgumentType::Value, $minValue2->getType()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $this->between ->setIdentifier('foo.bar') @@ -214,26 +223,26 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $this->between->getExpressionData(); // Verify specification (default built from arguments) - self::assertEquals('%s BETWEEN %s AND %s', $expressionData['spec']); + static::assertSame('%s BETWEEN %s AND %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(3, $values); + static::assertCount(3, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify min value argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals(10, $values[1]->getValue()); - self::assertEquals(ArgumentType::Value, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame(10, $values[1]->getValue()); + static::assertEquals(ArgumentType::Value, $values[1]->getType()); // Verify max value argument - self::assertInstanceOf(ArgumentInterface::class, $values[2]); - self::assertEquals(19, $values[2]->getValue()); - self::assertEquals(ArgumentType::Value, $values[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertSame(19, $values[2]->getValue()); + static::assertEquals(ArgumentType::Value, $values[2]->getType()); $this->between ->setIdentifier(Argument::value(10)) @@ -243,37 +252,39 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $this->between->getExpressionData(); // Verify specification (default built from arguments) - self::assertEquals('%s BETWEEN %s AND %s', $expressionData['spec']); + static::assertSame('%s BETWEEN %s AND %s', $expressionData['spec']); // Verify expression values with custom types $values = $expressionData['values']; - self::assertCount(3, $values); + static::assertCount(3, $values); // Verify identifier argument (passed as Value type) - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals(10, $values[0]->getValue()); - self::assertEquals(ArgumentType::Value, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame(10, $values[0]->getValue()); + static::assertEquals(ArgumentType::Value, $values[0]->getType()); // Verify min value argument (passed as Identifier type) - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('foo.bar', $values[1]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('foo.bar', $values[1]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); // Verify max value argument (passed as Identifier type) - self::assertInstanceOf(ArgumentInterface::class, $values[2]); - self::assertEquals('foo.baz', $values[2]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertSame('foo.baz', $values[2]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[2]->getType()); } - public function testSpecificationIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationIsMutable(): void { $this->between->setSpecification('%1$s IS INBETWEEN %2$s AND %3$s'); - self::assertEquals('%1$s IS INBETWEEN %2$s AND %3$s', $this->between->getSpecification()); + static::assertSame('%1$s IS INBETWEEN %2$s AND %3$s', $this->between->getSpecification()); } - public function testSpecificationIsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationIsNullByDefault(): void { - self::assertNull($this->between->getSpecification()); + static::assertNull($this->between->getSpecification()); } #[Override] diff --git a/test/unit/Sql/Predicate/ExpressionTest.php b/test/unit/Sql/Predicate/ExpressionTest.php index dbe741ad..0e74df87 100644 --- a/test/unit/Sql/Predicate/ExpressionTest.php +++ b/test/unit/Sql/Predicate/ExpressionTest.php @@ -16,134 +16,150 @@ final class ExpressionTest extends TestCase { + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfMultiNullsParameterToConstructor(): void + public function canPassArrayOfMultiNullsParameterToConstructor(): void { $expression = new Expression('? OR ?', [null, null]); $null = new Value(null); - self::assertEquals([$null, $null], $expression->getParameters()); + static::assertEquals([$null, $null], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfMultiPredicatesParameterToConstructor(): void + public function canPassArrayOfMultiPredicatesParameterToConstructor(): void { $predicate = new IsNull('foo.baz'); $expression = new Expression('? OR ?', [$predicate, $predicate]); $isNull = new Select($predicate); - self::assertEquals([$isNull, $isNull], $expression->getParameters()); + static::assertEquals([$isNull, $isNull], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfMultiScalarsParameterToConstructor(): void + public function canPassArrayOfMultiScalarsParameterToConstructor(): void { $expression = new Expression('? OR ?', ['foo', 'bar']); $foo = new Value('foo'); $bar = new Value('bar'); - self::assertEquals([$foo, $bar], $expression->getParameters()); + static::assertEquals([$foo, $bar], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfOneNullParameterToConstructor(): void + public function canPassArrayOfOneNullParameterToConstructor(): void { $expression = new Expression('?', [null]); $null = new Value(null); - self::assertEquals([$null], $expression->getParameters()); + static::assertEquals([$null], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfOnePredicateParameterToConstructor(): void + public function canPassArrayOfOnePredicateParameterToConstructor(): void { $predicate = new IsNull('foo.baz'); $expression = new Expression('?', [$predicate]); $isNull = new Select($predicate); - self::assertEquals([$isNull], $expression->getParameters()); + static::assertEquals([$isNull], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassArrayOfOneScalarParameterToConstructor(): void + public function canPassArrayOfOneScalarParameterToConstructor(): void { $expression = new Expression('?', ['foo']); $foo = new Value('foo'); - self::assertEquals([$foo], $expression->getParameters()); + static::assertEquals([$foo], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassLiteralAndSingleScalarParameterToConstructor(): void + public function canPassLiteralAndSingleScalarParameterToConstructor(): void { $expression = new Expression('foo.bar = ?', 'bar'); $bar = new Value('bar'); - self::assertEquals('foo.bar = ?', $expression->getExpression()); - self::assertEquals([$bar], $expression->getParameters()); + static::assertSame('foo.bar = ?', $expression->getExpression()); + static::assertEquals([$bar], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassMultiNullParametersToConstructor(): void + public function canPassMultiNullParametersToConstructor(): void { /** @psalm-suppress TooManyArguments */ $expression = new Expression('? OR ?', null, null); $null = new Value(null); - self::assertEquals([$null, $null], $expression->getParameters()); + static::assertEquals([$null, $null], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassMultiScalarParametersToConstructor(): void + public function canPassMultiScalarParametersToConstructor(): void { /** @psalm-suppress TooManyArguments */ $expression = new Expression('? OR ?', 'foo', 'bar'); $foo = new Value('foo'); $bar = new Value('bar'); - self::assertEquals([$foo, $bar], $expression->getParameters()); + static::assertEquals([$foo, $bar], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassNoParameterToConstructor(): void + public function canPassNoParameterToConstructor(): void { $expression = new Expression('foo.bar'); - self::assertEquals([], $expression->getParameters()); + static::assertEquals([], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassSingleNullParameterToConstructor(): void + public function canPassSingleNullParameterToConstructor(): void { $expression = new Expression('?', null); $null = new Value(null); - self::assertEquals([$null], $expression->getParameters()); + static::assertEquals([$null], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassSinglePredicateParameterToConstructor(): void + public function canPassSinglePredicateParameterToConstructor(): void { $predicate = new IsNull('foo.baz'); $expression = new Expression('?', $predicate); $isNull = new Select($predicate); - self::assertEquals([$isNull], $expression->getParameters()); + static::assertEquals([$isNull], $expression->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6849')] - public function testCanPassSingleZeroParameterValueToConstructor(): void + public function canPassSingleZeroParameterValueToConstructor(): void { $predicate = new Expression('?', 0); $expression = new Value(0); - self::assertEquals([$expression], $predicate->getParameters()); + static::assertEquals([$expression], $predicate->getParameters()); } - public function testEmptyConstructorYieldsEmptyLiteralAndParameter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsEmptyLiteralAndParameter(): void { $expression = new Expression(); - self::assertEquals('', $expression->getExpression()); - self::assertEmpty($expression->getParameters()); + static::assertSame('', $expression->getExpression()); + static::assertEmpty($expression->getParameters()); } - public function testLiteralIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function literalIsMutable(): void { $expression = new Expression(); $expression->setExpression('foo.bar = ?'); - self::assertEquals('foo.bar = ?', $expression->getExpression()); + static::assertSame('foo.bar = ?', $expression->getExpression()); } - public function testParameterIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function parameterIsMutable(): void { $expression = new Expression(); @@ -151,40 +167,41 @@ public function testParameterIsMutable(): void $result = $expression->setParameters(['foo', 'bar']); // Verify fluent interface - self::assertSame($expression, $result); + static::assertSame($expression, $result); // Verify the first mutation occurred - getParameters returns an array $parameters1 = $expression->getParameters(); - self::assertCount(2, $parameters1); - self::assertInstanceOf(ArgumentInterface::class, $parameters1[0]); - self::assertEquals('foo', $parameters1[0]->getValue()); - self::assertEquals(ArgumentType::Value, $parameters1[0]->getType()); - self::assertInstanceOf(ArgumentInterface::class, $parameters1[1]); - self::assertEquals('bar', $parameters1[1]->getValue()); - self::assertEquals(ArgumentType::Value, $parameters1[1]->getType()); + static::assertCount(2, $parameters1); + static::assertInstanceOf(ArgumentInterface::class, $parameters1[0]); + static::assertSame('foo', $parameters1[0]->getValue()); + static::assertEquals(ArgumentType::Value, $parameters1[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $parameters1[1]); + static::assertSame('bar', $parameters1[1]->getValue()); + static::assertEquals(ArgumentType::Value, $parameters1[1]->getType()); // Second mutation with different data to verify mutability $expression->setParameters(['baz', 'qux', 'quux']); // Verify the instance was actually mutated - parameters are accumulated $parameters2 = $expression->getParameters(); - self::assertCount(5, $parameters2); // 2 original + 3 new = 5 total + static::assertCount(5, $parameters2); // 2 original + 3 new = 5 total // First two are still there - self::assertEquals('foo', $parameters2[0]->getValue()); - self::assertEquals('bar', $parameters2[1]->getValue()); + static::assertSame('foo', $parameters2[0]->getValue()); + static::assertSame('bar', $parameters2[1]->getValue()); // New ones were appended - self::assertInstanceOf(ArgumentInterface::class, $parameters2[2]); - self::assertEquals('baz', $parameters2[2]->getValue()); - self::assertEquals(ArgumentType::Value, $parameters2[2]->getType()); - self::assertInstanceOf(ArgumentInterface::class, $parameters2[3]); - self::assertEquals('qux', $parameters2[3]->getValue()); - self::assertEquals(ArgumentType::Value, $parameters2[3]->getType()); - self::assertInstanceOf(ArgumentInterface::class, $parameters2[4]); - self::assertEquals('quux', $parameters2[4]->getValue()); - self::assertEquals(ArgumentType::Value, $parameters2[4]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $parameters2[2]); + static::assertSame('baz', $parameters2[2]->getValue()); + static::assertEquals(ArgumentType::Value, $parameters2[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $parameters2[3]); + static::assertSame('qux', $parameters2[3]->getValue()); + static::assertEquals(ArgumentType::Value, $parameters2[3]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $parameters2[4]); + static::assertSame('quux', $parameters2[4]->getValue()); + static::assertEquals(ArgumentType::Value, $parameters2[4]->getType()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes(): void { $expression = new Expression(); $expression->setExpression('foo.bar = ? AND id != ?') @@ -195,7 +212,7 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfLiteralAndPar $expressionData = $expression->getExpressionData(); - self::assertEquals('foo.bar = %s AND id != %s', $expressionData['spec']); - self::assertEquals([$parameter1, $parameter2], $expressionData['values']); + static::assertSame('foo.bar = %s AND id != %s', $expressionData['spec']); + static::assertEquals([$parameter1, $parameter2], $expressionData['values']); } } diff --git a/test/unit/Sql/Predicate/InTest.php b/test/unit/Sql/Predicate/InTest.php index dce40df1..27742053 100644 --- a/test/unit/Sql/Predicate/InTest.php +++ b/test/unit/Sql/Predicate/InTest.php @@ -25,48 +25,52 @@ #[Group('unit')] final class InTest extends TestCase { - public function testCanPassIdentifierAndEmptyValueSetToConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canPassIdentifierAndEmptyValueSetToConstructor(): void { $in = new In('foo.bar', []); // Verify identifier was set correctly $identifier = $in->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); // Verify empty value set was set correctly $valueSet = $in->getValueSet(); - self::assertInstanceOf(ArgumentInterface::class, $valueSet); - self::assertEquals([], $valueSet->getValue()); - self::assertEquals(ArgumentType::Values, $valueSet->getType()); + static::assertInstanceOf(ArgumentInterface::class, $valueSet); + static::assertEquals([], $valueSet->getValue()); + static::assertEquals(ArgumentType::Values, $valueSet->getType()); } - public function testCanPassIdentifierAndValueSetToConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canPassIdentifierAndValueSetToConstructor(): void { $in = new In('foo.bar', [1, 2]); // Verify identifier was set correctly $identifier = $in->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); // Verify value set was set correctly $valueSet = $in->getValueSet(); - self::assertInstanceOf(ArgumentInterface::class, $valueSet); - self::assertEquals([1, 2], $valueSet->getValue()); - self::assertEquals(ArgumentType::Values, $valueSet->getType()); + static::assertInstanceOf(ArgumentInterface::class, $valueSet); + static::assertEquals([1, 2], $valueSet->getValue()); + static::assertEquals(ArgumentType::Values, $valueSet->getType()); } - public function testEmptyConstructorYieldsNullIdentifierAndValueSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsNullIdentifierAndValueSet(): void { $in = new In(); - self::assertNull($in->getIdentifier()); - self::assertNull($in->getValueSet()); + static::assertNull($in->getIdentifier()); + static::assertNull($in->getValueSet()); } - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $in = new In(); $in->setValueSet([1, 2]); @@ -76,7 +80,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $in->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenValueSetNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenValueSetNotSet(): void { $in = new In(); $in->setIdentifier('foo'); @@ -86,17 +91,19 @@ public function testGetExpressionDataThrowsExceptionWhenValueSetNotSet(): void $in->getExpressionData(); } - public function testGetExpressionDataWithEmptyValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithEmptyValues(): void { new Select(); $in = new In('foo', []); $expressionData = $in->getExpressionData(); - self::assertEquals('%s IN (NULL)', $expressionData['spec']); + static::assertSame('%s IN (NULL)', $expressionData['spec']); } - public function testGetExpressionDataWithSubselect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselect(): void { $select = new Select(); $in = new In(Argument::value('foo'), $select); @@ -104,24 +111,25 @@ public function testGetExpressionDataWithSubselect(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s IN %s', $expressionData['spec']); + static::assertSame('%s IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify value argument (passed as value type) - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Value, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Value, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testGetExpressionDataWithSubselectAndArrayIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); $in = new In(Argument::identifiers(['foo', 'bar']), $select); @@ -129,24 +137,25 @@ public function testGetExpressionDataWithSubselectAndArrayIdentifier(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('(%s, %s) IN %s', $expressionData['spec']); + static::assertSame('(%s, %s) IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify array identifiers argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals(['foo', 'bar'], $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifiers, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertEquals(['foo', 'bar'], $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifiers, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testGetExpressionDataWithSubselectAndIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); $in = new In(Argument::identifier('foo'), $select); @@ -154,24 +163,25 @@ public function testGetExpressionDataWithSubselectAndIdentifier(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s IN %s', $expressionData['spec']); + static::assertSame('%s IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testIdentifierIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function identifierIsMutable(): void { $in = new In(); @@ -179,25 +189,26 @@ public function testIdentifierIsMutable(): void $result = $in->setIdentifier('foo.bar'); // Verify fluent interface - self::assertSame($in, $result); + static::assertSame($in, $result); // Verify the first mutation occurred $identifier1 = $in->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier1); - self::assertEquals('foo.bar', $identifier1->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier1); + static::assertSame('foo.bar', $identifier1->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier1->getType()); // Second mutation with different data to verify mutability $in->setIdentifier('baz.qux'); // Verify the instance was actually mutated $identifier2 = $in->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier2); - self::assertEquals('baz.qux', $identifier2->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier2); + static::assertSame('baz.qux', $identifier2->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new In(); $in->setIdentifier('foo.bar') @@ -206,21 +217,21 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s IN (%s, %s, %s)', $expressionData['spec']); + static::assertSame('%s IN (%s, %s, %s)', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify value set argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals([1, 2, 3], $values[1]->getValue()); - self::assertEquals(ArgumentType::Values, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertEquals([1, 2, 3], $values[1]->getValue()); + static::assertEquals(ArgumentType::Values, $values[1]->getType()); // Test with typed value sets $in->setIdentifier('foo.bar') @@ -233,20 +244,20 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s IN (%s, %s, %s)', $expressionData['spec']); + static::assertSame('%s IN (%s, %s, %s)', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify value set argument with types - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals( + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertEquals( [ [1 => ArgumentType::Literal], [2 => ArgumentType::Value], @@ -254,20 +265,22 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd ], $values[1]->getValue(), ); - self::assertEquals(ArgumentType::Values, $values[1]->getType()); + static::assertEquals(ArgumentType::Values, $values[1]->getType()); } - public function testSetValueSetWithArgumentInterfacePassesThrough(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setValueSetWithArgumentInterfacePassesThrough(): void { $in = new In(); $values = new Values([1, 2, 3]); $in->setValueSet($values); - self::assertSame($values, $in->getValueSet()); + static::assertSame($values, $in->getValueSet()); } - public function testSetValueSetWithSelectWrapsInArgumentSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setValueSetWithSelectWrapsInArgumentSelect(): void { $in = new In(); $select = new Select('users'); @@ -275,11 +288,12 @@ public function testSetValueSetWithSelectWrapsInArgumentSelect(): void $in->setValueSet($select); $valueSet = $in->getValueSet(); - self::assertInstanceOf(ArgumentSelect::class, $valueSet); - self::assertSame(ArgumentType::Select, $valueSet->getType()); + static::assertInstanceOf(ArgumentSelect::class, $valueSet); + static::assertSame(ArgumentType::Select, $valueSet->getType()); } - public function testValueSetIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function valueSetIsMutable(): void { $in = new In(); @@ -287,21 +301,21 @@ public function testValueSetIsMutable(): void $result = $in->setValueSet([1, 2]); // Verify fluent interface - self::assertSame($in, $result); + static::assertSame($in, $result); // Verify the first mutation occurred $valueSet1 = $in->getValueSet(); - self::assertInstanceOf(ArgumentInterface::class, $valueSet1); - self::assertEquals([1, 2], $valueSet1->getValue()); - self::assertEquals(ArgumentType::Values, $valueSet1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $valueSet1); + static::assertEquals([1, 2], $valueSet1->getValue()); + static::assertEquals(ArgumentType::Values, $valueSet1->getType()); // Second mutation with different data to verify mutability $in->setValueSet([3, 4, 5]); // Verify the instance was actually mutated $valueSet2 = $in->getValueSet(); - self::assertInstanceOf(ArgumentInterface::class, $valueSet2); - self::assertEquals([3, 4, 5], $valueSet2->getValue()); - self::assertEquals(ArgumentType::Values, $valueSet2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $valueSet2); + static::assertEquals([3, 4, 5], $valueSet2->getValue()); + static::assertEquals(ArgumentType::Values, $valueSet2->getType()); } } diff --git a/test/unit/Sql/Predicate/IsNullTest.php b/test/unit/Sql/Predicate/IsNullTest.php index e612b9f3..8d1939be 100644 --- a/test/unit/Sql/Predicate/IsNullTest.php +++ b/test/unit/Sql/Predicate/IsNullTest.php @@ -24,6 +24,25 @@ #[Group('unit')] final class IsNullTest extends TestCase { + #[\PHPUnit\Framework\Attributes\Test] + public function canPassIdentifierToConstructor(): void + { + $isnull = new IsNotNull('foo.bar'); + + // Verify identifier was set correctly + $identifier = $isnull->getIdentifier(); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('foo.bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); + } + + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsNullIdentifier(): void + { + $isNotNull = new IsNotNull(); + static::assertNull($isNotNull->getIdentifier()); + } + /** * A custom specification replaces the generated one rather than sitting unused * behind it. @@ -37,24 +56,8 @@ public function getExpressionDataPrefersACustomSpecification(): void static::assertSame('%1$s NOT NULL', $isNotNull->getExpressionData()['spec']); } - public function testCanPassIdentifierToConstructor(): void - { - $isnull = new IsNotNull('foo.bar'); - - // Verify identifier was set correctly - $identifier = $isnull->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('foo.bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); - } - - public function testEmptyConstructorYieldsNullIdentifier(): void - { - $isNotNull = new IsNotNull(); - self::assertNull($isNotNull->getIdentifier()); - } - - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $isNull = new IsNull(); @@ -63,7 +66,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $isNull->getExpressionData(); } - public function testIdentifierIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function identifierIsMutable(): void { $isNotNull = new IsNotNull(); @@ -71,25 +75,26 @@ public function testIdentifierIsMutable(): void $result = $isNotNull->setIdentifier('foo.bar'); // Verify fluent interface - self::assertSame($isNotNull, $result); + static::assertSame($isNotNull, $result); // Verify the first mutation occurred $identifier1 = $isNotNull->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier1); - self::assertEquals('foo.bar', $identifier1->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier1); + static::assertSame('foo.bar', $identifier1->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier1->getType()); // Second mutation to verify mutability $isNotNull->setIdentifier('baz.qux'); // Verify the instance was actually mutated $identifier2 = $isNotNull->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier2); - self::assertEquals('baz.qux', $identifier2->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier2); + static::assertSame('baz.qux', $identifier2->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndArrayOfTypes(): void { $isNotNull = new IsNotNull(); $isNotNull->setIdentifier('foo.bar'); @@ -97,49 +102,53 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $isNotNull->getExpressionData(); // Verify specification (default built from arguments) - self::assertEquals('%s IS NOT NULL', $expressionData['spec']); + static::assertSame('%s IS NOT NULL', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(1, $values); + static::assertCount(1, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); } - public function testSetIdentifierWithArgumentInterfacePassesThrough(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setIdentifierWithArgumentInterfacePassesThrough(): void { $isNull = new IsNull(); $identifier = new Identifier('bar'); $isNull->setIdentifier($identifier); - self::assertSame($identifier, $isNull->getIdentifier()); + static::assertSame($identifier, $isNull->getIdentifier()); } - public function testSetIdentifierWithStringConvertsToIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setIdentifierWithStringConvertsToIdentifier(): void { $isNull = new IsNull(); $isNull->setIdentifier('foo'); $identifier = $isNull->getIdentifier(); - self::assertInstanceOf(Identifier::class, $identifier); - self::assertSame('foo', $identifier->getValue()); + static::assertInstanceOf(Identifier::class, $identifier); + static::assertSame('foo', $identifier->getValue()); } - public function testSpecificationIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationIsMutable(): void { $isNotNull = new IsNotNull(); $isNotNull->setSpecification('%1$s NOT NULL'); - self::assertEquals('%1$s NOT NULL', $isNotNull->getSpecification()); + static::assertSame('%1$s NOT NULL', $isNotNull->getSpecification()); } - public function testSpecificationIsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationIsNullByDefault(): void { $isNotNull = new IsNotNull(); - self::assertNull($isNotNull->getSpecification()); + static::assertNull($isNotNull->getSpecification()); } } diff --git a/test/unit/Sql/Predicate/LikeTest.php b/test/unit/Sql/Predicate/LikeTest.php index 99cf1a75..24b1019d 100644 --- a/test/unit/Sql/Predicate/LikeTest.php +++ b/test/unit/Sql/Predicate/LikeTest.php @@ -23,20 +23,8 @@ #[CoversMethod(Like::class, 'getExpressionData')] final class LikeTest extends TestCase { - /** - * A custom specification replaces the generated one rather than sitting unused - * behind it. - */ - #[Test] - public function getExpressionDataPrefersACustomSpecification(): void - { - $like = new Like('foo.bar', 'baz%'); - $like->setSpecification('%1$s SOUNDS LIKE %2$s'); - - static::assertSame('%1$s SOUNDS LIKE %2$s', $like->getExpressionData()['spec']); - } - - public function testAccessorsMutators(): void + #[\PHPUnit\Framework\Attributes\Test] + public function accessorsMutators(): void { $like = new Like(); @@ -44,118 +32,135 @@ public function testAccessorsMutators(): void $result = $like->setIdentifier('bar'); // Verify fluent interface - self::assertInstanceOf(Like::class, $result); + static::assertInstanceOf(Like::class, $result); // Verify first identifier mutation $identifier1 = $like->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier1); - self::assertEquals('bar', $identifier1->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier1); + static::assertSame('bar', $identifier1->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier1->getType()); // Second mutation to verify mutability $like->setIdentifier('baz'); $identifier2 = $like->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier2); - self::assertEquals('baz', $identifier2->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier2); + static::assertSame('baz', $identifier2->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); // Test setLike - first mutation $result = $like->setLike('foo%'); // Verify fluent interface - self::assertInstanceOf(Like::class, $result); + static::assertInstanceOf(Like::class, $result); // Verify first like mutation $likeValue1 = $like->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue1); - self::assertEquals('foo%', $likeValue1->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue1); + static::assertSame('foo%', $likeValue1->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue1->getType()); // Second mutation to verify mutability $like->setLike('bar%'); $likeValue2 = $like->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue2); - self::assertEquals('bar%', $likeValue2->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue2); + static::assertSame('bar%', $likeValue2->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue2->getType()); // Test setSpecification (this returns string, not Argument) $result = $like->setSpecification('target = target'); - self::assertInstanceOf(Like::class, $result); - self::assertEquals('target = target', $like->getSpecification()); + static::assertInstanceOf(Like::class, $result); + static::assertSame('target = target', $like->getSpecification()); // Second mutation to verify mutability $like->setSpecification('custom spec'); - self::assertEquals('custom spec', $like->getSpecification()); + static::assertSame('custom spec', $like->getSpecification()); } - public function testConstructEmptyArgs(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructEmptyArgs(): void { $like = new Like(); - self::assertEquals('', $like->getIdentifier()); - self::assertEquals('', $like->getLike()); + static::assertNull($like->getIdentifier()); + static::assertNull($like->getLike()); } - public function testConstructWithArgs(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructWithArgs(): void { $like = new Like('bar', 'Foo%'); $identifier = $like->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); $likeValue = $like->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue); - self::assertEquals('Foo%', $likeValue->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue); + static::assertSame('Foo%', $likeValue->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue->getType()); } - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $like = new Like('bar', 'Foo%'); $expressionData = $like->getExpressionData(); // Verify specification - self::assertEquals('%s LIKE %s', $expressionData['spec']); + static::assertSame('%s LIKE %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify like expression argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('Foo%', $values[1]->getValue()); - self::assertEquals(ArgumentType::Value, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('Foo%', $values[1]->getValue()); + static::assertEquals(ArgumentType::Value, $values[1]->getType()); $like = new Like(Argument::value('Foo%'), Argument::identifier('bar')); $expressionData = $like->getExpressionData(); // Verify specification - self::assertEquals('%s LIKE %s', $expressionData['spec']); + static::assertSame('%s LIKE %s', $expressionData['spec']); // Verify expression values with custom types $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument (now with Value type) - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('Foo%', $values[0]->getValue()); - self::assertEquals(ArgumentType::Value, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('Foo%', $values[0]->getValue()); + static::assertEquals(ArgumentType::Value, $values[0]->getType()); // Verify like expression argument (now with Identifier type) - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('bar', $values[1]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('bar', $values[1]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + } + + /** + * A custom specification replaces the generated one rather than sitting unused + * behind it. + */ + #[Test] + public function getExpressionDataPrefersACustomSpecification(): void + { + $like = new Like('foo.bar', 'baz%'); + $like->setSpecification('%1$s SOUNDS LIKE %2$s'); + + static::assertSame('%1$s SOUNDS LIKE %2$s', $like->getExpressionData()['spec']); } - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $like = new Like(); $like->setLike('foo%'); @@ -165,7 +170,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $like->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenLikeNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenLikeNotSet(): void { $like = new Like(); $like->setIdentifier('bar'); @@ -175,11 +181,12 @@ public function testGetExpressionDataThrowsExceptionWhenLikeNotSet(): void $like->getExpressionData(); } - public function testInstanceOfPerSetters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function instanceOfPerSetters(): void { $like = new Like(); - self::assertInstanceOf(Like::class, $like->setIdentifier('bar')); - self::assertInstanceOf(Like::class, $like->setSpecification('%s LIKE %s')); - self::assertInstanceOf(Like::class, $like->setLike('foo%')); + static::assertInstanceOf(Like::class, $like->setIdentifier('bar')); + static::assertInstanceOf(Like::class, $like->setSpecification('%s LIKE %s')); + static::assertInstanceOf(Like::class, $like->setLike('foo%')); } } diff --git a/test/unit/Sql/Predicate/LiteralTest.php b/test/unit/Sql/Predicate/LiteralTest.php index 29ddcb81..53e1e295 100644 --- a/test/unit/Sql/Predicate/LiteralTest.php +++ b/test/unit/Sql/Predicate/LiteralTest.php @@ -9,22 +9,25 @@ class LiteralTest extends TestCase { - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $literal = new Literal('bar'); $expressionData = $literal->getExpressionData(); - self::assertEquals('bar', $expressionData['spec']); + static::assertSame('bar', $expressionData['spec']); } - public function testGetLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLiteral(): void { $literal = new Literal('bar'); - self::assertEquals('bar', $literal->getLiteral()); + static::assertSame('bar', $literal->getLiteral()); } - public function testSetLiteral(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setLiteral(): void { $literal = new Literal('bar'); @@ -32,15 +35,15 @@ public function testSetLiteral(): void $result = $literal->setLiteral('foo'); // Verify fluent interface - self::assertSame($literal, $result); + static::assertSame($literal, $result); // Verify the first mutation occurred - self::assertEquals('foo', $literal->getLiteral()); + static::assertSame('foo', $literal->getLiteral()); // Second mutation to verify mutability $literal->setLiteral('baz'); // Verify the instance was actually mutated - self::assertEquals('baz', $literal->getLiteral()); + static::assertSame('baz', $literal->getLiteral()); } } diff --git a/test/unit/Sql/Predicate/NotBetweenTest.php b/test/unit/Sql/Predicate/NotBetweenTest.php index fff32fff..b3081260 100644 --- a/test/unit/Sql/Predicate/NotBetweenTest.php +++ b/test/unit/Sql/Predicate/NotBetweenTest.php @@ -18,7 +18,8 @@ final class NotBetweenTest extends TestCase { protected NotBetween $notBetween; - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $this->notBetween ->setIdentifier('foo.bar') @@ -28,26 +29,26 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $this->notBetween->getExpressionData(); // Verify specification (default built from arguments) - self::assertEquals('%s NOT BETWEEN %s AND %s', $expressionData['spec']); + static::assertSame('%s NOT BETWEEN %s AND %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(3, $values); + static::assertCount(3, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify min value argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals(10, $values[1]->getValue()); - self::assertEquals(ArgumentType::Value, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame(10, $values[1]->getValue()); + static::assertEquals(ArgumentType::Value, $values[1]->getType()); // Verify max value argument - self::assertInstanceOf(ArgumentInterface::class, $values[2]); - self::assertEquals(19, $values[2]->getValue()); - self::assertEquals(ArgumentType::Value, $values[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertSame(19, $values[2]->getValue()); + static::assertEquals(ArgumentType::Value, $values[2]->getType()); $this->notBetween ->setIdentifier(Argument::value(10)) @@ -57,31 +58,32 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $this->notBetween->getExpressionData(); // Verify specification (default built from arguments) - self::assertEquals('%s NOT BETWEEN %s AND %s', $expressionData['spec']); + static::assertSame('%s NOT BETWEEN %s AND %s', $expressionData['spec']); // Verify expression values with custom types $values = $expressionData['values']; - self::assertCount(3, $values); + static::assertCount(3, $values); // Verify identifier argument (passed as Value type) - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals(10, $values[0]->getValue()); - self::assertEquals(ArgumentType::Value, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame(10, $values[0]->getValue()); + static::assertEquals(ArgumentType::Value, $values[0]->getType()); // Verify min value argument (passed as Identifier type) - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('foo.bar', $values[1]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('foo.bar', $values[1]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); // Verify max value argument (passed as Identifier type) - self::assertInstanceOf(ArgumentInterface::class, $values[2]); - self::assertEquals('foo.baz', $values[2]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[2]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[2]); + static::assertSame('foo.baz', $values[2]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[2]->getType()); } - public function testSpecificationIsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function specificationIsNullByDefault(): void { - self::assertNull($this->notBetween->getSpecification()); + static::assertNull($this->notBetween->getSpecification()); } #[Override] diff --git a/test/unit/Sql/Predicate/NotInTest.php b/test/unit/Sql/Predicate/NotInTest.php index 39798044..d5a6e643 100644 --- a/test/unit/Sql/Predicate/NotInTest.php +++ b/test/unit/Sql/Predicate/NotInTest.php @@ -13,7 +13,8 @@ final class NotInTest extends TestCase { - public function testGetExpressionDataWithSubselect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselect(): void { $select = new Select(); $in = new NotIn('foo', $select); @@ -21,24 +22,25 @@ public function testGetExpressionDataWithSubselect(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s NOT IN %s', $expressionData['spec']); + static::assertSame('%s NOT IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testGetExpressionDataWithSubselectAndArrayIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); $in = new NotIn(Argument::identifiers(['foo', 'bar']), $select); @@ -46,24 +48,25 @@ public function testGetExpressionDataWithSubselectAndArrayIdentifier(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('(%s, %s) NOT IN %s', $expressionData['spec']); + static::assertSame('(%s, %s) NOT IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify array identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals(['foo', 'bar'], $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifiers, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertEquals(['foo', 'bar'], $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifiers, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testGetExpressionDataWithSubselectAndIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); $in = new NotIn('foo', $select); @@ -71,24 +74,25 @@ public function testGetExpressionDataWithSubselectAndIdentifier(): void $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s NOT IN %s', $expressionData['spec']); + static::assertSame('%s NOT IN %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify subselect argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertSame($select, $values[1]->getValue()); - self::assertEquals(ArgumentType::Select, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame($select, $values[1]->getValue()); + static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new NotIn(); $in->setIdentifier('foo.bar') @@ -97,20 +101,20 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAnd $expressionData = $in->getExpressionData(); // Verify specification - self::assertEquals('%s NOT IN (%s, %s, %s)', $expressionData['spec']); + static::assertSame('%s NOT IN (%s, %s, %s)', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo.bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo.bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify value set argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals([1, 2, 3], $values[1]->getValue()); - self::assertEquals(ArgumentType::Values, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertEquals([1, 2, 3], $values[1]->getValue()); + static::assertEquals(ArgumentType::Values, $values[1]->getType()); } } diff --git a/test/unit/Sql/Predicate/NotLikeTest.php b/test/unit/Sql/Predicate/NotLikeTest.php index 7061d2d9..0f95112d 100644 --- a/test/unit/Sql/Predicate/NotLikeTest.php +++ b/test/unit/Sql/Predicate/NotLikeTest.php @@ -12,7 +12,8 @@ final class NotLikeTest extends TestCase { - public function testAccessorsMutators(): void + #[\PHPUnit\Framework\Attributes\Test] + public function accessorsMutators(): void { $notLike = new NotLike(); @@ -20,101 +21,105 @@ public function testAccessorsMutators(): void $result = $notLike->setIdentifier('bar'); // Verify fluent interface - self::assertInstanceOf(Like::class, $result); + static::assertInstanceOf(Like::class, $result); // Verify first identifier mutation $identifier1 = $notLike->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier1); - self::assertEquals('bar', $identifier1->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier1); + static::assertSame('bar', $identifier1->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier1->getType()); // Second mutation to verify mutability $notLike->setIdentifier('baz'); $identifier2 = $notLike->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier2); - self::assertEquals('baz', $identifier2->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier2); + static::assertSame('baz', $identifier2->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); // Test setLike - first mutation $result = $notLike->setLike('foo%'); // Verify fluent interface - self::assertInstanceOf(Like::class, $result); + static::assertInstanceOf(Like::class, $result); // Verify first like mutation $likeValue1 = $notLike->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue1); - self::assertEquals('foo%', $likeValue1->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue1); + static::assertSame('foo%', $likeValue1->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue1->getType()); // Second mutation to verify mutability $notLike->setLike('bar%'); $likeValue2 = $notLike->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue2); - self::assertEquals('bar%', $likeValue2->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue2); + static::assertSame('bar%', $likeValue2->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue2->getType()); // Test setSpecification (this returns string, not Argument) $result = $notLike->setSpecification('target = target'); - self::assertInstanceOf(Like::class, $result); - self::assertEquals('target = target', $notLike->getSpecification()); + static::assertInstanceOf(Like::class, $result); + static::assertSame('target = target', $notLike->getSpecification()); // Second mutation to verify mutability $notLike->setSpecification('custom spec'); - self::assertEquals('custom spec', $notLike->getSpecification()); + static::assertSame('custom spec', $notLike->getSpecification()); } - public function testConstructEmptyArgs(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructEmptyArgs(): void { $notLike = new NotLike(); - self::assertEquals('', $notLike->getIdentifier()); - self::assertEquals('', $notLike->getLike()); + static::assertNull($notLike->getIdentifier()); + static::assertNull($notLike->getLike()); } - public function testConstructWithArgs(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructWithArgs(): void { $notLike = new NotLike('bar', 'Foo%'); $identifier = $notLike->getIdentifier(); - self::assertInstanceOf(ArgumentInterface::class, $identifier); - self::assertEquals('bar', $identifier->getValue()); - self::assertEquals(ArgumentType::Identifier, $identifier->getType()); + static::assertInstanceOf(ArgumentInterface::class, $identifier); + static::assertSame('bar', $identifier->getValue()); + static::assertEquals(ArgumentType::Identifier, $identifier->getType()); $likeValue = $notLike->getLike(); - self::assertInstanceOf(ArgumentInterface::class, $likeValue); - self::assertEquals('Foo%', $likeValue->getValue()); - self::assertEquals(ArgumentType::Value, $likeValue->getType()); + static::assertInstanceOf(ArgumentInterface::class, $likeValue); + static::assertSame('Foo%', $likeValue->getValue()); + static::assertEquals(ArgumentType::Value, $likeValue->getType()); } - public function testGetExpressionData(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionData(): void { $notLike = new NotLike('bar', 'Foo%'); $expressionData = $notLike->getExpressionData(); // Verify specification - self::assertEquals('%s NOT LIKE %s', $expressionData['spec']); + static::assertSame('%s NOT LIKE %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify identifier argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('bar', $values[0]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('bar', $values[0]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); // Verify like expression argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('Foo%', $values[1]->getValue()); - self::assertEquals(ArgumentType::Value, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('Foo%', $values[1]->getValue()); + static::assertEquals(ArgumentType::Value, $values[1]->getType()); } - public function testInstanceOfPerSetters(): void + #[\PHPUnit\Framework\Attributes\Test] + public function instanceOfPerSetters(): void { $notLike = new NotLike(); - self::assertInstanceOf(Like::class, $notLike->setIdentifier('bar')); - self::assertInstanceOf(Like::class, $notLike->setSpecification('%s NOT LIKE %s')); - self::assertInstanceOf(Like::class, $notLike->setLike('foo%')); + static::assertInstanceOf(Like::class, $notLike->setIdentifier('bar')); + static::assertInstanceOf(Like::class, $notLike->setSpecification('%s NOT LIKE %s')); + static::assertInstanceOf(Like::class, $notLike->setLike('foo%')); } } diff --git a/test/unit/Sql/Predicate/OperatorTest.php b/test/unit/Sql/Predicate/OperatorTest.php index 61e182ad..b4dfd534 100644 --- a/test/unit/Sql/Predicate/OperatorTest.php +++ b/test/unit/Sql/Predicate/OperatorTest.php @@ -28,69 +28,73 @@ #[Group('unit')] final class OperatorTest extends TestCase { - /** - * A custom specification replaces the generated one rather than sitting unused - * behind it. - */ - #[Test] - public function getExpressionDataPrefersACustomSpecification(): void - { - $operator = new Operator('foo.bar', Operator::OPERATOR_EQUAL_TO, 'baz'); - $operator->setSpecification('%1$s IS NOT DISTINCT FROM %2$s'); - - static::assertSame('%1$s IS NOT DISTINCT FROM %2$s', $operator->getExpressionData()['spec']); - } - - public function testCanPassAllValuesToConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canPassAllValuesToConstructor(): void { $operator = new Operator('bar', '>=', 'foo.bar'); - self::assertEquals(Operator::OP_GTE, $operator->getOperator()); + static::assertEquals(Operator::OP_GTE, $operator->getOperator()); $left = $operator->getLeft(); - self::assertInstanceOf(ArgumentInterface::class, $left); - self::assertEquals('bar', $left->getValue()); - self::assertEquals(ArgumentType::Identifier, $left->getType()); + static::assertInstanceOf(ArgumentInterface::class, $left); + static::assertSame('bar', $left->getValue()); + static::assertEquals(ArgumentType::Identifier, $left->getType()); $right = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right); - self::assertEquals('foo.bar', $right->getValue()); - self::assertEquals(ArgumentType::Value, $right->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right); + static::assertSame('foo.bar', $right->getValue()); + static::assertEquals(ArgumentType::Value, $right->getType()); $operator = new Operator(new Value('bar'), '>=', new Identifier('foo.bar')); - self::assertEquals(Operator::OP_GTE, $operator->getOperator()); + static::assertEquals(Operator::OP_GTE, $operator->getOperator()); $left = $operator->getLeft(); - self::assertInstanceOf(ArgumentInterface::class, $left); - self::assertEquals('bar', $left->getValue()); - self::assertEquals(ArgumentType::Value, $left->getType()); + static::assertInstanceOf(ArgumentInterface::class, $left); + static::assertSame('bar', $left->getValue()); + static::assertEquals(ArgumentType::Value, $left->getType()); $right = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right); - self::assertEquals('foo.bar', $right->getValue()); - self::assertEquals(ArgumentType::Identifier, $right->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right); + static::assertSame('foo.bar', $right->getValue()); + static::assertEquals(ArgumentType::Identifier, $right->getType()); $operator = new Operator('bar', '>=', 0); $right = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right); - self::assertEquals(0, $right->getValue()); - self::assertEquals(ArgumentType::Value, $right->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right); + static::assertSame(0, $right->getValue()); + static::assertEquals(ArgumentType::Value, $right->getType()); } - public function testEmptyConstructorYieldsDefaultsForOperatorAndLeftAndRightTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsDefaultsForOperatorAndLeftAndRightTypes(): void { $operator = new Operator(); - self::assertEquals(Operator::OP_EQ, $operator->getOperator()); + static::assertEquals(Operator::OP_EQ, $operator->getOperator()); } - public function testEmptyConstructorYieldsNullLeftAndRightValues(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsNullLeftAndRightValues(): void { $operator = new Operator(); - self::assertNull($operator->getLeft()); - self::assertNull($operator->getRight()); + static::assertNull($operator->getLeft()); + static::assertNull($operator->getRight()); + } + + /** + * A custom specification replaces the generated one rather than sitting unused + * behind it. + */ + #[Test] + public function getExpressionDataPrefersACustomSpecification(): void + { + $operator = new Operator('foo.bar', Operator::OPERATOR_EQUAL_TO, 'baz'); + $operator->setSpecification('%1$s IS NOT DISTINCT FROM %2$s'); + + static::assertSame('%1$s IS NOT DISTINCT FROM %2$s', $operator->getExpressionData()['spec']); } - public function testGetExpressionDataThrowsExceptionWhenLeftNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenLeftNotSet(): void { $operator = new Operator(); $operator->setRight('value'); @@ -100,7 +104,8 @@ public function testGetExpressionDataThrowsExceptionWhenLeftNotSet(): void $operator->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenRightNotSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataThrowsExceptionWhenRightNotSet(): void { $operator = new Operator(); $operator->setLeft('left'); @@ -110,7 +115,8 @@ public function testGetExpressionDataThrowsExceptionWhenRightNotSet(): void $operator->getExpressionData(); } - public function testLeftIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function leftIsMutable(): void { $operator = new Operator(); @@ -118,32 +124,34 @@ public function testLeftIsMutable(): void $result = $operator->setLeft('foo.bar'); // Verify fluent interface - self::assertSame($operator, $result); + static::assertSame($operator, $result); // Verify the first mutation occurred $left1 = $operator->getLeft(); - self::assertInstanceOf(ArgumentInterface::class, $left1); - self::assertEquals('foo.bar', $left1->getValue()); - self::assertEquals(ArgumentType::Identifier, $left1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $left1); + static::assertSame('foo.bar', $left1->getValue()); + static::assertEquals(ArgumentType::Identifier, $left1->getType()); // Second mutation with different data to verify mutability $operator->setLeft('baz.qux'); // Verify the instance was actually mutated $left2 = $operator->getLeft(); - self::assertInstanceOf(ArgumentInterface::class, $left2); - self::assertEquals('baz.qux', $left2->getValue()); - self::assertEquals(ArgumentType::Identifier, $left2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $left2); + static::assertSame('baz.qux', $left2->getValue()); + static::assertEquals(ArgumentType::Identifier, $left2->getType()); } - public function testOperatorIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function operatorIsMutable(): void { $operator = new Operator(); $operator->setOperator(Operator::OP_LTE); - self::assertEquals(Operator::OP_LTE, $operator->getOperator()); + static::assertEquals(Operator::OP_LTE, $operator->getOperator()); } - public function testRetrievingWherePartsReturnsSpecificationArrayOfLeftAndRightAndArrayOfTypes(): void + #[\PHPUnit\Framework\Attributes\Test] + public function retrievingWherePartsReturnsSpecificationArrayOfLeftAndRightAndArrayOfTypes(): void { $operator = new Operator(); $operator->setLeft(new Value('foo')) @@ -153,24 +161,25 @@ public function testRetrievingWherePartsReturnsSpecificationArrayOfLeftAndRightA $expressionData = $operator->getExpressionData(); // Verify specification - self::assertEquals('%s >= %s', $expressionData['spec']); + static::assertSame('%s >= %s', $expressionData['spec']); // Verify expression values $values = $expressionData['values']; - self::assertCount(2, $values); + static::assertCount(2, $values); // Verify left argument - self::assertInstanceOf(ArgumentInterface::class, $values[0]); - self::assertEquals('foo', $values[0]->getValue()); - self::assertEquals(ArgumentType::Value, $values[0]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[0]); + static::assertSame('foo', $values[0]->getValue()); + static::assertEquals(ArgumentType::Value, $values[0]->getType()); // Verify right argument - self::assertInstanceOf(ArgumentInterface::class, $values[1]); - self::assertEquals('foo.bar', $values[1]->getValue()); - self::assertEquals(ArgumentType::Identifier, $values[1]->getType()); + static::assertInstanceOf(ArgumentInterface::class, $values[1]); + static::assertSame('foo.bar', $values[1]->getValue()); + static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); } - public function testRightIsMutable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rightIsMutable(): void { $operator = new Operator(); @@ -178,34 +187,35 @@ public function testRightIsMutable(): void $result = $operator->setRight('bar'); // Verify fluent interface - self::assertSame($operator, $result); + static::assertSame($operator, $result); // Verify the first mutation occurred $right1 = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right1); - self::assertEquals('bar', $right1->getValue()); - self::assertEquals(ArgumentType::Value, $right1->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right1); + static::assertSame('bar', $right1->getValue()); + static::assertEquals(ArgumentType::Value, $right1->getType()); // Second mutation - with explicit type (Identifier) using factory $operator->setRight(new Identifier('bar')); // Verify the instance was actually mutated (same value, different type) $right2 = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right2); - self::assertEquals('bar', $right2->getValue()); - self::assertEquals(ArgumentType::Identifier, $right2->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right2); + static::assertSame('bar', $right2->getValue()); + static::assertEquals(ArgumentType::Identifier, $right2->getType()); // Third mutation - different value with default type $operator->setRight('qux'); // Verify the instance was mutated again $right3 = $operator->getRight(); - self::assertInstanceOf(ArgumentInterface::class, $right3); - self::assertEquals('qux', $right3->getValue()); - self::assertEquals(ArgumentType::Value, $right3->getType()); + static::assertInstanceOf(ArgumentInterface::class, $right3); + static::assertSame('qux', $right3->getValue()); + static::assertEquals(ArgumentType::Value, $right3->getType()); } - public function testSetLeftWithExpressionInterfaceWrapsInSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setLeftWithExpressionInterfaceWrapsInSelect(): void { $operator = new Operator(); $expression = new Expression('NOW()'); @@ -213,11 +223,12 @@ public function testSetLeftWithExpressionInterfaceWrapsInSelect(): void $operator->setLeft($expression); $left = $operator->getLeft(); - self::assertInstanceOf(Select::class, $left); - self::assertSame(ArgumentType::Select, $left->getType()); + static::assertInstanceOf(Select::class, $left); + static::assertSame(ArgumentType::Select, $left->getType()); } - public function testSetRightWithExpressionInterfaceWrapsInSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setRightWithExpressionInterfaceWrapsInSelect(): void { $operator = new Operator(); $expression = new Expression('NOW()'); @@ -225,7 +236,7 @@ public function testSetRightWithExpressionInterfaceWrapsInSelect(): void $operator->setRight($expression); $right = $operator->getRight(); - self::assertInstanceOf(Select::class, $right); - self::assertSame(ArgumentType::Select, $right->getType()); + static::assertInstanceOf(Select::class, $right); + static::assertSame(ArgumentType::Select, $right->getType()); } } diff --git a/test/unit/Sql/Predicate/PredicateSetTest.php b/test/unit/Sql/Predicate/PredicateSetTest.php index f3f52996..be0501c7 100644 --- a/test/unit/Sql/Predicate/PredicateSetTest.php +++ b/test/unit/Sql/Predicate/PredicateSetTest.php @@ -40,7 +40,8 @@ final class PredicateSetTest extends TestCase /** * @throws ReflectionException */ - public function testAddPredicates(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addPredicates(): void { $predicateSet = new PredicateSet(); @@ -52,36 +53,36 @@ public function testAddPredicates(): void $predicateSet->addPredicates(['c2' => [1, 2, 3]]); $predicateSet->addPredicates([new IsNotNull('c3')]); - $predicates = (array) $this->readAttribute($predicateSet, 'predicates'); - self::assertCount(7, $predicates); + $predicates = (array) static::readAttribute($predicateSet, 'predicates'); + static::assertCount(7, $predicates); - self::assertIsArray($predicates[0]); - self::assertEquals('AND', $predicates[0][0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); + static::assertIsArray($predicates[0]); + static::assertSame('AND', $predicates[0][0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); - self::assertIsArray($predicates[1]); - self::assertEquals('AND', $predicates[1][0]); - self::assertInstanceOf(Expression::class, $predicates[1][1]); + static::assertIsArray($predicates[1]); + static::assertSame('AND', $predicates[1][0]); + static::assertInstanceOf(Expression::class, $predicates[1][1]); - self::assertIsArray($predicates[2]); - self::assertEquals('AND', $predicates[2][0]); - self::assertInstanceOf(Operator::class, $predicates[2][1]); + static::assertIsArray($predicates[2]); + static::assertSame('AND', $predicates[2][0]); + static::assertInstanceOf(Operator::class, $predicates[2][1]); - self::assertIsArray($predicates[3]); - self::assertEquals('OR', $predicates[3][0]); - self::assertInstanceOf(Literal::class, $predicates[3][1]); + static::assertIsArray($predicates[3]); + static::assertSame('OR', $predicates[3][0]); + static::assertInstanceOf(Literal::class, $predicates[3][1]); - self::assertIsArray($predicates[4]); - self::assertEquals('AND', $predicates[4][0]); - self::assertInstanceOf(IsNull::class, $predicates[4][1]); + static::assertIsArray($predicates[4]); + static::assertSame('AND', $predicates[4][0]); + static::assertInstanceOf(IsNull::class, $predicates[4][1]); - self::assertIsArray($predicates[5]); - self::assertEquals('AND', $predicates[5][0]); - self::assertInstanceOf(In::class, $predicates[5][1]); + static::assertIsArray($predicates[5]); + static::assertSame('AND', $predicates[5][0]); + static::assertInstanceOf(In::class, $predicates[5][1]); - self::assertIsArray($predicates[6]); - self::assertEquals('AND', $predicates[6][0]); - self::assertInstanceOf(IsNotNull::class, $predicates[6][1]); + static::assertIsArray($predicates[6]); + static::assertSame('AND', $predicates[6][0]); + static::assertInstanceOf(IsNotNull::class, $predicates[6][1]); $predicateSet->addPredicates(static function (PredicateSet $what) use ($predicateSet): void { self::assertSame($predicateSet, $what); @@ -92,7 +93,8 @@ public function testAddPredicates(): void $predicateSet->addPredicates(null); } - public function testAddPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): void { $predicateSet = new PredicateSet(); $mock = $this->createMock(PredicateInterface::class); @@ -107,7 +109,8 @@ public function testAddPredicatesThrowsWhenStringKeyUsedWithPredicateInterface() * * @throws ReflectionException */ - public function testAddPredicatesWithExpression(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addPredicatesWithExpression(): void { $predicateSet = new PredicateSet(); @@ -116,17 +119,17 @@ public function testAddPredicatesWithExpression(): void new SqlExpression('COUNT(?) > ?', [Argument::identifier('id'), Argument::value(5)]), ]); - $predicates = (array) $this->readAttribute($predicateSet, 'predicates'); - self::assertCount(1, $predicates); + $predicates = (array) static::readAttribute($predicateSet, 'predicates'); + static::assertCount(1, $predicates); - self::assertIsArray($predicates[0]); - self::assertEquals('AND', $predicates[0][0]); + static::assertIsArray($predicates[0]); + static::assertSame('AND', $predicates[0][0]); // Should be wrapped in a Predicate\Expression - self::assertInstanceOf(Expression::class, $predicates[0][1]); + static::assertInstanceOf(Expression::class, $predicates[0][1]); // Verify the expression data is preserved $expressionData = $predicateSet->getExpressionData(); - self::assertStringContainsString('COUNT', $expressionData['spec']); + static::assertStringContainsString('COUNT', $expressionData['spec']); } /** @@ -134,7 +137,8 @@ public function testAddPredicatesWithExpression(): void * * @throws ReflectionException */ - public function testAddPredicatesWithMultipleExpressions(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addPredicatesWithMultipleExpressions(): void { $predicateSet = new PredicateSet(); @@ -143,14 +147,15 @@ public function testAddPredicatesWithMultipleExpressions(): void new SqlExpression('AVG(?) < ?', [Argument::identifier('price'), Argument::value(50)]), ]); - $predicates = (array) $this->readAttribute($predicateSet, 'predicates'); - self::assertCount(2, $predicates); + $predicates = (array) static::readAttribute($predicateSet, 'predicates'); + static::assertCount(2, $predicates); - self::assertInstanceOf(Expression::class, $predicates[0][1]); - self::assertInstanceOf(Expression::class, $predicates[1][1]); + static::assertInstanceOf(Expression::class, $predicates[0][1]); + static::assertInstanceOf(Expression::class, $predicates[1][1]); } - public function testAddPredicateThrowsOnInvalidCombination(): void + #[\PHPUnit\Framework\Attributes\Test] + public function addPredicateThrowsOnInvalidCombination(): void { $predicateSet = new PredicateSet(); @@ -159,7 +164,8 @@ public function testAddPredicateThrowsOnInvalidCombination(): void $predicateSet->addPredicate(new IsNull('foo'), 'XOR'); } - public function testCanPassBothPredicateAndCombinationToAddPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canPassBothPredicateAndCombinationToAddPredicate(): void { $predicateSet = new PredicateSet(); $predicateSet->addPredicate(new IsNull('foo'), 'OR') @@ -170,14 +176,15 @@ public function testCanPassBothPredicateAndCombinationToAddPredicate(): void $expressionData = $predicateSet->getExpressionData(); // 4 predicates = 4 values - self::assertCount(4, $expressionData['values']); + static::assertCount(4, $expressionData['values']); // Verify combinators are in spec string: AND bar AND baz OR bat $spec = $expressionData['spec']; - self::assertEquals('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); + static::assertSame('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); } - public function testCanPassPredicatesAndDefaultCombinationViaConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canPassPredicatesAndDefaultCombinationViaConstructor(): void { new PredicateSet(); $predicateSet = new PredicateSet([ @@ -188,12 +195,13 @@ public function testCanPassPredicatesAndDefaultCombinationViaConstructor(): void $expressionData = $predicateSet->getExpressionData(); // 2 predicates = 2 values - self::assertCount(2, $expressionData['values']); - self::assertStringContainsString('OR', $expressionData['spec']); - self::assertStringNotContainsString('AND', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertStringContainsString('OR', $expressionData['spec']); + static::assertStringNotContainsString('AND', $expressionData['spec']); } - public function testCanUseOrPredicateAndAndPredicateMethods(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canUseOrPredicateAndAndPredicateMethods(): void { $predicateSet = new PredicateSet(); $predicateSet->orPredicate(new IsNull('foo')) @@ -204,14 +212,15 @@ public function testCanUseOrPredicateAndAndPredicateMethods(): void $expressionData = $predicateSet->getExpressionData(); // 4 predicates = 4 values - self::assertCount(4, $expressionData['values']); + static::assertCount(4, $expressionData['values']); // Verify spec contains correct pattern: foo AND bar OR baz AND bat $spec = $expressionData['spec']; - self::assertEquals('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); + static::assertSame('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); } - public function testCombinationIsAndByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function combinationIsAndByDefault(): void { $predicateSet = new PredicateSet(); $predicateSet->addPredicate(new IsNull('foo')) @@ -220,24 +229,26 @@ public function testCombinationIsAndByDefault(): void $expressionData = $predicateSet->getExpressionData(); // 2 predicates = 2 values - self::assertCount(2, $expressionData['values']); - self::assertStringContainsString('AND', $expressionData['spec']); - self::assertStringNotContainsString('OR', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertStringContainsString('AND', $expressionData['spec']); + static::assertStringNotContainsString('OR', $expressionData['spec']); } - public function testEmptyConstructorYieldsCountOfZero(): void + #[\PHPUnit\Framework\Attributes\Test] + public function emptyConstructorYieldsCountOfZero(): void { $predicateSet = new PredicateSet(); - self::assertCount(0, $predicateSet); + static::assertCount(0, $predicateSet); } - public function testGetExpressionDataReturnsEmptyWhenNoPredicates(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getExpressionDataReturnsEmptyWhenNoPredicates(): void { $predicateSet = new PredicateSet(); $expressionData = $predicateSet->getExpressionData(); - self::assertSame('', $expressionData['spec']); - self::assertSame([], $expressionData['values']); + static::assertSame('', $expressionData['spec']); + static::assertSame([], $expressionData['values']); } } diff --git a/test/unit/Sql/Predicate/PredicateTest.php b/test/unit/Sql/Predicate/PredicateTest.php index f257625a..b96f92d6 100644 --- a/test/unit/Sql/Predicate/PredicateTest.php +++ b/test/unit/Sql/Predicate/PredicateTest.php @@ -20,7 +20,8 @@ #[Group('unit')] final class PredicateTest extends TestCase { - public function testBetweenCreatesBetweenPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function betweenCreatesBetweenPredicate(): void { $predicate = new Predicate(); $predicate->between('foo.bar', 1, 10); @@ -31,14 +32,15 @@ public function testBetweenCreatesBetweenPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s BETWEEN %s AND %s', $expressionData['spec']); - self::assertCount(3, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($minValue, $expressionData['values'][1]); - self::assertEquals($maxValue, $expressionData['values'][2]); + static::assertSame('%s BETWEEN %s AND %s', $expressionData['spec']); + static::assertCount(3, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($minValue, $expressionData['values'][1]); + static::assertEquals($maxValue, $expressionData['values'][2]); } - public function testBetweenCreatesNotBetweenPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function betweenCreatesNotBetweenPredicate(): void { $predicate = new Predicate(); $predicate->notBetween('foo.bar', 1, 10); @@ -49,14 +51,15 @@ public function testBetweenCreatesNotBetweenPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s NOT BETWEEN %s AND %s', $expressionData['spec']); - self::assertCount(3, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($minValue, $expressionData['values'][1]); - self::assertEquals($maxValue, $expressionData['values'][2]); + static::assertSame('%s NOT BETWEEN %s AND %s', $expressionData['spec']); + static::assertCount(3, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($minValue, $expressionData['values'][1]); + static::assertEquals($maxValue, $expressionData['values'][2]); } - public function testCanChainPredicateFactoriesBetweenOperators(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canChainPredicateFactoriesBetweenOperators(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar')->or->isNotNull('bar.baz') @@ -70,16 +73,17 @@ public function testCanChainPredicateFactoriesBetweenOperators(): void $expressionData = $predicate->getExpressionData(); // 3 predicates: IsNull, IsNotNull, Operator = 4 values (1+1+2) - self::assertCount(4, $expressionData['values']); + static::assertCount(4, $expressionData['values']); // Verify combined spec - self::assertEquals('%s IS NULL OR %s IS NOT NULL AND %s = %s', $expressionData['spec']); - self::assertEquals($identifier1, $expressionData['values'][0]); - self::assertEquals($identifier2, $expressionData['values'][1]); - self::assertEquals($identifier3, $expressionData['values'][2]); - self::assertEquals($expression3, $expressionData['values'][3]); + static::assertSame('%s IS NULL OR %s IS NOT NULL AND %s = %s', $expressionData['spec']); + static::assertEquals($identifier1, $expressionData['values'][0]); + static::assertEquals($identifier2, $expressionData['values'][1]); + static::assertEquals($identifier3, $expressionData['values'][2]); + static::assertEquals($expression3, $expressionData['values'][3]); } - public function testCanNestPredicates(): void + #[\PHPUnit\Framework\Attributes\Test] + public function canNestPredicates(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar') @@ -97,16 +101,17 @@ public function testCanNestPredicates(): void $expressionData = $predicate->getExpressionData(); // 3 predicates: IsNull + nested(IsNotNull, Operator) = 4 values - self::assertCount(4, $expressionData['values']); + static::assertCount(4, $expressionData['values']); // Verify combined spec with nested brackets - self::assertEquals('%s IS NULL AND (%s IS NOT NULL AND %s = %s)', $expressionData['spec']); - self::assertEquals($identifier1, $expressionData['values'][0]); - self::assertEquals($identifier2, $expressionData['values'][1]); - self::assertEquals($identifier3, $expressionData['values'][2]); - self::assertEquals($expression3, $expressionData['values'][3]); + static::assertSame('%s IS NULL AND (%s IS NOT NULL AND %s = %s)', $expressionData['spec']); + static::assertEquals($identifier1, $expressionData['values'][0]); + static::assertEquals($identifier2, $expressionData['values'][1]); + static::assertEquals($identifier3, $expressionData['values'][2]); + static::assertEquals($expression3, $expressionData['values'][3]); } - public function testEqualToCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function equalToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->equalTo('foo.bar', 'bar'); @@ -116,28 +121,30 @@ public function testEqualToCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s = %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s = %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('Unit test: Test expression() is chainable and returns proper values')] - public function testExpression(): void + public function expression(): void { $predicate = new Predicate(); $value = Argument::value(0); // is chainable - self::assertSame($predicate, $predicate->expression('foo = ?', 0)); + static::assertSame($predicate, $predicate->expression('foo = ?', 0)); $expressionData = $predicate->getExpressionData(); // with parameter - self::assertEquals('foo = %s', $expressionData['spec']); - self::assertEquals([$value], $expressionData['values']); + static::assertSame('foo = %s', $expressionData['spec']); + static::assertEquals([$value], $expressionData['values']); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('Unit test: Test expression() allows null $parameters')] - public function testExpressionNullParameters(): void + public function expressionNullParameters(): void { $predicate = new Predicate(); @@ -147,14 +154,15 @@ public function testExpressionNullParameters(): void if (isset($predicates[0][1])) { $expression = $predicates[0][1]; - $this->assertInstanceOf(Expression::class, $expression); - self::assertEquals([], $expression->getParameters()); + static::assertInstanceOf(Expression::class, $expression); + static::assertEquals([], $expression->getParameters()); } else { - $this->fail('Expression not found'); + static::fail('Expression not found'); } } - public function testGreaterThanCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function greaterThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->greaterThan('foo.bar', 'bar'); @@ -164,13 +172,14 @@ public function testGreaterThanCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s > %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s > %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testGreaterThanOrEqualToCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function greaterThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->greaterThanOrEqualTo('foo.bar', 'bar'); @@ -180,13 +189,14 @@ public function testGreaterThanOrEqualToCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s >= %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s >= %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testInCreatesInPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function inCreatesInPredicate(): void { $predicate = new Predicate(); $predicate->in('foo.bar', ['foo', 'bar']); @@ -196,13 +206,14 @@ public function testInCreatesInPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s IN (%s, %s)', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s IN (%s, %s)', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testIsNotNullCreatesIsNotNullPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isNotNullCreatesIsNotNullPredicate(): void { $predicate = new Predicate(); $predicate->isNotNull('foo.bar'); @@ -211,12 +222,13 @@ public function testIsNotNullCreatesIsNotNullPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s IS NOT NULL', $expressionData['spec']); - self::assertCount(1, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); + static::assertSame('%s IS NOT NULL', $expressionData['spec']); + static::assertCount(1, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); } - public function testIsNullCreatesIsNullPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isNullCreatesIsNullPredicate(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar'); @@ -225,12 +237,13 @@ public function testIsNullCreatesIsNullPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s IS NULL', $expressionData['spec']); - self::assertCount(1, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); + static::assertSame('%s IS NULL', $expressionData['spec']); + static::assertCount(1, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); } - public function testLessThanCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function lessThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->lessThan('foo.bar', 'bar'); @@ -240,13 +253,14 @@ public function testLessThanCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s < %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s < %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testLessThanOrEqualToCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function lessThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->lessThanOrEqualTo('foo.bar', 'bar'); @@ -256,13 +270,14 @@ public function testLessThanOrEqualToCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s <= %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s <= %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testLikeCreatesLikePredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function likeCreatesLikePredicate(): void { $predicate = new Predicate(); $predicate->like('foo.bar', 'bar%'); @@ -272,25 +287,26 @@ public function testLikeCreatesLikePredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s LIKE %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s LIKE %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('Unit test: Test literal() is chainable, returns proper values, and is backwards compatible with 2.0.*')] - public function testLiteral(): void + public function literal(): void { $predicate = new Predicate(); // is chainable - self::assertSame($predicate, $predicate->literal('foo = bar')); + static::assertSame($predicate, $predicate->literal('foo = bar')); $expressionData = $predicate->getExpressionData(); // with parameter - self::assertEquals('foo = bar', $expressionData['spec']); - self::assertEquals([], $expressionData['values']); + static::assertSame('foo = bar', $expressionData['spec']); + static::assertEquals([], $expressionData['values']); // test literal() is backwards-compatible, and works with with parameters $predicate = new Predicate(); @@ -300,8 +316,8 @@ public function testLiteral(): void $expressionData = $predicate->getExpressionData(); // with parameter - self::assertEquals('foo = %s', $expressionData['spec']); - self::assertEquals([$expression], $expressionData['values']); + static::assertSame('foo = %s', $expressionData['spec']); + static::assertEquals([$expression], $expressionData['values']); // test literal() is backwards-compatible, and works with with parameters, even 0 which tests as false $predicate = new Predicate(); @@ -311,42 +327,46 @@ public function testLiteral(): void $expressionData = $predicate->getExpressionData(); // with parameter - self::assertEquals('foo = %s', $expressionData['spec']); - self::assertEquals([$expression], $expressionData['values']); + static::assertSame('foo = %s', $expressionData['spec']); + static::assertEquals([$expression], $expressionData['values']); } - public function testLiteralCreatesLiteralPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function literalCreatesLiteralPredicate(): void { $predicate = new Predicate(); $predicate->literal('foo.bar = ?'); $expressionData = $predicate->getExpressionData(); - self::assertCount(0, $expressionData['values']); - self::assertEquals('foo.bar = ?', $expressionData['spec']); + static::assertCount(0, $expressionData['values']); + static::assertSame('foo.bar = ?', $expressionData['spec']); } - public function testMagicGetNestReturnsNestedPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetNestReturnsNestedPredicate(): void { $predicate = new Predicate(); $nested = $predicate->nest; - self::assertInstanceOf(Predicate::class, $nested); - self::assertNotSame($predicate, $nested); + static::assertInstanceOf(Predicate::class, $nested); + static::assertNotSame($predicate, $nested); } - public function testMagicGetUnnestReturnsParentPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetUnnestReturnsParentPredicate(): void { $predicate = new Predicate(); $nested = $predicate->nest; $parent = $nested->unnest; - self::assertSame($predicate, $parent); + static::assertSame($predicate, $parent); } - public function testNotEqualToCreatesOperatorPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function notEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->notEqualTo('foo.bar', 'bar'); @@ -356,13 +376,14 @@ public function testNotEqualToCreatesOperatorPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s != %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s != %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testNotInCreatesNotInPredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function notInCreatesNotInPredicate(): void { $predicate = new Predicate(); $predicate->notIn('foo.bar', ['foo', 'bar']); @@ -372,13 +393,14 @@ public function testNotInCreatesNotInPredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s NOT IN (%s, %s)', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s NOT IN (%s, %s)', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testNotLikeCreatesLikePredicate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function notLikeCreatesLikePredicate(): void { $predicate = new Predicate(); $predicate->notLike('foo.bar', 'bar%'); @@ -388,24 +410,26 @@ public function testNotLikeCreatesLikePredicate(): void $expressionData = $predicate->getExpressionData(); - self::assertEquals('%s NOT LIKE %s', $expressionData['spec']); - self::assertCount(2, $expressionData['values']); - self::assertEquals($identifier, $expressionData['values'][0]); - self::assertEquals($expression, $expressionData['values'][1]); + static::assertSame('%s NOT LIKE %s', $expressionData['spec']); + static::assertCount(2, $expressionData['values']); + static::assertEquals($identifier, $expressionData['values'][0]); + static::assertEquals($expression, $expressionData['values'][1]); } - public function testPredicateMethodAddsCustomPredicateInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function predicateMethodAddsCustomPredicateInterface(): void { $predicate = new Predicate(); $mock = $this->createMock(PredicateInterface::class); $result = $predicate->predicate($mock); - self::assertSame($predicate, $result); - self::assertCount(1, $predicate); + static::assertSame($predicate, $result); + static::assertCount(1, $predicate); } - public function testUnnestThrowsWhenNotNested(): void + #[\PHPUnit\Framework\Attributes\Test] + public function unnestThrowsWhenNotNested(): void { $predicate = new Predicate(); @@ -420,7 +444,8 @@ public function testUnnestThrowsWhenNotNested(): void /** * @throws ErrorException */ - public function testWillBindSqlParametersToExpressionsWithGivenParameter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function willBindSqlParametersToExpressionsWithGivenParameter(): void { $where = new Predicate(); @@ -428,7 +453,7 @@ public function testWillBindSqlParametersToExpressionsWithGivenParameter(): void $actual = $this->makeSqlString($where); - self::assertSame( + static::assertSame( 'SELECT "a_table".* FROM "a_table" WHERE (some_expression(\'\'))', $actual, ); @@ -437,7 +462,8 @@ public function testWillBindSqlParametersToExpressionsWithGivenParameter(): void /** * @throws ErrorException */ - public function testWillBindSqlParametersToExpressionsWithGivenStringParameter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function willBindSqlParametersToExpressionsWithGivenStringParameter(): void { $where = new Predicate(); @@ -445,7 +471,7 @@ public function testWillBindSqlParametersToExpressionsWithGivenStringParameter() $actual = $this->makeSqlString($where); - self::assertSame( + static::assertSame( 'SELECT "a_table".* FROM "a_table" WHERE (some_expression(\'a string\'))', $actual, ); diff --git a/test/unit/Sql/SelectTest.php b/test/unit/Sql/SelectTest.php index 04377154..3bdf6cf9 100644 --- a/test/unit/Sql/SelectTest.php +++ b/test/unit/Sql/SelectTest.php @@ -833,8 +833,9 @@ public static function providerData(): array // phpcs:enable Generic.Files.LineLength.TooLong } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test join() exception with bad join')] - public function testBadJoin(): void + public function badJoin(): void { $select = new Select(); self::expectException(InvalidArgumentException::class); @@ -842,7 +843,8 @@ public function testBadJoin(): void $select->join(['foo'], 'x = y'); } - public function testCloneDeepCopiesAllSubObjects(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneDeepCopiesAllSubObjects(): void { $select = new Select(); $select->from('foo'); @@ -855,32 +857,34 @@ public function testCloneDeepCopiesAllSubObjects(): void $clone->having('cnt > 1'); $clone->join('baz', 'foo.id = baz.foo_id'); - self::assertCount(1, $select->where); - self::assertCount(2, $clone->where); - self::assertCount(1, $select->having); - self::assertCount(2, $clone->having); - self::assertCount(1, $select->joins); - self::assertCount(2, $clone->joins); + static::assertCount(1, $select->where); + static::assertCount(2, $clone->where); + static::assertCount(1, $select->having); + static::assertCount(2, $clone->having); + static::assertCount(1, $select->joins); + static::assertCount(2, $clone->joins); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test __clone() will clone the where object so that this select can be used in multiple contexts')] - public function testCloning(): void + public function cloning(): void { $select = new Select(); $select1 = clone $select; $select1->where('id = foo'); $select1->having('id = foo'); - self::assertEquals(0, $select->where->count()); - self::assertEquals(1, $select1->where->count()); + static::assertSame(0, $select->where->count()); + static::assertSame(1, $select1->where->count()); - self::assertEquals(0, $select->having->count()); - self::assertEquals(1, $select1->having->count()); + static::assertSame(0, $select->having->count()); + static::assertSame(1, $select1->having->count()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test columns() returns Select object (is chainable)')] - public function testColumns(): void + public function columns(): void { $select = new Select(); @@ -888,42 +892,45 @@ public function testColumns(): void $result = $select->columns(['foo', 'bar']); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred - self::assertEquals(['foo', 'bar'], $select->getRawState('columns')); + static::assertEquals(['foo', 'bar'], $select->getRawState('columns')); // Second mutation to verify mutability $select->columns(['baz', 'qux']); // Verify the instance was actually mutated - self::assertEquals(['baz', 'qux'], $select->getRawState('columns')); + static::assertEquals(['baz', 'qux'], $select->getRawState('columns')); } - public function testColumnsWithPrefixDisabled(): void + #[\PHPUnit\Framework\Attributes\Test] + public function columnsWithPrefixDisabled(): void { $select = new Select(); $select->from('foo')->columns(['col'], false); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringNotContainsString('"foo"."col"', $sql); - self::assertStringContainsString('"col"', $sql); + static::assertStringNotContainsString('"foo"."col"', $sql); + static::assertStringContainsString('"col"', $sql); } - public function testColumnsWithPrefixDisabledOmitsTablePrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function columnsWithPrefixDisabledOmitsTablePrefix(): void { $select = new Select(); $select->from(['a' => 'users'])->columns(['id'], false); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('"id"', $sql); - self::assertStringNotContainsString('"a"."id"', $sql); + static::assertStringContainsString('"id"', $sql); + static::assertStringNotContainsString('"a"."id"', $sql); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test combine() returns same Select object (is chainable)')] - public function testCombine(): void + public function combine(): void { $select = new Select(); $combine = new Select(); @@ -932,14 +939,14 @@ public function testCombine(): void $result = $select->combine($combine, Select::COMBINE_UNION, 'ALL'); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred $state = $select->getRawState('combine'); - self::assertInstanceOf(Select::class, $state['select']); - self::assertNotSame($select, $state['select']); - self::assertEquals(Select::COMBINE_UNION, $state['type']); - self::assertEquals('ALL', $state['modifier']); + static::assertInstanceOf(Select::class, $state['select']); + static::assertNotSame($select, $state['select']); + static::assertEquals(Select::COMBINE_UNION, $state['type']); + static::assertSame('ALL', $state['modifier']); // Second mutation to verify mutability using a fresh Select $select2 = new Select(); @@ -948,11 +955,12 @@ public function testCombine(): void // Verify the instance was actually mutated $state2 = $select2->getRawState('combine'); - self::assertEquals(Select::COMBINE_INTERSECT, $state2['type']); - self::assertEquals('DISTINCT', $state2['modifier']); + static::assertEquals(Select::COMBINE_INTERSECT, $state2['type']); + static::assertSame('DISTINCT', $state2['modifier']); } - public function testCombineThrowsWhenAlreadyCombined(): void + #[\PHPUnit\Framework\Attributes\Test] + public function combineThrowsWhenAlreadyCombined(): void { $select = new Select(); $select->from('t1'); @@ -962,7 +970,8 @@ public function testCombineThrowsWhenAlreadyCombined(): void $select->combine(new Select('t3')); } - public function testCombineWrapsStatementInParentheses(): void + #[\PHPUnit\Framework\Attributes\Test] + public function combineWrapsStatementInParentheses(): void { $select1 = new Select(); $select1->from('t1'); @@ -974,19 +983,21 @@ public function testCombineWrapsStatementInParentheses(): void $sql = $select1->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('( SELECT', $sql); - self::assertStringContainsString('UNION', $sql); - self::assertStringContainsString(') UNION (', $sql); + static::assertStringContainsString('( SELECT', $sql); + static::assertStringContainsString('UNION', $sql); + static::assertStringContainsString(') UNION (', $sql); } - public function testConstruct(): void + #[\PHPUnit\Framework\Attributes\Test] + public function construct(): void { $select = new Select('foo'); - self::assertEquals('foo', $select->getRawState('table')); + static::assertSame('foo', $select->getRawState('table')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test from() returns Select object (is chainable)')] - public function testFrom(): void + public function from(): void { $select = new Select(); @@ -994,19 +1005,20 @@ public function testFrom(): void $result = $select->from('foo'); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred - self::assertEquals('foo', $select->getRawState('table')); + static::assertSame('foo', $select->getRawState('table')); // Second mutation to verify mutability $select->from('bar'); // Verify the instance was actually mutated - self::assertEquals('bar', $select->getRawState('table')); + static::assertSame('bar', $select->getRawState('table')); } - public function testFromThrowsExceptionForInvalidArrayFormat(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fromThrowsExceptionForInvalidArrayFormat(): void { $select = new Select(); @@ -1015,7 +1027,8 @@ public function testFromThrowsExceptionForInvalidArrayFormat(): void $select->from(['foo', 'bar']); // Numeric array instead of associative } - public function testFromThrowsExceptionForInvalidTableType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fromThrowsExceptionForInvalidTableType(): void { $select = new Select(); @@ -1024,7 +1037,8 @@ public function testFromThrowsExceptionForInvalidTableType(): void $select->from(123); } - public function testFromThrowsExceptionWhenTableReadOnly(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fromThrowsExceptionWhenTableReadOnly(): void { $select = new Select('foo'); // Creating with table makes it read-only @@ -1035,37 +1049,41 @@ public function testFromThrowsExceptionWhenTableReadOnly(): void $select->from('bar'); } - public function testFromWithAliasArrayResolvesTableAndAlias(): void + #[\PHPUnit\Framework\Attributes\Test] + public function fromWithAliasArrayResolvesTableAndAlias(): void { $select = new Select(); $select->from(['a' => 'users'])->columns(['id']); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('"users" AS "a"', $sql); - self::assertStringContainsString('"a"."id"', $sql); + static::assertStringContainsString('"users" AS "a"', $sql); + static::assertStringContainsString('"a"."id"', $sql); } - public function testGetRawStateInitializesLazyProperties(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateInitializesLazyProperties(): void { $select = new Select(); $rawState = $select->getRawState(); - self::assertInstanceOf(Where::class, $rawState[Select::WHERE]); - self::assertInstanceOf(Join::class, $rawState[Select::JOINS]); - self::assertInstanceOf(Having::class, $rawState[Select::HAVING]); + static::assertInstanceOf(Where::class, $rawState[Select::WHERE]); + static::assertInstanceOf(Join::class, $rawState[Select::JOINS]); + static::assertInstanceOf(Having::class, $rawState[Select::HAVING]); } /** @noinspection PhpUnusedParameterInspection */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('providerData')] #[TestDox('unit test: Test getSqlString() will produce expected sql and parameters based on a variety of provided arguments [uses data provider]')] - public function testGetSqlString(Select $select, mixed $unused, mixed $unused2, string $expectedSqlString): void + public function getSqlString(Select $select, mixed $unused, mixed $unused2, string $expectedSqlString): void { - self::assertEquals($expectedSqlString, $select->getSqlString(new TrustingSql92Platform())); + static::assertEquals($expectedSqlString, $select->getSqlString(new TrustingSql92Platform())); } - public function testGetThrowsExceptionForInvalidProperty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getThrowsExceptionForInvalidProperty(): void { $select = new Select(); @@ -1075,8 +1093,9 @@ public function testGetThrowsExceptionForInvalidProperty(): void $value = $select->invalidProperty; /** @phpstan-ignore-line */ } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test group() returns same Select object (is chainable)')] - public function testGroup(): void + public function group(): void { $select = new Select(); @@ -1084,20 +1103,21 @@ public function testGroup(): void $result = $select->group(['col1', 'col2']); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred - self::assertEquals(['col1', 'col2'], $select->getRawState('group')); + static::assertEquals(['col1', 'col2'], $select->getRawState('group')); // Second mutation to verify mutability (group accumulates) $select->group('col3'); // Verify the instance was actually mutated - self::assertEquals(['col1', 'col2', 'col3'], $select->getRawState('group')); + static::assertEquals(['col1', 'col2', 'col3'], $select->getRawState('group')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test having() returns same Select object (is chainable)')] - public function testHaving(): void + public function having(): void { $select = new Select(); @@ -1105,22 +1125,23 @@ public function testHaving(): void $result = $select->having(['x = ?' => 5]); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred $having = $select->getRawState('having'); - self::assertInstanceOf(Having::class, $having); - self::assertEquals(1, $having->count()); + static::assertInstanceOf(Having::class, $having); + static::assertSame(1, $having->count()); // Second mutation to verify mutability (having predicates accumulate) $select->having(['y = ?' => 10]); // Verify the instance was actually mutated - self::assertEquals(2, $select->getRawState('having')->count()); + static::assertSame(2, $select->getRawState('having')->count()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test having() accepts Expression (ExpressionInterface) in array')] - public function testHavingAcceptsExpressionInterface(): void + public function havingAcceptsExpressionInterface(): void { $select = new Select(); $select->from('foo') @@ -1130,32 +1151,35 @@ public function testHavingAcceptsExpressionInterface(): void ]); $having = $select->getRawState('having'); - self::assertInstanceOf(Having::class, $having); - self::assertEquals(1, $having->count()); + static::assertInstanceOf(Having::class, $having); + static::assertSame(1, $having->count()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test having() returns same Select object (is chainable)')] - public function testHavingArgument1IsHavingObject(): void + public function havingArgument1IsHavingObject(): void { $select = new Select(); $having = new Having(); $return = $select->having($having); - self::assertSame($select, $return); - self::assertSame($having, $select->getRawState('having')); + static::assertSame($select, $return); + static::assertSame($having, $select->getRawState('having')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test isTableReadOnly() returns correct state for read only')] - public function testIsTableReadOnly(): void + public function isTableReadOnly(): void { $select = new Select('foo'); - self::assertTrue($select->isTableReadOnly()); + static::assertTrue($select->isTableReadOnly()); $select = new Select(); - self::assertFalse($select->isTableReadOnly()); + static::assertFalse($select->isTableReadOnly()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test join() returns same Select object (is chainable)')] - public function testJoin(): void + public function join(): void { $select = new Select(); @@ -1163,12 +1187,12 @@ public function testJoin(): void $result = $select->join('foo', 'x = y'); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred $joins = $select->getRawState('joins'); - self::assertInstanceOf(Join::class, $joins); - self::assertEquals( + static::assertInstanceOf(Join::class, $joins); + static::assertEquals( [ [ 'name' => 'foo', @@ -1185,12 +1209,13 @@ public function testJoin(): void // Verify the instance was actually mutated $joins2 = $select->getRawState('joins'); - self::assertCount(2, $joins2->getJoins()); - self::assertEquals('bar', $joins2->getJoins()[1]['name']); + static::assertCount(2, $joins2->getJoins()); + static::assertSame('bar', $joins2->getJoins()[1]['name']); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(': unit test: test limit()')] - public function testLimit(): void + public function limit(): void { $select = new Select(); @@ -1198,22 +1223,23 @@ public function testLimit(): void $result = $select->limit(5); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred $limit = $select->getRawState(Select::LIMIT); - self::assertIsNumeric($limit); - self::assertEquals(5, $limit); + static::assertIsNumeric($limit); + static::assertSame(5, $limit); // Second mutation to verify mutability $select->limit(10); // Verify the instance was actually mutated - self::assertEquals(10, $select->getRawState(Select::LIMIT)); + static::assertSame(10, $select->getRawState(Select::LIMIT)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(': unit test: test limit() throws exception when invalid parameter passed')] - public function testLimitExceptionOnInvalidParameter(): void + public function limitExceptionOnInvalidParameter(): void { $select = new Select(); self::expectException(InvalidArgumentException::class); @@ -1221,22 +1247,25 @@ public function testLimitExceptionOnInvalidParameter(): void $select->limit('foobar'); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test __get() returns expected objects magically')] - public function testMagicAccessor(): void + public function magicAccessor(): void { $select = new Select(); - self::assertInstanceOf(Where::class, $select->where); + static::assertInstanceOf(Where::class, $select->where); } - public function testMagicGetJoinsReturnsJoinInstance(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetJoinsReturnsJoinInstance(): void { $select = new Select(); - self::assertInstanceOf(Join::class, $select->joins); + static::assertInstanceOf(Join::class, $select->joins); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(': unit test: test offset()')] - public function testOffset(): void + public function offset(): void { $select = new Select(); @@ -1244,22 +1273,23 @@ public function testOffset(): void $result = $select->offset(10); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred $offset = $select->getRawState(Select::OFFSET); - self::assertIsNumeric($offset); - self::assertEquals(10, $offset); + static::assertIsNumeric($offset); + static::assertSame(10, $offset); // Second mutation to verify mutability $select->offset(20); // Verify the instance was actually mutated - self::assertEquals(20, $select->getRawState(Select::OFFSET)); + static::assertSame(20, $select->getRawState(Select::OFFSET)); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(': unit test: test offset() throws exception when invalid parameter passed')] - public function testOffsetExceptionOnInvalidParameter(): void + public function offsetExceptionOnInvalidParameter(): void { $select = new Select(); self::expectException(InvalidArgumentException::class); @@ -1270,29 +1300,30 @@ public function testOffsetExceptionOnInvalidParameter(): void /** * @throws ReflectionException */ + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test order()')] - public function testOrder(): void + public function order(): void { $select = new Select(); $return = $select->order('id DESC'); - self::assertSame($select, $return); // test fluent interface - self::assertEquals(['id DESC'], $select->getRawState('order')); + static::assertSame($select, $return); // test fluent interface + static::assertEquals(['id DESC'], $select->getRawState('order')); $select = new Select(); $select->order('id DESC') ->order('name ASC, age DESC'); - self::assertEquals(['id DESC', 'name ASC', 'age DESC'], $select->getRawState('order')); + static::assertEquals(['id DESC', 'name ASC', 'age DESC'], $select->getRawState('order')); $select = new Select(); $select->order(['name ASC', 'age DESC']); - self::assertEquals(['name ASC', 'age DESC'], $select->getRawState('order')); + static::assertEquals(['name ASC', 'age DESC'], $select->getRawState('order')); $select = new Select(); $select->order(new Expression('RAND()')); $sr = new ReflectionObject($select); $method = $sr->getMethod('processOrder'); - self::assertEquals( + static::assertEquals( [[['RAND()']]], $method->invokeArgs($select, [new TrustingSql92Platform()]), ); @@ -1307,58 +1338,63 @@ public function testOrder(): void ); $sr = new ReflectionObject($select); $method = $sr->getMethod('processOrder'); - self::assertEquals( + static::assertEquals( [[['"rating" < \'10\'']]], $method->invokeArgs($select, [new TrustingSql92Platform()]), ); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test order() correctly splits parameters.')] - public function testOrderCorrectlySplitsParameter(): void + public function orderCorrectlySplitsParameter(): void { $select = new Select(); $select->order('name desc'); - self::assertEquals( + static::assertSame( 'SELECT * ORDER BY "name" DESC', $select->getSqlString(new TrustingSql92Platform()), ); } - public function testOrderWithAssociativeArray(): void + #[\PHPUnit\Framework\Attributes\Test] + public function orderWithAssociativeArray(): void { $select = new Select(); $select->from('foo')->order(['name' => 'DESC']); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('ORDER BY "name" DESC', $sql); + static::assertStringContainsString('ORDER BY "name" DESC', $sql); } - public function testOrderWithExpressionObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function orderWithExpressionObject(): void { $select = new Select(); $select->from('foo')->order(new Expression('RAND()')); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('ORDER BY RAND()', $sql); + static::assertStringContainsString('ORDER BY RAND()', $sql); } - public function testOrderWithStringContainingDirection(): void + #[\PHPUnit\Framework\Attributes\Test] + public function orderWithStringContainingDirection(): void { $select = new Select(); $select->from('foo')->order('name DESC'); $sql = $select->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('ORDER BY "name" DESC', $sql); + static::assertStringContainsString('ORDER BY "name" DESC', $sql); } /** @noinspection PhpUnusedParameterInspection */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('providerData')] #[TestDox('unit test: Test prepareStatement() will produce expected sql and parameters based on a variety of provided arguments [uses data provider]')] - public function testPrepareStatement( + public function prepareStatement( Select $select, string $expectedSqlString, array $expectedParameters, @@ -1377,12 +1413,12 @@ public function testPrepareStatement( $mockStatement = $this->getMockBuilder(StatementInterface::class)->getMock(); $mockStatement->expects($this->any())->method('getParameterContainer')->willReturn($parameterContainer); - $mockStatement->expects($this->any())->method('setSql')->with($this->equalTo($expectedSqlString)); + $mockStatement->expects($this->any())->method('setSql')->with(static::equalTo($expectedSqlString)); $select->prepareStatement($mockAdapter, $mockStatement); if ([] !== $expectedParameters) { - self::assertEquals($expectedParameters, $parameterContainer->getNamedArray()); + static::assertEquals($expectedParameters, $parameterContainer->getNamedArray()); } } @@ -1390,10 +1426,11 @@ public function testPrepareStatement( * @throws ReflectionException * @noinspection PhpUnusedParameterInspection */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('providerData')] #[TestDox('unit test: Text process*() methods will return proper array when internally called, part of extension API')] - public function testProcessMethods( + public function processMethods( Select $select, mixed $unused, mixed $unused2, @@ -1419,12 +1456,13 @@ public function testProcessMethods( $mr = $sr->getMethod($method); /** @psalm-suppress MixedAssignment */ $return = $mr->invokeArgs($select, [new Sql92(), $mockDriver, $parameterContainer]); - self::assertEquals($expected, $return); + static::assertEquals($expected, $return); } } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test quantifier() returns Select object (is chainable)')] - public function testQuantifier(): void + public function quantifier(): void { $select = new Select(); @@ -1432,128 +1470,133 @@ public function testQuantifier(): void $result = $select->quantifier(Select::QUANTIFIER_DISTINCT); // Verify fluent interface - self::assertSame($select, $result); + static::assertSame($select, $result); // Verify the first mutation occurred - self::assertEquals(Select::QUANTIFIER_DISTINCT, $select->getRawState('quantifier')); + static::assertEquals(Select::QUANTIFIER_DISTINCT, $select->getRawState('quantifier')); // Second mutation to verify mutability $select->quantifier(Select::QUANTIFIER_ALL); // Verify the instance was actually mutated - self::assertEquals(Select::QUANTIFIER_ALL, $select->getRawState('quantifier')); + static::assertEquals(Select::QUANTIFIER_ALL, $select->getRawState('quantifier')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test quantifier() accepts expression')] - public function testQuantifierParameterExpressionInterface(): void + public function quantifierParameterExpressionInterface(): void { $expr = $this->getMockBuilder(ExpressionInterface::class)->onlyMethods([])->getMock(); $select = new Select(); /** @psalm-suppress InvalidArgument */ $select->quantifier($expr); - self::assertSame( + static::assertSame( $expr, $select->getRawState(Select::QUANTIFIER), ); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test reset() resets internal stat of Select object, based on input')] - public function testReset(): void + public function reset(): void { $select = new Select(); // table $select->from('foo'); - self::assertEquals('foo', $select->getRawState(Select::TABLE)); + static::assertSame('foo', $select->getRawState(Select::TABLE)); $select->reset(Select::TABLE); - self::assertNull($select->getRawState(Select::TABLE)); + static::assertNull($select->getRawState(Select::TABLE)); // columns $select->columns(['foo']); - self::assertEquals(['foo'], $select->getRawState(Select::COLUMNS)); + static::assertEquals(['foo'], $select->getRawState(Select::COLUMNS)); $select->reset(Select::COLUMNS); - self::assertEmpty($select->getRawState(Select::COLUMNS)); + static::assertEmpty($select->getRawState(Select::COLUMNS)); // joins $select->join('foo', 'id = boo'); $joins = $select->getRawState(Select::JOINS); - self::assertInstanceOf(Join::class, $joins); - self::assertEquals( + static::assertInstanceOf(Join::class, $joins); + static::assertEquals( [['name' => 'foo', 'on' => 'id = boo', 'columns' => ['*'], 'type' => 'inner']], $joins->getJoins(), ); $select->reset(Select::JOINS); $emptyJoins = $select->getRawState(Select::JOINS); - self::assertInstanceOf(Join::class, $emptyJoins); - self::assertEmpty($emptyJoins->getJoins()); + static::assertInstanceOf(Join::class, $emptyJoins); + static::assertEmpty($emptyJoins->getJoins()); // where $select->where('foo = bar'); /** @var Where $where1 */ $where1 = $select->getRawState(Select::WHERE); - self::assertEquals(1, $where1->count()); + static::assertSame(1, $where1->count()); $select->reset(Select::WHERE); /** @var Where $where2 */ $where2 = $select->getRawState(Select::WHERE); - self::assertEquals(0, $where2->count()); - self::assertNotSame($where1, $where2); + static::assertSame(0, $where2->count()); + static::assertNotSame($where1, $where2); // group $select->group(['foo']); - self::assertEquals(['foo'], $select->getRawState(Select::GROUP)); + static::assertEquals(['foo'], $select->getRawState(Select::GROUP)); $select->reset(Select::GROUP); - self::assertEmpty($select->getRawState(Select::GROUP)); + static::assertEmpty($select->getRawState(Select::GROUP)); // having $select->having('foo = bar'); /** @var Having $having1 */ $having1 = $select->getRawState(Select::HAVING); - self::assertEquals(1, $having1->count()); + static::assertSame(1, $having1->count()); $select->reset(Select::HAVING); /** @var Having $having2 */ $having2 = $select->getRawState(Select::HAVING); - self::assertEquals(0, $having2->count()); - self::assertNotSame($having1, $having2); + static::assertSame(0, $having2->count()); + static::assertNotSame($having1, $having2); // limit $select->limit(5); - self::assertEquals(5, $select->getRawState(Select::LIMIT)); + static::assertSame(5, $select->getRawState(Select::LIMIT)); $select->reset(Select::LIMIT); - self::assertNull($select->getRawState(Select::LIMIT)); + static::assertNull($select->getRawState(Select::LIMIT)); // offset $select->offset(10); - self::assertEquals(10, $select->getRawState(Select::OFFSET)); + static::assertSame(10, $select->getRawState(Select::OFFSET)); $select->reset(Select::OFFSET); - self::assertNull($select->getRawState(Select::OFFSET)); + static::assertNull($select->getRawState(Select::OFFSET)); // order $select->order('foo asc'); - self::assertEquals(['foo asc'], $select->getRawState(Select::ORDER)); + static::assertEquals(['foo asc'], $select->getRawState(Select::ORDER)); $select->reset(Select::ORDER); - self::assertEmpty($select->getRawState(Select::ORDER)); + static::assertEmpty($select->getRawState(Select::ORDER)); } - public function testResetCombine(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resetCombine(): void { $select = new Select(); $select->from('t1'); $select->combine(new Select('t2')); $select->reset(Select::COMBINE); - self::assertEmpty($select->getRawState(Select::COMBINE)); + static::assertEmpty($select->getRawState(Select::COMBINE)); } - public function testResetQuantifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resetQuantifier(): void { $select = new Select(); $select->from('foo')->quantifier(Select::QUANTIFIER_DISTINCT); $select->reset(Select::QUANTIFIER); - self::assertNull($select->getRawState(Select::QUANTIFIER)); + static::assertNull($select->getRawState(Select::QUANTIFIER)); } - public function testResetTableThrowsWhenTableReadOnly(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resetTableThrowsWhenTableReadOnly(): void { $select = new Select('foo'); @@ -1562,37 +1605,41 @@ public function testResetTableThrowsWhenTableReadOnly(): void $select->reset(Select::TABLE); } - public function testResetThrowsOnInvalidPart(): void + #[\PHPUnit\Framework\Attributes\Test] + public function resetThrowsOnInvalidPart(): void { $select = new Select(); $result = $select->reset('invalid'); - self::assertSame($select, $result); + static::assertSame($select, $result); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-5192')] - public function testSelectUsingTableIdentifierWithEmptyScheme(): void + public function selectUsingTableIdentifierWithEmptyScheme(): void { $select = new Select(); $select->from(new TableIdentifier('foo')); $select->join(new TableIdentifier('bar'), 'foo.id = bar.fooid'); - self::assertEquals( + static::assertSame( 'SELECT "foo".*, "bar".* FROM "foo" INNER JOIN "bar" ON "foo"."id" = "bar"."fooid"', $select->getSqlString(new TrustingSql92Platform()), ); } - public function testSetSpecificationStoresValidSpecification(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setSpecificationStoresValidSpecification(): void { $select = new Select(); $select->setSpecification('Select', 'CUSTOM %1$s FROM %2$s'); $rawState = (new ReflectionObject($select))->getProperty('specifications'); - self::assertSame('CUSTOM %1$s FROM %2$s', $rawState->getValue($select)['Select']); + static::assertSame('CUSTOM %1$s FROM %2$s', $rawState->getValue($select)['Select']); } - public function testSetSpecificationThrowsExceptionForInvalidName(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setSpecificationThrowsExceptionForInvalidName(): void { $select = new Select(); @@ -1601,8 +1648,9 @@ public function testSetSpecificationThrowsExceptionForInvalidName(): void $select->setSpecification('invalid_spec', 'some spec'); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] - public function testWhereAcceptsExpressionInterface(): void + public function whereAcceptsExpressionInterface(): void { $select = new Select(); $select->from('foo') @@ -1611,13 +1659,14 @@ public function testWhereAcceptsExpressionInterface(): void ]); $where = $select->getRawState('where'); - self::assertInstanceOf(Where::class, $where); - self::assertEquals(1, $where->count()); + static::assertInstanceOf(Where::class, $where); + static::assertSame(1, $where->count()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept an array with a string key (containing ?) used as an expression with placeholder')] - public function testWhereArgument1IsAssociativeArrayContainingReplacementCharacter(): void + public function whereArgument1IsAssociativeArrayContainingReplacementCharacter(): void { $select = new Select(); $select->where(['foo > ?' => 5]); @@ -1627,18 +1676,19 @@ public function testWhereArgument1IsAssociativeArrayContainingReplacementCharact $predicates = $where->getPredicates(); $expression = new Value(5); - self::assertCount(1, $predicates); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Predicate\Expression::class, $predicates[0][1]); - self::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); - self::assertEquals('foo > ?', $predicates[0][1]->getExpression()); - self::assertEquals([$expression], $predicates[0][1]->getParameters()); + static::assertCount(1, $predicates); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Predicate\Expression::class, $predicates[0][1]); + static::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); + static::assertSame('foo > ?', $predicates[0][1]->getExpression()); + static::assertEquals([$expression], $predicates[0][1]->getParameters()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox(' unit test: Test where() will accept any array with string key (without ?) with Predicate throw Exception ')] - public function testWhereArgument1IsAssociativeArrayIsPredicate(): void + public function whereArgument1IsAssociativeArrayIsPredicate(): void { $select = new Select(); $where = [ @@ -1650,9 +1700,10 @@ public function testWhereArgument1IsAssociativeArrayIsPredicate(): void $select->where($where); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept any array with string key (without ?) to be used as Operator predicate')] - public function testWhereArgument1IsAssociativeArrayNotContainingReplacementCharacter(): void + public function whereArgument1IsAssociativeArrayNotContainingReplacementCharacter(): void { $select = new Select(); $select->where(['name' => 'Ralph', 'age' => 33]); @@ -1665,19 +1716,19 @@ public function testWhereArgument1IsAssociativeArrayNotContainingReplacementChar /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertCount(2, $predicates); - self::assertIsArray($predicates[0]); - self::assertIsArray($predicates[1]); + static::assertCount(2, $predicates); + static::assertIsArray($predicates[0]); + static::assertIsArray($predicates[1]); - self::assertInstanceOf(Operator::class, $predicates[0][1]); - self::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); - self::assertEquals($identifier1, $predicates[0][1]->getLeft()); - self::assertEquals($expression1, $predicates[0][1]->getRight()); + static::assertInstanceOf(Operator::class, $predicates[0][1]); + static::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); + static::assertEquals($identifier1, $predicates[0][1]->getLeft()); + static::assertEquals($expression1, $predicates[0][1]->getRight()); - self::assertInstanceOf(Operator::class, $predicates[1][1]); - self::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[1][0]); - self::assertEquals($identifier2, $predicates[1][1]->getLeft()); - self::assertEquals($expression2, $predicates[1][1]->getRight()); + static::assertInstanceOf(Operator::class, $predicates[1][1]); + static::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[1][0]); + static::assertEquals($identifier2, $predicates[1][1]->getLeft()); + static::assertEquals($expression2, $predicates[1][1]->getRight()); $select = new Select(); $select->where(['x = y']); @@ -1685,12 +1736,13 @@ public function testWhereArgument1IsAssociativeArrayNotContainingReplacementChar /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept a closure to be executed with Where object as argument')] - public function testWhereArgument1IsClosure(): void + public function whereArgument1IsClosure(): void { $select = new Select(); /** @var Where $where */ @@ -1701,8 +1753,9 @@ public function testWhereArgument1IsClosure(): void }); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept an indexed array to be used by joining string expressions')] - public function testWhereArgument1IsIndexedArray(): void + public function whereArgument1IsIndexedArray(): void { $select = new Select(); $select->where(['name = "Ralph"']); @@ -1710,16 +1763,17 @@ public function testWhereArgument1IsIndexedArray(): void /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertCount(1, $predicates); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); - self::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); - self::assertEquals('name = "Ralph"', $predicates[0][1]->getLiteral()); + static::assertCount(1, $predicates); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); + static::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); + static::assertSame('name = "Ralph"', $predicates[0][1]->getLiteral()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept an indexed array to be used by joining string expressions, combined by OR')] - public function testWhereArgument1IsIndexedArrayArgument2IsOr(): void + public function whereArgument1IsIndexedArrayArgument2IsOr(): void { $select = new Select(); $select->where(['name = "Ralph"'], Predicate\PredicateSet::OP_OR); @@ -1727,15 +1781,16 @@ public function testWhereArgument1IsIndexedArrayArgument2IsOr(): void /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertCount(1, $predicates); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); - self::assertEquals(Predicate\PredicateSet::OP_OR, $predicates[0][0]); - self::assertEquals('name = "Ralph"', $predicates[0][1]->getLiteral()); + static::assertCount(1, $predicates); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); + static::assertEquals(Predicate\PredicateSet::OP_OR, $predicates[0][0]); + static::assertSame('name = "Ralph"', $predicates[0][1]->getLiteral()); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept any Predicate object as-is')] - public function testWhereArgument1IsPredicate(): void + public function whereArgument1IsPredicate(): void { $select = new Select(); $predicate = new Predicate\Predicate([ @@ -1747,12 +1802,13 @@ public function testWhereArgument1IsPredicate(): void /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertIsArray($predicates[0]); - self::assertSame($predicate, $predicates[0][1]); + static::assertIsArray($predicates[0]); + static::assertSame($predicate, $predicates[0][1]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept a string for the predicate to create an expression predicate')] - public function testWhereArgument1IsString(): void + public function whereArgument1IsString(): void { $select = new Select(); $select->where('x = ?'); @@ -1760,11 +1816,11 @@ public function testWhereArgument1IsString(): void /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertCount(1, $predicates); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Predicate\Expression::class, $predicates[0][1]); - self::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); - self::assertEquals('x = ?', $predicates[0][1]->getExpression()); + static::assertCount(1, $predicates); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Predicate\Expression::class, $predicates[0][1]); + static::assertEquals(Predicate\PredicateSet::OP_AND, $predicates[0][0]); + static::assertSame('x = ?', $predicates[0][1]->getExpression()); $select = new Select(); $select->where('x = y'); @@ -1772,22 +1828,24 @@ public function testWhereArgument1IsString(): void /** @var Where $where */ $where = $select->getRawState('where'); $predicates = $where->getPredicates(); - self::assertIsArray($predicates[0]); - self::assertInstanceOf(Literal::class, $predicates[0][1]); + static::assertIsArray($predicates[0]); + static::assertInstanceOf(Literal::class, $predicates[0][1]); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() will accept a Where object')] - public function testWhereArgument1IsWhereObject(): void + public function whereArgument1IsWhereObject(): void { $select = new Select(); $select->where($newWhere = new Where()); - self::assertSame($newWhere, $select->getRawState('where')); + static::assertSame($newWhere, $select->getRawState('where')); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() returns Select object (is chainable)')] - public function testWhereReturnsSameSelectObject(): void + public function whereReturnsSameSelectObject(): void { $select = new Select(); - self::assertSame($select, $select->where('x = y')); + static::assertSame($select, $select->where('x = y')); } } diff --git a/test/unit/Sql/SqlTest.php b/test/unit/Sql/SqlTest.php index 39bcedc9..7f462ed6 100644 --- a/test/unit/Sql/SqlTest.php +++ b/test/unit/Sql/SqlTest.php @@ -49,29 +49,32 @@ final class SqlTest extends TestCase protected Sql $sql; // @codingStandardsIgnoreStart - public function test__construct(): void + #[\PHPUnit\Framework\Attributes\Test] + public function _construct(): void { // @codingStandardsIgnoreEnd $sql = new Sql($this->mockAdapter); - self::assertFalse($sql->hasTable()); + static::assertFalse($sql->hasTable()); $sql->setTable('foo'); - self::assertSame('foo', $sql->getTable()); + static::assertSame('foo', $sql->getTable()); self::expectException(TypeError::class); /** @noinspection PhpStrictTypeCheckingInspection */ $sql->setTable(null); } - public function testBuildSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function buildSqlString(): void { $select = $this->sql->select()->where(['bar' => 'baz']); $sqlString = $this->sql->buildSqlString($select); - self::assertEquals('SELECT "foo".* FROM "foo" WHERE "bar" = \'baz\'', $sqlString); + static::assertSame('SELECT "foo".* FROM "foo" WHERE "bar" = \'baz\'', $sqlString); } - public function testBuildSqlStringThrowsWhenPlatformNotSqlInterface(): void + #[\PHPUnit\Framework\Attributes\Test] + public function buildSqlStringThrowsWhenPlatformNotSqlInterface(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $platform = $this->createMock(PlatformInterface::class); @@ -92,12 +95,13 @@ public function testBuildSqlStringThrowsWhenPlatformNotSqlInterface(): void $sql->buildSqlString($this->sql->select()); } - public function testDelete(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delete(): void { $delete = $this->sql->delete(); - self::assertInstanceOf(Delete::class, $delete); - self::assertSame('foo', $delete->getRawState('table')); + static::assertInstanceOf(Delete::class, $delete); + static::assertSame('foo', $delete->getRawState('table')); self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -106,7 +110,8 @@ public function testDelete(): void $this->sql->delete('bar'); } - public function testDeleteThrowsWhenTableConflicts(): void + #[\PHPUnit\Framework\Attributes\Test] + public function deleteThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -115,16 +120,18 @@ public function testDeleteThrowsWhenTableConflicts(): void $this->sql->delete(new TableIdentifier('bar')); } - public function testGetSqlPlatformReturnsPlatformDecorator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlPlatformReturnsPlatformDecorator(): void { - self::assertInstanceOf(PlatformDecoratorInterface::class, $this->sql->getSqlPlatform()); + static::assertInstanceOf(PlatformDecoratorInterface::class, $this->sql->getSqlPlatform()); } - public function testInsert(): void + #[\PHPUnit\Framework\Attributes\Test] + public function insert(): void { $insert = $this->sql->insert(); - self::assertInstanceOf(Insert::class, $insert); - self::assertSame('foo', $insert->getRawState('table')); + static::assertInstanceOf(Insert::class, $insert); + static::assertSame('foo', $insert->getRawState('table')); self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -133,7 +140,8 @@ public function testInsert(): void $this->sql->insert('bar'); } - public function testInsertThrowsWhenTableConflicts(): void + #[\PHPUnit\Framework\Attributes\Test] + public function insertThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -142,14 +150,16 @@ public function testInsertThrowsWhenTableConflicts(): void $this->sql->insert(new TableIdentifier('bar')); } - public function testPrepareStatementForSqlObject(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementForSqlObject(): void { $insert = $this->sql->insert()->columns(['foo'])->values(['foo' => 'bar']); $stmt = $this->sql->prepareStatementForSqlObject($insert); - self::assertInstanceOf(StatementInterface::class, $stmt); + static::assertInstanceOf(StatementInterface::class, $stmt); } - public function testPrepareStatementThrowsWhenPlatformNotPreparable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatementThrowsWhenPlatformNotPreparable(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $platform = $this->createMock(PlatformInterface::class); @@ -170,11 +180,12 @@ public function testPrepareStatementThrowsWhenPlatformNotPreparable(): void $sql->prepareStatementForSqlObject($this->sql->select()); } - public function testSelect(): void + #[\PHPUnit\Framework\Attributes\Test] + public function select(): void { $select = $this->sql->select(); - self::assertInstanceOf(Select::class, $select); - self::assertSame('foo', $select->getRawState('table')); + static::assertInstanceOf(Select::class, $select); + static::assertSame('foo', $select->getRawState('table')); self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -183,7 +194,8 @@ public function testSelect(): void $this->sql->select('bar'); } - public function testSelectThrowsWhenTableConflicts(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -192,11 +204,12 @@ public function testSelectThrowsWhenTableConflicts(): void $this->sql->select(new TableIdentifier('bar')); } - public function testUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function update(): void { $update = $this->sql->update(); - self::assertInstanceOf(Update::class, $update); - self::assertSame('foo', $update->getRawState('table')); + static::assertInstanceOf(Update::class, $update); + static::assertSame('foo', $update->getRawState('table')); self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -205,7 +218,8 @@ public function testUpdate(): void $this->sql->update('bar'); } - public function testUpdateThrowsWhenTableConflicts(): void + #[\PHPUnit\Framework\Attributes\Test] + public function updateThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( diff --git a/test/unit/Sql/TableIdentifierFactoryTest.php b/test/unit/Sql/TableIdentifierFactoryTest.php index 7d7b88bb..08c80875 100644 --- a/test/unit/Sql/TableIdentifierFactoryTest.php +++ b/test/unit/Sql/TableIdentifierFactoryTest.php @@ -14,96 +14,107 @@ #[CoversClass(TableIdentifierFactory::class)] final class TableIdentifierFactoryTest extends TestCase { - public function testCallTimePrefixIsAppliedWhenNonePreconfigured(): void + #[\PHPUnit\Framework\Attributes\Test] + public function callTimePrefixIsAppliedWhenNonePreconfigured(): void { $factory = new TableIdentifierFactory(); $tableIdentifier = $factory('users', null, 'archive'); - self::assertSame('archive', $tableIdentifier->getPrefix()); - self::assertSame('archive_users', $tableIdentifier->getTable()); + static::assertSame('archive', $tableIdentifier->getPrefix()); + static::assertSame('archive_users', $tableIdentifier->getTable()); } - public function testCallTimePrefixOverridesConfiguredPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function callTimePrefixOverridesConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); $tableIdentifier = $factory('users', null, 'archive'); - self::assertSame('archive', $tableIdentifier->getPrefix()); - self::assertSame('archive_users', $tableIdentifier->getTable()); + static::assertSame('archive', $tableIdentifier->getPrefix()); + static::assertSame('archive_users', $tableIdentifier->getTable()); } - public function testCallTimeSeparatorIsAppliedWhenNonePreconfigured(): void + #[\PHPUnit\Framework\Attributes\Test] + public function callTimeSeparatorIsAppliedWhenNonePreconfigured(): void { $factory = new TableIdentifierFactory(); $tableIdentifier = $factory('users', null, 'archive', '__'); - self::assertSame('__', $tableIdentifier->getSeparator()); - self::assertSame('archive__users', $tableIdentifier->getTable()); + static::assertSame('__', $tableIdentifier->getSeparator()); + static::assertSame('archive__users', $tableIdentifier->getTable()); } - public function testCallTimeSeparatorOverridesConfiguredSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function callTimeSeparatorOverridesConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); $tableIdentifier = $factory('users', null, null, '_'); - self::assertSame('_', $tableIdentifier->getSeparator()); - self::assertSame('backup_users', $tableIdentifier->getTable()); + static::assertSame('_', $tableIdentifier->getSeparator()); + static::assertSame('backup_users', $tableIdentifier->getTable()); } - public function testConfiguredSeparatorIsCarriedButUnusedWhenNoPrefixApplies(): void + #[\PHPUnit\Framework\Attributes\Test] + public function configuredSeparatorIsCarriedButUnusedWhenNoPrefixApplies(): void { $factory = new TableIdentifierFactory(null, '__'); $tableIdentifier = $factory('users'); - self::assertSame('__', $tableIdentifier->getSeparator()); - self::assertNull($tableIdentifier->getPrefix()); - self::assertSame('users', $tableIdentifier->getTable()); + static::assertSame('__', $tableIdentifier->getSeparator()); + static::assertNull($tableIdentifier->getPrefix()); + static::assertSame('users', $tableIdentifier->getTable()); } - public function testCreatesIdentifierWithConfiguredPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createsIdentifierWithConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); $tableIdentifier = $factory('users'); - self::assertSame('backup', $tableIdentifier->getPrefix()); - self::assertSame('backup_users', $tableIdentifier->getTable()); - self::assertNull($tableIdentifier->getSchema()); + static::assertSame('backup', $tableIdentifier->getPrefix()); + static::assertSame('backup_users', $tableIdentifier->getTable()); + static::assertNull($tableIdentifier->getSchema()); } - public function testCreatesIdentifierWithConfiguredSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createsIdentifierWithConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); $tableIdentifier = $factory('users'); - self::assertSame('__', $tableIdentifier->getSeparator()); - self::assertSame('backup__users', $tableIdentifier->getTable()); + static::assertSame('__', $tableIdentifier->getSeparator()); + static::assertSame('backup__users', $tableIdentifier->getTable()); } - public function testCreatesIdentifierWithoutPrefixWhenNoneConfigured(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createsIdentifierWithoutPrefixWhenNoneConfigured(): void { $factory = new TableIdentifierFactory(); $tableIdentifier = $factory('users', 'public'); - self::assertNull($tableIdentifier->getPrefix()); - self::assertSame('users', $tableIdentifier->getTable()); + static::assertNull($tableIdentifier->getPrefix()); + static::assertSame('users', $tableIdentifier->getTable()); } - public function testCreatesIdentifierWithSchema(): void + #[\PHPUnit\Framework\Attributes\Test] + public function createsIdentifierWithSchema(): void { $factory = new TableIdentifierFactory('backup'); $tableIdentifier = $factory('users', 'public'); - self::assertSame(['backup_users', 'public'], $tableIdentifier->getTableAndSchema()); + static::assertSame(['backup_users', 'public'], $tableIdentifier->getTableAndSchema()); } - public function testPrefixIsNullByDefault(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prefixIsNullByDefault(): void { $factory = new TableIdentifierFactory(); - self::assertNull($factory->getPrefix()); + static::assertNull($factory->getPrefix()); } - public function testRejectsEmptyStringCallTimePrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringCallTimePrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -112,7 +123,8 @@ public function testRejectsEmptyStringCallTimePrefix(): void $factory('users', null, ''); } - public function testRejectsEmptyStringCallTimeSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringCallTimeSeparator(): void { $factory = new TableIdentifierFactory('backup'); @@ -121,59 +133,67 @@ public function testRejectsEmptyStringCallTimeSeparator(): void $factory('users', null, null, ''); } - public function testRejectsEmptyStringPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_PREFIX); new TableIdentifierFactory(''); } - public function testRejectsEmptyStringSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringSeparator(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifierFactory('backup', ''); } - public function testRejectsEmptyStringSeparatorWithoutPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifierFactory(null, ''); } - public function testReturnsConfiguredPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function returnsConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); - self::assertSame('backup', $factory->getPrefix()); + static::assertSame('backup', $factory->getPrefix()); } - public function testReturnsConfiguredSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function returnsConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); - self::assertSame('__', $factory->getSeparator()); + static::assertSame('__', $factory->getSeparator()); } - public function testSeparatorDefaultsToUnderscore(): void + #[\PHPUnit\Framework\Attributes\Test] + public function separatorDefaultsToUnderscore(): void { $factory = new TableIdentifierFactory('backup'); - self::assertSame('_', $factory->getSeparator()); + static::assertSame('_', $factory->getSeparator()); } - public function testSeparatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void + #[\PHPUnit\Framework\Attributes\Test] + public function separatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void { $factory = new TableIdentifierFactory(); - self::assertSame('_', $factory->getSeparator()); + static::assertSame('_', $factory->getSeparator()); } - public function testSeparatorFallsBackToDefaultWhenPassedAsNull(): void + #[\PHPUnit\Framework\Attributes\Test] + public function separatorFallsBackToDefaultWhenPassedAsNull(): void { $factory = new TableIdentifierFactory('backup', null); - self::assertSame('_', $factory->getSeparator()); + static::assertSame('_', $factory->getSeparator()); } } diff --git a/test/unit/Sql/TableIdentifierTest.php b/test/unit/Sql/TableIdentifierTest.php index 27fa7034..0f33fcee 100644 --- a/test/unit/Sql/TableIdentifierTest.php +++ b/test/unit/Sql/TableIdentifierTest.php @@ -48,151 +48,171 @@ public static function invalidTableProvider(): array ]; } - public function testGetDefaultPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDefaultPrefix(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertNull($tableIdentifier->getPrefix()); + static::assertNull($tableIdentifier->getPrefix()); } - public function testGetDefaultSchema(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDefaultSchema(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertNull($tableIdentifier->getSchema()); + static::assertNull($tableIdentifier->getSchema()); } - public function testGetDefaultSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getDefaultSeparator(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertSame('_', $tableIdentifier->getSeparator()); + static::assertSame('_', $tableIdentifier->getSeparator()); } - public function testGetPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getPrefix(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); - self::assertSame('backup', $tableIdentifier->getPrefix()); + static::assertSame('backup', $tableIdentifier->getPrefix()); } - public function testGetSchema(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSchema(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); - self::assertSame('bar', $tableIdentifier->getSchema()); + static::assertSame('bar', $tableIdentifier->getSchema()); } /** * @todo Review test to see if relevant? */ - public function testGetSchemaFromObjectStringCast(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSchemaFromObjectStringCast(): void { $schema = new ObjectToString('castResult'); $tableIdentifier = new TableIdentifier('foo', (string) $schema); - self::assertSame('castResult', $tableIdentifier->getSchema()); - self::assertSame('castResult', $tableIdentifier->getSchema()); + static::assertSame('castResult', $tableIdentifier->getSchema()); + static::assertSame('castResult', $tableIdentifier->getSchema()); } - public function testGetSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup', '__'); - self::assertSame('__', $tableIdentifier->getSeparator()); + static::assertSame('__', $tableIdentifier->getSeparator()); } - public function testGetTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTable(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertSame('foo', $tableIdentifier->getTable()); + static::assertSame('foo', $tableIdentifier->getTable()); } - public function testGetTableAndSchemaAppliesPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableAndSchemaAppliesPrefix(): void { $tableIdentifier = new TableIdentifier('foo', 'bar', 'backup'); - self::assertSame(['backup_foo', 'bar'], $tableIdentifier->getTableAndSchema()); + static::assertSame(['backup_foo', 'bar'], $tableIdentifier->getTableAndSchema()); } - public function testGetTableAndSchemaWithoutPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableAndSchemaWithoutPrefix(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); - self::assertSame(['foo', 'bar'], $tableIdentifier->getTableAndSchema()); + static::assertSame(['foo', 'bar'], $tableIdentifier->getTableAndSchema()); } - public function testGetTableAppliesPrefixWithCustomSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableAppliesPrefixWithCustomSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup', '__'); - self::assertSame('backup__foo', $tableIdentifier->getTable()); + static::assertSame('backup__foo', $tableIdentifier->getTable()); } - public function testGetTableAppliesPrefixWithDefaultSeparator(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableAppliesPrefixWithDefaultSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); - self::assertSame('backup_foo', $tableIdentifier->getTable()); + static::assertSame('backup_foo', $tableIdentifier->getTable()); } - public function testGetTableFromObjectStringCast(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableFromObjectStringCast(): void { $table = new ObjectToString('castResult'); $tableIdentifier = new TableIdentifier((string) $table); - self::assertSame('castResult', $tableIdentifier->getTable()); - self::assertSame('castResult', $tableIdentifier->getTable()); + static::assertSame('castResult', $tableIdentifier->getTable()); + static::assertSame('castResult', $tableIdentifier->getTable()); } - public function testGetTableIgnoresSeparatorWithoutPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTableIgnoresSeparatorWithoutPrefix(): void { $tableIdentifier = new TableIdentifier('foo', null, null, '__'); - self::assertSame('foo', $tableIdentifier->getTable()); + static::assertSame('foo', $tableIdentifier->getTable()); } - public function testGetUnprefixedTableReturnsTableAsGiven(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getUnprefixedTableReturnsTableAsGiven(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); - self::assertSame('foo', $tableIdentifier->getUnprefixedTable()); + static::assertSame('foo', $tableIdentifier->getUnprefixedTable()); } - public function testRejectsEmptyStringSeparatorWithoutPrefix(): void + #[\PHPUnit\Framework\Attributes\Test] + public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifier('foo', null, null, ''); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidNameArgumentProvider')] - public function testRejectsInvalidPrefix(mixed $invalidPrefix): void + public function rejectsInvalidPrefix(mixed $invalidPrefix): void { self::expectException('' === $invalidPrefix ? InvalidArgumentException::class : TypeError::class); /** @psalm-suppress MixedArgument */ new TableIdentifier('foo', 'bar', $invalidPrefix); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidNameArgumentProvider')] - public function testRejectsInvalidSchema(mixed $invalidSchema): void + public function rejectsInvalidSchema(mixed $invalidSchema): void { self::expectException('' === $invalidSchema ? InvalidArgumentException::class : TypeError::class); /** @psalm-suppress MixedArgument */ new TableIdentifier('foo', $invalidSchema); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidNameArgumentProvider')] - public function testRejectsInvalidSeparator(mixed $invalidSeparator): void + public function rejectsInvalidSeparator(mixed $invalidSeparator): void { self::expectException('' === $invalidSeparator ? InvalidArgumentException::class : TypeError::class); /** @psalm-suppress MixedArgument */ new TableIdentifier('foo', 'bar', 'backup', $invalidSeparator); } + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('invalidTableProvider')] - public function testRejectsInvalidTable(mixed $invalidTable): void + public function rejectsInvalidTable(mixed $invalidTable): void { self::expectException('' === $invalidTable ? InvalidArgumentException::class : TypeError::class); /** @psalm-suppress MixedArgument */ diff --git a/test/unit/Sql/UpdateTest.php b/test/unit/Sql/UpdateTest.php index f8131084..7df8d8ee 100644 --- a/test/unit/Sql/UpdateTest.php +++ b/test/unit/Sql/UpdateTest.php @@ -63,7 +63,8 @@ final class UpdateTest extends TestCase protected Update $update; - public function testCloneDeepCopiesSetWhereAndJoins(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneDeepCopiesSetWhereAndJoins(): void { $this->update ->table('foo') @@ -77,21 +78,22 @@ public function testCloneDeepCopiesSetWhereAndJoins(): void $clone->where('z = w'); $clone->join('another', 'foo.id = another.id'); - self::assertEquals(['bar' => 'baz'], $this->update->getRawState('set')); - self::assertEquals(['bar' => 'changed'], $clone->getRawState('set')); + static::assertEquals(['bar' => 'baz'], $this->update->getRawState('set')); + static::assertEquals(['bar' => 'changed'], $clone->getRawState('set')); - self::assertNotSame( + static::assertNotSame( $this->update->getRawState('where'), $clone->getRawState('where'), ); - self::assertNotSame( + static::assertNotSame( $this->update->getRawState('joins'), $clone->getRawState('joins'), ); } - public function testCloneUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneUpdate(): void { $update1 = clone $this->update; $update1->table('foo') @@ -104,7 +106,7 @@ public function testCloneUpdate(): void ->where([ 'id = ?' => 1, ]); - self::assertEquals( + static::assertSame( 'UPDATE "foo" SET "bar" = \'baz\' WHERE id = \'1\'', $update2->getSqlString(new TrustingSql92Platform()), ); @@ -113,34 +115,38 @@ public function testCloneUpdate(): void /** * @throws ReflectionException */ - public function testConstruct(): void + #[\PHPUnit\Framework\Attributes\Test] + public function construct(): void { $update = new Update('foo'); - self::assertEquals('foo', $this->readAttribute($update, 'table')); + static::assertSame('foo', static::readAttribute($update, 'table')); } - public function testConstructWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); $update = new Update($tableIdentifier); - self::assertEquals($tableIdentifier, $update->getRawState('table')); + static::assertEquals($tableIdentifier, $update->getRawState('table')); } - public function testGetRawState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawState(): void { $this->update ->table('foo') ->set(['bar' => 'baz']) ->where('x = y'); - self::assertEquals('foo', $this->update->getRawState('table')); - self::assertTrue($this->update->getRawState('emptyWhereProtection')); - self::assertEquals(['bar' => 'baz'], $this->update->getRawState('set')); - self::assertInstanceOf(Where::class, $this->update->getRawState('where')); + static::assertSame('foo', $this->update->getRawState('table')); + static::assertTrue($this->update->getRawState('emptyWhereProtection')); + static::assertEquals(['bar' => 'baz'], $this->update->getRawState('set')); + static::assertInstanceOf(Where::class, $this->update->getRawState('where')); } - public function testGetRawStateReturnsAllState(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getRawStateReturnsAllState(): void { $this->update ->table('foo') @@ -149,28 +155,29 @@ public function testGetRawStateReturnsAllState(): void $rawState = $this->update->getRawState(); - self::assertIsArray($rawState); - self::assertArrayHasKey('table', $rawState); - self::assertArrayHasKey('set', $rawState); - self::assertArrayHasKey('where', $rawState); - self::assertArrayHasKey('emptyWhereProtection', $rawState); - self::assertArrayHasKey('joins', $rawState); - - self::assertEquals('foo', $rawState['table']); - self::assertEquals(['bar' => 'baz'], $rawState['set']); - self::assertInstanceOf(Where::class, $rawState['where']); - self::assertInstanceOf(Join::class, $rawState['joins']); - self::assertTrue($rawState['emptyWhereProtection']); + static::assertIsArray($rawState); + static::assertArrayHasKey('table', $rawState); + static::assertArrayHasKey('set', $rawState); + static::assertArrayHasKey('where', $rawState); + static::assertArrayHasKey('emptyWhereProtection', $rawState); + static::assertArrayHasKey('joins', $rawState); + + static::assertSame('foo', $rawState['table']); + static::assertEquals(['bar' => 'baz'], $rawState['set']); + static::assertInstanceOf(Where::class, $rawState['where']); + static::assertInstanceOf(Join::class, $rawState['joins']); + static::assertTrue($rawState['emptyWhereProtection']); } - public function testGetSqlString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlString(): void { $this->update ->table('foo') ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); - self::assertEquals( + static::assertSame( 'UPDATE "foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()), ); @@ -182,52 +189,57 @@ public function testGetSqlString(): void ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); - self::assertEquals( + static::assertSame( 'UPDATE "sch"."foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()), ); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6768')] #[Group('6773')] - public function testGetSqlStringForFalseUpdateValueParameter(): void + public function getSqlStringForFalseUpdateValueParameter(): void { $this->update = new Update(); $this->update ->table(new TableIdentifier('foo', 'sch')) ->set(['bar' => false, 'boo' => 'test', 'bam' => true]) ->where('x = y'); - self::assertEquals( + static::assertSame( 'UPDATE "sch"."foo" SET "bar" = \'\', "boo" = \'test\', "bam" = \'1\' WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()), ); } - public function testGetSqlStringWithEmptyWhere(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSqlStringWithEmptyWhere(): void { $this->update->table('foo') ->set(['bar' => 'baz']); - self::assertEquals( + static::assertSame( 'UPDATE "foo" SET "bar" = \'baz\'', $this->update->getSqlString(new TrustingSql92Platform()), ); } - public function testGetUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getUpdate(): void { $getWhere = $this->update->__get('where'); - self::assertInstanceOf(Where::class, $getWhere); + static::assertInstanceOf(Where::class, $getWhere); } - public function testGetUpdateFails(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getUpdateFails(): void { /** @psalm-suppress UndefinedThisPropertyFetch - Ensure non-existent property returns null */ $getWhat = $this->update->__get('what'); - self::assertNull($getWhat); + static::assertNull($getWhat); } - public function testJoin(): void + #[\PHPUnit\Framework\Attributes\Test] + public function join(): void { $this->update->table('Document'); $this->update @@ -243,18 +255,19 @@ public function testJoin(): void Join::JOIN_LEFT, // (optional), one of inner, outer, left, right ); - self::assertEquals( + static::assertEquals( 'UPDATE "Document" INNER JOIN "User" ON "User"."UserId" = "Document"."UserId" ' . 'LEFT JOIN "Category" ON "Category"."CategoryId" = "Document"."CategoryId" SET "x" = \'y\'', $this->update->getSqlString(new TrustingSql92Platform()), ); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test join() returns Update object (is chainable)')] - public function testJoinChainable(): void + public function joinChainable(): void { $return = $this->update->join('baz', 'foo.fooId = baz.fooId', Join::JOIN_LEFT); - self::assertSame($this->update, $return); + static::assertSame($this->update, $return); } /** @@ -262,7 +275,8 @@ public function testJoinChainable(): void * Important when we're updating fields that are existing in several tables in one query. * The same test as above but here we will specify table in update params */ - public function testJoinMultiUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function joinMultiUpdate(): void { $this->update->table('Document'); $this->update @@ -277,14 +291,15 @@ public function testJoinMultiUpdate(): void Join::JOIN_LEFT, ); - self::assertEquals( + static::assertEquals( 'UPDATE "Document" INNER JOIN "User" ON "User"."UserId" = "Document"."UserId" ' . 'LEFT JOIN "Category" ON "Category"."CategoryId" = "Document"."CategoryId" SET "Documents"."x" = \'y\'', $this->update->getSqlString(new TrustingSql92Platform()), ); } - public function testJoinWithTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function joinWithTableIdentifier(): void { $this->update ->table('foo') @@ -292,23 +307,25 @@ public function testJoinWithTableIdentifier(): void ->join(new TableIdentifier('bar', 'schema'), 'foo.id = bar.foo_id'); $sql = $this->update->getSqlString(new TrustingSql92Platform()); - self::assertStringContainsString('JOIN "schema"."bar"', $sql); + static::assertStringContainsString('JOIN "schema"."bar"', $sql); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('Laminas-240')] - public function testPassingMultipleKeyValueInWhereClause(): void + public function passingMultipleKeyValueInWhereClause(): void { $update = clone $this->update; $update->table('table'); $update->set(['fld1' => 'val1']); $update->where(['id1' => 'val1', 'id2' => 'val2']); - self::assertEquals( + static::assertSame( 'UPDATE "table" SET "fld1" = \'val1\' WHERE "id1" = \'val1\' AND "id2" = \'val2\'', $update->getSqlString(new TrustingSql92Platform()), ); } - public function testPrepareStatement(): void + #[\PHPUnit\Framework\Attributes\Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -321,7 +338,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('UPDATE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); + ->with(static::equalTo('UPDATE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $this->update ->table('foo') @@ -344,7 +361,7 @@ public function testPrepareStatement(): void $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('UPDATE "sch"."foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); + ->with(static::equalTo('UPDATE "sch"."foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $this->update ->table(new TableIdentifier('foo', 'sch')) @@ -354,7 +371,8 @@ public function testPrepareStatement(): void $this->update->prepareStatement($mockAdapter, $mockStatement); } - public function testProcessSetWithPdoDriverUsesDriverColumnQuoting(): void + #[\PHPUnit\Framework\Attributes\Test] + public function processSetWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -371,26 +389,29 @@ public function testProcessSetWithPdoDriverUsesDriverColumnQuoting(): void $this->update->prepareStatement($mockAdapter, $mockStatement); $sql = $mockStatement->getSql(); - self::assertStringContainsString(':c_0', $sql); - self::assertStringContainsString(':c_1', $sql); + static::assertStringContainsString(':c_0', $sql); + static::assertStringContainsString(':c_1', $sql); } - public function testSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function set(): void { $this->update->set(['foo' => 'bar']); - self::assertEquals(['foo' => 'bar'], $this->update->getRawState('set')); + static::assertEquals(['foo' => 'bar'], $this->update->getRawState('set')); } - public function testSetWithMergeFlag(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setWithMergeFlag(): void { $this->update->set(['foo' => 'bar']); $this->update->set(['baz' => 'qux'], Update::VALUES_MERGE); $set = $this->update->getRawState('set'); - self::assertEquals(['foo' => 'bar', 'baz' => 'qux'], $set); + static::assertEquals(['foo' => 'bar', 'baz' => 'qux'], $set); } - public function testSetWithNonStringKeyThrowsException(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setWithNonStringKeyThrowsException(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::NON_STRING_VALUE_KEY); @@ -399,17 +420,19 @@ public function testSetWithNonStringKeyThrowsException(): void $this->update->set([0 => 'value']); } - public function testSetWithNumericPriority(): void + #[\PHPUnit\Framework\Attributes\Test] + public function setWithNumericPriority(): void { $this->update->set(['three' => 'c'], 30); $this->update->set(['one' => 'a'], 10); $this->update->set(['two' => 'b'], 20); $set = $this->update->getRawState('set'); - self::assertEquals(['one' => 'a', 'two' => 'b', 'three' => 'c'], $set); + static::assertEquals(['one' => 'a', 'two' => 'b', 'three' => 'c'], $set); } - public function testSortableSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function sortableSet(): void { $this->update->set([ 'two' => 'с_two', @@ -417,7 +440,7 @@ public function testSortableSet(): void ]); $this->update->set(['one' => 'с_one'], '10'); - self::assertEquals( + static::assertEquals( [ 'one' => 'с_one', 'two' => 'с_two', @@ -427,8 +450,9 @@ public function testSortableSet(): void ); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void + public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $this->update = new UpdateIgnore(); @@ -437,7 +461,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); - self::assertEquals( + static::assertSame( 'UPDATE IGNORE "foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()), ); @@ -449,14 +473,15 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlStr ->set(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]) ->where('x = y'); - self::assertEquals( + static::assertSame( 'UPDATE IGNORE "sch"."foo" SET "bar" = \'baz\', "boo" = NOW(), "bam" = NULL WHERE x = y', $this->update->getSqlString(new TrustingSql92Platform()), ); } + #[\PHPUnit\Framework\Attributes\Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $updateIgnore = new UpdateIgnore(); @@ -471,7 +496,7 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $mockStatement->expects($this->once()) ->method('setSql') - ->with($this->equalTo('UPDATE IGNORE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); + ->with(static::equalTo('UPDATE IGNORE "foo" SET "bar" = ?, "boo" = NOW() WHERE x = y')); $updateIgnore->table('foo') ->set(['bar' => 'baz', 'boo' => new Expression('NOW()')]) @@ -483,20 +508,22 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt /** * @throws ReflectionException */ - public function testTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function table(): void { $this->update->table('foo'); - self::assertEquals('foo', $this->readAttribute($this->update, 'table')); + static::assertSame('foo', static::readAttribute($this->update, 'table')); $tableIdentifier = new TableIdentifier('foo', 'bar'); $this->update->table($tableIdentifier); - self::assertEquals($tableIdentifier, $this->readAttribute($this->update, 'table')); + static::assertEquals($tableIdentifier, static::readAttribute($this->update, 'table')); } /** * @throws ReflectionException */ - public function testWhere(): void + #[\PHPUnit\Framework\Attributes\Test] + public function where(): void { $this->update->where('x = y'); $this->update->where(['foo > ?' => 5]); @@ -508,34 +535,34 @@ public function testWhere(): void $where = $this->update->where; - $predicates = $this->readAttribute($where, 'predicates'); + $predicates = static::readAttribute($where, 'predicates'); - self::assertIsArray($predicates); + static::assertIsArray($predicates); - self::assertEquals('AND', $predicates[0][0] ?? ''); - self::assertInstanceOf(Literal::class, $predicates[0][1] ?? null); + static::assertSame('AND', $predicates[0][0] ?? ''); + static::assertInstanceOf(Literal::class, $predicates[0][1] ?? null); - self::assertEquals('AND', $predicates[1][0] ?? ''); - self::assertInstanceOf(\PhpDb\Sql\Predicate\Expression::class, $predicates[1][1] ?? null); + static::assertSame('AND', $predicates[1][0] ?? ''); + static::assertInstanceOf(\PhpDb\Sql\Predicate\Expression::class, $predicates[1][1] ?? null); - self::assertEquals('AND', $predicates[2][0] ?? ''); - self::assertInstanceOf(Operator::class, $predicates[2][1] ?? null); + static::assertSame('AND', $predicates[2][0] ?? ''); + static::assertInstanceOf(Operator::class, $predicates[2][1] ?? null); - self::assertEquals('OR', $predicates[3][0] ?? ''); - self::assertInstanceOf(Literal::class, $predicates[3][1] ?? null); + static::assertSame('OR', $predicates[3][0] ?? ''); + static::assertInstanceOf(Literal::class, $predicates[3][1] ?? null); - self::assertEquals('AND', $predicates[4][0] ?? ''); - self::assertInstanceOf(IsNull::class, $predicates[4][1] ?? null); + static::assertSame('AND', $predicates[4][0] ?? ''); + static::assertInstanceOf(IsNull::class, $predicates[4][1] ?? null); - self::assertEquals('AND', $predicates[5][0] ?? ''); - self::assertInstanceOf(In::class, $predicates[5][1] ?? null); + static::assertSame('AND', $predicates[5][0] ?? ''); + static::assertInstanceOf(In::class, $predicates[5][1] ?? null); - self::assertEquals('AND', $predicates[6][0] ?? ''); - self::assertInstanceOf(IsNotNull::class, $predicates[6][1] ?? null); + static::assertSame('AND', $predicates[6][0] ?? ''); + static::assertInstanceOf(IsNotNull::class, $predicates[6][1] ?? null); $where = new Where(); $this->update->where($where); - self::assertSame($where, $this->update->where); + static::assertSame($where, $this->update->where); $this->update->where(static function (Where $what) use ($where): void { self::assertSame($where, $what); @@ -546,8 +573,9 @@ public function testWhere(): void $this->update->where(null); } + #[\PHPUnit\Framework\Attributes\Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] - public function testWhereAcceptsExpressionInterface(): void + public function whereAcceptsExpressionInterface(): void { $this->update ->table('foo') @@ -557,8 +585,8 @@ public function testWhereAcceptsExpressionInterface(): void ]); $where = $this->update->getRawState('where'); - self::assertInstanceOf(Where::class, $where); - self::assertEquals(1, $where->count()); + static::assertInstanceOf(Where::class, $where); + static::assertSame(1, $where->count()); } /** diff --git a/test/unit/TableGateway/AbstractTableGatewayTest.php b/test/unit/TableGateway/AbstractTableGatewayTest.php index 9624a1b8..550fb6cf 100644 --- a/test/unit/TableGateway/AbstractTableGatewayTest.php +++ b/test/unit/TableGateway/AbstractTableGatewayTest.php @@ -74,13 +74,15 @@ final class AbstractTableGatewayTest extends TestCase protected MockObject&Update $mockUpdate; protected MockObject&Delete $mockDelete; - public function testCloneKeepsTheAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneKeepsTheAdapter(): void { $cTable = clone $this->table; - self::assertSame($this->mockAdapter, $cTable->getAdapter()); + static::assertSame($this->mockAdapter, $cTable->getAdapter()); } - public function testCloneWithAnAliasedTableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneWithAnAliasedTableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); $aliasedTable = ['alias' => $tableIdentifier]; @@ -92,12 +94,13 @@ public function testCloneWithAnAliasedTableIdentifier(): void $cloned = clone $this->table; $clonedTable = $cloned->getTable(); - self::assertIsArray($clonedTable); + static::assertIsArray($clonedTable); // The TableIdentifier inside the array should be cloned - self::assertNotSame($tableIdentifier, $clonedTable['alias']); + static::assertNotSame($tableIdentifier, $clonedTable['alias']); } - public function testCloneWithATableIdentifier(): void + #[\PHPUnit\Framework\Attributes\Test] + public function cloneWithATableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); @@ -108,24 +111,26 @@ public function testCloneWithATableIdentifier(): void $cloned = clone $this->table; // The table should be cloned, not the same instance - self::assertNotSame($tableIdentifier, $cloned->getTable()); - self::assertEquals($tableIdentifier->getTable(), $cloned->getTable()->getTable()); + static::assertNotSame($tableIdentifier, $cloned->getTable()); + static::assertEquals($tableIdentifier->getTable(), $cloned->getTable()->getTable()); } - public function testDelete(): void + #[\PHPUnit\Framework\Attributes\Test] + public function delete(): void { $mockDelete = $this->mockDelete; // assert select::from() is called $mockDelete->expects($this->once()) ->method('where') - ->with($this->equalTo('foo')); + ->with(static::equalTo('foo')); $affectedRows = $this->table->delete('foo'); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testDeleteWith(): void + #[\PHPUnit\Framework\Attributes\Test] + public function deleteWith(): void { $delete = $this->getMockBuilder(Delete::class) ->onlyMethods(['getRawState']) @@ -137,10 +142,11 @@ public function testDeleteWith(): void ->willReturn(['table' => 'foo']); $affectedRows = $this->table->deleteWith($delete); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testDeleteWithClosure(): void + #[\PHPUnit\Framework\Attributes\Test] + public function deleteWithClosure(): void { // The closure receives the Delete object created by $this->sql->delete() // We verify that the closure is called with a Delete instance @@ -150,11 +156,12 @@ public function testDeleteWithClosure(): void self::assertInstanceOf(Delete::class, $delete); }); - self::assertTrue($closureCalled); - self::assertEquals(5, $affectedRows); + static::assertTrue($closureCalled); + static::assertSame(5, $affectedRows); } - public function testExecuteDeleteThrowsExceptionWhenTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeDeleteThrowsExceptionWhenTableDoesNotMatch(): void { $delete = new Delete('bar'); $delete->where(['id' => 1]); @@ -165,7 +172,8 @@ public function testExecuteDeleteThrowsExceptionWhenTableDoesNotMatch(): void $this->table->deleteWith($delete); } - public function testExecuteInsertThrowsExceptionWhenTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeInsertThrowsExceptionWhenTableDoesNotMatch(): void { $insert = new Insert('bar'); $insert->values(['name' => 'test']); @@ -176,7 +184,8 @@ public function testExecuteInsertThrowsExceptionWhenTableDoesNotMatch(): void $this->table->insertWith($insert); } - public function testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void { $select = $this->getMockBuilder(Select::class) ->onlyMethods(['getRawState']) @@ -197,7 +206,8 @@ public function testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch(): vo $this->table->selectWith($select); } - public function testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function executeUpdateThrowsExceptionWhenTableDoesNotMatch(): void { $update = new Update('bar'); $update->set(['name' => 'test']); @@ -208,47 +218,55 @@ public function testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch(): void $this->table->updateWith($update); } - public function testGetAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getAdapter(): void { - self::assertSame($this->mockAdapter, $this->table->getAdapter()); + static::assertSame($this->mockAdapter, $this->table->getAdapter()); } - public function testGetColumns(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getColumns(): void { $tgReflection = new ReflectionClass(AbstractTableGateway::class); $columnsProp = $tgReflection->getProperty('columns'); $columnsProp->setValue($this->table, ['id', 'name', 'email']); - self::assertEquals(['id', 'name', 'email'], $this->table->getColumns()); + static::assertEquals(['id', 'name', 'email'], $this->table->getColumns()); } - public function testGetFeatureSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getFeatureSet(): void { - self::assertSame($this->mockFeatureSet, $this->table->getFeatureSet()); + static::assertSame($this->mockFeatureSet, $this->table->getFeatureSet()); } - public function testGetLastInsertValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getLastInsertValue(): void { $this->table->insert(['foo' => 'bar']); - self::assertEquals(10, $this->table->getLastInsertValue()); + static::assertSame(10, $this->table->getLastInsertValue()); } - public function testGetSelectResultPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSelectResultPrototype(): void { - self::assertInstanceOf(ResultSet::class, $this->table->getResultSetPrototype()); + static::assertInstanceOf(ResultSet::class, $this->table->getResultSetPrototype()); } - public function testGetSql(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getSql(): void { - self::assertInstanceOf(Sql\Sql::class, $this->table->getSql()); + static::assertInstanceOf(Sql\Sql::class, $this->table->getSql()); } - public function testGetTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function getTable(): void { - self::assertEquals('foo', $this->table->getTable()); + static::assertSame('foo', $this->table->getTable()); } - public function testInitializeBuildsAResultSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeBuildsAResultSet(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -270,10 +288,11 @@ public function testInitializeBuildsAResultSet(): void } $stub->initialize(); - $this->assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype()); + static::assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype()); } - public function testInitializeEarlyReturnWhenAlreadyInitialized(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeEarlyReturnWhenAlreadyInitialized(): void { // Create a fresh mock without initialization $stub = $this->getMockBuilder(AbstractTableGateway::class) @@ -291,7 +310,7 @@ public function testInitializeEarlyReturnWhenAlreadyInitialized(): void // First initialization $stub->initialize(); - self::assertTrue($stub->isInitialized()); + static::assertTrue($stub->isInitialized()); // Get the featureSet that was created during first init $featureSetProp = $tgReflection->getProperty('featureSet'); @@ -301,10 +320,11 @@ public function testInitializeEarlyReturnWhenAlreadyInitialized(): void $stub->initialize(); // Verify featureSet is still the same object (proving early return was taken) - self::assertSame($originalFeatureSet, $featureSetProp->getValue($stub)); + static::assertSame($originalFeatureSet, $featureSetProp->getValue($stub)); } - public function testInitializeThrowsExceptionWithoutAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsExceptionWithoutAdapter(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -320,7 +340,8 @@ public function testInitializeThrowsExceptionWithoutAdapter(): void $stub->initialize(); } - public function testInitializeThrowsExceptionWithoutTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function initializeThrowsExceptionWithoutTable(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -336,7 +357,8 @@ public function testInitializeThrowsExceptionWithoutTable(): void $stub->initialize(); } - public function testInsert(): void + #[\PHPUnit\Framework\Attributes\Test] + public function insert(): void { $mockInsert = $this->mockInsert; @@ -346,29 +368,31 @@ public function testInsert(): void $mockInsert->expects($this->once()) ->method('values') - ->with($this->equalTo(['foo' => 'bar'])); + ->with(static::equalTo(['foo' => 'bar'])); $affectedRows = $this->table->insert(['foo' => 'bar']); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testInsertWith(): void + #[\PHPUnit\Framework\Attributes\Test] + public function insertWith(): void { $insert = new Insert('foo'); $insert->values(['column' => 'value']); $affectedRows = $this->table->insertWith($insert); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testIsInitialized(): void + #[\PHPUnit\Framework\Attributes\Test] + public function isInitialized(): void { // Create a fresh mock without initialization $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) ->getMock(); - self::assertFalse($stub->isInitialized()); + static::assertFalse($stub->isInitialized()); // Set required properties for initialization $tgReflection = new ReflectionClass(AbstractTableGateway::class); @@ -381,10 +405,11 @@ public function testIsInitialized(): void $stub->initialize(); - self::assertTrue($stub->isInitialized()); + static::assertTrue($stub->isInitialized()); } - public function testMagicCallDelegatesToTheFeatureSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicCallDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicCall $featureSet = $this->getMockBuilder(FeatureSet::class) @@ -406,10 +431,11 @@ public function testMagicCallDelegatesToTheFeatureSet(): void /** @phpstan-ignore method.notFound */ $result = $this->table->customMethod('arg1', 'arg2'); - self::assertEquals('customResult', $result); + static::assertSame('customResult', $result); } - public function testMagicCallThrowsForUnknownMethod(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicCallThrowsForUnknownMethod(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -420,7 +446,8 @@ public function testMagicCallThrowsForUnknownMethod(): void $this->table->invalidMethod(); } - public function testMagicGetDelegatesToTheFeatureSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetDelegatesToTheFeatureSet(): void { // Create a custom feature that can handle magic get $feature = new TestTableGatewayFeature(); @@ -446,35 +473,40 @@ public function testMagicGetDelegatesToTheFeatureSet(): void /** @phpstan-ignore property.notFound */ $result = $this->table->customProperty; - self::assertEquals('customValue', $result); + static::assertSame('customValue', $result); } - public function testMagicGetReturnsTheAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsTheAdapter(): void { - self::assertSame($this->mockAdapter, $this->table->adapter); + static::assertSame($this->mockAdapter, $this->table->adapter); } - public function testMagicGetReturnsTheLastInsertValue(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsTheLastInsertValue(): void { - self::assertNull($this->table->lastInsertValue); + static::assertNull($this->table->lastInsertValue); } - public function testMagicGetReturnsTheLastInsertValueAndAdapter(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsTheLastInsertValueAndAdapter(): void { $this->table->insert(['foo']); // trigger last insert id update - self::assertEquals(10, $this->table->lastInsertValue); - self::assertSame($this->mockAdapter, $this->table->adapter); + static::assertSame(10, $this->table->lastInsertValue); + static::assertSame($this->mockAdapter, $this->table->adapter); //self::assertEquals('foo', $this->table->table); } - public function testMagicGetReturnsTheTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetReturnsTheTable(): void { - self::assertEquals('foo', $this->table->table); + static::assertSame('foo', $this->table->table); } - public function testMagicGetThrowsForUnknownProperty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicGetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -485,7 +517,8 @@ public function testMagicGetThrowsForUnknownProperty(): void $this->table->invalidProperty; } - public function testMagicSetDelegatesToTheFeatureSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicSetDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicSet $featureSet = $this->getMockBuilder(FeatureSet::class) @@ -507,7 +540,8 @@ public function testMagicSetDelegatesToTheFeatureSet(): void $this->table->customProperty = 'customValue'; } - public function testMagicSetThrowsForUnknownProperty(): void + #[\PHPUnit\Framework\Attributes\Test] + public function magicSetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -518,7 +552,8 @@ public function testMagicSetThrowsForUnknownProperty(): void $this->table->invalidProperty = 'value'; } - public function testSelectAppliesColumnsWhenStarSelected(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectAppliesColumnsWhenStarSelected(): void { // Set up columns on the table $tgReflection = new ReflectionClass(AbstractTableGateway::class); @@ -544,7 +579,8 @@ public function testSelectAppliesColumnsWhenStarSelected(): void $this->table->selectWith($select); } - public function testSelectWithArrayTable(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectWithArrayTable(): void { // Case 1 $select1 = $this->getMockBuilder(Select::class)->onlyMethods(['getRawState'])->getMock(); @@ -555,7 +591,7 @@ public function testSelectWithArrayTable(): void 'columns' => null, ]); $return = $this->table->selectWith($select1); - $this->assertInstanceOf(ResultSet::class, $return); + static::assertInstanceOf(ResultSet::class, $return); // Case 2 $select1 = $this->getMockBuilder(Select::class)->onlyMethods(['getRawState'])->getMock(); @@ -566,10 +602,11 @@ public function testSelectWithArrayTable(): void 'columns' => null, ]); $return = $this->table->selectWith($select1); - $this->assertInstanceOf(ResultSet::class, $return); + static::assertInstanceOf(ResultSet::class, $return); } - public function testSelectWithClosure(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectWithClosure(): void { $mockSelect = $this->mockSelect; $mockSelect->expects($this->any()) @@ -585,20 +622,22 @@ public function testSelectWithClosure(): void self::assertInstanceOf(Select::class, $select); }); - self::assertTrue($closureCalled); - self::assertInstanceOf(ResultSet::class, $result); + static::assertTrue($closureCalled); + static::assertInstanceOf(ResultSet::class, $result); } - public function testSelectWithNoWhere(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectWithNoWhere(): void { $resultSet = $this->table->select(); // check return types - self::assertInstanceOf(ResultSet::class, $resultSet); - self::assertNotSame($this->table->getResultSetPrototype(), $resultSet); + static::assertInstanceOf(ResultSet::class, $resultSet); + static::assertNotSame($this->table->getResultSetPrototype(), $resultSet); } - public function testSelectWithWhereString(): void + #[\PHPUnit\Framework\Attributes\Test] + public function selectWithWhereString(): void { $mockSelect = $this->mockSelect; $mockSelect->expects($this->any()) @@ -611,25 +650,27 @@ public function testSelectWithWhereString(): void // assert select::from() is called $mockSelect->expects($this->once()) ->method('where') - ->with($this->equalTo('foo')); + ->with(static::equalTo('foo')); $this->table->select('foo'); } - public function testUpdate(): void + #[\PHPUnit\Framework\Attributes\Test] + public function update(): void { $mockUpdate = $this->mockUpdate; // assert select::from() is called $mockUpdate->expects($this->once()) ->method('where') - ->with($this->equalTo('id = 2')); + ->with(static::equalTo('id = 2')); $affectedRows = $this->table->update(['foo' => 'bar'], 'id = 2'); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testUpdateWith(): void + #[\PHPUnit\Framework\Attributes\Test] + public function updateWith(): void { $update = $this->getMockBuilder(Update::class) ->onlyMethods(['getRawState']) @@ -641,10 +682,11 @@ public function testUpdateWith(): void ->willReturn(['table' => 'foo']); $affectedRows = $this->table->updateWith($update); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testUpdateWithJoin(): void + #[\PHPUnit\Framework\Attributes\Test] + public function updateWithJoin(): void { $mockUpdate = $this->mockUpdate; @@ -659,17 +701,18 @@ public function testUpdateWithJoin(): void // assert select::from() is called $mockUpdate->expects($this->once()) ->method('where') - ->with($this->equalTo('id = 2')); + ->with(static::equalTo('id = 2')); $mockUpdate->expects($this->once()) ->method('join') ->with($joins[0]['name'], $joins[0]['on'], $joins[0]['type']); $affectedRows = $this->table->update(['foo.field' => 'bar'], 'id = 2', $joins); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testUpdateWithJoinDefaultType(): void + #[\PHPUnit\Framework\Attributes\Test] + public function updateWithJoinDefaultType(): void { $mockUpdate = $this->mockUpdate; @@ -683,23 +726,24 @@ public function testUpdateWithJoinDefaultType(): void // assert select::from() is called $mockUpdate->expects($this->once()) ->method('where') - ->with($this->equalTo('id = 2')); + ->with(static::equalTo('id = 2')); $mockUpdate->expects($this->once()) ->method('join') ->with($joins[0]['name'], $joins[0]['on'], Sql\Join::JOIN_INNER); $affectedRows = $this->table->update(['foo.field' => 'bar'], 'id = 2', $joins); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } - public function testUpdateWithNoCriteria(): void + #[\PHPUnit\Framework\Attributes\Test] + public function updateWithNoCriteria(): void { /** @phpstan-ignore expr.resultUnused */ $this->mockUpdate; $affectedRows = $this->table->update(['foo' => 'bar']); - self::assertEquals(5, $affectedRows); + static::assertSame(5, $affectedRows); } #[Override] diff --git a/test/unit/TableGateway/TableGatewayTest.php b/test/unit/TableGateway/TableGatewayTest.php index a9a6c27d..9a6ec199 100644 --- a/test/unit/TableGateway/TableGatewayTest.php +++ b/test/unit/TableGateway/TableGatewayTest.php @@ -53,7 +53,8 @@ public static function aliasedTables(): array /** * Beside other tests checks for plain string table identifier */ - public function testConstructor(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructor(): void { // constructor with only required args $table = new TableGateway( @@ -61,11 +62,11 @@ public function testConstructor(): void $this->mockAdapter, ); - self::assertEquals('foo', $table->getTable()); - self::assertSame($this->mockAdapter, $table->getAdapter()); - self::assertInstanceOf(FeatureSet::class, $table->getFeatureSet()); - self::assertInstanceOf(ResultSet::class, $table->getResultSetPrototype()); - self::assertInstanceOf(Sql::class, $table->getSql()); + static::assertSame('foo', $table->getTable()); + static::assertSame($this->mockAdapter, $table->getAdapter()); + static::assertInstanceOf(FeatureSet::class, $table->getFeatureSet()); + static::assertInstanceOf(ResultSet::class, $table->getResultSetPrototype()); + static::assertInstanceOf(Sql::class, $table->getSql()); // injecting all args $table = new TableGateway( @@ -76,11 +77,11 @@ public function testConstructor(): void $sql = new Sql($this->mockAdapter, 'foo'), ); - self::assertEquals('foo', $table->getTable()); - self::assertSame($this->mockAdapter, $table->getAdapter()); - self::assertSame($featureSet, $table->getFeatureSet()); - self::assertSame($resultSet, $table->getResultSetPrototype()); - self::assertSame($sql, $table->getSql()); + static::assertSame('foo', $table->getTable()); + static::assertSame($this->mockAdapter, $table->getAdapter()); + static::assertSame($featureSet, $table->getFeatureSet()); + static::assertSame($resultSet, $table->getResultSetPrototype()); + static::assertSame($sql, $table->getSql()); // constructor expects exception - native type declaration throws TypeError for null table self::expectException(TypeError::class); @@ -91,7 +92,8 @@ public function testConstructor(): void ); } - public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -103,7 +105,8 @@ public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new TableGateway('foo', $this->mockAdapter, null, null, $sql); } - public function testConstructorWithArrayOfFeatures(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithArrayOfFeatures(): void { $feature1 = new Feature\SequenceFeature('id', 'foo_seq'); $feature2 = new Feature\GlobalAdapterFeature(); @@ -114,50 +117,54 @@ public function testConstructorWithArrayOfFeatures(): void $table = new TableGateway('foo', $this->mockAdapter, [$feature1, $feature2]); $featureSet = $table->getFeatureSet(); - self::assertInstanceOf(FeatureSet::class, $featureSet); - self::assertSame($feature1, $featureSet->getFeatureByClassName(Feature\SequenceFeature::class)); - self::assertSame($feature2, $featureSet->getFeatureByClassName(Feature\GlobalAdapterFeature::class)); + static::assertInstanceOf(FeatureSet::class, $featureSet); + static::assertSame($feature1, $featureSet->getFeatureByClassName(Feature\SequenceFeature::class)); + static::assertSame($feature2, $featureSet->getFeatureByClassName(Feature\GlobalAdapterFeature::class)); // Clean up static adapter $reflection = new ReflectionProperty(Feature\GlobalAdapterFeature::class, 'staticAdapters'); $reflection->setValue(null, []); } - public function testConstructorWithCustomResultSetPrototype(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithCustomResultSetPrototype(): void { $resultSet = new ResultSet(); $table = new TableGateway('foo', $this->mockAdapter, null, $resultSet); - self::assertSame($resultSet, $table->getResultSetPrototype()); + static::assertSame($resultSet, $table->getResultSetPrototype()); } - public function testConstructorWithFeatureSet(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithFeatureSet(): void { $feature = new Feature\SequenceFeature('id', 'foo_seq'); $featureSet = new FeatureSet([$feature]); $table = new TableGateway('foo', $this->mockAdapter, $featureSet); - self::assertSame($featureSet, $table->getFeatureSet()); + static::assertSame($featureSet, $table->getFeatureSet()); } - public function testConstructorWithSingleFeature(): void + #[\PHPUnit\Framework\Attributes\Test] + public function constructorWithSingleFeature(): void { $feature = new Feature\SequenceFeature('id', 'foo_seq'); $table = new TableGateway('foo', $this->mockAdapter, $feature); $featureSet = $table->getFeatureSet(); - self::assertInstanceOf(FeatureSet::class, $featureSet); - self::assertSame($feature, $featureSet->getFeatureByClassName(Feature\SequenceFeature::class)); + static::assertInstanceOf(FeatureSet::class, $featureSet); + static::assertSame($feature, $featureSet->getFeatureByClassName(Feature\SequenceFeature::class)); } /** * @param AliasedTable $tableValue */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('aliasedTables')] - public function testDeleteShouldResetTableToUnaliasedTable( + public function deleteShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -194,7 +201,7 @@ public function testDeleteShouldResetTableToUnaliasedTable( ->willReturn($delete); $sql->expects($this->once()) ->method('prepareStatementForSqlObject') - ->with($this->equalTo($delete)) + ->with(static::equalTo($delete)) ->willReturnCallback($statementExpectation); $table = new TableGateway( @@ -211,9 +218,9 @@ public function testDeleteShouldResetTableToUnaliasedTable( $state = $delete->getRawState(); - $this->assertIsArray($state); - $this->assertIsArray($state['table']); - $this->assertEquals( + static::assertIsArray($state); + static::assertIsArray($state['table']); + static::assertEquals( $tableValue, $state['table'], ); @@ -222,9 +229,10 @@ public function testDeleteShouldResetTableToUnaliasedTable( /** * @param AliasedTable $tableValue */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('aliasedTables')] #[Group('7311')] - public function testInsertShouldResetTableToUnaliasedTable( + public function insertShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -261,7 +269,7 @@ public function testInsertShouldResetTableToUnaliasedTable( ->willReturn($insert); $sql->expects($this->once()) ->method('prepareStatementForSqlObject') - ->with($this->equalTo($insert)) + ->with(static::equalTo($insert)) ->willReturnCallback($statementExpectation); $table = new TableGateway( @@ -277,17 +285,18 @@ public function testInsertShouldResetTableToUnaliasedTable( ]); $state = $insert->getRawState(); - $this->assertIsArray($state); - $this->assertIsArray($state['table']); - $this->assertEquals( + static::assertIsArray($state); + static::assertIsArray($state['table']); + static::assertEquals( $tableValue, $state['table'], ); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6726')] #[Group('6740')] - public function testTableAsAliasedTableIdentifierObject(): void + public function tableAsAliasedTableIdentifierObject(): void { // phpcs:disable WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps $aliasedTI = ['foo' => new TableIdentifier('fooTable', 'barSchema')]; @@ -297,14 +306,15 @@ public function testTableAsAliasedTableIdentifierObject(): void $this->mockAdapter, ); - self::assertEquals($aliasedTI, $table->getTable()); + static::assertEquals($aliasedTI, $table->getTable()); // phpcs:enable WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6726')] #[Group('6740')] - public function testTableAsString(): void + public function tableAsString(): void { $ti = 'fooTable.barSchema'; // constructor with only required args @@ -313,12 +323,13 @@ public function testTableAsString(): void $this->mockAdapter, ); - self::assertEquals($ti, $table->getTable()); + static::assertEquals($ti, $table->getTable()); } + #[\PHPUnit\Framework\Attributes\Test] #[Group('6726')] #[Group('6740')] - public function testTableAsTableIdentifierObject(): void + public function tableAsTableIdentifierObject(): void { $ti = new TableIdentifier('fooTable', 'barSchema'); // constructor with only required args @@ -327,14 +338,15 @@ public function testTableAsTableIdentifierObject(): void $this->mockAdapter, ); - self::assertEquals($ti, $table->getTable()); + static::assertEquals($ti, $table->getTable()); } /** * @param AliasedTable $tableValue */ + #[\PHPUnit\Framework\Attributes\Test] #[DataProvider('aliasedTables')] - public function testUpdateShouldResetTableToUnaliasedTable( + public function updateShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -371,7 +383,7 @@ public function testUpdateShouldResetTableToUnaliasedTable( ->willReturn($update); $sql->expects($this->once()) ->method('prepareStatementForSqlObject') - ->with($this->equalTo($update)) + ->with(static::equalTo($update)) ->willReturnCallback($statementExpectation); $table = new TableGateway( @@ -389,9 +401,9 @@ public function testUpdateShouldResetTableToUnaliasedTable( ]); $state = $update->getRawState(); - $this->assertIsArray($state); - $this->assertIsArray($state['table']); - $this->assertEquals( + static::assertIsArray($state); + static::assertIsArray($state['table']); + static::assertEquals( $tableValue, $state['table'], ); From 37c7a483f9702feecaf4c83b4a91ff5a53759d62 Mon Sep 17 00:00:00 2001 From: Simon Mundy Date: Tue, 29 Sep 2026 15:18:00 +1000 Subject: [PATCH 3/3] Import the Test attribute and regenerate the lint baseline The first fix pass wrote the PHPUnit Test attribute fully qualified, which traded 3592 assertion and attribute issues for 1008 new no-fully-qualified-global-class-like ones. A second pass imports the attribute instead. The lint baseline now holds 348 issues, down from 3948. 249 sit in src and 99 in test, so test is no longer the bulk of the suppression. prefer-self-return-type is deliberately left unapplied: in ArrayObjectResultSetInterface it rewrites an intersection type to use self, which does not parse. --- lint-baseline.toml | 7402 +---------------- .../Driver/Pdo/AbstractAdapterTestCase.php | 5 +- test/unit/Adapter/AdapterAwareTraitTest.php | 5 +- test/unit/Adapter/AdapterTest.php | 59 +- .../AbstractAdapterInterfaceFactoryTest.php | 15 +- .../AdapterInterfaceDelegatorTest.php | 21 +- .../Adapter/Driver/AbstractConnectionTest.php | 21 +- .../Driver/Feature/AbstractFeatureTest.php | 3 +- .../DriverFeatureProviderTraitTest.php | 11 +- .../Adapter/Driver/Pdo/ConnectionTest.php | 27 +- .../Driver/Pdo/ConnectionTransactionsTest.php | 25 +- test/unit/Adapter/Driver/Pdo/PdoTest.php | 33 +- test/unit/Adapter/Driver/Pdo/ResultTest.php | 69 +- .../Driver/Pdo/StatementIntegrationTest.php | 9 +- .../unit/Adapter/Driver/Pdo/StatementTest.php | 71 +- ...validConnectionParametersExceptionTest.php | 3 +- test/unit/Adapter/ParameterContainerTest.php | 83 +- test/unit/Adapter/Platform/Sql92Test.php | 33 +- test/unit/Adapter/Profiler/ProfilerTest.php | 13 +- test/unit/Adapter/StatementContainerTest.php | 9 +- test/unit/ConfigProviderTest.php | 2 +- .../Container/AdapterInterfaceFactoryTest.php | 11 +- .../TableIdentifierFactoryFactoryTest.php | 19 +- .../AbstractResultSetIntegrationTest.php | 5 +- test/unit/ResultSet/AbstractResultSetTest.php | 58 +- .../HydratingResultSetIntegrationTest.php | 3 +- .../unit/ResultSet/HydratingResultSetTest.php | 27 +- .../ResultSet/ResultSetIntegrationTest.php | 49 +- .../RowGateway/AbstractRowGatewayTest.php | 55 +- test/unit/RowGateway/RowGatewayTest.php | 21 +- .../Sql/AbstractSqlFunctionalTestCase.php | 3 +- test/unit/Sql/AbstractSqlTest.php | 71 +- test/unit/Sql/Argument/LiteralTest.php | 7 +- test/unit/Sql/ArgumentTest.php | 29 +- test/unit/Sql/CombineTest.php | 25 +- test/unit/Sql/Ddl/AlterTableTest.php | 69 +- .../Ddl/Column/AbstractLengthColumnTest.php | 6 +- .../Column/AbstractPrecisionColumnTest.php | 10 +- test/unit/Sql/Ddl/Column/BigIntegerTest.php | 4 +- test/unit/Sql/Ddl/Column/BinaryTest.php | 2 +- test/unit/Sql/Ddl/Column/BlobTest.php | 2 +- test/unit/Sql/Ddl/Column/BooleanTest.php | 5 +- test/unit/Sql/Ddl/Column/CharTest.php | 2 +- test/unit/Sql/Ddl/Column/ColumnTest.php | 36 +- test/unit/Sql/Ddl/Column/DateTest.php | 3 +- test/unit/Sql/Ddl/Column/DatetimeTest.php | 3 +- test/unit/Sql/Ddl/Column/DecimalTest.php | 12 +- test/unit/Sql/Ddl/Column/DoubleTest.php | 2 +- test/unit/Sql/Ddl/Column/FloatingTest.php | 2 +- test/unit/Sql/Ddl/Column/IntegerTest.php | 8 +- test/unit/Sql/Ddl/Column/JsonTest.php | 3 +- test/unit/Sql/Ddl/Column/SmallIntegerTest.php | 4 +- test/unit/Sql/Ddl/Column/TextTest.php | 2 +- test/unit/Sql/Ddl/Column/TimeTest.php | 3 +- test/unit/Sql/Ddl/Column/TimestampTest.php | 13 +- test/unit/Sql/Ddl/Column/VarbinaryTest.php | 2 +- test/unit/Sql/Ddl/Column/VarcharTest.php | 6 +- .../Ddl/Constraint/AbstractConstraintTest.php | 7 +- test/unit/Sql/Ddl/Constraint/CheckTest.php | 2 +- .../Sql/Ddl/Constraint/ForeignKeyTest.php | 13 +- .../Sql/Ddl/Constraint/PrimaryKeyTest.php | 3 +- .../unit/Sql/Ddl/Constraint/UniqueKeyTest.php | 3 +- test/unit/Sql/Ddl/CreateTableTest.php | 59 +- test/unit/Sql/Ddl/DropTableTest.php | 9 +- test/unit/Sql/Ddl/Index/IndexTest.php | 15 +- test/unit/Sql/DeleteTest.php | 29 +- test/unit/Sql/ExpressionTest.php | 33 +- test/unit/Sql/InsertIgnoreTest.php | 37 +- test/unit/Sql/InsertTest.php | 47 +- test/unit/Sql/JoinTest.php | 25 +- test/unit/Sql/LiteralTest.php | 9 +- .../Sql/Platform/AbstractPlatformTest.php | 17 +- test/unit/Sql/Platform/PlatformTest.php | 29 +- test/unit/Sql/Predicate/BetweenTest.php | 22 +- test/unit/Sql/Predicate/ExpressionTest.php | 35 +- test/unit/Sql/Predicate/InTest.php | 29 +- test/unit/Sql/Predicate/IsNullTest.php | 18 +- test/unit/Sql/Predicate/LikeTest.php | 14 +- test/unit/Sql/Predicate/LiteralTest.php | 7 +- test/unit/Sql/Predicate/NotBetweenTest.php | 5 +- test/unit/Sql/Predicate/NotInTest.php | 9 +- test/unit/Sql/Predicate/NotLikeTest.php | 11 +- test/unit/Sql/Predicate/OperatorTest.php | 22 +- test/unit/Sql/Predicate/PredicateSetTest.php | 23 +- test/unit/Sql/Predicate/PredicateTest.php | 53 +- test/unit/Sql/SelectTest.php | 117 +- test/unit/Sql/SqlTest.php | 29 +- test/unit/Sql/TableIdentifierFactoryTest.php | 41 +- test/unit/Sql/TableIdentifierTest.php | 41 +- test/unit/Sql/UpdateTest.php | 57 +- .../TableGateway/AbstractTableGatewayTest.php | 89 +- test/unit/TableGateway/TableGatewayTest.php | 25 +- 92 files changed, 1270 insertions(+), 8215 deletions(-) diff --git a/lint-baseline.toml b/lint-baseline.toml index 0de9388f..a167d2d1 100644 --- a/lint-baseline.toml +++ b/lint-baseline.toml @@ -1009,7369 +1009,355 @@ message = "Use of the shorthand ternary operator." count = 1 [[issues]] -file = "test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 9 - -[[issues]] -file = "test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConnection`." -count = 1 - -[[issues]] -file = "test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDriverDisconnectAfterQuoteWithPlatform`." -count = 1 - -[[issues]] -file = "test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php" -code = "strict-types" -message = "Missing `declare(strict_types=1);` statement at the beginning of the file." -count = 1 - -[[issues]] -file = "test/integration/Adapter/Driver/Pdo/AdapterTrait.php" -code = "strict-types" -message = "Missing `declare(strict_types=1);` statement at the beginning of the file." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterAwareTraitTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 3 - -[[issues]] -file = "test/unit/Adapter/AdapterAwareTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDbAdapterSetsProperty`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterAwareTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDbAdapter`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 33 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "no-assign-in-argument" -message = "Avoid assignments in function call arguments." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithProfilerDelegatesToSetProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateStatementDelegatesToDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryReturnsRawResultWithoutWrappingQueryResults`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryThrowsWhenExecutionDoesNotProduceAResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryWithRawSqlDelegatesToConnectionExecute`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryWithStatementExecutesStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentSetProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetCurrentSchemaDelegatesToConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDriverReturnsDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersQuoteIdentifierClosureCallsPlatform`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersQuoteValueClosureCallsPlatform`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersReturnsBothFunctions`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersReturnsQuoteIdentifierFunction`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersReturnsQuoteValueFunction`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetPlatformReturnsPlatform`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerReturnsProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultSetPrototypeReturnsResultSet`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsDriverAndPlatformCaseInsensitively`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareQueryBindsParameterArray`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareQueryBindsParameterContainerDirectly`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareQueryPreparesStatementWithoutExecuting`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProducedResultSetPrototypeIsDifferentForEachQuery`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryThrowsOnInvalidParameterType`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenExecutedProducesAResultSetObjectWhenResultIsQuery`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenExecutedProducesAResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenPreparedProducesStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenPreparedWithParameterArrayProducesResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenPreparedWithParameterContainerProducesResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetProfilerDelegatesToDriverWhenProfilerAware`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 6 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "literal-named-argument" -message = '''Literal argument `'PhpDb\Adapter\NoDriver'` should be passed as a named argument for clarity.''' -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "no-literal-namespace-string" -message = "Use `::class` notation instead of a hardcoded namespace string." -count = 9 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-arrow-function" -message = "This closure can be simplified to a more concise arrow function." -count = 2 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanCreateReturnsFalseForEmptyConfig`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetConfigCachesResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetConfigReturnsEmptyWhenContainerHasNoConfig`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvalidService`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeThrowsWhenDriverNotConfigured`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeUsesResultSetFromContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidService`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 10 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelegatorWithPluginManager`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelegatorWithServiceManagerAndCustomAdapterName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelegatorWithServiceManager`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeReturnsInstanceWhenAdapterIsNotAdapterInterface`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAdapterShouldBeCalledForExistingAdapter`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAdapterShouldBeCalledForOnlyConcreteAdapter`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAdapterShouldNotBeCalledForMissingAdapter`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAdapterShouldNotBeCalledForWrongClassInstance`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetStateWithCustomAdapterName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetStateWithDefaultAdapterName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 15 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDisconnectIsNoOpWhenNotConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDisconnectNullsResourceWhenConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetConnectionParametersReturnsEmptyByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDriverNameReturnsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDriverNameReturnsValueWhenSet`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerReturnsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetResourceAutoConnectsWhenNotConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInTransactionReturnsFalseByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetConnectionParametersStoresAndReturnsConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/AbstractConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetProfilerStoresAndReturnsProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDriverStoresDriverAndReturnsInstance`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 4 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddFeatureSetsDriverAndStoresFeature`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddFeatureThrowsWhenUsedOutsideDriverInterface`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddFeaturesAddsMultipleFeatures`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFeatureReturnsFalseWhenNotFound`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFeatureReturnsFeatureByClassName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 15 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "no-empty-catch-clause" -message = "Do not use empty `catch` blocks." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "no-error-control-operator" -message = "Unsafe use of error control operator `@`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "no-literal-password" -message = "Literal passwords or sensitive data should not be stored in code." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "no-redundant-variable" -message = "Variable `$driver` is assigned but never used." -count = 4 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBeginTransactionAutoConnectsWhenNotConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCommitAutoConnectsWhenNotConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithArraySetsConnectionParameters`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithPdoResourceSetsConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteAutoConnectsWhenNotConnected`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteCallsProfilerFinishBeforeThrowingOnError`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteCallsProfilerStartAndFinish`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentSetDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDsnReturnsDsnAfterConnect`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDsnThrowsWhenDsnIsNull`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareAutoConnectsAndReturnsStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResource`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetConnectionParametersStoresParams`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 27 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "no-redundant-variable" -message = "Variable `$nested` is assigned but never used." -count = 2 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBeginTransactionReturnsInstanceOfConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBeginTransactionSetsInTransactionAtTrue`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCommitReturnsInstanceOfConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCommitSetsInTransactionAtFalse`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCommitWithoutBeginReturnsInstanceOfConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNestedTransactionsCommit`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNestedTransactionsRollback`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRollbackDisconnectedThrowsException`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRollbackReturnsInstanceOfConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRollbackSetsInTransactionAtFalse`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRollbackWithoutBeginThrowsException`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStandaloneCommit`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 18 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "no-redundant-variable" -message = "Variable `$unused` is assigned but never used." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCheckEnvironmentReturnsTrue`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorAddsFeaturesWhenDriverSupportsFeatures`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorSetsDriverOnConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateStatementWithNullConnectsAndInitializes`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateStatementWithPdoStatementResource`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateStatementWithSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFormatParameterNameFormatsCorrectly`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFormatParameterNameReturnsQuestionMarkForNumericWithoutType`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFormatParameterNameWithInvalidCharacters`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetConnectionReturnsConnectionInstance`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLastGeneratedValueDelegatesToConnection`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetPrepareTypeReturnsNamed`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerReturnsSetProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerThrowsWhenNotInitialized`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetResultPrototypeReturnsResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetProfilerPropagatesProfilerToConnectionAndStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "assert-description" -message = "Missing description in assert function." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 39 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-first-class-callable" -message = "Use first-class callable syntax `...` instead of a arrow function." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBufferIsCallableWithNoEffect`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountCachesResultFromClosure`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountCachesResultFromStatementRowCount`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountWithClosureInvokesClosureAndReturnsValue`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountWithIntReturnsProvidedValue`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountWithNoRowCountFallsBackToStatementRowCount`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsSameDataOnConsecutiveCalls`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFetchModeAcceptsNamedMode`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFetchModeObjReturnsStdClass`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetAffectedRowsDelegatesToRowCount`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFetchModeDefaultIsAssoc`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCountDelegatesToColumnCount`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetGeneratedValueReturnsInitializedValue`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetGeneratedValueReturnsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultClonesGivenPrototypeRatherThanMutatingIt`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultInitializesReturnedResultSetWithThisResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultThrowsWhenResultIsNotAQueryResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetResourceReturnsPdoStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeStoresResourceAndValues`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsBufferedReturnsFalse`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsQueryResultReturnsFalseWhenNoColumns`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsQueryResultReturnsTrueWhenColumnsExist`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNextAdvancesPositionAndFetchesData`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewindResetsIterationToStart`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewindThrowsExceptionOnForwardOnlyAfterAdvancing`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetFetchModeStoresValidMode`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetFetchModeThrowsOnInvalidFetchMode`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetFetchModeThrowsOnInvalidMode`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetStatementModeThrowsOnInvalidMode`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetStatementModeToForward`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetStatementModeToScrollable`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidReturnsFalseWhenCurrentDataIsFalse`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidReturnsTrueWhenCurrentDataExists`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 6 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 12 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "no-assign-in-argument" -message = "Avoid assignments in function call arguments." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStatementExecuteWillConvertPhpBoolToPdoBoolWhenBinding`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStatementExecuteWillUsePdoIntForIntWhenBinding`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStatementExecuteWillUsePdoStrByDefaultWhenBinding`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStatementExecuteWillUsePdoStrForStringIntegerWhenBinding`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 39 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "no-assign-in-argument" -message = "Avoid assignments in function call arguments." -count = 2 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersDetectsBooleanValueType`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersDetectsNullValueType`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersFromContainerSkipsWhenAlreadyBound`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersWithErrataTypeDefaultsToString`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersWithErrataTypeInteger`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersWithErrataTypeLob`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersWithErrataTypeNull`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBindParametersWithPositionalIntegers`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneClonesParameterContainerWhenSet`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneResetsState`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorAcceptsParameterContainerAndOptions`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteAutoPrepares`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteCallsProfilerFinishOnFailure`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteCallsProfilerOnSuccess`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteCastsNonIntErrorCodeToZero`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteReturnsResult`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteThrowsInvalidQueryExceptionOnPdoException`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteThrowsOnInvalidParameterName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteWithArrayParametersMergesIntoContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteWithParameterContainerSetsContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentPrepare`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentSetDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentSetParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetParameterContainerReturnsContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerReturnsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetResourceReturnsPdoStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSql`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeSetsPdoResource`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsPreparedReturnsTrueAfterPrepare`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareThrowsRuntimeExceptionOnPdoFailure`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareThrowsWhenAlreadyPrepared`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSecondExecuteSkipsBindingWhenAlreadyBound`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetProfilerStoresProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetResourceStoresPdoStatement`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetSql`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 2 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/TestAsset/SqliteMemoryPdo.php" -code = "no-empty" -message = "Use of the `empty` construct." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php" -code = "no-else-clause" -message = "Avoid `elseif` clauses." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorStoresMessageAndParameters`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 55 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 2 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithDataPopulatesContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCount`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrent`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetErrataIterator`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetMaxLengthIterator`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetNamedArray`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetPositionalArrayReturnsValues`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testKey`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNext`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetExists`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGetErrataByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGetErrataThrowsWhenNameDoesNotExist`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGetErrata`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGetMaxLengthByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGetMaxLengthThrowsWhenNameDoesNotExist`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGet`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetHasErrataByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetHasErrata`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetHasMaxLengthByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetHasMaxLength`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetAndGetMaxLength`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetErrataByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetErrata`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetMaxLengthByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetReferenceCreatesReference`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetThrowsOnInvalidKeyType`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetWithIntNotInPositionsCastsToString`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSetWithNameMappingMatchForNonColonName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSet`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetErrataByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetErrataThrowsWhenNameDoesNotExist`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetErrata`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetMaxLengthByPositionalIndex`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetMaxLengthThrowsWhenNameDoesNotExist`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnsetMaxLength`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnset`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewind`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetFromArrayNamed`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetFromArray`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValid`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/ParameterContainerTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 15 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 28 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "no-error-control-operator" -message = "Unsafe use of error control operator `@`." -count = 4 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAbstractPlatformQuoteValueEscapesWithDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAbstractPlatformQuoteValueThrowsWithoutDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetIdentifierSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetName`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQuoteIdentifierSymbol`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQuoteValueSymbol`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteIdentifierChain`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteIdentifierInFragment`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteIdentifierReturnsUnquotedWhenQuotingDisabled`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteTrustedValueEscapesSpecialCharacters`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteValueEscapesSpecialCharacters`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteValueListThrowsWithoutDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteValueRaisesNoticeWithoutPlatformSupport`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuoteValueThrowsWithoutDriver`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Platform/Sql92Test.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 22 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 12 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLastProfileReturnsSqlAndTimings`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilesReturnsAllRecordedProfiles`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProfilerFinishThrowsWithoutStart`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProfilerStartClonesParameterContainerFromStatementContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProfilerStartWithStatementContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProfilerStartWithString`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/Profiler/ProfilerTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Adapter/StatementContainerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 6 - -[[issues]] -file = "test/unit/Adapter/StatementContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSqlSetsSql`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/StatementContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithoutSqlDoesNotSetSql`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/StatementContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAndGetParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Adapter/StatementContainerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAndGetSql`." -count = 1 - -[[issues]] -file = "test/unit/ConfigProviderTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 1 - -[[issues]] -file = "test/unit/ConfigProviderTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvocationProvidesDependencyConfiguration`." -count = 1 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 4 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesAdapterWithAllDependencies`." -count = 1 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesAdapterWithDefaultResultSet`." -count = 1 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesAdapterWithoutOptionalProfiler`." -count = 1 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeThrowsWhenAdapterConfigIsEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Container/AdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeThrowsWhenContainerHasNoConfig`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 9 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithConfiguredPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithConfiguredSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeRejectsEmptyStringSeparatorFromConfig`." -count = 1 - -[[issues]] -file = "test/unit/Container/TableIdentifierFactoryFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetIntegrationTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentCallsDataSourceCurrentAsManyTimesWithoutBuffer`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentCallsDataSourceCurrentOnceWithBuffer`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "assert-description" -message = "Missing description in assert function." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 45 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-static-closure" -message = "This closure does not use `$this` and should be declared static." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBufferIterations`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBuffer`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountReturnsCachedResult`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountReturnsNullForUncountableDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCount`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsBufferedDataOnSecondPass`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrent`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCountReturnsCachedValue`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCountReturnsZeroForEmptyIterator`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCountReturnsZeroWithNoDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCountWithCountableRow`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFieldCount`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeDoesNotCallCount`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeResetsBufferWhenAlreadyBuffered`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeWithBufferedResultInterface`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeWithEmptyArray`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeWithIteratorAggregate`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeWithResultInterfaceRewindsWhenBuffered`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitialize`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsBuffered`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testKey`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleRewindBufferIterations`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNext`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewindResetsIteratorPosition`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewindWithNonIteratorDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidReturnsFalseAfterLastElement`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidWithNonIteratorDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValid`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/AbstractResultSetTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 15 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetIntegrationTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentWillReturnBufferedRow`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 21 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorDefaultsToArraySerializableHydrator`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentDisablesBufferingImplicitly`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentDoesnotHasData`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentHasData`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentWithBufferReturnsBufferedObject`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHydrator`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetObjectPrototype`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRowPrototypeReturnsDefaultArrayObject`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetHydrator`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetObjectPrototype`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetRowPrototypeStoresPrototype`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArrayUsesHydratorExtract`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/HydratingResultSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArray`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 27 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "literal-named-argument" -message = "Literal argument `75` should be passed as a named argument for clarity." -count = 2 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "literal-named-argument" -message = "Literal argument `true` should be passed as a named argument for clarity." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBufferCalledAfterIterationThrowsException`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanProvideArrayAsDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanProvideIteratorAggregateAsDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanProvideIteratorAsDataSource`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCountReturnsCountOfRows`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentClonesRowPrototypeOnEachCall`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsArrayObjectWhenReturnTypeIsArrayObject`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsArrayWhenReturnTypeIsArray`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsNullForNonExistingValues`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentWithBufferingCallsDataSourceCurrentOnce`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDataSourceIsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFieldCountIsZeroWithNoDataSourcePresent`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFieldCountRepresentsNumberOfFieldsInARowOfData`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetArrayObjectPrototypeDelegatesToGetRowPrototype`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetReturnTypeReturnsArrayWhenSetToArray`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInvalidDataSourceRaisesException`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testReturnTypeIsObjectByDefault`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowObjectPrototypeIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowObjectPrototypeIsPopulatedByRowObjectByDefault`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowObjectPrototypeMayBePassedToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSettingInvalidReturnTypeRaisesException`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArrayCreatesArrayOfArraysRepresentingRows`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhenReturnTypeIsArrayThenIterationReturnsArrays`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhenReturnTypeIsObjectThenIterationReturnsRowObjects`." -count = 1 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 2 - -[[issues]] -file = "test/unit/ResultSet/ResultSetIntegrationTest.php" -code = "string-style" -message = "String concatenation can be replaced with interpolation." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 48 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 4 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCount`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelete`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExchangeArray`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeCreatesFeatureSetIfNotSet`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeEarlyReturnWhenAlreadyInitialized`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeOnlyRunsOnce`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWhenPrimaryKeyColumnIsNull`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWhenSqlIsNull`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWhenTableIsNull`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheColumnValue`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownColumn`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicIssetReportsWhetherAColumnIsSet`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetAssignsTheColumnValue`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicUnsetClearsTheColumnValue`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetExists`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetGet`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetSet`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetUnset`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPopulate`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessPrimaryKeyData`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsFalseWhenNew`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRowExistsInDatabaseReturnsTrueAfterPopulateWithTrue`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsertMultiKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveInsert`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdateChangingPrimaryKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSaveUpdate`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testToArray`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/AbstractRowGatewayTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 21 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 9 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorThrowsExceptionWhenSqlTableDoesNotMatch`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithArrayPrimaryKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithNullPrimaryKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSqlObject`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithStringPrimaryKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyPrimaryKey`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeReturnsEarlyWhenAlreadyInitialized`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsWhenSqlIsNull`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsWhenTableIsNull`." -count = 1 - -[[issues]] -file = "test/unit/RowGateway/RowGatewayTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 3 - -[[issues]] -file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" -code = "halstead" -message = "Method has a high halstead volume" -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 3 - -[[issues]] -file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" -code = "prefer-first-class-callable" -message = "Use first-class callable syntax `...` instead of a arrow function." -count = 2 - -[[issues]] -file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" -code = "tagged-todo" -message = "TODO should be tagged with (@username) or (#issue)." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 54 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateSqlFromSpecWithCombinedByScalarParam`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateSqlFromSpecWithCombinedByThrowsOnUnsupportedCount`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateSqlFromSpecWithNonCombinedByParam`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateSqlFromSpecificationThrowsOnParameterCountMismatch`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFlattenExpressionValuesViaInPredicateWithParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFlattenExpressionValuesViaInPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLocalizeVariablesCopiesSubjectProperties`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionThrowsOnUnknownArgumentType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWithIdentifiersArgument`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWithParameterContainerAndParameterizationTypeNamed`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWithValuesArgument`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWithoutParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithExpressionContainingExpressionObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithExpressionContainingSelectObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithExpressionContainingStringParts`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithExpressionObjectWithPercentageSigns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithNamedParameterPrefixContainingWhitespace`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessExpressionWorksWithNamedParameterPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinReturnsNullWhenEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinWithArrayAlias`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinWithExpressionNameViaArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinWithPredicateExpressionOnClause`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinWithSelectSubqueryViaArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessJoinWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessSubSelectUsesDecoratorWhenPlatformDecorator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessSubSelectWithParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessSubSelectWithoutParameterContainer`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRenderTableWithAlias`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveColumnValueWithArrayAndFromTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveColumnValueWithNamedParameterPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveColumnValueWithNull`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveColumnValueWithSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveTableWithSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveTableWithTableIdentifierAndSchema`." -count = 1 - -[[issues]] -file = "test/unit/Sql/AbstractSqlTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 8 - -[[issues]] -file = "test/unit/Sql/Argument/LiteralTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 3 - -[[issues]] -file = "test/unit/Sql/Argument/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSpecificationReturnsPlaceholder`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Argument/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeReturnsLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Argument/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetValueReturnsLiteralString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 26 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorThrowsExceptionForInvalidSelectType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithArrayContainingArgumentType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithBooleanValue`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithExplicitType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithExpressionInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithFloatValue`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithNullValue`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSimpleArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSimpleValue`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSqlInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStaticIdentifierMethod`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStaticLiteralMethod`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStaticSelectMethodCreatesSelectArgument`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testStaticValueMethod`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ArgumentTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 7 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 17 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAlignColumnsAppendsNullExpressionsForMissingColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAlignColumnsReturnsEarlyWhenEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAlignColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCombineWithArrayOfSelectAndModifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSelectDelegatesToCombine`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringFromArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithModifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementWithModifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsInvalidStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/CombineTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 6 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 86 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "literal-named-argument" -message = "Literal argument `''` should be passed as a named argument for clarity." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddConstraintGeneratesCorrectSql`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddConstraint`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testChainedOperations`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testChangeColumnGeneratesCorrectSql`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testChangeColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithEmptyTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDropColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDropConstraint`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDropIndex`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyAlterTableGeneratesMinimalSql`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetOptionsReturnsEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateIncludesTableOptions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateReturnsAllState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateWithInvalidKey`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateWithSpecificKey`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithBoolOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithColumnAndEngineOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithEngineOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithIntOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithMultipleOptions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithStringOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMixedOperationsInCorrectOrder`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleChangeColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleColumnsAndConstraints`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleConstraints`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleDropOperations`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOptionFluentInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOptionsReplacesAll`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableIdentifierInChangeColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/AlterTableTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 9 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 6 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLength`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetLength`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 4 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 10 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDecimal`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDigits`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDecimal`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDigits`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 7 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BigIntegerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 3 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BigIntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BigIntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testObjectConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BigIntegerTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BinaryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BinaryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BinaryTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BlobTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BlobTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BlobTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BooleanTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 4 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BooleanTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BooleanTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsAlwaysNotNullable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/BooleanTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/CharTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/CharTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/CharTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 44 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddConstraintAppendsConstraintToColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataIncludesConstraintValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataIncludesConstraints`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithBoolDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithFloatDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithLiteralDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithValueDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDefaultWithBool`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDefaultWithFloat`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDefaultWithLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDefaultWithValue`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetName`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetNullable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOptions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/ColumnTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 13 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DateTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DateTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DatetimeTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DatetimeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DatetimeTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 13 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorSetsDigitsAndDecimal`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithNullDecimal`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInheritanceFromAbstractPrecisionColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDecimalAndGetDecimal`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDigitsAndGetDigits`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DecimalTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 5 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DoubleTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DoubleTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/DoubleTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/FloatingTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/FloatingTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/FloatingTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 6 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataExcludesLengthWhenNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataIncludesLengthWhenOptionSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testObjectConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/IntegerTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 3 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/JsonTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/JsonTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/JsonTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/SmallIntegerTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 3 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/SmallIntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/SmallIntegerTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testObjectConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/SmallIntegerTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TextTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TextTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TextTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimeTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimeTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 16 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithCurrentTimestampDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithOnUpdateOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithoutOnUpdateOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInheritanceFromAbstractTimestampColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/TimestampTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 4 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarbinaryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarbinaryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarbinaryTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarcharTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 7 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarcharTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarcharTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInheritanceFromAbstractLengthColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarcharTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetLengthAndGetLength`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Column/VarcharTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 3 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 5 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/CheckTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/CheckTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/CheckTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 35 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetName`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOnDeleteRule`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOnUpdateRule`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetReferenceColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetReferenceTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 15 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 2 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 87 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddConstraint`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testChainedOperations`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTemporaryFlag`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyTableConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetOptionsReturnsEmpty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateIncludesTableOptions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateReturnsAllState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateWithInvalidKey`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithBoolOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithIntOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithLiteralOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithMultipleOptions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithNoOptionsUnchanged`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithStringOption`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfNotExistsCombinedWithTemporary`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfNotExistsDisable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfNotExists`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsTemporary`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMultipleConstraints`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testObjectConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOptionFluentInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetOptionsReplacesAll`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTableAfterConstruction`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTemporary`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/CreateTableTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 29 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 11 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfExistsDisable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfExistsWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIfExists`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/DropTableTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 6 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 15 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithBtreeType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithHashType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithLengthUnmatched`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithLength`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithTypeAndLengths`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTypeAndGetType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Ddl/Index/IndexTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 7 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 50 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFrom`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateWithKey`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithEmptyWhere`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsNullForUnknownProperty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsWhereClause`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereAcceptsExpressionInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhere`." -count = 1 - -[[issues]] -file = "test/unit/Sql/DeleteTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 19 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 22 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithFalsyValidParameters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithInvalidParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithLiteralZero`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithMultipleArguments`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenParameterCountMismatch`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataUsesRegexWhenPlaceholderCountMismatches`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWillEscapePercent`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionPreservesPercentageSignInFromUnixtime`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNumberOfReplacementsConsidersWhenSameVariableIsUsedManyTimes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNumberOfReplacementsForExpressionWithParameters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetExpressionException`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetExpressionThrowsOnEmptyString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetExpression`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetParametersWrapsArrayInValuesArgument`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetParameters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/ExpressionTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 8 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 39 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "method-name" -message = "Method name `test__get` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "method-name" -message = "Method name `test__isset` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "method-name" -message = "Method name `test__set` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "method-name" -message = "Method name `test__unset` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 2 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyArrayValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringUsingColumnsAndValuesMethods`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInto`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementWithSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesMerge`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenArrayMergeOverSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenNotArrayOrSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenSelectMergeOverArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__get`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__isset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__set`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__unset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertIgnoreTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 11 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 45 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "method-name" -message = "Method name `test__get` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "method-name" -message = "Method name `test__isset` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "method-name" -message = "Method name `test__set` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "method-name" -message = "Method name `test__unset` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 2 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "no-redundant-variable" -message = "Variable `$value` is assigned but never used." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyArrayValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringThrowsExceptionWhenNoValuesOrSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringUsingColumnsAndValuesMethods`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetThrowsExceptionForNonExistentColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInto`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementCreatesParameterContainerWhenNotPresent`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementWithSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessInsertWithPdoDriverUsesDriverColumnQuoting`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUnsetThrowsExceptionForNonExistentColumn`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesMerge`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenArrayMergeOverSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenNotArrayOrSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValuesThrowsExceptionWhenSelectMergeOverArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__get`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__isset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__set`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__unset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/InsertTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 11 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 13 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCount`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCurrentReturnsTheCurrentJoinSpecification`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitialPositionIsZero`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinFullOuter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinThrowsOnInvalidMultiElementArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinWillThrowAnExceptionIfNameIsNoValid`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoin`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testKeyReturnsTheCurrentPosition`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNextIncrementsThePosition`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testReset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRewindResetsPositionToZero`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValidReturnsTrueIfTheIteratorIsAtAValidPositionAndFalseIfNot`." -count = 1 - -[[issues]] -file = "test/unit/Sql/JoinTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 7 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 8 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWillEscapePercent`." -count = 1 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/LiteralTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 5 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 9 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringDelegatesToDecoratorSubject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringThrowsWhenSubjectNotSqlInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorLoopMatchesByInstanceof`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorReturnsSubjectWhenNoMatch`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementDelegatesToDecoratorSubject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementThrowsWhenSubjectNotPreparable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetAndGetTypeDecorator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetSubjectReturnsStatic`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/AbstractPlatformTest.php" -code = "string-style" -message = "String concatenation can be replaced with interpolation." -count = 2 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 18 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDefaultPlatformReturnsInstance`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringDelegatesToTypeDecorator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringThrowsWhenSubjectNotSqlInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorFallsThroughWhenNoMatch`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorMatchesByInstanceofLoop`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorMatchesExactClass`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementThrowsWhenSubjectNotPreparable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolveDefaultPlatform`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolvePlatformNameCachesResult`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolvePlatformName`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolvePlatformWithAdapterInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResolvePlatformWithPlatformInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetTypeDecoratorRegistersDecorator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Platform/PlatformTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 5 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 75 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorCanPassIdentifierMinimumAndMaximumValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorYieldsNullIdentifierMinimumAndMaximumValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenIdentifierNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenMaxValueNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenMinValueNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIdentifierIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMaxValueIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMinValueIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationIsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/BetweenTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 23 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 39 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfMultiNullsParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfMultiPredicatesParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfMultiScalarsParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfOneNullParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfOnePredicateParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassArrayOfOneScalarParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassLiteralAndSingleScalarParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassMultiNullParametersToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassMultiScalarParametersToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassNoParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassSingleNullParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassSinglePredicateParameterToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassSingleZeroParameterValueToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsEmptyLiteralAndParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLiteralIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testParameterIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/ExpressionTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 11 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 72 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassIdentifierAndEmptyValueSetToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassIdentifierAndValueSetToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsNullIdentifierAndValueSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenIdentifierNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenValueSetNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithEmptyValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselectAndArrayIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselectAndIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIdentifierIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetValueSetWithArgumentInterfacePassesThrough`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetValueSetWithSelectWrapsInArgumentSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testValueSetIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/InTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 14 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 21 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassIdentifierToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsNullIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenIdentifierNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIdentifierIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetIdentifierWithArgumentInterfacePassesThrough`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetIdentifierWithStringConvertsToIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationIsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/IsNullTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 6 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 44 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAccessorsMutators`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructEmptyArgs`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructWithArgs`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenIdentifierNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenLikeNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInstanceOfPerSetters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LikeTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 16 - -[[issues]] -file = "test/unit/Sql/Predicate/LiteralTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 5 - -[[issues]] -file = "test/unit/Sql/Predicate/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LiteralTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/LiteralTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 4 - -[[issues]] -file = "test/unit/Sql/Predicate/NotBetweenTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 23 - -[[issues]] -file = "test/unit/Sql/Predicate/NotBetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotBetweenTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationIsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotBetweenTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 8 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 32 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselectAndArrayIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselectAndIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataWithSubselect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotInTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 7 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 36 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAccessorsMutators`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructEmptyArgs`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructWithArgs`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionData`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInstanceOfPerSetters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/NotLikeTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 13 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 50 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassAllValuesToConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsDefaultsForOperatorAndLeftAndRightTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsNullLeftAndRightValues`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenLeftNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataThrowsExceptionWhenRightNotSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLeftIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOperatorIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRetrievingWherePartsReturnsSpecificationArrayOfLeftAndRightAndArrayOfTypes`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRightIsMutable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetLeftWithExpressionInterfaceWrapsInSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetRightWithExpressionInterfaceWrapsInSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/OperatorTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 13 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 46 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddPredicateThrowsOnInvalidCombination`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddPredicatesThrowsWhenStringKeyUsedWithPredicateInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddPredicatesWithExpression`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddPredicatesWithMultipleExpressions`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testAddPredicates`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassBothPredicateAndCombinationToAddPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanPassPredicatesAndDefaultCombinationViaConstructor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanUseOrPredicateAndAndPredicateMethods`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCombinationIsAndByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEmptyConstructorYieldsCountOfZero`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetExpressionDataReturnsEmptyWhenNoPredicates`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateSetTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 10 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 90 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "no-else-clause" -message = "Avoid `else` clauses." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "no-isset" -message = "Use of the `isset` construct." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBetweenCreatesBetweenPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBetweenCreatesNotBetweenPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanChainPredicateFactoriesBetweenOperators`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanNestPredicates`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testEqualToCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExpressionNullParameters`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExpression`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGreaterThanCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGreaterThanOrEqualToCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInCreatesInPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsNotNullCreatesIsNotNullPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsNullCreatesIsNullPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLessThanCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLessThanOrEqualToCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLikeCreatesLikePredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLiteralCreatesLiteralPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLiteral`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetNestReturnsNestedPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetUnnestReturnsParentPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNotEqualToCreatesOperatorPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNotInCreatesNotInPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testNotLikeCreatesLikePredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPredicateMethodAddsCustomPredicateInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUnnestThrowsWhenNotNested`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWillBindSqlParametersToExpressionsWithGivenParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWillBindSqlParametersToExpressionsWithGivenStringParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/Predicate/PredicateTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 21 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 151 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "excessive-parameter-list" -message = "Parameter list is too long." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "halstead" -message = "Method has a high halstead volume and effort" -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "no-assign-in-argument" -message = "Avoid assignments in function call arguments." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "no-boolean-flag-parameter" -message = "Avoid boolean flag parameters." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "no-redundant-variable" -message = "Variable `$value` is assigned but never used." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBadJoin`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneDeepCopiesAllSubObjects`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloning`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testColumnsWithPrefixDisabledOmitsTablePrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testColumnsWithPrefixDisabled`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testColumns`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCombineThrowsWhenAlreadyCombined`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCombineWrapsStatementInParentheses`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCombine`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstruct`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFromThrowsExceptionForInvalidArrayFormat`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFromThrowsExceptionForInvalidTableType`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFromThrowsExceptionWhenTableReadOnly`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFromWithAliasArrayResolvesTableAndAlias`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFrom`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateInitializesLazyProperties`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetThrowsExceptionForInvalidProperty`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGroup`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testHavingAcceptsExpressionInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testHavingArgument1IsHavingObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testHaving`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsTableReadOnly`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoin`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLimitExceptionOnInvalidParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testLimit`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicAccessor`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetJoinsReturnsJoinInstance`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffsetExceptionOnInvalidParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOffset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOrderCorrectlySplitsParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOrderWithAssociativeArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOrderWithExpressionObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOrderWithStringContainingDirection`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testOrder`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessMethods`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuantifierParameterExpressionInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQuantifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResetCombine`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResetQuantifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResetTableThrowsWhenTableReadOnly`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testResetThrowsOnInvalidPart`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testReset`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectUsingTableIdentifierWithEmptyScheme`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetSpecificationStoresValidSpecification`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetSpecificationThrowsExceptionForInvalidName`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereAcceptsExpressionInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsAssociativeArrayContainingReplacementCharacter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsAssociativeArrayIsPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsAssociativeArrayNotContainingReplacementCharacter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsClosure`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsIndexedArrayArgument2IsOr`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsIndexedArray`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsPredicate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereArgument1IsWhereObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereReturnsSameSelectObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 31 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "variable-name" -message = "Variable name `$select32subselect` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "variable-name" -message = "Variable name `$select39subselect` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "variable-name" -message = "Variable name `$select44b` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "variable-name" -message = "Variable name `$select48b` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SelectTest.php" -code = "variable-name" -message = "Variable name `$select48combined` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 13 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "method-name" -message = "Method name `test__construct` should be in camel case." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBuildSqlStringThrowsWhenPlatformNotSqlInterface`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testBuildSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDeleteThrowsWhenTableConflicts`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelete`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlPlatformReturnsPlatformDecorator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsertThrowsWhenTableConflicts`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsert`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementForSqlObject`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatementThrowsWhenPlatformNotPreparable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectThrowsWhenTableConflicts`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelect`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateThrowsWhenTableConflicts`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `test__construct`." -count = 1 - -[[issues]] -file = "test/unit/Sql/SqlTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 25 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `''` should be passed as a named argument for clarity." -count = 2 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `'_'` should be passed as a named argument for clarity." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `'__'` should be passed as a named argument for clarity." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `'archive'` should be passed as a named argument for clarity." -count = 3 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `'public'` should be passed as a named argument for clarity." -count = 2 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "literal-named-argument" -message = "Literal argument `null` should be passed as a named argument for clarity." -count = 8 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCallTimePrefixIsAppliedWhenNonePreconfigured`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCallTimePrefixOverridesConfiguredPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCallTimeSeparatorIsAppliedWhenNonePreconfigured`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCallTimeSeparatorOverridesConfiguredSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConfiguredSeparatorIsCarriedButUnusedWhenNoPrefixApplies`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreatesIdentifierWithConfiguredPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreatesIdentifierWithConfiguredSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreatesIdentifierWithSchema`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreatesIdentifierWithoutPrefixWhenNoneConfigured`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrefixIsNullByDefault`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringCallTimePrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringCallTimeSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringSeparatorWithoutPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testReturnsConfiguredPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testReturnsConfiguredSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSeparatorDefaultsToUnderscoreWhenNoPrefixConfigured`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSeparatorDefaultsToUnderscore`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSeparatorFallsBackToDefaultWhenPassedAsNull`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 17 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDefaultPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDefaultSchema`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDefaultSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSchemaFromObjectStringCast`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSchema`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableAndSchemaAppliesPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableAndSchemaWithoutPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableAppliesPrefixWithCustomSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableAppliesPrefixWithDefaultSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableFromObjectStringCast`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTableIgnoresSeparatorWithoutPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetUnprefixedTableReturnsTableAsGiven`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsEmptyStringSeparatorWithoutPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsInvalidPrefix`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsInvalidSchema`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsInvalidSeparator`." -count = 1 - -[[issues]] -file = "test/unit/Sql/TableIdentifierTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testRejectsInvalidTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 68 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "no-fully-qualified-global-class-like" -message = "Fully-qualified class-like reference detected." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneDeepCopiesSetWhereAndJoins`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneUpdate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstruct`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawStateReturnsAllState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetRawState`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringForFalseUpdateValueParameter`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlStringWithEmptyWhere`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetUpdateFails`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetUpdate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinChainable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinMultiUpdate`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoinWithTableIdentifier`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testJoin`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPassingMultipleKeyValueInWhereClause`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProcessSetWithPdoDriverUsesDriverColumnQuoting`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetWithMergeFlag`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetWithNonStringKeyThrowsException`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetWithNumericPriority`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSortableSet`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTable`." -count = 1 - -[[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereAcceptsExpressionInterface`." +file = "test/unit/Adapter/AdapterTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." count = 1 [[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhere`." +file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" +code = "literal-named-argument" +message = '''Literal argument `'PhpDb\Adapter\NoDriver'` should be passed as a named argument for clarity.''' count = 1 [[issues]] -file = "test/unit/Sql/UpdateTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 20 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 47 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneKeepsTheAdapter`." -count = 1 +file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" +code = "no-literal-namespace-string" +message = "Use `::class` notation instead of a hardcoded namespace string." +count = 9 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithATableIdentifier`." +file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" +code = "no-empty-catch-clause" +message = "Do not use empty `catch` blocks." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCloneWithAnAliasedTableIdentifier`." +file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" +code = "no-error-control-operator" +message = "Unsafe use of error control operator `@`." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDeleteWithClosure`." +file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" +code = "no-literal-password" +message = "Literal passwords or sensitive data should not be stored in code." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDeleteWith`." -count = 1 +file = "test/unit/Adapter/Driver/Pdo/ConnectionTest.php" +code = "no-redundant-variable" +message = "Variable `$driver` is assigned but never used." +count = 4 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelete`." -count = 1 +file = "test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php" +code = "no-redundant-variable" +message = "Variable `$nested` is assigned but never used." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteDeleteThrowsExceptionWhenTableDoesNotMatch`." +file = "test/unit/Adapter/Driver/Pdo/PdoTest.php" +code = "no-redundant-variable" +message = "Variable `$unused` is assigned but never used." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteInsertThrowsExceptionWhenTableDoesNotMatch`." +file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" +code = "assert-description" +message = "Missing description in assert function." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch`." +file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" +code = "prefer-first-class-callable" +message = "Use first-class callable syntax `...` instead of a arrow function." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch`." +file = "test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetAdapter`." -count = 1 +file = "test/unit/Adapter/Driver/Pdo/StatementTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetColumns`." +file = "test/unit/Adapter/Driver/Pdo/TestAsset/SqliteMemoryPdo.php" +code = "no-empty" +message = "Use of the `empty` construct." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFeatureSet`." +file = "test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php" +code = "no-else-clause" +message = "Avoid `elseif` clauses." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLastInsertValue`." +file = "test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php" +code = "no-isset" +message = "Use of the `isset` construct." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSelectResultPrototype`." -count = 1 +file = "test/unit/Adapter/ParameterContainerTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSql`." -count = 1 +file = "test/unit/Adapter/Platform/Sql92Test.php" +code = "no-error-control-operator" +message = "Unsafe use of error control operator `@`." +count = 4 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTable`." +file = "test/unit/ResultSet/AbstractResultSetTest.php" +code = "assert-description" +message = "Missing description in assert function." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeBuildsAResultSet`." -count = 1 +file = "test/unit/ResultSet/ResultSetIntegrationTest.php" +code = "literal-named-argument" +message = "Literal argument `75` should be passed as a named argument for clarity." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeEarlyReturnWhenAlreadyInitialized`." +file = "test/unit/ResultSet/ResultSetIntegrationTest.php" +code = "literal-named-argument" +message = "Literal argument `true` should be passed as a named argument for clarity." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWithoutAdapter`." -count = 1 +file = "test/unit/RowGateway/AbstractRowGatewayTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 4 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWithoutTable`." +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "halstead" +message = "Method has a high halstead volume" count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsertWith`." -count = 1 +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 3 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsert`." +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "tagged-todo" +message = "TODO should be tagged with (@username) or (#issue)." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testIsInitialized`." -count = 1 +file = "test/unit/Sql/Ddl/AlterTableTest.php" +code = "literal-named-argument" +message = "Literal argument `''` should be passed as a named argument for clarity." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallDelegatesToTheFeatureSet`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_get` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicCallThrowsForUnknownMethod`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_isset` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetDelegatesToTheFeatureSet`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_set` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheAdapter`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_unset` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValueAndAdapter`." -count = 1 +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheLastInsertValue`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_get` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsTheTable`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_isset` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetThrowsForUnknownProperty`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_set` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetDelegatesToTheFeatureSet`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_unset` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetThrowsForUnknownProperty`." -count = 1 +file = "test/unit/Sql/InsertTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectAppliesColumnsWhenStarSelected`." +file = "test/unit/Sql/InsertTest.php" +code = "no-redundant-variable" +message = "Variable `$value` is assigned but never used." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithArrayTable`." -count = 1 +file = "test/unit/Sql/Platform/AbstractPlatformTest.php" +code = "string-style" +message = "String concatenation can be replaced with interpolation." +count = 2 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithClosure`." +file = "test/unit/Sql/Predicate/PredicateTest.php" +code = "no-else-clause" +message = "Avoid `else` clauses." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithNoWhere`." +file = "test/unit/Sql/Predicate/PredicateTest.php" +code = "no-isset" +message = "Use of the `isset` construct." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSelectWithWhereString`." +file = "test/unit/Sql/SelectTest.php" +code = "excessive-parameter-list" +message = "Parameter list is too long." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoinDefaultType`." +file = "test/unit/Sql/SelectTest.php" +code = "halstead" +message = "Method has a high halstead volume and effort" count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithJoin`." +file = "test/unit/Sql/SelectTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWithNoCriteria`." +file = "test/unit/Sql/SelectTest.php" +code = "no-boolean-flag-parameter" +message = "Avoid boolean flag parameters." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateWith`." +file = "test/unit/Sql/SelectTest.php" +code = "no-redundant-variable" +message = "Variable `$value` is assigned but never used." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdate`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select32subselect` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 16 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 32 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "no-assign-in-argument" -message = "Avoid assignments in function call arguments." -count = 3 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorThrowsExceptionWhenSqlTableDoesNotMatch`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select39subselect` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithArrayOfFeatures`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select44b` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithCustomResultSetPrototype`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select48b` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithFeatureSet`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select48combined` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSingleFeature`." +file = "test/unit/Sql/SqlTest.php" +code = "method-name" +message = "Method name `_construct` should be in camel case." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructor`." -count = 1 +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `''` should be passed as a named argument for clarity." +count = 2 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDeleteShouldResetTableToUnaliasedTable`." +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `'_'` should be passed as a named argument for clarity." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsertShouldResetTableToUnaliasedTable`." +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `'__'` should be passed as a named argument for clarity." count = 1 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableAsAliasedTableIdentifierObject`." -count = 1 +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `'archive'` should be passed as a named argument for clarity." +count = 3 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableAsString`." -count = 1 +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `'public'` should be passed as a named argument for clarity." +count = 2 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableAsTableIdentifierObject`." -count = 1 +file = "test/unit/Sql/TableIdentifierFactoryTest.php" +code = "literal-named-argument" +message = "Literal argument `null` should be passed as a named argument for clarity." +count = 8 [[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateShouldResetTableToUnaliasedTable`." +file = "test/unit/Sql/UpdateTest.php" +code = "no-fully-qualified-global-class-like" +message = "Fully-qualified class-like reference detected." count = 1 [[issues]] file = "test/unit/TableGateway/TableGatewayTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." -count = 2 +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." +count = 3 diff --git a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php index 34af92a1..3133b11e 100644 --- a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php +++ b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php @@ -6,6 +6,7 @@ use PhpDb\Adapter\AdapterInterface; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function getmypid; @@ -19,13 +20,13 @@ abstract class AbstractAdapterTestCase extends TestCase public ?int $port = null; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function connection(): void { static::assertInstanceOf(AdapterInterface::class, $this->adapter); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function driverDisconnectAfterQuoteWithPlatform(): void { $isTcpConnection = $this->isTcpConnection(); diff --git a/test/unit/Adapter/AdapterAwareTraitTest.php b/test/unit/Adapter/AdapterAwareTraitTest.php index 1dc235b3..b84301ed 100644 --- a/test/unit/Adapter/AdapterAwareTraitTest.php +++ b/test/unit/Adapter/AdapterAwareTraitTest.php @@ -11,6 +11,7 @@ use PhpDbTest\Adapter\TestAsset\ConcreteAdapterAwareObject; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -18,7 +19,7 @@ #[Group('unit')] class AdapterAwareTraitTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDbAdapter(): void { $object = new ConcreteAdapterAwareObject(); @@ -35,7 +36,7 @@ public function setDbAdapter(): void static::assertSame($adapter, $object->getAdapter()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDbAdapterSetsProperty(): void { $object = new ConcreteAdapterAwareObject(); diff --git a/test/unit/Adapter/AdapterTest.php b/test/unit/Adapter/AdapterTest.php index 78c475ed..ca137f23 100644 --- a/test/unit/Adapter/AdapterTest.php +++ b/test/unit/Adapter/AdapterTest.php @@ -21,6 +21,7 @@ use PhpDbTest\TestAsset\TemporaryResultSet; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; @@ -51,7 +52,7 @@ final class AdapterTest extends TestCase protected Adapter $adapter; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithProfilerDelegatesToSetProfiler(): void { $profilerMock = $this->createMock(Profiler\ProfilerInterface::class); @@ -67,14 +68,14 @@ public function constructorWithProfilerDelegatesToSetProfiler(): void static::assertSame($profilerMock, $adapter->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test createStatement() produces a statement object')] public function createStatementDelegatesToDriver(): void { static::assertSame($this->mockStatement, $this->adapter->createStatement()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test executeQuery() returns the raw result without wrapping query results')] public function executeQueryReturnsRawResultWithoutWrappingQueryResults(): void { @@ -88,7 +89,7 @@ public function executeQueryReturnsRawResultWithoutWrappingQueryResults(): void static::assertSame($result, $this->adapter->executeQuery($sql)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test executeQuery() throws when execution does not produce a result')] public function executeQueryThrowsWhenExecutionDoesNotProduceAResult(): void { @@ -101,7 +102,7 @@ public function executeQueryThrowsWhenExecutionDoesNotProduceAResult(): void $this->adapter->executeQuery($sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test executeQuery() with raw SQL delegates to connection execute')] public function executeQueryWithRawSqlDelegatesToConnectionExecute(): void { @@ -112,7 +113,7 @@ public function executeQueryWithRawSqlDelegatesToConnectionExecute(): void static::assertSame($result, $this->adapter->executeQuery($sql)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test executeQuery() with a prepared statement executes the statement')] public function executeQueryWithStatementExecutesStatement(): void { @@ -123,7 +124,7 @@ public function executeQueryWithStatementExecutesStatement(): void static::assertSame($result, $this->adapter->executeQuery($this->mockStatement)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test setProfiler() will store profiler')] public function fluentSetProfiler(): void { @@ -131,7 +132,7 @@ public function fluentSetProfiler(): void static::assertSame($this->adapter, $ret); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getCurrentSchema() returns current schema from connection object')] public function getCurrentSchemaDelegatesToConnection(): void { @@ -139,14 +140,14 @@ public function getCurrentSchemaDelegatesToConnection(): void static::assertSame('FooSchema', $this->adapter->getCurrentSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getDriver() will return driver object')] public function getDriverReturnsDriver(): void { static::assertSame($this->mockDriver, $this->adapter->getDriver()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHelpersQuoteIdentifierClosureCallsPlatform(): void { $this->mockPlatform @@ -160,7 +161,7 @@ public function getHelpersQuoteIdentifierClosureCallsPlatform(): void static::assertSame('"test"', $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHelpersQuoteValueClosureCallsPlatform(): void { $this->mockPlatform @@ -174,7 +175,7 @@ public function getHelpersQuoteValueClosureCallsPlatform(): void $functions[0]('test'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHelpersReturnsBothFunctions(): void { $functions = $this->adapter->getHelpers( @@ -187,7 +188,7 @@ public function getHelpersReturnsBothFunctions(): void static::assertIsCallable($functions[1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHelpersReturnsQuoteIdentifierFunction(): void { $functions = $this->adapter->getHelpers(Adapter::FUNCTION_QUOTE_IDENTIFIER); @@ -196,7 +197,7 @@ public function getHelpersReturnsQuoteIdentifierFunction(): void static::assertIsCallable($functions[0]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHelpersReturnsQuoteValueFunction(): void { $functions = $this->adapter->getHelpers(Adapter::FUNCTION_QUOTE_VALUE); @@ -205,14 +206,14 @@ public function getHelpersReturnsQuoteValueFunction(): void static::assertIsCallable($functions[0]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getPlatform() returns platform object')] public function getPlatformReturnsPlatform(): void { static::assertSame($this->mockPlatform, $this->adapter->getPlatform()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getProfiler() will store profiler')] public function getProfilerReturnsProfiler(): void { @@ -227,14 +228,14 @@ public function getProfilerReturnsProfiler(): void static::assertInstanceOf(Profiler\Profiler::class, $adapter->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getPlatform() returns platform object')] public function getQueryResultSetPrototypeReturnsResultSet(): void { static::assertInstanceOf(ResultSetInterface::class, $this->adapter->getQueryResultSetPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsDriverAndPlatformCaseInsensitively(): void { static::assertSame($this->mockDriver, $this->adapter->driver); @@ -250,7 +251,7 @@ public function magicGetReturnsDriverAndPlatformCaseInsensitively(): void $this->adapter->foo; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test prepareQuery() binds an array of parameters as a ParameterContainer')] public function prepareQueryBindsParameterArray(): void { @@ -264,7 +265,7 @@ public function prepareQueryBindsParameterArray(): void $this->adapter->prepareQuery('SELECT foo, :bar', ['bar' => 'foo']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test prepareQuery() binds a ParameterContainer directly')] public function prepareQueryBindsParameterContainerDirectly(): void { @@ -278,7 +279,7 @@ public function prepareQueryBindsParameterContainerDirectly(): void $this->adapter->prepareQuery('SELECT foo, :bar', $parameterContainer); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test prepareQuery() prepares a statement without executing it')] public function prepareQueryPreparesStatementWithoutExecuting(): void { @@ -294,7 +295,7 @@ public function prepareQueryPreparesStatementWithoutExecuting(): void * @throws Exception * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('#210')] public function producedResultSetPrototypeIsDifferentForEachQuery(): void { @@ -314,7 +315,7 @@ public function producedResultSetPrototypeIsDifferentForEachQuery(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function queryThrowsOnInvalidParameterType(): void { self::expectException(InvalidArgumentException::class); @@ -326,7 +327,7 @@ public function queryThrowsOnInvalidParameterType(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test query() in execute mode produces a driver result object')] public function queryWhenExecutedProducesAResult(): void { @@ -341,7 +342,7 @@ public function queryWhenExecutedProducesAResult(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test query() in execute mode produces a resultset object')] public function queryWhenExecutedProducesAResultSetObjectWhenResultIsQuery(): void { @@ -370,7 +371,7 @@ static function (?ResultSetInterface $resultPrototype = null): ResultSetInterfac /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test query() in prepare mode produces a statement object')] public function queryWhenPreparedProducesStatement(): void { @@ -381,7 +382,7 @@ public function queryWhenPreparedProducesStatement(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test query() in prepare mode, with array of parameters, produces a result object')] public function queryWhenPreparedWithParameterArrayProducesResult(): void { @@ -403,7 +404,7 @@ public function queryWhenPreparedWithParameterArrayProducesResult(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test query() in prepare mode, with ParameterContainer, produces a result object')] public function queryWhenPreparedWithParameterContainerProducesResult(): void { @@ -423,7 +424,7 @@ public function queryWhenPreparedWithParameterContainerProducesResult(): void static::assertInstanceOf(ResultSet::class, $r); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setProfilerDelegatesToDriverWhenProfilerAware(): void { $profiler = $this->createMock(Profiler\ProfilerInterface::class); diff --git a/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php b/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php index a85dea92..29852926 100644 --- a/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php +++ b/test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php @@ -19,6 +19,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; @@ -48,7 +49,7 @@ public static function providerValidService(): array ]; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canCreateReturnsFalseForEmptyConfig(): void { $container = new ServiceManager(); @@ -59,7 +60,7 @@ public function canCreateReturnsFalseForEmptyConfig(): void static::assertFalse($factory->canCreate($container, 'PhpDb\Adapter\Writer')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getConfigCachesResult(): void { $container = $this->createMock(ContainerInterface::class); @@ -78,7 +79,7 @@ public function getConfigCachesResult(): void $factory->canCreate($container, 'anything'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getConfigReturnsEmptyWhenContainerHasNoConfig(): void { $container = $this->createMock(ContainerInterface::class); @@ -93,7 +94,7 @@ public function getConfigReturnsEmptyWhenContainerHasNoConfig(): void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('providerInvalidService')] public function invalidService(string $service): void { @@ -101,7 +102,7 @@ public function invalidService(string $service): void $this->serviceManager->get($service); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeThrowsWhenDriverNotConfigured(): void { $container = new ServiceManager(); @@ -121,7 +122,7 @@ public function invokeThrowsWhenDriverNotConfigured(): void $factory($container, 'PhpDb\Adapter\NoDriver'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeUsesResultSetFromContainer(): void { $resultSet = new ResultSet(); @@ -163,7 +164,7 @@ public function invokeUsesResultSetFromContainer(): void * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('providerValidService')] public function validService(string $service): void { diff --git a/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php b/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php index bc635a84..466e0ef1 100644 --- a/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php +++ b/test/unit/Adapter/Container/AdapterInterfaceDelegatorTest.php @@ -19,6 +19,7 @@ use PhpDbTest\Adapter\TestAsset\ConcreteAdapterAwareObject; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerExceptionInterface; @@ -34,7 +35,7 @@ #[CoversMethod(AdapterInterfaceDelegator::class, '__invoke')] final class AdapterInterfaceDelegatorTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delegatorWithPluginManager(): void { $databaseAdapter = new Adapter( @@ -87,7 +88,7 @@ public function validate(mixed $instance): void {} * @throws NotFoundExceptionInterface * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delegatorWithServiceManager(): void { $databaseAdapter = new Adapter( @@ -123,7 +124,7 @@ public function delegatorWithServiceManager(): void * @throws NotFoundExceptionInterface * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delegatorWithServiceManagerAndCustomAdapterName(): void { $databaseAdapter = new Adapter( @@ -154,7 +155,7 @@ public function delegatorWithServiceManagerAndCustomAdapterName(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void { $container = $this->createMock(ContainerInterface::class); @@ -182,7 +183,7 @@ public function invokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAdapterShouldBeCalledForExistingAdapter(): void { $container = $this->createMock(ContainerInterface::class); @@ -213,7 +214,7 @@ public function setAdapterShouldBeCalledForExistingAdapter(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAdapterShouldBeCalledForOnlyConcreteAdapter(): void { $container = $this->createMock(ContainerInterface::class); @@ -245,7 +246,7 @@ public function setAdapterShouldBeCalledForOnlyConcreteAdapter(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAdapterShouldNotBeCalledForMissingAdapter(): void { $container = $this->createMock(ContainerInterface::class); @@ -271,7 +272,7 @@ public function setAdapterShouldNotBeCalledForMissingAdapter(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAdapterShouldNotBeCalledForWrongClassInstance(): void { $container = $this->createMock(ContainerInterface::class); @@ -294,7 +295,7 @@ public function setAdapterShouldNotBeCalledForWrongClassInstance(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setStateWithCustomAdapterName(): void { $delegator = AdapterInterfaceDelegator::__set_state(['adapterName' => 'custom']); @@ -317,7 +318,7 @@ public function setStateWithCustomAdapterName(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setStateWithDefaultAdapterName(): void { $delegator = AdapterInterfaceDelegator::__set_state([]); diff --git a/test/unit/Adapter/Driver/AbstractConnectionTest.php b/test/unit/Adapter/Driver/AbstractConnectionTest.php index f8aa87c2..d11cadda 100644 --- a/test/unit/Adapter/Driver/AbstractConnectionTest.php +++ b/test/unit/Adapter/Driver/AbstractConnectionTest.php @@ -9,6 +9,7 @@ use PhpDbTest\Adapter\Driver\TestAsset\TestConnection; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(AbstractConnection::class, 'disconnect')] @@ -22,7 +23,7 @@ #[Group('unit')] final class AbstractConnectionTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function disconnectIsNoOpWhenNotConnected(): void { $connection = new TestConnection(); @@ -32,7 +33,7 @@ public function disconnectIsNoOpWhenNotConnected(): void static::assertSame($connection, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function disconnectNullsResourceWhenConnected(): void { $connection = new TestConnection(); @@ -45,7 +46,7 @@ public function disconnectNullsResourceWhenConnected(): void static::assertFalse($connection->isConnected()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getConnectionParametersReturnsEmptyByDefault(): void { $connection = new TestConnection(); @@ -53,7 +54,7 @@ public function getConnectionParametersReturnsEmptyByDefault(): void static::assertSame([], $connection->getConnectionParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDriverNameReturnsNullByDefault(): void { $connection = new TestConnection(); @@ -61,7 +62,7 @@ public function getDriverNameReturnsNullByDefault(): void static::assertNull($connection->getDriverName()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDriverNameReturnsValueWhenSet(): void { $connection = new TestConnection('sqlite'); @@ -69,7 +70,7 @@ public function getDriverNameReturnsValueWhenSet(): void static::assertSame('sqlite', $connection->getDriverName()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getProfilerReturnsNullByDefault(): void { $connection = new TestConnection(); @@ -77,7 +78,7 @@ public function getProfilerReturnsNullByDefault(): void static::assertNull($connection->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getResourceAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(); @@ -90,7 +91,7 @@ public function getResourceAutoConnectsWhenNotConnected(): void static::assertSame('fake-resource', $resource); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function inTransactionReturnsFalseByDefault(): void { $connection = new TestConnection(); @@ -98,7 +99,7 @@ public function inTransactionReturnsFalseByDefault(): void static::assertFalse($connection->inTransaction()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setConnectionParametersStoresAndReturnsConnection(): void { $connection = new TestConnection(); @@ -110,7 +111,7 @@ public function setConnectionParametersStoresAndReturnsConnection(): void static::assertSame($params, $connection->getConnectionParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setProfilerStoresAndReturnsProfiler(): void { $connection = new TestConnection(); diff --git a/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php b/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php index 2a2b35dc..f21d9a26 100644 --- a/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php +++ b/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php @@ -10,13 +10,14 @@ use PhpDbTest\Adapter\Driver\Feature\TestAsset\TestDriverFeature; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] #[CoversMethod(AbstractFeature::class, 'setDriver')] final class AbstractFeatureTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDriverStoresDriverAndReturnsInstance(): void { $feature = new TestDriverFeature(); diff --git a/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php b/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php index ee56381e..66f45040 100644 --- a/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php +++ b/test/unit/Adapter/Driver/Feature/DriverFeatureProviderTraitTest.php @@ -12,6 +12,7 @@ use PhpDbTest\Adapter\Driver\TestAsset\TestFeatureDriver; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function sprintf; @@ -22,7 +23,7 @@ #[CoversMethod(DriverFeatureProviderTrait::class, 'getFeature')] final class DriverFeatureProviderTraitTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addFeaturesAddsMultipleFeatures(): void { $driver = new TestFeatureDriver(); @@ -34,7 +35,7 @@ public function addFeaturesAddsMultipleFeatures(): void static::assertNotFalse($driver->getFeature($feature1::class)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addFeatureSetsDriverAndStoresFeature(): void { $driver = new TestFeatureDriver(); @@ -46,7 +47,7 @@ public function addFeatureSetsDriverAndStoresFeature(): void static::assertSame($feature, $driver->getFeature($feature::class)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addFeatureThrowsWhenUsedOutsideDriverInterface(): void { $nonDriver = new class implements DriverFeatureProviderInterface { @@ -65,7 +66,7 @@ public function addFeatureThrowsWhenUsedOutsideDriverInterface(): void $nonDriver->addFeature($feature); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFeatureReturnsFalseWhenNotFound(): void { $driver = new TestFeatureDriver(); @@ -73,7 +74,7 @@ public function getFeatureReturnsFalseWhenNotFound(): void static::assertFalse($driver->getFeature('NonExistent')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFeatureReturnsFeatureByClassName(): void { $driver = new TestFeatureDriver(); diff --git a/test/unit/Adapter/Driver/Pdo/ConnectionTest.php b/test/unit/Adapter/Driver/Pdo/ConnectionTest.php index 673651eb..81fae63e 100644 --- a/test/unit/Adapter/Driver/Pdo/ConnectionTest.php +++ b/test/unit/Adapter/Driver/Pdo/ConnectionTest.php @@ -18,6 +18,7 @@ use PhpDbTest\Adapter\Driver\Pdo\TestAsset\TestPdo; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -36,7 +37,7 @@ final class ConnectionTest extends TestCase { protected TestConnection $connection; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function beginTransactionAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); @@ -48,7 +49,7 @@ public function beginTransactionAutoConnectsWhenNotConnected(): void static::assertTrue($connection->isConnected()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function commitAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(new SqliteMemoryPdo()); @@ -63,7 +64,7 @@ public function commitAutoConnectsWhenNotConnected(): void static::assertTrue($connection->isConnected()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithArraySetsConnectionParameters(): void { $params = ['dsn' => 'sqlite::memory:', 'username' => 'user']; @@ -72,7 +73,7 @@ public function constructorWithArraySetsConnectionParameters(): void static::assertSame($params, $connection->getConnectionParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithPdoResourceSetsConnected(): void { $pdo = new SqliteMemoryPdo(); @@ -81,7 +82,7 @@ public function constructorWithPdoResourceSetsConnected(): void static::assertTrue($connection->isConnected()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeAutoConnectsWhenNotConnected(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); @@ -94,7 +95,7 @@ public function executeAutoConnectsWhenNotConnected(): void static::assertTrue($connection->isConnected()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeCallsProfilerFinishBeforeThrowingOnError(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -111,7 +112,7 @@ public function executeCallsProfilerFinishBeforeThrowingOnError(): void @$connection->execute('INVALID SQL STATEMENT HERE %%%'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeCallsProfilerStartAndFinish(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -126,7 +127,7 @@ public function executeCallsProfilerStartAndFinish(): void $connection->execute('SELECT 1'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fluentSetDriver(): void { $driver = $this->createMock(PdoDriverInterface::class); @@ -139,7 +140,7 @@ public function fluentSetDriver(): void /** * Test getConnectedDsn returns a DSN string if it has been set */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDsnReturnsDsnAfterConnect(): void { $dsn = 'sqlite::memory:'; @@ -153,7 +154,7 @@ public function getDsnReturnsDsnAfterConnect(): void static::assertEquals($dsn, $responseString); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDsnThrowsWhenDsnIsNull(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); @@ -168,7 +169,7 @@ public function getDsnThrowsWhenDsnIsNull(): void $connection->getDsn(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareAutoConnectsAndReturnsStatement(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); @@ -185,14 +186,14 @@ public function prepareAutoConnectsAndReturnsStatement(): void /** * Test getResource method tries to connect to the database, it should never return null */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resource(): void { $resource = $this->connection->getResource(); static::assertNotNull($resource); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setConnectionParametersStoresParams(): void { $params = ['dsn' => 'sqlite::memory:', 'username' => 'test']; diff --git a/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php b/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php index eb83add0..f16face9 100644 --- a/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php +++ b/test/unit/Adapter/Driver/Pdo/ConnectionTransactionsTest.php @@ -12,6 +12,7 @@ use PhpDbTest\TestAsset\ConnectionWrapper; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; /** @@ -27,27 +28,27 @@ final class ConnectionTransactionsTest extends TestCase { protected ConnectionWrapper $wrapper; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function beginTransactionReturnsInstanceOfConnection(): void { static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->beginTransaction()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function beginTransactionSetsInTransactionAtTrue(): void { $this->wrapper->beginTransaction(); static::assertTrue($this->wrapper->inTransaction()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function commitReturnsInstanceOfConnection(): void { $this->wrapper->beginTransaction(); static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function commitSetsInTransactionAtFalse(): void { $this->wrapper->beginTransaction(); @@ -58,13 +59,13 @@ public function commitSetsInTransactionAtFalse(): void /** * Standalone commit after a SET autocommit=0; */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function commitWithoutBeginReturnsInstanceOfConnection(): void { static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function nestedTransactionsCommit(): void { $nested = 0; @@ -92,7 +93,7 @@ public function nestedTransactionsCommit(): void static::assertSame(--$nested, $this->wrapper->getNestedTransactionsCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function nestedTransactionsRollback(): void { $nested = 0; @@ -115,7 +116,7 @@ public function nestedTransactionsRollback(): void static::assertSame(0, $this->wrapper->getNestedTransactionsCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rollbackDisconnectedThrowsException(): void { $this->wrapper->disconnect(); @@ -125,14 +126,14 @@ public function rollbackDisconnectedThrowsException(): void $this->wrapper->rollback(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rollbackReturnsInstanceOfConnection(): void { $this->wrapper->beginTransaction(); static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->rollback()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rollbackSetsInTransactionAtFalse(): void { $this->wrapper->beginTransaction(); @@ -140,7 +141,7 @@ public function rollbackSetsInTransactionAtFalse(): void static::assertFalse($this->wrapper->inTransaction()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rollbackWithoutBeginThrowsException(): void { self::expectException(RuntimeException::class); @@ -151,7 +152,7 @@ public function rollbackWithoutBeginThrowsException(): void /** * Standalone commit after a SET autocommit=0; */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function standaloneCommit(): void { static::assertFalse($this->wrapper->inTransaction()); diff --git a/test/unit/Adapter/Driver/Pdo/PdoTest.php b/test/unit/Adapter/Driver/Pdo/PdoTest.php index 874e819d..caa6368c 100644 --- a/test/unit/Adapter/Driver/Pdo/PdoTest.php +++ b/test/unit/Adapter/Driver/Pdo/PdoTest.php @@ -21,6 +21,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(AbstractPdo::class, 'getResultPrototype')] @@ -66,13 +67,13 @@ public static function getParamsAndType(): array ]; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function checkEnvironmentReturnsTrue(): void { static::assertTrue($this->pdo->checkEnvironment()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorAddsFeaturesWhenDriverSupportsFeatures(): void { $feature = $this->createMock(DriverFeatureInterface::class); @@ -83,7 +84,7 @@ public function constructorAddsFeaturesWhenDriverSupportsFeatures(): void static::assertSame($feature, $pdo->getFeature($feature::class)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorSetsDriverOnConnection(): void { $connection = new TestConnection(new SqliteMemoryPdo()); @@ -92,7 +93,7 @@ public function constructorSetsDriverOnConnection(): void static::assertSame($connection, $pdo->getConnection()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createStatementWithNullConnectsAndInitializes(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); @@ -103,7 +104,7 @@ public function createStatementWithNullConnectsAndInitializes(): void static::assertInstanceOf(Statement::class, $statement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createStatementWithPdoStatementResource(): void { $connection = new TestConnection(new SqliteMemoryPdo()); @@ -116,7 +117,7 @@ public function createStatementWithPdoStatementResource(): void static::assertSame($pdoStmt, $statement->getResource()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createStatementWithSqlString(): void { $connection = new TestConnection(new SqliteMemoryPdo()); @@ -128,7 +129,7 @@ public function createStatementWithSqlString(): void static::assertSame('SELECT 1', $statement->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('getParamsAndType')] public function formatParameterNameFormatsCorrectly(int|string $name, ?string $type, string $expected): void { @@ -136,13 +137,13 @@ public function formatParameterNameFormatsCorrectly(int|string $name, ?string $t static::assertEquals($expected, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function formatParameterNameReturnsQuestionMarkForNumericWithoutType(): void { static::assertSame('?', $this->pdo->formatParameterName(42)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('getInvalidParamName')] public function formatParameterNameWithInvalidCharacters(string $name): void { @@ -150,7 +151,7 @@ public function formatParameterNameWithInvalidCharacters(string $name): void $this->pdo->formatParameterName($name); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getConnectionReturnsConnectionInstance(): void { $connection = $this->pdo->getConnection(); @@ -158,7 +159,7 @@ public function getConnectionReturnsConnectionInstance(): void static::assertInstanceOf(TestConnection::class, $connection); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLastGeneratedValueDelegatesToConnection(): void { $connection = new TestConnection(new SqliteMemoryPdo()); @@ -169,13 +170,13 @@ public function getLastGeneratedValueDelegatesToConnection(): void static::assertSame('0', $value); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getPrepareTypeReturnsNamed(): void { static::assertSame(DriverInterface::PARAMETERIZATION_NAMED, $this->pdo->getPrepareType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getProfilerReturnsSetProfiler(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -185,7 +186,7 @@ public function getProfilerReturnsSetProfiler(): void static::assertSame($profiler, $this->pdo->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getProfilerThrowsWhenNotInitialized(): void { $pdo = new TestPdo([]); @@ -195,7 +196,7 @@ public function getProfilerThrowsWhenNotInitialized(): void $unused = $pdo->getProfiler(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getResultPrototypeReturnsResult(): void { $resultPrototype = $this->pdo->getResultPrototype(); @@ -203,7 +204,7 @@ public function getResultPrototypeReturnsResult(): void static::assertInstanceOf(Result::class, $resultPrototype); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setProfilerPropagatesProfilerToConnectionAndStatement(): void { $profiler = $this->createMock(ProfilerInterface::class); diff --git a/test/unit/Adapter/Driver/Pdo/ResultTest.php b/test/unit/Adapter/Driver/Pdo/ResultTest.php index 1da02c86..e4f9cd1a 100644 --- a/test/unit/Adapter/Driver/Pdo/ResultTest.php +++ b/test/unit/Adapter/Driver/Pdo/ResultTest.php @@ -13,6 +13,7 @@ use PhpDbTest\TestAsset\TemporaryResultSet; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use stdClass; @@ -42,7 +43,7 @@ #[Group('unit')] final class ResultTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bufferIsCallableWithNoEffect(): void { $result = new Result(); @@ -51,7 +52,7 @@ public function bufferIsCallableWithNoEffect(): void static::assertFalse($result->isBuffered()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countCachesResultFromClosure(): void { $callCount = 0; @@ -71,7 +72,7 @@ public function countCachesResultFromClosure(): void static::assertSame(1, $callCount); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countCachesResultFromStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); @@ -86,7 +87,7 @@ public function countCachesResultFromStatementRowCount(): void static::assertSame(3, $result->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countWithClosureInvokesClosureAndReturnsValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); @@ -100,7 +101,7 @@ public function countWithClosureInvokesClosureAndReturnsValue(): void static::assertSame(42, $result->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countWithIntReturnsProvidedValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); @@ -112,7 +113,7 @@ public function countWithIntReturnsProvidedValue(): void static::assertSame(10, $result->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countWithNoRowCountFallsBackToStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); @@ -129,7 +130,7 @@ public function countWithNoRowCountFallsBackToStatementRowCount(): void /** * Tests current method returns same data on consecutive calls. */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsSameDataOnConsecutiveCalls(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); @@ -146,7 +147,7 @@ public function currentReturnsSameDataOnConsecutiveCalls(): void /** * Tests whether the fetch mode has a broader range */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fetchModeAcceptsNamedMode(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); @@ -163,7 +164,7 @@ public function fetchModeAcceptsNamedMode(): void /** * Tests whether the fetch mode was set properly and */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fetchModeObjReturnsStdClass(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); @@ -179,7 +180,7 @@ public function fetchModeObjReturnsStdClass(): void static::assertInstanceOf('stdClass', $result->current()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getAffectedRowsDelegatesToRowCount(): void { $stub = $this->createMock(PDOStatement::class); @@ -191,7 +192,7 @@ public function getAffectedRowsDelegatesToRowCount(): void static::assertSame(5, $result->getAffectedRows()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFetchModeDefaultIsAssoc(): void { $result = new Result(); @@ -199,7 +200,7 @@ public function getFetchModeDefaultIsAssoc(): void static::assertSame(PDO::FETCH_ASSOC, $result->getFetchMode()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCountDelegatesToColumnCount(): void { $stub = $this->createMock(PDOStatement::class); @@ -211,7 +212,7 @@ public function getFieldCountDelegatesToColumnCount(): void static::assertSame(3, $result->getFieldCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getGeneratedValueReturnsInitializedValue(): void { $stub = $this->createMock(PDOStatement::class); @@ -221,7 +222,7 @@ public function getGeneratedValueReturnsInitializedValue(): void static::assertSame(42, $result->getGeneratedValue()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getGeneratedValueReturnsNullByDefault(): void { $result = new Result(); @@ -229,7 +230,7 @@ public function getGeneratedValueReturnsNullByDefault(): void static::assertNull($result->getGeneratedValue()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void { $stub = $this->createMock(PDOStatement::class); @@ -245,7 +246,7 @@ public function getQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void static::assertNotSame($prototype, $returned); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQueryResultInitializesReturnedResultSetWithThisResult(): void { $stub = $this->createMock(PDOStatement::class); @@ -257,7 +258,7 @@ public function getQueryResultInitializesReturnedResultSetWithThisResult(): void static::assertSame($result->getFieldCount(), $result->getQueryResult()->getFieldCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven(): void { $stub = $this->createMock(PDOStatement::class); @@ -269,7 +270,7 @@ public function getQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven(): v static::assertInstanceOf(ResultSet::class, $result->getQueryResult()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQueryResultThrowsWhenResultIsNotAQueryResult(): void { $stub = $this->createMock(PDOStatement::class); @@ -282,7 +283,7 @@ public function getQueryResultThrowsWhenResultIsNotAQueryResult(): void $result->getQueryResult(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getResourceReturnsPdoStatement(): void { $stub = $this->createMock(PDOStatement::class); @@ -292,7 +293,7 @@ public function getResourceReturnsPdoStatement(): void static::assertSame($stub, $result->getResource()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeStoresResourceAndValues(): void { $stub = $this->createMock(PDOStatement::class); @@ -304,7 +305,7 @@ public function initializeStoresResourceAndValues(): void static::assertSame(5, $result->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isBufferedReturnsFalse(): void { $result = new Result(); @@ -312,7 +313,7 @@ public function isBufferedReturnsFalse(): void static::assertFalse($result->isBuffered()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isQueryResultReturnsFalseWhenNoColumns(): void { $stub = $this->createMock(PDOStatement::class); @@ -324,7 +325,7 @@ public function isQueryResultReturnsFalseWhenNoColumns(): void static::assertFalse($result->isQueryResult()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isQueryResultReturnsTrueWhenColumnsExist(): void { $stub = $this->createMock(PDOStatement::class); @@ -336,7 +337,7 @@ public function isQueryResultReturnsTrueWhenColumnsExist(): void static::assertTrue($result->isQueryResult()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function nextAdvancesPositionAndFetchesData(): void { $stub = $this->createMock(PDOStatement::class); @@ -352,7 +353,7 @@ public function nextAdvancesPositionAndFetchesData(): void static::assertSame(1, $result->key()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rewindResetsIterationToStart(): void { $data = [ @@ -384,7 +385,7 @@ public function rewindResetsIterationToStart(): void static::assertEquals($data[1], $result->current()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void { $stub = $this->createMock(PDOStatement::class); @@ -401,7 +402,7 @@ public function rewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void $result->rewind(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setFetchModeStoresValidMode(): void { $result = new Result(); @@ -410,7 +411,7 @@ public function setFetchModeStoresValidMode(): void static::assertSame(PDO::FETCH_NUM, $result->getFetchMode()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setFetchModeThrowsOnInvalidFetchMode(): void { $result = new Result(); @@ -421,7 +422,7 @@ public function setFetchModeThrowsOnInvalidFetchMode(): void $result->setFetchMode(9999); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setFetchModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -430,7 +431,7 @@ public function setFetchModeThrowsOnInvalidMode(): void $result->setFetchMode(13); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setStatementModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -439,7 +440,7 @@ public function setStatementModeThrowsOnInvalidMode(): void $result->setStatementMode('invalid'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setStatementModeToForward(): void { $result = new Result(); @@ -449,7 +450,7 @@ public function setStatementModeToForward(): void static::assertSame(Result::STATEMENT_MODE_FORWARD, $result->getStatementMode()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setStatementModeToScrollable(): void { $result = new Result(); @@ -459,7 +460,7 @@ public function setStatementModeToScrollable(): void static::assertSame(Result::STATEMENT_MODE_SCROLLABLE, $result->getStatementMode()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function validReturnsFalseWhenCurrentDataIsFalse(): void { $stub = $this->createMock(PDOStatement::class); @@ -472,7 +473,7 @@ public function validReturnsFalseWhenCurrentDataIsFalse(): void static::assertFalse($result->valid()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function validReturnsTrueWhenCurrentDataExists(): void { $stub = $this->createMock(PDOStatement::class); diff --git a/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php b/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php index 8dcbb5fb..033fc3e3 100644 --- a/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php +++ b/test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php @@ -9,6 +9,7 @@ use PDOStatement; use PhpDb\Adapter\Driver\Pdo\AbstractPdo; use PhpDb\Adapter\Driver\Pdo\Statement; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -18,7 +19,7 @@ final class StatementIntegrationTest extends TestCase protected PDOStatement|MockObject $pdoStatementMock; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function statementExecuteWillConvertPhpBoolToPdoBoolWhenBinding(): void { $this->pdoStatementMock @@ -32,7 +33,7 @@ public function statementExecuteWillConvertPhpBoolToPdoBoolWhenBinding(): void $this->statement->execute(['foo' => false]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function statementExecuteWillUsePdoIntForIntWhenBinding(): void { $this->pdoStatementMock @@ -46,7 +47,7 @@ public function statementExecuteWillUsePdoIntForIntWhenBinding(): void $this->statement->execute(['foo' => 123]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function statementExecuteWillUsePdoStrByDefaultWhenBinding(): void { $this->pdoStatementMock @@ -60,7 +61,7 @@ public function statementExecuteWillUsePdoStrByDefaultWhenBinding(): void $this->statement->execute(['foo' => 'bar']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function statementExecuteWillUsePdoStrForStringIntegerWhenBinding(): void { $this->pdoStatementMock diff --git a/test/unit/Adapter/Driver/Pdo/StatementTest.php b/test/unit/Adapter/Driver/Pdo/StatementTest.php index fda6a7e9..f95ff1a6 100644 --- a/test/unit/Adapter/Driver/Pdo/StatementTest.php +++ b/test/unit/Adapter/Driver/Pdo/StatementTest.php @@ -20,6 +20,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -59,7 +60,7 @@ public static function invalidParameterNameProvider(): array ]; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersDetectsBooleanValueType(): void { $pdo = new SqliteMemoryPdo(); @@ -76,7 +77,7 @@ public function bindParametersDetectsBooleanValueType(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersDetectsNullValueType(): void { $pdo = new SqliteMemoryPdo(); @@ -93,7 +94,7 @@ public function bindParametersDetectsNullValueType(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersFromContainerSkipsWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); @@ -106,7 +107,7 @@ public function bindParametersFromContainerSkipsWhenAlreadyBound(): void static::assertInstanceOf(Result::class, $result1); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersWithErrataTypeDefaultsToString(): void { $pdo = new SqliteMemoryPdo(); @@ -123,7 +124,7 @@ public function bindParametersWithErrataTypeDefaultsToString(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersWithErrataTypeInteger(): void { $pdo = new SqliteMemoryPdo(); @@ -140,7 +141,7 @@ public function bindParametersWithErrataTypeInteger(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersWithErrataTypeLob(): void { $pdo = new SqliteMemoryPdo(); @@ -157,7 +158,7 @@ public function bindParametersWithErrataTypeLob(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersWithErrataTypeNull(): void { $pdo = new SqliteMemoryPdo(); @@ -174,7 +175,7 @@ public function bindParametersWithErrataTypeNull(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bindParametersWithPositionalIntegers(): void { $pdo = new SqliteMemoryPdo(); @@ -193,7 +194,7 @@ public function bindParametersWithPositionalIntegers(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneClonesParameterContainerWhenSet(): void { $container = new ParameterContainer(['key' => 'value']); @@ -205,7 +206,7 @@ public function cloneClonesParameterContainerWhenSet(): void static::assertSame('value', $clone->getParameterContainer()->offsetGet('key')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneResetsState(): void { $pdo = new SqliteMemoryPdo(); @@ -224,7 +225,7 @@ public function cloneResetsState(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorAcceptsParameterContainerAndOptions(): void { $container = new ParameterContainer(['key' => 'value']); @@ -233,7 +234,7 @@ public function constructorAcceptsParameterContainerAndOptions(): void static::assertSame($container, $statement->getParameterContainer()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeAutoPrepares(): void { $pdo = new SqliteMemoryPdo(); @@ -249,7 +250,7 @@ public function executeAutoPrepares(): void static::assertTrue($this->statement->isPrepared()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeCallsProfilerFinishOnFailure(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -274,7 +275,7 @@ public function executeCallsProfilerFinishOnFailure(): void $this->statement->execute(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeCallsProfilerOnSuccess(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -290,7 +291,7 @@ public function executeCallsProfilerOnSuccess(): void $this->statement->execute(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeCastsNonIntErrorCodeToZero(): void { $pdoException = new PDOException('fail'); @@ -318,7 +319,7 @@ public function executeCastsNonIntErrorCodeToZero(): void } } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeReturnsResult(): void { $this->statement->setDriver(new TestPdo(new TestConnection($pdo = new SqliteMemoryPdo()))); @@ -327,7 +328,7 @@ public function executeReturnsResult(): void static::assertInstanceOf(Result::class, $this->statement->execute()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeThrowsInvalidQueryExceptionOnPdoException(): void { $pdoStmt = $this->createMock(PDOStatement::class); @@ -347,7 +348,7 @@ public function executeThrowsInvalidQueryExceptionOnPdoException(): void $this->statement->execute(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidParameterNameProvider')] public function executeThrowsOnInvalidParameterName(string $name): void { @@ -360,7 +361,7 @@ public function executeThrowsOnInvalidParameterName(string $name): void $this->statement->execute([$name => 'value']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeWithArrayParametersMergesIntoContainer(): void { $pdo = new SqliteMemoryPdo(); @@ -374,7 +375,7 @@ public function executeWithArrayParametersMergesIntoContainer(): void static::assertInstanceOf(Result::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeWithParameterContainerSetsContainer(): void { $pdo = new SqliteMemoryPdo(); @@ -392,7 +393,7 @@ public function executeWithParameterContainerSetsContainer(): void static::assertSame($container, $statement->getParameterContainer()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fluentPrepare(): void { $this->statement->initialize(new SqliteMemoryPdo()); @@ -401,19 +402,19 @@ public function fluentPrepare(): void static::assertSame($this->statement, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fluentSetDriver(): void { static::assertEquals($this->statement, $this->statement->setDriver(new TestPdo([]))); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fluentSetParameterContainer(): void { static::assertSame($this->statement, $this->statement->setParameterContainer(new ParameterContainer())); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getParameterContainerReturnsContainer(): void { $container = new ParameterContainer(); @@ -421,13 +422,13 @@ public function getParameterContainerReturnsContainer(): void static::assertSame($container, $this->statement->getParameterContainer()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getProfilerReturnsNullByDefault(): void { static::assertNull($this->statement->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getResourceReturnsPdoStatement(): void { $pdo = new SqliteMemoryPdo(); @@ -437,14 +438,14 @@ public function getResourceReturnsPdoStatement(): void static::assertSame($stmt, $this->statement->getResource()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSql(): void { $this->statement->setSql('SELECT 1'); static::assertSame('SELECT 1', $this->statement->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeSetsPdoResource(): void { $pdo = new SqliteMemoryPdo(); @@ -456,7 +457,7 @@ public function initializeSetsPdoResource(): void static::assertTrue($this->statement->isPrepared()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isPreparedReturnsTrueAfterPrepare(): void { static::assertFalse($this->statement->isPrepared()); @@ -465,7 +466,7 @@ public function isPreparedReturnsTrueAfterPrepare(): void static::assertTrue($this->statement->isPrepared()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareThrowsRuntimeExceptionOnPdoFailure(): void { $pdo = $this->createMock(PDO::class); @@ -479,7 +480,7 @@ public function prepareThrowsRuntimeExceptionOnPdoFailure(): void $this->statement->prepare(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareThrowsWhenAlreadyPrepared(): void { $this->statement->initialize(new SqliteMemoryPdo()); @@ -491,7 +492,7 @@ public function prepareThrowsWhenAlreadyPrepared(): void $this->statement->prepare('SELECT 2'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function secondExecuteSkipsBindingWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); @@ -507,7 +508,7 @@ public function secondExecuteSkipsBindingWhenAlreadyBound(): void static::assertInstanceOf(Result::class, $result2); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setProfilerStoresProfiler(): void { $profiler = $this->createMock(ProfilerInterface::class); @@ -517,7 +518,7 @@ public function setProfilerStoresProfiler(): void static::assertSame($profiler, $this->statement->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setResourceStoresPdoStatement(): void { $pdoStmt = $this->createMock(PDOStatement::class); @@ -527,7 +528,7 @@ public function setResourceStoresPdoStatement(): void static::assertSame($pdoStmt, $this->statement->getResource()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setSql(): void { $this->statement->setSql('SELECT 1'); diff --git a/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php b/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php index 33c50913..e363cb0f 100644 --- a/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php +++ b/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php @@ -7,13 +7,14 @@ use PhpDb\Adapter\Exception\InvalidConnectionParametersException; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] #[CoversMethod(InvalidConnectionParametersException::class, '__construct')] final class InvalidConnectionParametersExceptionTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorStoresMessageAndParameters(): void { $exception = new InvalidConnectionParametersException('msg', ['host', 'port']); diff --git a/test/unit/Adapter/ParameterContainerTest.php b/test/unit/Adapter/ParameterContainerTest.php index 8b5ce4c6..532e3c8e 100644 --- a/test/unit/Adapter/ParameterContainerTest.php +++ b/test/unit/Adapter/ParameterContainerTest.php @@ -9,6 +9,7 @@ use PhpDb\Adapter\ParameterContainer; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; @@ -42,7 +43,7 @@ final class ParameterContainerTest extends TestCase { protected ParameterContainer $parameterContainer; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithDataPopulatesContainer(): void { $container = new ParameterContainer(['a' => 1, 'b' => 2]); @@ -52,14 +53,14 @@ public function constructorWithDataPopulatesContainer(): void static::assertSame(2, $container->offsetGet('b')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test count() returns the proper count')] public function countsStoredParameters(): void { static::assertSame(1, $this->parameterContainer->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test current() returns the current element when used as an iterator')] public function current(): void { @@ -67,7 +68,7 @@ public function current(): void static::assertSame('bar', $value); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getErrataIterator() will return an iterator for the errata data')] public function getErrataIterator(): void { @@ -76,7 +77,7 @@ public function getErrataIterator(): void static::assertInstanceOf('ArrayIterator', $data); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getMaxLengthIterator() will return an iterator for the errata data')] public function getMaxLengthIterator(): void { @@ -85,7 +86,7 @@ public function getMaxLengthIterator(): void static::assertInstanceOf('ArrayIterator', $data); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test getNamedArray()')] public function getNamedArray(): void { @@ -93,7 +94,7 @@ public function getNamedArray(): void static::assertEquals(['foo' => 'bar'], $data); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getPositionalArrayReturnsValues(): void { $container = new ParameterContainer(['a' => 1, 'b' => 2, 'c' => 3]); @@ -101,14 +102,14 @@ public function getPositionalArrayReturnsValues(): void static::assertSame([1, 2, 3], $container->getPositionalArray()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox("unit test: Test key() returns the name of the current item's name")] public function key(): void { static::assertSame('foo', $this->parameterContainer->key()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test next() increases the pointer when used as an iterator')] public function next(): void { @@ -117,7 +118,7 @@ public function next(): void static::assertSame('baz', $this->parameterContainer->current()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetExists() returns proper values via method call and isset()')] public function offsetExists(): void { @@ -127,7 +128,7 @@ public function offsetExists(): void static::assertFalse(isset($this->parameterContainer['bar'])); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetGet() returns proper values via method call and array access')] public function offsetGet(): void { @@ -139,7 +140,7 @@ public function offsetGet(): void // @todo determine what should come back here } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetGetErrata() return persisted errata data, if it exists')] public function offsetGetErrata(): void { @@ -147,7 +148,7 @@ public function offsetGetErrata(): void static::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetGetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -156,7 +157,7 @@ public function offsetGetErrataByPositionalIndex(): void static::assertSame(ParameterContainer::TYPE_INTEGER, $container->offsetGetErrata(0)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetGetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -167,7 +168,7 @@ public function offsetGetErrataThrowsWhenNameDoesNotExist(): void $container->offsetGetErrata('nonexistent'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetGetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -176,7 +177,7 @@ public function offsetGetMaxLengthByPositionalIndex(): void static::assertSame(50, $container->offsetGetMaxLength(0)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetGetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -187,7 +188,7 @@ public function offsetGetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetGetMaxLength('nonexistent'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetHasErrata() will check if errata exists for a particular key')] public function offsetHasErrata(): void { @@ -195,7 +196,7 @@ public function offsetHasErrata(): void static::assertTrue($this->parameterContainer->offsetHasErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetHasErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -204,7 +205,7 @@ public function offsetHasErrataByPositionalIndex(): void static::assertTrue($container->offsetHasErrata(0)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetHasMaxLength() will check if errata exists for a particular key')] public function offsetHasMaxLength(): void { @@ -212,7 +213,7 @@ public function offsetHasMaxLength(): void static::assertTrue($this->parameterContainer->offsetHasMaxLength('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetHasMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -221,7 +222,7 @@ public function offsetHasMaxLengthByPositionalIndex(): void static::assertTrue($container->offsetHasMaxLength(0)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetSet() works via method call and array access')] public function offsetSet(): void { @@ -270,7 +271,7 @@ public function offsetSet(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(' unit test: Test offsetSetMaxLength() will persist errata data unit test: Test offsetGetMaxLength() return persisted errata data, if it exists @@ -281,7 +282,7 @@ public function offsetSetAndGetMaxLength(): void static::assertSame(100, $this->parameterContainer->offsetGetMaxLength('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetSetErrata() will persist errata data')] public function offsetSetErrata(): void { @@ -289,7 +290,7 @@ public function offsetSetErrata(): void static::assertEquals(ParameterContainer::TYPE_INTEGER, $this->parameterContainer->offsetGetErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -298,7 +299,7 @@ public function offsetSetErrataByPositionalIndex(): void static::assertSame(ParameterContainer::TYPE_STRING, $container->offsetGetErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -307,7 +308,7 @@ public function offsetSetMaxLengthByPositionalIndex(): void static::assertSame(50, $container->offsetGetMaxLength('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetReferenceCreatesReference(): void { $container = new ParameterContainer(['source' => 'original']); @@ -316,7 +317,7 @@ public function offsetSetReferenceCreatesReference(): void static::assertSame('original', $container->offsetGet('alias')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetThrowsOnInvalidKeyType(): void { $container = new ParameterContainer(); @@ -327,7 +328,7 @@ public function offsetSetThrowsOnInvalidKeyType(): void $container->offsetSet(1.5, 'value'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetWithIntNotInPositionsCastsToString(): void { $container = new ParameterContainer(); @@ -336,7 +337,7 @@ public function offsetSetWithIntNotInPositionsCastsToString(): void static::assertSame('value', $container->offsetGet('5')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSetWithNameMappingMatchForNonColonName(): void { $container = new ParameterContainer(); @@ -346,7 +347,7 @@ public function offsetSetWithNameMappingMatchForNonColonName(): void static::assertSame('updated', $container->offsetGet('c_0')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetUnset() works via method call and array access')] public function offsetUnset(): void { @@ -357,7 +358,7 @@ public function offsetUnset(): void static::assertFalse($this->parameterContainer->offsetExists('boo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnsetByPositionalIndex(): void { $container = new ParameterContainer(['a' => 'one', 'b' => 'two']); @@ -367,7 +368,7 @@ public function offsetUnsetByPositionalIndex(): void static::assertTrue($container->offsetExists('b')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetUnsetErrata() will unset data for a particular key')] public function offsetUnsetErrata(): void { @@ -376,7 +377,7 @@ public function offsetUnsetErrata(): void static::assertNull($this->parameterContainer->offsetGetErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnsetErrataByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -386,7 +387,7 @@ public function offsetUnsetErrataByPositionalIndex(): void static::assertNull($container->offsetGetErrata('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnsetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -397,7 +398,7 @@ public function offsetUnsetErrataThrowsWhenNameDoesNotExist(): void $container->offsetUnsetErrata('foo'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test offsetUnsetMaxLength() will unset data for a particular key')] public function offsetUnsetMaxLength(): void { @@ -406,7 +407,7 @@ public function offsetUnsetMaxLength(): void static::assertNull($this->parameterContainer->offsetGetMaxLength('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnsetMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -416,7 +417,7 @@ public function offsetUnsetMaxLengthByPositionalIndex(): void static::assertNull($container->offsetGetMaxLength('foo')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -427,7 +428,7 @@ public function offsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetUnsetMaxLength('foo'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test rewind() resets the iterators pointer')] public function rewind(): void { @@ -438,7 +439,7 @@ public function rewind(): void static::assertSame('foo', $this->parameterContainer->key()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test setFromArray() will populate the container')] public function setFromArray(): void { @@ -451,7 +452,7 @@ public function setFromArray(): void * * @see Insert::procesInsert as example */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setFromArrayNamed(): void { $this->parameterContainer->offsetSet('c_0', ':myparam'); @@ -460,7 +461,7 @@ public function setFromArrayNamed(): void static::assertSame('baz', $this->parameterContainer[':myparam']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test valid() returns whether the iterators current position is valid')] public function valid(): void { diff --git a/test/unit/Adapter/Platform/Sql92Test.php b/test/unit/Adapter/Platform/Sql92Test.php index 55d8cf44..3be65869 100644 --- a/test/unit/Adapter/Platform/Sql92Test.php +++ b/test/unit/Adapter/Platform/Sql92Test.php @@ -13,6 +13,7 @@ use PhpDbTest\TestAsset\TestSql92Platform; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Sql92::class, 'getName')] @@ -39,7 +40,7 @@ final class Sql92Test extends TestCase { protected Sql92 $platform; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function abstractPlatformQuoteValueEscapesWithDriver(): void { $platform = new TestPlatform($this->createStub(DriverInterface::class)); @@ -47,7 +48,7 @@ public function abstractPlatformQuoteValueEscapesWithDriver(): void static::assertSame("'test\\'value'", $platform->quoteValue("test'value")); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function abstractPlatformQuoteValueThrowsWithoutDriver(): void { $platform = new TestPlatform(); @@ -56,37 +57,37 @@ public function abstractPlatformQuoteValueThrowsWithoutDriver(): void $platform->quoteValue('value'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getIdentifierSeparator(): void { static::assertSame('.', $this->platform->getIdentifierSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getName(): void { static::assertSame('SQL92', $this->platform->getName()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQuoteIdentifierSymbol(): void { static::assertSame('"', $this->platform->getQuoteIdentifierSymbol()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getQuoteValueSymbol(): void { static::assertSame("'", $this->platform->getQuoteValueSymbol()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteIdentifier(): void { static::assertSame('"identifier"', $this->platform->quoteIdentifier('identifier')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteIdentifierChain(): void { static::assertSame('"identifier"', $this->platform->quoteIdentifierChain('identifier')); @@ -94,7 +95,7 @@ public function quoteIdentifierChain(): void static::assertSame('"schema"."identifier"', $this->platform->quoteIdentifierChain(['schema', 'identifier'])); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteIdentifierInFragment(): void { static::assertSame('"foo"."bar"', $this->platform->quoteIdentifierInFragment('foo.bar')); @@ -125,7 +126,7 @@ public function quoteIdentifierInFragment(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled(): void { $platform = new TestSql92Platform(quoteIdentifiers: false); @@ -133,7 +134,7 @@ public function quoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled(): v static::assertSame('foo.bar', $platform->quoteIdentifierInFragment('foo.bar')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteIdentifierReturnsUnquotedWhenQuotingDisabled(): void { $platform = new TestSql92Platform(quoteIdentifiers: false); @@ -141,7 +142,7 @@ public function quoteIdentifierReturnsUnquotedWhenQuotingDisabled(): void static::assertSame('test', $platform->quoteIdentifier('test')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteTrustedValueEscapesSpecialCharacters(): void { static::assertSame("'value'", $this->platform->quoteTrustedValue('value')); @@ -158,7 +159,7 @@ public function quoteTrustedValueEscapesSpecialCharacters(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteValueEscapesSpecialCharacters(): void { $platform = new TestSql92Platform(driver: $this->createStub(DriverInterface::class)); @@ -170,21 +171,21 @@ public function quoteValueEscapesSpecialCharacters(): void static::assertStringEndsWith("'", $quoted); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteValueListThrowsWithoutDriver(): void { $this->expectException(RuntimeException::class); static::assertSame("'Foo O\\'Bar'", $this->platform->quoteValueList("Foo O'Bar")); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteValueRaisesNoticeWithoutPlatformSupport(): void { $this->expectException(RuntimeException::class); $this->platform->quoteValue('value'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function quoteValueThrowsWithoutDriver(): void { $this->expectException(RuntimeException::class); diff --git a/test/unit/Adapter/Profiler/ProfilerTest.php b/test/unit/Adapter/Profiler/ProfilerTest.php index a794e9bd..805289c3 100644 --- a/test/unit/Adapter/Profiler/ProfilerTest.php +++ b/test/unit/Adapter/Profiler/ProfilerTest.php @@ -11,6 +11,7 @@ use PhpDb\Adapter\StatementContainer; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function sprintf; @@ -24,7 +25,7 @@ final class ProfilerTest extends TestCase { protected Profiler $profiler; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLastProfileReturnsSqlAndTimings(): void { $this->profiler->profilerStart('SELECT * FROM FOO'); @@ -37,7 +38,7 @@ public function getLastProfileReturnsSqlAndTimings(): void static::assertIsFloat($profile['elapse']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getProfilesReturnsAllRecordedProfiles(): void { $this->profiler->profilerStart('SELECT * FROM FOO1'); @@ -48,7 +49,7 @@ public function getProfilesReturnsAllRecordedProfiles(): void static::assertCount(2, $this->profiler->getProfiles()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function profilerFinishThrowsWithoutStart(): void { $this->profiler->profilerStart('SELECT * FROM FOO'); @@ -61,7 +62,7 @@ public function profilerFinishThrowsWithoutStart(): void $profiler->profilerFinish(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function profilerStartClonesParameterContainerFromStatementContainer(): void { $parameterContainer = new ParameterContainer(['key' => 'value']); @@ -77,14 +78,14 @@ public function profilerStartClonesParameterContainerFromStatementContainer(): v static::assertNotSame($parameterContainer, $profile['parameters']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function profilerStartWithStatementContainer(): void { $ret = $this->profiler->profilerStart(new StatementContainer()); static::assertSame($this->profiler, $ret); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function profilerStartWithString(): void { $ret = $this->profiler->profilerStart('SELECT * FROM FOO'); diff --git a/test/unit/Adapter/StatementContainerTest.php b/test/unit/Adapter/StatementContainerTest.php index 3aacd102..447a6241 100644 --- a/test/unit/Adapter/StatementContainerTest.php +++ b/test/unit/Adapter/StatementContainerTest.php @@ -8,6 +8,7 @@ use PhpDb\Adapter\StatementContainer; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] @@ -18,7 +19,7 @@ #[CoversMethod(StatementContainer::class, 'getParameterContainer')] final class StatementContainerTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithoutSqlDoesNotSetSql(): void { $container = new StatementContainer(); @@ -26,7 +27,7 @@ public function constructorWithoutSqlDoesNotSetSql(): void static::assertSame('', $container->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSqlSetsSql(): void { $container = new StatementContainer('SELECT 1'); @@ -34,7 +35,7 @@ public function constructorWithSqlSetsSql(): void static::assertSame('SELECT 1', $container->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAndGetParameterContainer(): void { $container = new StatementContainer(); @@ -46,7 +47,7 @@ public function setAndGetParameterContainer(): void static::assertSame($parameterContainer, $container->getParameterContainer()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAndGetSql(): void { $container = new StatementContainer(); diff --git a/test/unit/ConfigProviderTest.php b/test/unit/ConfigProviderTest.php index 3639c7e4..a8a325ca 100644 --- a/test/unit/ConfigProviderTest.php +++ b/test/unit/ConfigProviderTest.php @@ -47,7 +47,7 @@ public function getDependenciesIsCallableAsPartOfThePublicApi(): void static::assertEquals($this->config['dependencies'], (new ConfigProvider())->getDependencies()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invocationProvidesDependencyConfiguration(): void { static::assertEquals($this->config, (new ConfigProvider())()); diff --git a/test/unit/Container/AdapterInterfaceFactoryTest.php b/test/unit/Container/AdapterInterfaceFactoryTest.php index a8d7a40d..3d390e01 100644 --- a/test/unit/Container/AdapterInterfaceFactoryTest.php +++ b/test/unit/Container/AdapterInterfaceFactoryTest.php @@ -16,13 +16,14 @@ use PhpDb\ResultSet\ResultSetInterface; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] #[CoversMethod(AdapterInterfaceFactory::class, '__invoke')] final class AdapterInterfaceFactoryTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesAdapterWithAllDependencies(): void { $driverMock = $this->createMock(DriverInterface::class); @@ -50,7 +51,7 @@ public function invokeCreatesAdapterWithAllDependencies(): void static::assertInstanceOf(Adapter::class, $adapter); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesAdapterWithDefaultResultSet(): void { $driverMock = $this->createMock(DriverInterface::class); @@ -74,7 +75,7 @@ public function invokeCreatesAdapterWithDefaultResultSet(): void static::assertInstanceOf(ResultSet::class, $adapter->getQueryResultSetPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesAdapterWithoutOptionalProfiler(): void { $driverMock = $this->createMock(DriverInterface::class); @@ -99,7 +100,7 @@ public function invokeCreatesAdapterWithoutOptionalProfiler(): void static::assertNull($adapter->getProfiler()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeThrowsWhenAdapterConfigIsEmpty(): void { $driverMock = $this->createMock(DriverInterface::class); @@ -120,7 +121,7 @@ public function invokeThrowsWhenAdapterConfigIsEmpty(): void $factory($container, AdapterInterface::class); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeThrowsWhenContainerHasNoConfig(): void { $driverMock = $this->createMock(DriverInterface::class); diff --git a/test/unit/Container/TableIdentifierFactoryFactoryTest.php b/test/unit/Container/TableIdentifierFactoryFactoryTest.php index 02cd881c..3c3421ee 100644 --- a/test/unit/Container/TableIdentifierFactoryFactoryTest.php +++ b/test/unit/Container/TableIdentifierFactoryFactoryTest.php @@ -10,6 +10,7 @@ use PhpDb\Sql\TableIdentifierFactory; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; @@ -17,7 +18,7 @@ #[CoversMethod(TableIdentifierFactoryFactory::class, '__invoke')] final class TableIdentifierFactoryFactoryTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithConfiguredPrefix(): void { $container = new ServiceManager(); @@ -33,7 +34,7 @@ public function invokeCreatesFactoryWithConfiguredPrefix(): void static::assertSame('backup', $result->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithConfiguredSeparator(): void { $container = new ServiceManager(); @@ -50,7 +51,7 @@ public function invokeCreatesFactoryWithConfiguredSeparator(): void static::assertSame('__', $result->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void { $container = new ServiceManager(); @@ -67,7 +68,7 @@ public function invokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void static::assertSame('__', $result->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void { $container = new ServiceManager(); @@ -79,7 +80,7 @@ public function invokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void static::assertNull($result->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void { $container = $this->createMock(ContainerInterface::class); @@ -92,7 +93,7 @@ public function invokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void static::assertNull($result->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig(): void { $container = new ServiceManager(); @@ -103,7 +104,7 @@ public function invokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig(): voi static::assertNull($result->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): void { $container = new ServiceManager(); @@ -117,7 +118,7 @@ public function invokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): void static::assertNull($result->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeRejectsEmptyStringSeparatorFromConfig(): void { $container = new ServiceManager(); @@ -134,7 +135,7 @@ public function invokeRejectsEmptyStringSeparatorFromConfig(): void $factory($container); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function invokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void { $container = new ServiceManager(); diff --git a/test/unit/ResultSet/AbstractResultSetIntegrationTest.php b/test/unit/ResultSet/AbstractResultSetIntegrationTest.php index c810f213..a7cd3d59 100644 --- a/test/unit/ResultSet/AbstractResultSetIntegrationTest.php +++ b/test/unit/ResultSet/AbstractResultSetIntegrationTest.php @@ -8,6 +8,7 @@ use PhpDb\Adapter\Driver\ResultInterface; use PhpDb\ResultSet\AbstractResultSet; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -20,7 +21,7 @@ final class AbstractResultSetIntegrationTest extends TestCase /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); @@ -36,7 +37,7 @@ public function currentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentCallsDataSourceCurrentOnceWithBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); diff --git a/test/unit/ResultSet/AbstractResultSetTest.php b/test/unit/ResultSet/AbstractResultSetTest.php index 14ce51ca..83bd3b7c 100644 --- a/test/unit/ResultSet/AbstractResultSetTest.php +++ b/test/unit/ResultSet/AbstractResultSetTest.php @@ -42,7 +42,7 @@ final class AbstractResultSetTest extends TestCase /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function buffer(): void { $resultSet = $this->createResultSetMock(); @@ -67,7 +67,7 @@ public function buffer(): void * * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('issue-6845')] public function bufferIterations(): void { @@ -98,7 +98,7 @@ public function bufferIterations(): void static::assertSame(3, $data['id']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countReturnsCachedResult(): void { $resultSet = $this->createResultSetMock(); @@ -111,7 +111,7 @@ public function countReturnsCachedResult(): void static::assertSame($first, $second); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countReturnsNullForUncountableDataSource(): void { $resultSet = $this->createResultSetMock(); @@ -124,7 +124,7 @@ public function countReturnsNullForUncountableDataSource(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countsRowsInDataSource(): void { $resultSet = $this->createResultSetMock(); @@ -140,7 +140,7 @@ public function countsRowsInDataSource(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function current(): void { $resultSet = $this->createResultSetMock(); @@ -153,7 +153,7 @@ public function current(): void static::assertEquals(['id' => 1, 'name' => 'one'], $resultSet->current()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsBufferedDataOnSecondPass(): void { $resultSet = $this->createResultSetMock(); @@ -181,7 +181,7 @@ public function currentReturnsBufferedDataOnSecondPass(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDataSource(): void { $resultSet = $this->createResultSetMock(); @@ -197,7 +197,7 @@ public function getDataSource(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCount(): void { $resultSet = $this->createResultSetMock(); @@ -208,7 +208,7 @@ public function getFieldCount(): void static::assertSame(2, $resultSet->getFieldCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCountReturnsCachedValue(): void { $resultSet = $this->createResultSetMock(); @@ -221,7 +221,7 @@ public function getFieldCountReturnsCachedValue(): void static::assertSame($first, $second); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCountReturnsZeroForEmptyIterator(): void { $resultSet = $this->createResultSetMock(); @@ -230,7 +230,7 @@ public function getFieldCountReturnsZeroForEmptyIterator(): void static::assertSame(0, $resultSet->getFieldCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCountReturnsZeroWithNoDataSource(): void { $resultSet = $this->createResultSetMock(); @@ -238,7 +238,7 @@ public function getFieldCountReturnsZeroWithNoDataSource(): void static::assertSame(0, $resultSet->getFieldCount()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFieldCountWithCountableRow(): void { $resultSet = $this->createResultSetMock(); @@ -250,7 +250,7 @@ public function getFieldCountWithCountableRow(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initialize(): void { $resultSet = $this->createResultSetMock(); @@ -271,7 +271,7 @@ public function initialize(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeDoesNotCallCount(): void { $resultSet = $this->createResultSetMock(); @@ -284,7 +284,7 @@ public function initializeDoesNotCallCount(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeResetsBufferWhenAlreadyBuffered(): void { $resultSet = $this->createResultSetMock(); @@ -296,7 +296,7 @@ public function initializeResetsBufferWhenAlreadyBuffered(): void static::assertSame(2, $resultSet->current()['id']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeWithBufferedResultInterface(): void { $result = $this->createMock(ResultInterface::class); @@ -312,7 +312,7 @@ public function initializeWithBufferedResultInterface(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeWithEmptyArray(): void { $resultSet = $this->createResultSetMock(); @@ -323,7 +323,7 @@ public function initializeWithEmptyArray(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeWithIteratorAggregate(): void { $resultSet = $this->createResultSetMock(); @@ -342,7 +342,7 @@ public function getIterator(): ArrayIterator /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeWithResultInterfaceRewindsWhenBuffered(): void { $resultSet = $this->createResultSetMock(); @@ -357,7 +357,7 @@ public function initializeWithResultInterfaceRewindsWhenBuffered(): void $resultSet->initialize($result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isBuffered(): void { $resultSet = $this->createResultSetMock(); @@ -371,7 +371,7 @@ public function isBuffered(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function key(): void { $resultSet = $this->createResultSetMock(); @@ -394,7 +394,7 @@ public function key(): void * * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('issue-6845')] public function multipleRewindBufferIterations(): void { @@ -447,7 +447,7 @@ public function multipleRewindBufferIterations(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function next(): void { $rows = [ @@ -468,7 +468,7 @@ public function next(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rewindResetsIteratorPosition(): void { $rows = [ @@ -489,7 +489,7 @@ public function rewindResetsIteratorPosition(): void static::assertEquals($rows[0], $this->resultSet->current()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rewindWithNonIteratorDataSource(): void { $resultSet = $this->createResultSetMock(); @@ -510,7 +510,7 @@ public function getIterator(): ArrayIterator /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valid(): void { $resultSet = $this->createResultSetMock(); @@ -545,7 +545,7 @@ public function validAnswersFromTheBufferAfterTheDataSourceIsExhausted(): void static::assertTrue($resultSet->valid()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function validReturnsFalseAfterLastElement(): void { $resultSet = $this->createResultSetMock(); @@ -570,7 +570,7 @@ public function validReturnsFalseBeyondTheEndOfTheBuffer(): void static::assertFalse($resultSet->valid()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function validWithNonIteratorDataSource(): void { $resultSet = $this->createResultSetMock(); diff --git a/test/unit/ResultSet/HydratingResultSetIntegrationTest.php b/test/unit/ResultSet/HydratingResultSetIntegrationTest.php index 4d8676e7..04952f3d 100644 --- a/test/unit/ResultSet/HydratingResultSetIntegrationTest.php +++ b/test/unit/ResultSet/HydratingResultSetIntegrationTest.php @@ -8,6 +8,7 @@ use Exception; use PhpDb\ResultSet\HydratingResultSet; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(HydratingResultSet::class, 'current')] @@ -16,7 +17,7 @@ class HydratingResultSetIntegrationTest extends TestCase /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentWillReturnBufferedRow(): void { $hydratingRs = new HydratingResultSet(); diff --git a/test/unit/ResultSet/HydratingResultSetTest.php b/test/unit/ResultSet/HydratingResultSetTest.php index c5729679..d8e79255 100644 --- a/test/unit/ResultSet/HydratingResultSetTest.php +++ b/test/unit/ResultSet/HydratingResultSetTest.php @@ -14,6 +14,7 @@ use PhpDb\ResultSet\HydratingResultSet; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use stdClass; @@ -33,7 +34,7 @@ final class HydratingResultSetTest extends TestCase private string $classMethodsHydratorClass; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorDefaultsToArraySerializableHydrator(): void { $hydratingRs = new HydratingResultSet(); @@ -41,7 +42,7 @@ public function constructorDefaultsToArraySerializableHydrator(): void static::assertInstanceOf(ArraySerializableHydrator::class, $hydratingRs->getHydrator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentDisablesBufferingImplicitly(): void { $hydratingRs = new HydratingResultSet(); @@ -58,7 +59,7 @@ public function currentDisablesBufferingImplicitly(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentDoesnotHasData(): void { $hydratingRs = new HydratingResultSet(); @@ -72,7 +73,7 @@ public function currentDoesnotHasData(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentHasData(): void { $hydratingRs = new HydratingResultSet(); @@ -84,7 +85,7 @@ public function currentHasData(): void static::assertInstanceOf('ArrayObject', $obj); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentWithBufferReturnsBufferedObject(): void { $hydratingRs = new HydratingResultSet(); @@ -101,7 +102,7 @@ public function currentWithBufferReturnsBufferedObject(): void static::assertSame($first, $buffered); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getHydrator(): void { $hydratingRs = new HydratingResultSet(); @@ -109,7 +110,7 @@ public function getHydrator(): void static::assertInstanceOf($this->arraySerializableHydratorClass, $hydratingRs->getHydrator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getObjectPrototype(): void { $hydratingRs = new HydratingResultSet(); @@ -117,7 +118,7 @@ public function getObjectPrototype(): void static::assertInstanceOf('ArrayObject', $hydratingRs->getObjectPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRowPrototypeReturnsDefaultArrayObject(): void { $hydratingRs = new HydratingResultSet(); @@ -125,7 +126,7 @@ public function getRowPrototypeReturnsDefaultArrayObject(): void static::assertInstanceOf(ArrayObject::class, $hydratingRs->getRowPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setHydrator(): void { $hydratingRs = new HydratingResultSet(); @@ -152,7 +153,7 @@ public function setHydrator(): void static::assertNotSame($hydrator1, $hydratingRs->getHydrator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setObjectPrototype(): void { $prototype1 = new stdClass(); @@ -178,7 +179,7 @@ public function setObjectPrototype(): void static::assertNotSame($prototype1, $hydratingRs->getObjectPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setRowPrototypeStoresPrototype(): void { $hydratingRs = new HydratingResultSet(); @@ -194,7 +195,7 @@ public function setRowPrototypeStoresPrototype(): void * @throws Exception * @todo Implement testToArray(). */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function toArray(): void { $hydratingRs = new HydratingResultSet(); @@ -206,7 +207,7 @@ public function toArray(): void static::assertIsArray($obj); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function toArrayUsesHydratorExtract(): void { $hydratingRs = new HydratingResultSet(); diff --git a/test/unit/ResultSet/ResultSetIntegrationTest.php b/test/unit/ResultSet/ResultSetIntegrationTest.php index 83c7e7e4..b1bfd67b 100644 --- a/test/unit/ResultSet/ResultSetIntegrationTest.php +++ b/test/unit/ResultSet/ResultSetIntegrationTest.php @@ -15,6 +15,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\TestCase; use Random\RandomException; @@ -58,7 +59,7 @@ public static function invalidReturnTypes(): array * @throws Exception * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function bufferCalledAfterIterationThrowsException(): void { $this->resultSet->initialize($this->createMock(ResultInterface::class)); @@ -73,7 +74,7 @@ public function bufferCalledAfterIterationThrowsException(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canProvideArrayAsDataSource(): void { $dataSource = [['foo']]; @@ -93,7 +94,7 @@ public function canProvideArrayAsDataSource(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canProvideIteratorAggregateAsDataSource(): void { $iteratorAggregate = $this->getMockBuilder('IteratorAggregate') @@ -108,7 +109,7 @@ public function canProvideIteratorAggregateAsDataSource(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canProvideIteratorAsDataSource(): void { $it = new SplStack(); @@ -121,7 +122,7 @@ public function canProvideIteratorAsDataSource(): void * @throws RandomException * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countReturnsCountOfRows(): void { $count = random_int(3, 75); @@ -131,7 +132,7 @@ public function countReturnsCountOfRows(): void static::assertEquals($count, $this->resultSet->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentClonesRowPrototypeOnEachCall(): void { $resultSet = new ResultSet(ResultSetReturnType::ArrayObject); @@ -147,7 +148,7 @@ public function currentClonesRowPrototypeOnEachCall(): void static::assertNotSame($first, $second); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsArrayObjectWhenReturnTypeIsArrayObject(): void { $resultSet = new ResultSet(ResultSetReturnType::ArrayObject); @@ -159,7 +160,7 @@ public function currentReturnsArrayObjectWhenReturnTypeIsArrayObject(): void static::assertSame(1, $current['id']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsArrayWhenReturnTypeIsArray(): void { $resultSet = new ResultSet(ResultSetReturnType::Array); @@ -175,7 +176,7 @@ public function currentReturnsArrayWhenReturnTypeIsArray(): void * @throws Exception * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsNullForNonExistingValues(): void { $mockResult = $this->createMock(ResultInterface::class); @@ -191,7 +192,7 @@ public function currentReturnsNullForNonExistingValues(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentWithBufferingCallsDataSourceCurrentOnce(): void { $mockResult = $this->getMockBuilder(ResultInterface::class)->getMock(); @@ -206,14 +207,14 @@ public function currentWithBufferingCallsDataSourceCurrentOnce(): void $this->resultSet->current(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function dataSourceIsNullByDefault(): void { // Verify data source is null before initialization static::assertNull($this->resultSet->getDataSource()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fieldCountIsZeroWithNoDataSourcePresent(): void { // Verify field count is 0 when no data source is set @@ -223,7 +224,7 @@ public function fieldCountIsZeroWithNoDataSourcePresent(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fieldCountRepresentsNumberOfFieldsInARowOfData(): void { $resultSet = new ResultSet(ResultSet::TYPE_ARRAY); @@ -246,7 +247,7 @@ public function getArrayDataSource(int $count): ArrayIterator return new ArrayIterator($array); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getArrayObjectPrototypeDelegatesToGetRowPrototype(): void { static::assertSame( @@ -255,7 +256,7 @@ public function getArrayObjectPrototypeDelegatesToGetRowPrototype(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getReturnTypeReturnsArrayWhenSetToArray(): void { $resultSet = new ResultSet(ResultSetReturnType::Array); @@ -266,7 +267,7 @@ public function getReturnTypeReturnsArrayWhenSetToArray(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidReturnTypes')] public function invalidDataSourceRaisesException(mixed $dataSource): void { @@ -281,14 +282,14 @@ public function invalidDataSourceRaisesException(mixed $dataSource): void $this->resultSet->initialize($dataSource); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function returnTypeIsObjectByDefault(): void { // Verify default return type is ArrayObject static::assertEquals(ResultSetReturnType::ArrayObject, $this->resultSet->getReturnType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rowObjectPrototypeIsMutable(): void { $row1 = new ArrayObject(['test1' => 'value1']); @@ -308,7 +309,7 @@ public function rowObjectPrototypeIsMutable(): void static::assertNotSame($row1, $this->resultSet->getArrayObjectPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rowObjectPrototypeIsPopulatedByRowObjectByDefault(): void { // Verify default row object prototype is ArrayObject @@ -316,7 +317,7 @@ public function rowObjectPrototypeIsPopulatedByRowObjectByDefault(): void static::assertInstanceOf('ArrayObject', $row); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rowObjectPrototypeMayBePassedToConstructor(): void { $row = new ArrayObject(); @@ -325,7 +326,7 @@ public function rowObjectPrototypeMayBePassedToConstructor(): void static::assertSame($row, $resultSet->getArrayObjectPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidReturnTypes')] public function settingInvalidReturnTypeRaisesException(mixed $type): void { @@ -338,7 +339,7 @@ public function settingInvalidReturnTypeRaisesException(mixed $type): void * @throws RandomException * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function toArrayCreatesArrayOfArraysRepresentingRows(): void { $count = random_int(3, 75); @@ -352,7 +353,7 @@ public function toArrayCreatesArrayOfArraysRepresentingRows(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function whenReturnTypeIsArrayThenIterationReturnsArrays(): void { $resultSet = new ResultSet(ResultSet::TYPE_ARRAY); @@ -367,7 +368,7 @@ public function whenReturnTypeIsArrayThenIterationReturnsArrays(): void /** * @throws \Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function whenReturnTypeIsObjectThenIterationReturnsRowObjects(): void { $dataSource = $this->getArrayDataSource(10); diff --git a/test/unit/RowGateway/AbstractRowGatewayTest.php b/test/unit/RowGateway/AbstractRowGatewayTest.php index ed1ceb94..df35f323 100644 --- a/test/unit/RowGateway/AbstractRowGatewayTest.php +++ b/test/unit/RowGateway/AbstractRowGatewayTest.php @@ -21,6 +21,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -57,14 +58,14 @@ final class AbstractRowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function countsPopulatedColumns(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); static::assertSame(2, $this->rowGateway->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delete(): void { $this->rowGateway->foo = 'bar'; @@ -73,7 +74,7 @@ public function delete(): void static::assertSame(1, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function exchangeArray(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); @@ -90,7 +91,7 @@ public function exchangeArray(): void static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeCreatesFeatureSetIfNotSet(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -114,7 +115,7 @@ public function initializeCreatesFeatureSetIfNotSet(): void static::assertInstanceOf(FeatureSet::class, $featureSetProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeEarlyReturnWhenAlreadyInitialized(): void { $rowGateway = new RowGateway('id', 'test_table', $this->mockAdapter); @@ -131,7 +132,7 @@ public function initializeEarlyReturnWhenAlreadyInitialized(): void static::assertSame($originalFeatureSet, $featureSetProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeOnlyRunsOnce(): void { $this->rowGateway->populate(['id' => 1, 'name' => 'foo'], true); @@ -146,7 +147,7 @@ public function initializeOnlyRunsOnce(): void static::assertSame('bar', $this->rowGateway['name']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -165,7 +166,7 @@ public function initializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void $rowGateway->populate(['name' => 'test']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsExceptionWhenSqlIsNull(): void { self::expectException(RuntimeException::class); @@ -184,7 +185,7 @@ public function initializeThrowsExceptionWhenSqlIsNull(): void $rowGateway->populate(['name' => 'test']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsExceptionWhenTableIsNull(): void { self::expectException(RuntimeException::class); @@ -202,7 +203,7 @@ public function initializeThrowsExceptionWhenTableIsNull(): void $rowGateway->populate(['name' => 'test']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsTheColumnValue(): void { $this->rowGateway->testColumn = 'test'; @@ -210,7 +211,7 @@ public function magicGetReturnsTheColumnValue(): void static::assertSame('test', $this->rowGateway['testColumn']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetThrowsForUnknownColumn(): void { self::expectException(InvalidArgumentException::class); @@ -220,7 +221,7 @@ public function magicGetThrowsForUnknownColumn(): void $this->rowGateway->nonExistentColumn; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicIssetReportsWhetherAColumnIsSet(): void { static::assertFalse(isset($this->rowGateway->foo)); @@ -228,7 +229,7 @@ public function magicIssetReportsWhetherAColumnIsSet(): void static::assertTrue(isset($this->rowGateway->foo)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicSetAssignsTheColumnValue(): void { $this->rowGateway->testColumn = 'test'; @@ -236,7 +237,7 @@ public function magicSetAssignsTheColumnValue(): void static::assertSame('test', $this->rowGateway['testColumn']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicUnsetClearsTheColumnValue(): void { $this->rowGateway->foo = 'bar'; @@ -246,7 +247,7 @@ public function magicUnsetClearsTheColumnValue(): void static::assertEmpty($this->rowGateway['foo']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetExists(): void { static::assertFalse(isset($this->rowGateway['foo'])); @@ -254,7 +255,7 @@ public function offsetExists(): void static::assertTrue(isset($this->rowGateway['foo'])); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetGet(): void { $this->rowGateway['testColumn'] = 'test'; @@ -262,7 +263,7 @@ public function offsetGet(): void static::assertSame('test', $this->rowGateway['testColumn']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetSet(): void { $this->rowGateway['testColumn'] = 'test'; @@ -270,7 +271,7 @@ public function offsetSet(): void static::assertSame('test', $this->rowGateway['testColumn']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function offsetUnset(): void { $this->rowGateway['foo'] = 'bar'; @@ -280,7 +281,7 @@ public function offsetUnset(): void static::assertEmpty($this->rowGateway['foo']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function populate(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo']); @@ -292,7 +293,7 @@ public function populate(): void static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processPrimaryKeyData(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); @@ -302,21 +303,21 @@ public function processPrimaryKeyData(): void $this->rowGateway->populate(['boo' => 5, 'name' => 'foo'], true); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rowExistsInDatabaseReturnsFalseWhenNew(): void { $this->rowGateway->populate(['name' => 'foo']); static::assertFalse($this->rowGateway->rowExistsInDatabase()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rowExistsInDatabaseReturnsTrueAfterPopulateWithTrue(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); static::assertTrue($this->rowGateway->rowExistsInDatabase()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function saveInsert(): void { $this->mockResult->expects($this->any())->method('current')->willReturn(['id' => 5, 'name' => 'foo']); @@ -331,7 +332,7 @@ public function saveInsert(): void * @throws ReflectionException * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[RequiresPhp('<= 8.6')] public function saveInsertMultiKey(): void { @@ -365,7 +366,7 @@ public function saveInsertMultiKey(): void static::assertEquals(['one' => 'foo', 'two' => 'bar'], $refRowGatewayProp->getValue($this->rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function saveUpdate(): void { $this->mockResult->expects($this->any())->method('current')->willReturn(['id' => 6, 'name' => 'foo']); @@ -374,7 +375,7 @@ public function saveUpdate(): void static::assertSame(6, $this->rowGateway['id']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function saveUpdateChangingPrimaryKey(): void { $selectMock = $this->getMockBuilder(Select::class) @@ -406,7 +407,7 @@ public function saveUpdateChangingPrimaryKey(): void static::assertEquals(['id' => 7, 'name' => 'fooUpdated'], $this->rowGateway->toArray()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function toArray(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); diff --git a/test/unit/RowGateway/RowGatewayTest.php b/test/unit/RowGateway/RowGatewayTest.php index eb2bef3d..048198c2 100644 --- a/test/unit/RowGateway/RowGatewayTest.php +++ b/test/unit/RowGateway/RowGatewayTest.php @@ -16,6 +16,7 @@ use PhpDb\RowGateway\RowGateway; use PhpDb\Sql\Sql; use PhpDb\Sql\TableIdentifier; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -30,7 +31,7 @@ final class RowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -41,7 +42,7 @@ public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new RowGateway('id', 'foo', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithArrayPrimaryKey(): void { $rowGateway = new RowGateway(['id', 'name'], 'foo', $this->mockAdapter); @@ -53,7 +54,7 @@ public function constructorWithArrayPrimaryKey(): void static::assertEquals(['id', 'name'], $pkProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithNullPrimaryKey(): void { self::expectException(RuntimeException::class); @@ -62,7 +63,7 @@ public function constructorWithNullPrimaryKey(): void new RowGateway(null, 'foo', $this->mockAdapter); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSqlObject(): void { $sql = new Sql($this->mockAdapter, 'foo'); @@ -75,7 +76,7 @@ public function constructorWithSqlObject(): void static::assertSame('foo', $tableProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithStringPrimaryKey(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); @@ -87,7 +88,7 @@ public function constructorWithStringPrimaryKey(): void static::assertInstanceOf(Sql::class, $sqlProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'schema'); @@ -97,7 +98,7 @@ public function constructorWithTableIdentifier(): void static::assertSame($tableIdentifier, $tableProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyPrimaryKey(): void { self::expectException(RuntimeException::class); @@ -105,7 +106,7 @@ public function emptyPrimaryKey(): void $this->rowGateway = new RowGateway('', 'foo', $this->mockAdapter); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeReturnsEarlyWhenAlreadyInitialized(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); @@ -118,7 +119,7 @@ public function initializeReturnsEarlyWhenAlreadyInitialized(): void static::assertTrue($isInitializedProp->getValue($rowGateway)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsWhenSqlIsNull(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); @@ -135,7 +136,7 @@ public function initializeThrowsWhenSqlIsNull(): void $rowGateway->initialize(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsWhenTableIsNull(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); diff --git a/test/unit/Sql/AbstractSqlFunctionalTestCase.php b/test/unit/Sql/AbstractSqlFunctionalTestCase.php index c895d96d..cbd9ec00 100644 --- a/test/unit/Sql/AbstractSqlFunctionalTestCase.php +++ b/test/unit/Sql/AbstractSqlFunctionalTestCase.php @@ -22,6 +22,7 @@ use PhpDb\Sql\Update; use PhpDbTest\TestAsset; use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -289,7 +290,7 @@ protected static function update(string|TableIdentifier|null $sqlString): Sql\Up return new Sql\Update($sqlString); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('dataProvider')] public function test(PreparableSqlInterface|SqlInterface $sqlObject, string $platform, string|array $expected): void { diff --git a/test/unit/Sql/AbstractSqlTest.php b/test/unit/Sql/AbstractSqlTest.php index 94ae0f86..93b90d5e 100644 --- a/test/unit/Sql/AbstractSqlTest.php +++ b/test/unit/Sql/AbstractSqlTest.php @@ -29,6 +29,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -68,7 +69,7 @@ final class AbstractSqlTest extends TestCase /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createSqlFromSpecificationThrowsOnParameterCountMismatch(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -88,7 +89,7 @@ public function createSqlFromSpecificationThrowsOnParameterCountMismatch(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -108,7 +109,7 @@ public function createSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createSqlFromSpecWithCombinedByScalarParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -129,7 +130,7 @@ public function createSqlFromSpecWithCombinedByScalarParam(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -150,7 +151,7 @@ public function createSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createSqlFromSpecWithNonCombinedByParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -167,7 +168,7 @@ public function createSqlFromSpecWithNonCombinedByParam(): void static::assertSame('FROM my_table', $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function flattenExpressionValuesViaInPredicate(): void { $select = new Select('users'); @@ -178,7 +179,7 @@ public function flattenExpressionValuesViaInPredicate(): void static::assertStringContainsString("\"id\" IN ('1', '2', '3')", $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function flattenExpressionValuesViaInPredicateWithParameterContainer(): void { $select = new Select('users'); @@ -203,7 +204,7 @@ public function flattenExpressionValuesViaInPredicateWithParameterContainer(): v static::assertSame(3, $parameterContainer->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function localizeVariablesCopiesSubjectProperties(): void { $decorator = new SelectDecorator(); @@ -217,7 +218,7 @@ public function localizeVariablesCopiesSubjectProperties(): void static::assertStringContainsString('"id"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionThrowsOnUnknownArgumentType(): void { $unknownArg = new class implements ArgumentInterface { @@ -247,7 +248,7 @@ public function getValue(): string /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWithIdentifiersArgument(): void { $expression = new Expression('? IN (SELECT col1, col2 FROM bar)', [ @@ -263,7 +264,7 @@ public function processExpressionWithIdentifiersArgument(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWithoutParameterContainer(): void { $expression = new Expression('? > ? AND y < ?', [new Identifier('x'), 5, 10]); @@ -275,7 +276,7 @@ public function processExpressionWithoutParameterContainer(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWithParameterContainerAndParameterizationTypeNamed(): void { $parameterContainer = new ParameterContainer(); @@ -312,7 +313,7 @@ public function processExpressionWithParameterContainerAndParameterizationTypeNa /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWithValuesArgument(): void { $expression = new Expression( @@ -336,7 +337,7 @@ public function processExpressionWithValuesArgument(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWorksWithExpressionContainingExpressionObject(): void { $expression = new Predicate\Operator( @@ -352,7 +353,7 @@ public function processExpressionWorksWithExpressionContainingExpressionObject() /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWorksWithExpressionContainingSelectObject(): void { $select = new Select(); @@ -368,7 +369,7 @@ public function processExpressionWorksWithExpressionContainingSelectObject(): vo /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWorksWithExpressionContainingStringParts(): void { $expression = new Predicate\Expression('x = ?', 5); @@ -382,7 +383,7 @@ public function processExpressionWorksWithExpressionContainingStringParts(): voi /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('7407')] public function processExpressionWorksWithExpressionObjectWithPercentageSigns(): void { @@ -396,7 +397,7 @@ public function processExpressionWorksWithExpressionObjectWithPercentageSigns(): /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWorksWithNamedParameterPrefix(): void { $parameterContainer = new ParameterContainer(); @@ -410,7 +411,7 @@ public function processExpressionWorksWithNamedParameterPrefix(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processExpressionWorksWithNamedParameterPrefixContainingWhitespace(): void { $parameterContainer = new ParameterContainer(); @@ -424,7 +425,7 @@ public function processExpressionWorksWithNamedParameterPrefixContainingWhitespa /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinReturnsNullWhenEmpty(): void { $method = new ReflectionMethod($this->abstractSql, 'processJoin'); @@ -442,7 +443,7 @@ public function processJoinReturnsNullWhenEmpty(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinWithArrayAlias(): void { $join = new Join(); @@ -464,7 +465,7 @@ public function processJoinWithArrayAlias(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinWithExpressionNameViaArray(): void { $join = new Join(); @@ -485,7 +486,7 @@ public function processJoinWithExpressionNameViaArray(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinWithPredicateExpressionOnClause(): void { $join = new Join(); @@ -507,7 +508,7 @@ public function processJoinWithPredicateExpressionOnClause(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinWithSelectSubqueryViaArray(): void { $subselect = new Select('bar'); @@ -530,7 +531,7 @@ public function processJoinWithSelectSubqueryViaArray(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processJoinWithTableIdentifier(): void { $join = new Join(); @@ -550,7 +551,7 @@ public function processJoinWithTableIdentifier(): void static::assertStringContainsString('"bar"', $result[0][0][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processSubSelectUsesDecoratorWhenPlatformDecorator(): void { $decorator = new SelectDecorator(); @@ -568,7 +569,7 @@ public function processSubSelectUsesDecoratorWhenPlatformDecorator(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processSubSelectWithoutParameterContainer(): void { $select = new Select('foo'); @@ -589,7 +590,7 @@ public function processSubSelectWithoutParameterContainer(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processSubSelectWithParameterContainer(): void { $select = new Select('foo'); @@ -613,7 +614,7 @@ public function processSubSelectWithParameterContainer(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function renderTableWithAlias(): void { $method = new ReflectionMethod($this->abstractSql, 'renderTable'); @@ -625,7 +626,7 @@ public function renderTableWithAlias(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveColumnValueWithArrayAndFromTable(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -647,7 +648,7 @@ public function resolveColumnValueWithArrayAndFromTable(): void static::assertStringContainsString('id', $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveColumnValueWithNamedParameterPrefix(): void { $select = new Select('users'); @@ -677,7 +678,7 @@ public function resolveColumnValueWithNamedParameterPrefix(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveColumnValueWithNull(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -697,7 +698,7 @@ public function resolveColumnValueWithNull(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveColumnValueWithSelect(): void { $select = new Select('foo'); @@ -720,7 +721,7 @@ public function resolveColumnValueWithSelect(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveTableWithSelect(): void { $select = new Select('foo'); @@ -742,7 +743,7 @@ public function resolveTableWithSelect(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveTableWithTableIdentifierAndSchema(): void { $table = new TableIdentifier('users', 'public'); diff --git a/test/unit/Sql/Argument/LiteralTest.php b/test/unit/Sql/Argument/LiteralTest.php index 1ab98e27..2bd6a4cb 100644 --- a/test/unit/Sql/Argument/LiteralTest.php +++ b/test/unit/Sql/Argument/LiteralTest.php @@ -8,6 +8,7 @@ use PhpDb\Sql\ArgumentType; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] @@ -17,7 +18,7 @@ #[CoversMethod(Literal::class, 'getSpecification')] final class LiteralTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSpecificationReturnsPlaceholder(): void { $literal = new Literal('test'); @@ -25,7 +26,7 @@ public function getSpecificationReturnsPlaceholder(): void static::assertSame('%s', $literal->getSpecification()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeReturnsLiteral(): void { $literal = new Literal('test'); @@ -33,7 +34,7 @@ public function getTypeReturnsLiteral(): void static::assertSame(ArgumentType::Literal, $literal->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getValueReturnsLiteralString(): void { $literal = new Literal('NOW()'); diff --git a/test/unit/Sql/ArgumentTest.php b/test/unit/Sql/ArgumentTest.php index 043a7146..8917ed14 100644 --- a/test/unit/Sql/ArgumentTest.php +++ b/test/unit/Sql/ArgumentTest.php @@ -13,6 +13,7 @@ use PhpDb\Sql\Expression; use PhpDb\Sql\Select; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use TypeError; @@ -22,7 +23,7 @@ #[CoversMethod(Argument::class, 'select')] final class ArgumentTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorThrowsExceptionForInvalidSelectType(): void { self::expectException(TypeError::class); @@ -31,7 +32,7 @@ public function constructorThrowsExceptionForInvalidSelectType(): void new ArgumentSelect('simple_value'); /** @phpstan-ignore-line */ } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithArrayContainingArgumentType(): void { $argument = new Identifier('column'); @@ -40,7 +41,7 @@ public function constructorWithArrayContainingArgumentType(): void static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithBooleanValue(): void { $argument = new Value(true); @@ -48,7 +49,7 @@ public function constructorWithBooleanValue(): void static::assertEquals(ArgumentType::Value, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithExplicitType(): void { $argument = new Identifier('column_name'); @@ -56,7 +57,7 @@ public function constructorWithExplicitType(): void static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithExpressionInterface(): void { $expression = new Expression('NOW()'); @@ -66,7 +67,7 @@ public function constructorWithExpressionInterface(): void static::assertEquals(ArgumentType::Select, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithFloatValue(): void { $argument = new Value(3.14); @@ -74,7 +75,7 @@ public function constructorWithFloatValue(): void static::assertEquals(ArgumentType::Value, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithNullValue(): void { $argument = new Value(null); @@ -82,7 +83,7 @@ public function constructorWithNullValue(): void static::assertEquals(ArgumentType::Value, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSimpleArray(): void { $argument = new Values([1, 2, 3]); @@ -91,7 +92,7 @@ public function constructorWithSimpleArray(): void static::assertEquals(ArgumentType::Values, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSimpleValue(): void { $argument = new Value('test'); @@ -99,7 +100,7 @@ public function constructorWithSimpleValue(): void static::assertEquals(ArgumentType::Value, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSqlInterface(): void { $select = new Select(); @@ -109,7 +110,7 @@ public function constructorWithSqlInterface(): void static::assertEquals(ArgumentType::Select, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function staticIdentifierMethod(): void { $argument = Argument::identifier('column_name'); @@ -118,7 +119,7 @@ public function staticIdentifierMethod(): void static::assertEquals(ArgumentType::Identifier, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function staticLiteralMethod(): void { $argument = Argument::literal('LITERAL_VALUE'); @@ -127,7 +128,7 @@ public function staticLiteralMethod(): void static::assertEquals(ArgumentType::Literal, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function staticSelectMethodCreatesSelectArgument(): void { $select = new Select(); @@ -137,7 +138,7 @@ public function staticSelectMethodCreatesSelectArgument(): void static::assertEquals(ArgumentType::Select, $argument->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function staticValueMethod(): void { $argument = Argument::value('test_value'); diff --git a/test/unit/Sql/CombineTest.php b/test/unit/Sql/CombineTest.php index f7e94a97..40efd2b8 100644 --- a/test/unit/Sql/CombineTest.php +++ b/test/unit/Sql/CombineTest.php @@ -16,6 +16,7 @@ use PhpDb\Sql\Select; use PhpDbTest\AdapterTestTrait; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use TypeError; @@ -34,7 +35,7 @@ final class CombineTest extends TestCase protected Combine $combine; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function alignColumns(): void { $select1 = new Select('t1'); @@ -73,7 +74,7 @@ public function alignColumns(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function alignColumnsAppendsNullExpressionsForMissingColumns(): void { $select1 = new Select('t1'); @@ -89,7 +90,7 @@ public function alignColumnsAppendsNullExpressionsForMissingColumns(): void static::assertInstanceOf(Expression::class, $columns1['b']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function alignColumnsReturnsEarlyWhenEmpty(): void { $combine = new Combine(); @@ -98,7 +99,7 @@ public function alignColumnsReturnsEarlyWhenEmpty(): void static::assertSame($combine, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function combineWithArrayOfSelectAndModifier(): void { $this->combine->combine([ @@ -112,7 +113,7 @@ public function combineWithArrayOfSelectAndModifier(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSelectDelegatesToCombine(): void { $select = new Select('foo'); @@ -124,7 +125,7 @@ public function constructorWithSelectDelegatesToCombine(): void static::assertSame('ALL', $rawState['combine'][0]['modifier']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawState(): void { $select = new Select('t1'); @@ -146,7 +147,7 @@ public function getRawState(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $this->combine @@ -163,13 +164,13 @@ public function getSqlString(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringEmpty(): void { static::assertEmpty($this->combine->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringFromArray(): void { $this->combine->combine([ @@ -196,7 +197,7 @@ public function getSqlStringFromArray(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithModifier(): void { $this->combine @@ -209,7 +210,7 @@ public function getSqlStringWithModifier(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementWithModifier(): void { $select1 = new Select('t1'); @@ -233,7 +234,7 @@ public function prepareStatementWithModifier(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsInvalidStatement(): void { self::expectException(TypeError::class); diff --git a/test/unit/Sql/Ddl/AlterTableTest.php b/test/unit/Sql/Ddl/AlterTableTest.php index 698059a8..f3625fb8 100644 --- a/test/unit/Sql/Ddl/AlterTableTest.php +++ b/test/unit/Sql/Ddl/AlterTableTest.php @@ -12,6 +12,7 @@ use PhpDb\Sql\Literal; use PhpDb\Sql\TableIdentifier; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function str_replace; @@ -38,7 +39,7 @@ #[CoversMethod(AlterTable::class, 'processTableOptions')] class AlterTableTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addColumn(): void { $at = new AlterTable(); @@ -48,7 +49,7 @@ public function addColumn(): void static::assertEquals([$colMock], $at->getRawState(AlterTable::ADD_COLUMNS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addConstraint(): void { $at = new AlterTable(); @@ -58,7 +59,7 @@ public function addConstraint(): void static::assertEquals([$conMock], $at->getRawState(AlterTable::ADD_CONSTRAINTS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addConstraintGeneratesCorrectSql(): void { $at = new AlterTable('orders'); @@ -71,7 +72,7 @@ public function addConstraintGeneratesCorrectSql(): void static::assertStringContainsString('FOREIGN KEY', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function chainedOperations(): void { $at = new AlterTable(); @@ -89,7 +90,7 @@ public function chainedOperations(): void static::assertSame('test', $at->getRawState(AlterTable::TABLE)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function changeColumn(): void { $at = new AlterTable(); @@ -99,7 +100,7 @@ public function changeColumn(): void static::assertEquals(['newname' => $colMock], $at->getRawState(AlterTable::CHANGE_COLUMNS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function changeColumnGeneratesCorrectSql(): void { $at = new AlterTable('users'); @@ -112,21 +113,21 @@ public function changeColumnGeneratesCorrectSql(): void static::assertStringContainsString('VARCHAR(100)', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithEmptyTable(): void { $at = new AlterTable(); static::assertSame('', $at->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTable(): void { $at = new AlterTable('test_table'); static::assertSame('test_table', $at->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTableIdentifier(): void { $tableId = new TableIdentifier('bar', 'foo'); @@ -137,7 +138,7 @@ public function constructorWithTableIdentifier(): void static::assertSame($tableId, $rawState['table']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function dropColumn(): void { $at = new AlterTable(); @@ -145,7 +146,7 @@ public function dropColumn(): void static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_COLUMNS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function dropConstraint(): void { $at = new AlterTable(); @@ -153,7 +154,7 @@ public function dropConstraint(): void static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_CONSTRAINTS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function dropIndex(): void { $at = new AlterTable(); @@ -161,7 +162,7 @@ public function dropIndex(): void static::assertEquals(['foo'], $at->getRawState(AlterTable::DROP_INDEXES)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyAlterTableGeneratesMinimalSql(): void { $at = new AlterTable('test_table'); @@ -171,14 +172,14 @@ public function emptyAlterTableGeneratesMinimalSql(): void static::assertStringContainsString('ALTER TABLE "test_table"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getOptionsReturnsEmpty(): void { $at = new AlterTable('foo'); static::assertEquals([], $at->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateIncludesTableOptions(): void { $at = new AlterTable('foo'); @@ -190,7 +191,7 @@ public function getRawStateIncludesTableOptions(): void static::assertEquals(['engine' => new Literal('InnoDB')], $rawState[AlterTable::TABLE_OPTIONS]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateReturnsAllState(): void { $at = new AlterTable('test'); @@ -224,7 +225,7 @@ public function getRawStateReturnsAllState(): void static::assertEquals(['drop_idx'], $rawState[AlterTable::DROP_INDEXES]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateWithInvalidKey(): void { $at = new AlterTable('test'); @@ -235,7 +236,7 @@ public function getRawStateWithInvalidKey(): void static::assertArrayHasKey(AlterTable::TABLE, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateWithSpecificKey(): void { $at = new AlterTable('my_table'); @@ -250,7 +251,7 @@ public function getRawStateWithSpecificKey(): void /** * @todo Implement testGetSqlString(). */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $at = new AlterTable('foo'); @@ -286,7 +287,7 @@ public function getSqlString(): void static::assertSame("ALTER TABLE \"foo\".\"bar\"\n ADD COLUMN \"baz\" INTEGER NOT NULL", $at->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithBoolOption(): void { $at = new AlterTable('foo'); @@ -296,7 +297,7 @@ public function getSqlStringWithBoolOption(): void static::assertStringContainsString('PACK_KEYS = 1', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithColumnAndEngineOption(): void { $at = new AlterTable('foo'); @@ -308,7 +309,7 @@ public function getSqlStringWithColumnAndEngineOption(): void static::assertStringContainsString('ENGINE = InnoDB', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithEngineOption(): void { $at = new AlterTable('foo'); @@ -319,7 +320,7 @@ public function getSqlStringWithEngineOption(): void static::assertStringContainsString('ENGINE = InnoDB', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithIntOption(): void { $at = new AlterTable('foo'); @@ -329,7 +330,7 @@ public function getSqlStringWithIntOption(): void static::assertStringContainsString('AUTO_INCREMENT = 100', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithMultipleOptions(): void { $at = new AlterTable('foo'); @@ -341,7 +342,7 @@ public function getSqlStringWithMultipleOptions(): void static::assertStringContainsString('AUTO_INCREMENT = 100', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithStringOption(): void { $at = new AlterTable('foo'); @@ -351,7 +352,7 @@ public function getSqlStringWithStringOption(): void static::assertStringContainsString('COMMENT = \'My table\'', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function mixedOperationsInCorrectOrder(): void { $at = new AlterTable('complex_table'); @@ -375,7 +376,7 @@ public function mixedOperationsInCorrectOrder(): void static::assertStringContainsString('DROP INDEX "old_index"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleChangeColumns(): void { $at = new AlterTable('products'); @@ -387,7 +388,7 @@ public function multipleChangeColumns(): void static::assertStringContainsString('CHANGE COLUMN "name" "title"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleColumnsAndConstraints(): void { $at = new AlterTable('users'); @@ -408,7 +409,7 @@ public function multipleColumnsAndConstraints(): void static::assertStringContainsString('ADD COLUMN "bio"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleConstraints(): void { $at = new AlterTable('orders'); @@ -423,7 +424,7 @@ public function multipleConstraints(): void static::assertStringContainsString('"fk_product"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleDropOperations(): void { $at = new AlterTable('products'); @@ -440,7 +441,7 @@ public function multipleDropOperations(): void static::assertStringContainsString('DROP INDEX "old_idx"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOptionFluentInterface(): void { $at = new AlterTable('foo'); @@ -450,7 +451,7 @@ public function setOptionFluentInterface(): void static::assertEquals(['engine' => new Literal('InnoDB')], $at->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOptionsReplacesAll(): void { $at = new AlterTable('foo'); @@ -461,7 +462,7 @@ public function setOptionsReplacesAll(): void static::assertEquals(['charset' => new Literal('utf8mb4')], $at->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTable(): void { $at = new AlterTable(); @@ -470,7 +471,7 @@ public function setTable(): void static::assertSame('test', $at->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function tableIdentifierInChangeColumn(): void { $at = new AlterTable(new TableIdentifier('table', 'schema')); diff --git a/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php b/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php index c991141f..839271e4 100644 --- a/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php +++ b/test/unit/Sql/Ddl/Column/AbstractLengthColumnTest.php @@ -27,7 +27,7 @@ final class AbstractLengthColumnTest extends TestCase /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) @@ -104,7 +104,7 @@ public function getExpressionDataOmitsLengthPlaceholderWhenLengthIsNotSet(): voi /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLength(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) @@ -145,7 +145,7 @@ public function rendersWithoutParenthesesWhenLengthIsNotSet(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setLength(): void { $column = $this->getMockBuilder(AbstractLengthColumn::class) diff --git a/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php b/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php index ccdbda0c..eb0190f0 100644 --- a/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php +++ b/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php @@ -27,7 +27,7 @@ final class AbstractPrecisionColumnTest extends TestCase /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDecimal(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) @@ -40,7 +40,7 @@ public function getDecimal(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDigits(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) @@ -53,7 +53,7 @@ public function getDigits(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) @@ -124,7 +124,7 @@ public function getExpressionDataUsesDigitsOnlyWhenDecimalIsNotSet(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDecimal(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) @@ -139,7 +139,7 @@ public function setDecimal(): void /** * @throws Exception */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDigits(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) diff --git a/test/unit/Sql/Ddl/Column/BigIntegerTest.php b/test/unit/Sql/Ddl/Column/BigIntegerTest.php index c0ebbcbc..861484b1 100644 --- a/test/unit/Sql/Ddl/Column/BigIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/BigIntegerTest.php @@ -20,7 +20,7 @@ #[Group('unit')] final class BigIntegerTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new BigInteger('foo'); @@ -40,7 +40,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function objectConstruction(): void { $integer = new BigInteger('foo'); diff --git a/test/unit/Sql/Ddl/Column/BinaryTest.php b/test/unit/Sql/Ddl/Column/BinaryTest.php index 53724fc1..db473a28 100644 --- a/test/unit/Sql/Ddl/Column/BinaryTest.php +++ b/test/unit/Sql/Ddl/Column/BinaryTest.php @@ -20,7 +20,7 @@ final class BinaryTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Binary('foo', 10_000_000); diff --git a/test/unit/Sql/Ddl/Column/BlobTest.php b/test/unit/Sql/Ddl/Column/BlobTest.php index ce4e81b6..243c1449 100644 --- a/test/unit/Sql/Ddl/Column/BlobTest.php +++ b/test/unit/Sql/Ddl/Column/BlobTest.php @@ -19,7 +19,7 @@ final class BlobTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Blob('foo'); diff --git a/test/unit/Sql/Ddl/Column/BooleanTest.php b/test/unit/Sql/Ddl/Column/BooleanTest.php index b2394e9a..32beca95 100644 --- a/test/unit/Sql/Ddl/Column/BooleanTest.php +++ b/test/unit/Sql/Ddl/Column/BooleanTest.php @@ -9,13 +9,14 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Boolean::class, 'getExpressionData')] #[CoversClass(Boolean::class)] final class BooleanTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Boolean('foo'); @@ -32,7 +33,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6257')] public function isAlwaysNotNullable(): void { diff --git a/test/unit/Sql/Ddl/Column/CharTest.php b/test/unit/Sql/Ddl/Column/CharTest.php index 6aaba5a5..32d1f8e6 100644 --- a/test/unit/Sql/Ddl/Column/CharTest.php +++ b/test/unit/Sql/Ddl/Column/CharTest.php @@ -21,7 +21,7 @@ final class CharTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Char('foo', 20); diff --git a/test/unit/Sql/Ddl/Column/ColumnTest.php b/test/unit/Sql/Ddl/Column/ColumnTest.php index de97144a..d542a38b 100644 --- a/test/unit/Sql/Ddl/Column/ColumnTest.php +++ b/test/unit/Sql/Ddl/Column/ColumnTest.php @@ -29,7 +29,7 @@ #[Group('unit')] final class ColumnTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addConstraintAppendsConstraintToColumn(): void { $column = new Column('id'); @@ -39,7 +39,7 @@ public function addConstraintAppendsConstraintToColumn(): void static::assertSame($column, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructor(): void { $column = new Column('test_col', true, 'default_val', ['option1' => 'value1']); @@ -49,7 +49,7 @@ public function constructor(): void static::assertEquals(['option1' => 'value1'], $column->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Column(); @@ -94,7 +94,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataIncludesConstraints(): void { $column = new Column('id'); @@ -105,7 +105,7 @@ public function getExpressionDataIncludesConstraints(): void static::assertStringContainsString('PRIMARY KEY', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataIncludesConstraintValues(): void { $column = new Column('id'); @@ -116,7 +116,7 @@ public function getExpressionDataIncludesConstraintValues(): void static::assertNotEmpty($expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithBoolDefault(): void { $column = new Column(); @@ -136,7 +136,7 @@ public function getExpressionDataWithBoolDefault(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithFloatDefault(): void { $column = new Column(); @@ -156,7 +156,7 @@ public function getExpressionDataWithFloatDefault(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithLiteralDefault(): void { $column = new Column(); @@ -176,7 +176,7 @@ public function getExpressionDataWithLiteralDefault(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithValueDefault(): void { $column = new Column(); @@ -196,7 +196,7 @@ public function getExpressionDataWithValueDefault(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDefault(): void { $column = new Column(); @@ -217,7 +217,7 @@ public function setDefault(): void static::assertSame('baz qux', $column->getDefault()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDefaultWithBool(): void { $column = new Column(); @@ -229,7 +229,7 @@ public function setDefaultWithBool(): void static::assertTrue($column->getDefault()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDefaultWithFloat(): void { $column = new Column(); @@ -241,7 +241,7 @@ public function setDefaultWithFloat(): void static::assertSame(3.14, $column->getDefault()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDefaultWithLiteral(): void { $column = new Column(); @@ -254,7 +254,7 @@ public function setDefaultWithLiteral(): void static::assertSame($literal, $column->getDefault()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDefaultWithValue(): void { $column = new Column(); @@ -267,7 +267,7 @@ public function setDefaultWithValue(): void static::assertSame($value, $column->getDefault()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setName(): void { $column = new Column(); @@ -288,7 +288,7 @@ public function setName(): void static::assertSame('bar', $column->getName()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setNullable(): void { $column = new Column(); @@ -309,7 +309,7 @@ public function setNullable(): void static::assertFalse($column->isNullable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOption(): void { $column = new Column(); @@ -341,7 +341,7 @@ public function setOptionAcceptsIntegerValue(): void static::assertSame(['length' => 11], $column->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOptions(): void { $column = new Column(); diff --git a/test/unit/Sql/Ddl/Column/DateTest.php b/test/unit/Sql/Ddl/Column/DateTest.php index 12c9fd00..842f379d 100644 --- a/test/unit/Sql/Ddl/Column/DateTest.php +++ b/test/unit/Sql/Ddl/Column/DateTest.php @@ -7,12 +7,13 @@ use PhpDb\Sql\Argument; use PhpDb\Sql\Ddl\Column\Date; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Date::class, 'getExpressionData')] final class DateTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Date('foo'); diff --git a/test/unit/Sql/Ddl/Column/DatetimeTest.php b/test/unit/Sql/Ddl/Column/DatetimeTest.php index b99ed2d0..244dd7ac 100644 --- a/test/unit/Sql/Ddl/Column/DatetimeTest.php +++ b/test/unit/Sql/Ddl/Column/DatetimeTest.php @@ -7,12 +7,13 @@ use PhpDb\Sql\Argument; use PhpDb\Sql\Ddl\Column\Datetime; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Datetime::class, 'getExpressionData')] final class DatetimeTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Datetime('foo'); diff --git a/test/unit/Sql/Ddl/Column/DecimalTest.php b/test/unit/Sql/Ddl/Column/DecimalTest.php index 05c4730f..01d5c6aa 100644 --- a/test/unit/Sql/Ddl/Column/DecimalTest.php +++ b/test/unit/Sql/Ddl/Column/DecimalTest.php @@ -29,7 +29,7 @@ final class DecimalTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorSetsDigitsAndDecimal(): void { $column = new Decimal('price', 10, 2); @@ -38,7 +38,7 @@ public function constructorSetsDigitsAndDecimal(): void static::assertSame(2, $column->getDecimal()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Decimal('foo', 10, 5); @@ -71,7 +71,7 @@ public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithNullDecimal(): void { $column = new Decimal('amount', 10); @@ -88,7 +88,7 @@ public function getExpressionDataWithNullDecimal(): void static::assertEquals(Argument::literal((string) 10), $values[2]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function inheritanceFromAbstractPrecisionColumn(): void { $column = new Decimal('test'); @@ -113,7 +113,7 @@ public function rendersWithoutParenthesesWhenPrecisionIsNotSet(): void static::assertColumnRenders('"price" DECIMAL NOT NULL', new Decimal('price')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDecimalAndGetDecimal(): void { $column = new Decimal('value'); @@ -123,7 +123,7 @@ public function setDecimalAndGetDecimal(): void static::assertSame(4, $column->getDecimal()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setDigitsAndGetDigits(): void { $column = new Decimal('amount'); diff --git a/test/unit/Sql/Ddl/Column/DoubleTest.php b/test/unit/Sql/Ddl/Column/DoubleTest.php index 93d6b7d2..17821db1 100644 --- a/test/unit/Sql/Ddl/Column/DoubleTest.php +++ b/test/unit/Sql/Ddl/Column/DoubleTest.php @@ -24,7 +24,7 @@ final class DoubleTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Double('foo', 10, 5); diff --git a/test/unit/Sql/Ddl/Column/FloatingTest.php b/test/unit/Sql/Ddl/Column/FloatingTest.php index adc9bc92..8ce1af9c 100644 --- a/test/unit/Sql/Ddl/Column/FloatingTest.php +++ b/test/unit/Sql/Ddl/Column/FloatingTest.php @@ -24,7 +24,7 @@ final class FloatingTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Floating('foo', 10, 5); diff --git a/test/unit/Sql/Ddl/Column/IntegerTest.php b/test/unit/Sql/Ddl/Column/IntegerTest.php index aee21743..7841b8f7 100644 --- a/test/unit/Sql/Ddl/Column/IntegerTest.php +++ b/test/unit/Sql/Ddl/Column/IntegerTest.php @@ -53,7 +53,7 @@ private static function assertColumnRenders(string $expected, ColumnInterface $c ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Integer('foo'); @@ -84,7 +84,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataExcludesLengthWhenNotSet(): void { $column = new Integer('id'); @@ -94,7 +94,7 @@ public function getExpressionDataExcludesLengthWhenNotSet(): void static::assertStringNotContainsString('(', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataIncludesLengthWhenOptionSet(): void { $column = new Integer('id'); @@ -154,7 +154,7 @@ public function getExpressionDataPlacesLengthDirectlyAfterType(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function objectConstruction(): void { $integer = new Integer('foo'); diff --git a/test/unit/Sql/Ddl/Column/JsonTest.php b/test/unit/Sql/Ddl/Column/JsonTest.php index cbd1e9f0..ef544808 100644 --- a/test/unit/Sql/Ddl/Column/JsonTest.php +++ b/test/unit/Sql/Ddl/Column/JsonTest.php @@ -7,12 +7,13 @@ use PhpDb\Sql\Argument; use PhpDb\Sql\Ddl\Column\Json; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Json::class, 'getExpressionData')] final class JsonTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Json('foo'); diff --git a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php index 267daef1..d0f6ec51 100644 --- a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php @@ -20,7 +20,7 @@ #[Group('unit')] final class SmallIntegerTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new SmallInteger('foo'); @@ -40,7 +40,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function objectConstruction(): void { $integer = new SmallInteger('foo'); diff --git a/test/unit/Sql/Ddl/Column/TextTest.php b/test/unit/Sql/Ddl/Column/TextTest.php index 834a7e51..804b8735 100644 --- a/test/unit/Sql/Ddl/Column/TextTest.php +++ b/test/unit/Sql/Ddl/Column/TextTest.php @@ -18,7 +18,7 @@ final class TextTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Text('foo'); diff --git a/test/unit/Sql/Ddl/Column/TimeTest.php b/test/unit/Sql/Ddl/Column/TimeTest.php index b7517635..65e4de1b 100644 --- a/test/unit/Sql/Ddl/Column/TimeTest.php +++ b/test/unit/Sql/Ddl/Column/TimeTest.php @@ -8,12 +8,13 @@ use PhpDb\Sql\Argument\Literal; use PhpDb\Sql\Ddl\Column\Time; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Time::class, 'getExpressionData')] final class TimeTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Time('foo'); diff --git a/test/unit/Sql/Ddl/Column/TimestampTest.php b/test/unit/Sql/Ddl/Column/TimestampTest.php index f68fa929..1c1f938c 100644 --- a/test/unit/Sql/Ddl/Column/TimestampTest.php +++ b/test/unit/Sql/Ddl/Column/TimestampTest.php @@ -11,13 +11,14 @@ use PhpDb\Sql\Ddl\Column\AbstractTimestampColumn; use PhpDb\Sql\Ddl\Column\Timestamp; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Timestamp::class, 'getExpressionData')] #[CoversMethod(AbstractTimestampColumn::class, 'getExpressionData')] final class TimestampTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Timestamp('foo'); @@ -34,7 +35,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithCurrentTimestampDefault(): void { $column = new Timestamp('created_at'); @@ -53,7 +54,7 @@ public function getExpressionDataWithCurrentTimestampDefault(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void { $column = new Timestamp('updated_at'); @@ -74,7 +75,7 @@ public function getExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithOnUpdateOption(): void { $column = new Timestamp('created_at'); @@ -99,7 +100,7 @@ public function getExpressionDataWithOnUpdateOption(): void static::assertEquals(new Literal('ON UPDATE CURRENT_TIMESTAMP'), $values[2]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithoutOnUpdateOption(): void { $column = new Timestamp('updated_at'); @@ -113,7 +114,7 @@ public function getExpressionDataWithoutOnUpdateOption(): void static::assertEquals(Argument::literal('TIMESTAMP'), $values[1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function inheritanceFromAbstractTimestampColumn(): void { $column = new Timestamp('test'); diff --git a/test/unit/Sql/Ddl/Column/VarbinaryTest.php b/test/unit/Sql/Ddl/Column/VarbinaryTest.php index 02567993..12d44326 100644 --- a/test/unit/Sql/Ddl/Column/VarbinaryTest.php +++ b/test/unit/Sql/Ddl/Column/VarbinaryTest.php @@ -23,7 +23,7 @@ final class VarbinaryTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Varbinary('foo', 20); diff --git a/test/unit/Sql/Ddl/Column/VarcharTest.php b/test/unit/Sql/Ddl/Column/VarcharTest.php index 8cfb9662..8fb0ca20 100644 --- a/test/unit/Sql/Ddl/Column/VarcharTest.php +++ b/test/unit/Sql/Ddl/Column/VarcharTest.php @@ -27,7 +27,7 @@ final class VarcharTest extends TestCase { use ColumnAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $column = new Varchar('foo', 20); @@ -60,7 +60,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function inheritanceFromAbstractLengthColumn(): void { $column = new Varchar('test'); @@ -79,7 +79,7 @@ public function rendersLengthDirectlyAfterType(): void static::assertColumnRenders('"name" VARCHAR(20) NOT NULL', new Varchar('name', 20)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setLengthAndGetLength(): void { $column = new Varchar('name'); diff --git a/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php b/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php index 866acfcf..44acdc8e 100644 --- a/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php +++ b/test/unit/Sql/Ddl/Constraint/AbstractConstraintTest.php @@ -7,6 +7,7 @@ use Override; use PhpDb\Sql\Ddl\Constraint\AbstractConstraint; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -18,21 +19,21 @@ final class AbstractConstraintTest extends TestCase { protected MockObject $ac; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addColumn(): void { static::assertSame($this->ac, $this->ac->addColumn('foo')); static::assertEquals(['foo'], $this->ac->getColumns()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getColumns(): void { $this->ac->setColumns(['foo', 'bar']); static::assertEquals(['foo', 'bar'], $this->ac->getColumns()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setColumns(): void { static::assertSame($this->ac, $this->ac->setColumns(['foo', 'bar'])); diff --git a/test/unit/Sql/Ddl/Constraint/CheckTest.php b/test/unit/Sql/Ddl/Constraint/CheckTest.php index 17929cfc..2f501fd5 100644 --- a/test/unit/Sql/Ddl/Constraint/CheckTest.php +++ b/test/unit/Sql/Ddl/Constraint/CheckTest.php @@ -37,7 +37,7 @@ private static function assertConstraintRenders(string $expected, ConstraintInte ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $check = new Check('id>0', 'foo'); diff --git a/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php b/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php index d1535a4f..ed965417 100644 --- a/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/ForeignKeyTest.php @@ -9,6 +9,7 @@ use PhpDb\Sql\Ddl\Constraint\AbstractConstraint; use PhpDb\Sql\Ddl\Constraint\ForeignKey; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(AbstractConstraint::class, '__construct')] @@ -32,7 +33,7 @@ #[CoversMethod(ForeignKey::class, 'getExpressionData')] final class ForeignKeyTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam', 'CASCADE', 'SET NULL'); @@ -80,7 +81,7 @@ public function getExpressionData(): void static::assertEquals(ArgumentType::Literal, $values[5]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setName(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -101,7 +102,7 @@ public function setName(): void static::assertSame('yyyy', $fk->getName()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOnDeleteRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -122,7 +123,7 @@ public function setOnDeleteRule(): void static::assertSame('SET NULL', $fk->getOnDeleteRule()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOnUpdateRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -143,7 +144,7 @@ public function setOnUpdateRule(): void static::assertSame('RESTRICT', $fk->getOnUpdateRule()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setReferenceColumn(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -164,7 +165,7 @@ public function setReferenceColumn(): void static::assertEquals(['yyyy'], $fk->getReferenceColumn()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setReferenceTable(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); diff --git a/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php b/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php index a4d3db91..b656a204 100644 --- a/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php @@ -7,12 +7,13 @@ use PhpDb\Sql\Argument; use PhpDb\Sql\Ddl\Constraint\PrimaryKey; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(PrimaryKey::class, 'getExpressionData')] final class PrimaryKeyTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $pk = new PrimaryKey('foo'); diff --git a/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php b/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php index 0d0e8696..8eeef080 100644 --- a/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php @@ -7,12 +7,13 @@ use PhpDb\Sql\Argument; use PhpDb\Sql\Ddl\Constraint\UniqueKey; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(UniqueKey::class, 'getExpressionData')] final class UniqueKeyTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $uk = new UniqueKey('foo', 'my_uk'); diff --git a/test/unit/Sql/Ddl/CreateTableTest.php b/test/unit/Sql/Ddl/CreateTableTest.php index d7feeb02..69d7dcac 100644 --- a/test/unit/Sql/Ddl/CreateTableTest.php +++ b/test/unit/Sql/Ddl/CreateTableTest.php @@ -12,6 +12,7 @@ use PhpDb\Sql\Literal; use PhpDb\Sql\TableIdentifier; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(CreateTable::class, '__construct')] @@ -35,7 +36,7 @@ #[CoversMethod(CreateTable::class, 'processTableOptions')] class CreateTableTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addColumn(): void { $column = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -63,7 +64,7 @@ public function addColumn(): void static::assertInstanceOf(ColumnInterface::class, $state2[1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addConstraint(): void { $constraint = $this->getMockBuilder(ConstraintInterface::class)->getMock(); @@ -91,7 +92,7 @@ public function addConstraint(): void static::assertInstanceOf(ConstraintInterface::class, $state2[1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function chainedOperations(): void { $ct = new CreateTable(); @@ -112,7 +113,7 @@ public function chainedOperations(): void static::assertCount(1, $ct->getRawState(CreateTable::CONSTRAINTS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTableIdentifier(): void { $tableId = new TableIdentifier('bar', 'foo'); @@ -122,7 +123,7 @@ public function constructorWithTableIdentifier(): void static::assertSame($tableId, $rawState[CreateTable::TABLE]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTemporaryFlag(): void { $ct = new CreateTable('test', true); @@ -133,7 +134,7 @@ public function constructorWithTemporaryFlag(): void static::assertFalse($ct2->isTemporary()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyTableConstruction(): void { $ct = new CreateTable(); @@ -143,14 +144,14 @@ public function emptyTableConstruction(): void static::assertEmpty($ct->getRawState(CreateTable::CONSTRAINTS)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getOptionsReturnsEmpty(): void { $ct = new CreateTable('foo'); static::assertEquals([], $ct->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateIncludesTableOptions(): void { $ct = new CreateTable('foo'); @@ -162,7 +163,7 @@ public function getRawStateIncludesTableOptions(): void static::assertEquals(['engine' => new Literal('InnoDB')], $rawState[CreateTable::TABLE_OPTIONS]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateReturnsAllState(): void { $ct = new CreateTable('users'); @@ -184,7 +185,7 @@ public function getRawStateReturnsAllState(): void static::assertEquals([$con], $rawState[CreateTable::CONSTRAINTS]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateWithInvalidKey(): void { $ct = new CreateTable('test'); @@ -196,7 +197,7 @@ public function getRawStateWithInvalidKey(): void static::assertArrayHasKey(CreateTable::TABLE, $rawState); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $ct = new CreateTable('foo'); @@ -246,7 +247,7 @@ public function getSqlString(): void static::assertSame("CREATE TABLE \"foo\".\"bar\" ( \n \"baz\" INTEGER NOT NULL \n)", $ct->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithBoolOption(): void { $ct = new CreateTable('foo'); @@ -259,7 +260,7 @@ public function getSqlStringWithBoolOption(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithIntOption(): void { $ct = new CreateTable('foo'); @@ -272,7 +273,7 @@ public function getSqlStringWithIntOption(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithLiteralOption(): void { $ct = new CreateTable('foo'); @@ -285,7 +286,7 @@ public function getSqlStringWithLiteralOption(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithMultipleOptions(): void { $ct = new CreateTable('foo'); @@ -299,7 +300,7 @@ public function getSqlStringWithMultipleOptions(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithNoOptionsUnchanged(): void { $ct = new CreateTable('foo'); @@ -311,7 +312,7 @@ public function getSqlStringWithNoOptionsUnchanged(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithStringOption(): void { $ct = new CreateTable('foo'); @@ -324,7 +325,7 @@ public function getSqlStringWithStringOption(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifNotExists(): void { $ct = new CreateTable('foo'); @@ -337,7 +338,7 @@ public function ifNotExists(): void static::assertSame("CREATE TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifNotExistsCombinedWithTemporary(): void { $ct = new CreateTable('foo', true); @@ -346,7 +347,7 @@ public function ifNotExistsCombinedWithTemporary(): void static::assertSame("CREATE TEMPORARY TABLE IF NOT EXISTS \"foo\" ( \n)", $ct->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifNotExistsDisable(): void { $ct = new CreateTable('foo'); @@ -359,7 +360,7 @@ public function ifNotExistsDisable(): void static::assertSame("CREATE TABLE \"foo\" ( \n)", $ct->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isTemporary(): void { $ct = new CreateTable(); @@ -368,7 +369,7 @@ public function isTemporary(): void static::assertTrue($ct->isTemporary()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleColumns(): void { $ct = new CreateTable('users'); @@ -385,7 +386,7 @@ public function multipleColumns(): void static::assertStringContainsString('"email"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function multipleConstraints(): void { $ct = new CreateTable('orders'); @@ -403,7 +404,7 @@ public function multipleConstraints(): void /** * test object construction */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function objectConstruction(): void { $ct = new CreateTable('foo', true); @@ -411,7 +412,7 @@ public function objectConstruction(): void static::assertTrue($ct->isTemporary()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOptionFluentInterface(): void { $ct = new CreateTable('foo'); @@ -421,7 +422,7 @@ public function setOptionFluentInterface(): void static::assertEquals(['engine' => new Literal('InnoDB')], $ct->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setOptionsReplacesAll(): void { $ct = new CreateTable('foo'); @@ -432,7 +433,7 @@ public function setOptionsReplacesAll(): void static::assertEquals(['charset' => new Literal('utf8mb4')], $ct->getOptions()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTable(): void { $ct = new CreateTable(); @@ -456,7 +457,7 @@ public function setTable(): void static::assertSame('another_table', $ct->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTableAfterConstruction(): void { $ct = new CreateTable(); @@ -471,7 +472,7 @@ public function setTableAfterConstruction(): void static::assertSame('another_table', $ct->getRawState(CreateTable::TABLE)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTemporary(): void { $ct = new CreateTable(); diff --git a/test/unit/Sql/Ddl/DropTableTest.php b/test/unit/Sql/Ddl/DropTableTest.php index 0f5dcd33..bc4028b7 100644 --- a/test/unit/Sql/Ddl/DropTableTest.php +++ b/test/unit/Sql/Ddl/DropTableTest.php @@ -7,6 +7,7 @@ use PhpDb\Sql\Ddl\DropTable; use PhpDb\Sql\TableIdentifier; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(DropTable::class, '__construct')] @@ -16,7 +17,7 @@ #[CoversMethod(DropTable::class, 'processTable')] class DropTableTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $dt = new DropTable('foo'); @@ -29,7 +30,7 @@ public function getSqlString(): void static::assertSame('DROP TABLE "foo"."bar"', $dt->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifExists(): void { $dt = new DropTable('foo'); @@ -42,7 +43,7 @@ public function ifExists(): void static::assertSame('DROP TABLE IF EXISTS "foo"', $dt->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifExistsDisable(): void { $dt = new DropTable('foo'); @@ -55,7 +56,7 @@ public function ifExistsDisable(): void static::assertSame('DROP TABLE "foo"', $dt->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function ifExistsWithTableIdentifier(): void { $dt = new DropTable(new TableIdentifier('bar', 'foo')); diff --git a/test/unit/Sql/Ddl/Index/IndexTest.php b/test/unit/Sql/Ddl/Index/IndexTest.php index 59a718bf..bf3e56f2 100644 --- a/test/unit/Sql/Ddl/Index/IndexTest.php +++ b/test/unit/Sql/Ddl/Index/IndexTest.php @@ -8,6 +8,7 @@ use PhpDb\Sql\Argument\Literal; use PhpDb\Sql\Ddl\Index\Index; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(Index::class, '__construct')] @@ -16,7 +17,7 @@ #[CoversMethod(Index::class, 'getExpressionData')] final class IndexTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $uk = new Index('foo', 'my_uk'); @@ -33,7 +34,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithBtreeType(): void { $index = new Index('foo', 'my_idx'); @@ -52,7 +53,7 @@ public function getExpressionDataWithBtreeType(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithHashType(): void { $index = new Index('foo', 'my_idx'); @@ -71,7 +72,7 @@ public function getExpressionDataWithHashType(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithLength(): void { $key = new Index(['foo', 'bar'], 'my_uk', [10, 5]); @@ -89,7 +90,7 @@ public function getExpressionDataWithLength(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithLengthUnmatched(): void { $key = new Index(['foo', 'bar'], 'my_uk', [10]); @@ -107,7 +108,7 @@ public function getExpressionDataWithLengthUnmatched(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithTypeAndLengths(): void { $index = new Index(['foo', 'bar'], 'my_idx', [10, 5]); @@ -127,7 +128,7 @@ public function getExpressionDataWithTypeAndLengths(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTypeAndGetType(): void { $index = new Index('foo', 'my_idx'); diff --git a/test/unit/Sql/DeleteTest.php b/test/unit/Sql/DeleteTest.php index 4a3c081a..17734f81 100644 --- a/test/unit/Sql/DeleteTest.php +++ b/test/unit/Sql/DeleteTest.php @@ -27,6 +27,7 @@ use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; use ReflectionException; @@ -47,14 +48,14 @@ final class DeleteTest extends TestCase protected Delete $delete; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTable(): void { $delete = new Delete('foo'); static::assertSame('foo', $delete->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); @@ -65,7 +66,7 @@ public function constructorWithTableIdentifier(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function from(): void { // Set table with string @@ -78,7 +79,7 @@ public function from(): void static::assertEquals($tableIdentifier, static::readAttribute($this->delete, 'table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawState(): void { $this->delete->from('foo')->where('x = y'); @@ -95,7 +96,7 @@ public function getRawState(): void static::assertTrue($rawState['emptyWhereProtection']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateWithKey(): void { $this->delete->from('foo'); @@ -105,7 +106,7 @@ public function getRawStateWithKey(): void static::assertTrue($this->delete->getRawState('emptyWhereProtection')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $this->delete->from('foo')->where('x = y'); @@ -117,7 +118,7 @@ public function getSqlString(): void static::assertSame('DELETE FROM "sch"."foo" WHERE x = y', $this->delete->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithEmptyWhere(): void { $this->delete->from('foo'); @@ -125,7 +126,7 @@ public function getSqlStringWithEmptyWhere(): void static::assertSame('DELETE FROM "foo"', $this->delete->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsNullForUnknownProperty(): void { /** @noinspection PhpUndefinedFieldInspection */ @@ -133,14 +134,14 @@ public function magicGetReturnsNullForUnknownProperty(): void static::assertNull($this->delete->table); // @phpstan-ignore-line } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsWhereClause(): void { $where = $this->delete->where; static::assertInstanceOf(Where::class, $where); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -171,7 +172,7 @@ public function prepareStatement(): void $this->delete->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { @@ -188,7 +189,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString( static::assertSame('DELETE IGNORE FROM "sch"."foo" WHERE x = y', $deleteIgnore->getSqlString()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { @@ -228,7 +229,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatem * @throws ReflectionException * @todo REMOVE THIS IN 3.x */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function where(): void { $this->delete->where('x = y'); @@ -279,7 +280,7 @@ public function where(): void }); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] public function whereAcceptsExpressionInterface(): void { diff --git a/test/unit/Sql/ExpressionTest.php b/test/unit/Sql/ExpressionTest.php index 04c31ddd..2237448d 100644 --- a/test/unit/Sql/ExpressionTest.php +++ b/test/unit/Sql/ExpressionTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use TypeError; @@ -43,7 +44,7 @@ public static function falsyExpressionParametersProvider(): array ]; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('falsyExpressionParametersProvider')] public function constructorWithFalsyValidParameters(mixed $falsyParameter): void { @@ -55,21 +56,21 @@ public function constructorWithFalsyValidParameters(mixed $falsyParameter): void static::assertEquals([$falsyValue], $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithInvalidParameter(): void { self::expectException(TypeError::class); new Expression('?', (object) []); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithLiteralZero(): void { $expression = new Expression('0'); static::assertSame('0', $expression->getExpression()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithMultipleArguments(): void { $expression = new Expression('? + ? - ?', 1, 2, 3); @@ -87,7 +88,7 @@ public function constructorWithMultipleArguments(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $expression = new Expression( @@ -112,7 +113,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenParameterCountMismatch(): void { $expression = new Expression('? AND ?', [1]); // Two placeholders but only one parameter @@ -124,7 +125,7 @@ public function getExpressionDataThrowsExceptionWhenParameterCountMismatch(): vo $expression->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataUsesRegexWhenPlaceholderCountMismatches(): void { $expression = new Expression('uf.user_id = :user_id OR uf.friend_id = :user_id', ['user_id' => 1]); @@ -138,7 +139,7 @@ public function getExpressionDataUsesRegexWhenPlaceholderCountMismatches(): void static::assertCount(1, $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWillEscapePercent(): void { $expression = new Expression('X LIKE "foo%"'); @@ -148,7 +149,7 @@ public function getExpressionDataWillEscapePercent(): void static::assertSame('X LIKE "foo%%"', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('7407')] public function getExpressionPreservesPercentageSignInFromUnixtime(): void { @@ -158,7 +159,7 @@ public function getExpressionPreservesPercentageSignInFromUnixtime(): void static::assertSame($expressionString, $expression->getExpression()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function numberOfReplacementsConsidersWhenSameVariableIsUsedManyTimes(): void { $expression = new Expression('uf.user_id = :user_id OR uf.friend_id = :user_id', ['user_id' => 1]); @@ -173,7 +174,7 @@ public function numberOfReplacementsConsidersWhenSameVariableIsUsedManyTimes(): static::assertEquals([$value], $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function numberOfReplacementsForExpressionWithParameters(): void { $expression = new Expression(':a + :b', ['a' => 1, 'b' => 2]); @@ -186,7 +187,7 @@ public function numberOfReplacementsForExpressionWithParameters(): void static::assertEquals([$value1, $value2], $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setExpression(): void { $expression = new Expression(); @@ -207,7 +208,7 @@ public function setExpression(): void static::assertSame('Baz Qux', $expression->getExpression()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setExpressionException(): void { $expression = new Expression(); @@ -221,7 +222,7 @@ public function setExpressionException(): void $expression->setExpression(''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setExpressionThrowsOnEmptyString(): void { $expression = new Expression(); @@ -230,7 +231,7 @@ public function setExpressionThrowsOnEmptyString(): void $expression->setExpression(''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setParameters(): void { $expression = new Expression(); @@ -251,7 +252,7 @@ public function setParameters(): void static::assertEquals([new Value('foo'), new Value('bar')], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setParametersWrapsArrayInValuesArgument(): void { $expression = new Expression('? IN (?)', [Argument::identifier('id'), [1, 2, 3]]); diff --git a/test/unit/Sql/InsertIgnoreTest.php b/test/unit/Sql/InsertIgnoreTest.php index 593104b7..6b3a5461 100644 --- a/test/unit/Sql/InsertIgnoreTest.php +++ b/test/unit/Sql/InsertIgnoreTest.php @@ -22,6 +22,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionException; use TypeError; @@ -36,7 +37,7 @@ final class InsertIgnoreTest extends TestCase protected InsertIgnore $insert; // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _get(): void { // @codingStandardsIgnoreEnd @@ -48,7 +49,7 @@ public function _get(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _isset(): void { // @codingStandardsIgnoreEnd @@ -60,7 +61,7 @@ public function _isset(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _set(): void { // @codingStandardsIgnoreEnd @@ -70,7 +71,7 @@ public function _set(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _unset(): void { // @codingStandardsIgnoreEnd @@ -90,7 +91,7 @@ public function _unset(): void static::assertEquals([], $this->insert->getRawState('values')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function columns(): void { $columns = ['foo', 'bar']; @@ -101,7 +102,7 @@ public function columns(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-4926')] public function emptyArrayValues(): void { @@ -109,7 +110,7 @@ public function emptyArrayValues(): void static::assertEquals([], static::readAttribute($this->insert, 'columns')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); @@ -148,7 +149,7 @@ public function getSqlString(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringUsingColumnsAndValuesMethods(): void { // With columns() and values() @@ -162,7 +163,7 @@ public function getSqlStringUsingColumnsAndValuesMethods(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function into(): void { $this->insert->into('table'); @@ -173,7 +174,7 @@ public function into(): void static::assertEquals($tableIdentifier, $this->insert->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -214,7 +215,7 @@ public function prepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -239,7 +240,7 @@ public function prepareStatementWithSelect(): void static::assertSame(['subselect1where1' => 5], $parameters); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $replace = new Replace(); @@ -262,7 +263,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString( ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $replace = new Replace(); @@ -305,7 +306,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatem $replace->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function values(): void { $this->insert->values(['foo' => 'bar']); @@ -323,7 +324,7 @@ public function values(): void static::assertEquals(['bax'], $this->insert->getRawState('values')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-536')] public function valuesMerge(): void { @@ -337,7 +338,7 @@ public function valuesMerge(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -350,14 +351,14 @@ public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); $this->insert->values(5); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenSelectMergeOverArray(): void { $this->insert->values(['foo' => 'bar']); diff --git a/test/unit/Sql/InsertTest.php b/test/unit/Sql/InsertTest.php index f1204f74..82cc0cbf 100644 --- a/test/unit/Sql/InsertTest.php +++ b/test/unit/Sql/InsertTest.php @@ -24,6 +24,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionException; use TypeError; @@ -54,7 +55,7 @@ final class InsertTest extends TestCase protected Insert $insert; // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _get(): void { // @codingStandardsIgnoreEnd @@ -68,7 +69,7 @@ public function _get(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _isset(): void { // @codingStandardsIgnoreEnd @@ -84,7 +85,7 @@ public function _isset(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _set(): void { // @codingStandardsIgnoreEnd @@ -95,7 +96,7 @@ public function _set(): void } // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _unset(): void { // @codingStandardsIgnoreEnd @@ -117,7 +118,7 @@ public function _unset(): void static::assertEquals([], $this->insert->getRawState('values')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function columns(): void { $columns = ['foo', 'bar']; @@ -128,7 +129,7 @@ public function columns(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-4926')] public function emptyArrayValues(): void { @@ -136,7 +137,7 @@ public function emptyArrayValues(): void static::assertEquals([], static::readAttribute($this->insert, 'columns')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $this->insert->into('foo')->values(['bar' => 'baz', 'boo' => new Expression('NOW()'), 'bam' => null]); @@ -175,7 +176,7 @@ public function getSqlString(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringThrowsExceptionWhenNoValuesOrSelect(): void { $this->insert->into('foo'); @@ -185,7 +186,7 @@ public function getSqlStringThrowsExceptionWhenNoValuesOrSelect(): void $this->insert->getSqlString(new TrustingSql92Platform()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringUsingColumnsAndValuesMethods(): void { // With columns() and values() @@ -199,7 +200,7 @@ public function getSqlStringUsingColumnsAndValuesMethods(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getThrowsExceptionForNonExistentColumn(): void { self::expectException(InvalidArgumentException::class); @@ -207,7 +208,7 @@ public function getThrowsExceptionForNonExistentColumn(): void $value = $this->insert->nonexistent; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function into(): void { $this->insert->into('table'); @@ -218,7 +219,7 @@ public function into(): void static::assertEquals($tableIdentifier, $this->insert->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -259,7 +260,7 @@ public function prepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementCreatesParameterContainerWhenNotPresent(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -287,7 +288,7 @@ public function prepareStatementCreatesParameterContainerWhenNotPresent(): void static::assertSame($mockStatement, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -315,7 +316,7 @@ public function prepareStatementWithSelect(): void static::assertSame(['subselect1where1' => 5], $namedArray); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processInsertWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); @@ -336,7 +337,7 @@ public function processInsertWithPdoDriverUsesDriverColumnQuoting(): void static::assertStringContainsString(':c_1', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { @@ -360,7 +361,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString( ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { @@ -404,7 +405,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatem $replace->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function unsetThrowsExceptionForNonExistentColumn(): void { self::expectException(InvalidArgumentException::class); @@ -412,7 +413,7 @@ public function unsetThrowsExceptionForNonExistentColumn(): void unset($this->insert->nonexistent); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function values(): void { $this->insert->values(['foo' => 'bar']); @@ -430,7 +431,7 @@ public function values(): void static::assertEquals(['bax'], $this->insert->getRawState('values')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-536')] public function valuesMerge(): void { @@ -444,7 +445,7 @@ public function valuesMerge(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -457,7 +458,7 @@ public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); @@ -465,7 +466,7 @@ public function valuesThrowsExceptionWhenNotArrayOrSelect(): void $this->insert->values(5); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valuesThrowsExceptionWhenSelectMergeOverArray(): void { $this->insert->values(['foo' => 'bar']); diff --git a/test/unit/Sql/JoinTest.php b/test/unit/Sql/JoinTest.php index 15160bc5..89e3cfe2 100644 --- a/test/unit/Sql/JoinTest.php +++ b/test/unit/Sql/JoinTest.php @@ -11,6 +11,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; use ReflectionException; @@ -31,7 +32,7 @@ class JoinTest extends TestCase { use DeprecatedAssertionsTrait; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test count() returns correct count')] public function countsJoinedTables(): void { @@ -43,7 +44,7 @@ public function countsJoinedTables(): void static::assertCount($join->count(), $join->getJoins()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function currentReturnsTheCurrentJoinSpecification(): void { $name = 'baz'; @@ -65,7 +66,7 @@ public function currentReturnsTheCurrentJoinSpecification(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initialPositionIsZero(): void { $join = new Join(); @@ -73,7 +74,7 @@ public function initialPositionIsZero(): void static::assertAttributeSame(0, 'position', $join); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test join() returns Join object (is chainable)')] public function join(): void { @@ -82,7 +83,7 @@ public function join(): void static::assertSame($join, $return); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function joinFullOuter(): void { $join = new Join(); @@ -90,7 +91,7 @@ public function joinFullOuter(): void static::assertSame($join, $return); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function joinThrowsOnInvalidMultiElementArray(): void { $join = new Join(); @@ -100,7 +101,7 @@ public function joinThrowsOnInvalidMultiElementArray(): void $join->join(['a' => 'b', 'c' => 'd'], 'on'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function joinWillThrowAnExceptionIfNameIsNoValid(): void { $join = new Join(); @@ -110,7 +111,7 @@ public function joinWillThrowAnExceptionIfNameIsNoValid(): void $join->join([], false); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function keyReturnsTheCurrentPosition(): void { $join = new Join(); @@ -125,7 +126,7 @@ public function keyReturnsTheCurrentPosition(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function nextIncrementsThePosition(): void { $join = new Join(); @@ -135,7 +136,7 @@ public function nextIncrementsThePosition(): void static::assertAttributeSame(1, 'position', $join); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test reset() resets the joins')] public function reset(): void { @@ -150,7 +151,7 @@ public function reset(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rewindResetsPositionToZero(): void { $join = new Join(); @@ -163,7 +164,7 @@ public function rewindResetsPositionToZero(): void static::assertAttributeSame(0, 'position', $join); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function validReturnsTrueIfTheIteratorIsAtAValidPositionAndFalseIfNot(): void { $join = new Join(); diff --git a/test/unit/Sql/LiteralTest.php b/test/unit/Sql/LiteralTest.php index 104e8870..f88cd104 100644 --- a/test/unit/Sql/LiteralTest.php +++ b/test/unit/Sql/LiteralTest.php @@ -5,11 +5,12 @@ namespace PhpDbTest\Sql; use PhpDb\Sql\Literal; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class LiteralTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $literal = new Literal('bar'); @@ -26,7 +27,7 @@ public function getExpressionData(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWillEscapePercent(): void { $literal = new Literal('X LIKE "foo%"'); @@ -43,14 +44,14 @@ public function getExpressionDataWillEscapePercent(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLiteral(): void { $literal = new Literal('bar'); static::assertSame('bar', $literal->getLiteral()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setLiteral(): void { $literal = new Literal('bar'); diff --git a/test/unit/Sql/Platform/AbstractPlatformTest.php b/test/unit/Sql/Platform/AbstractPlatformTest.php index 1f150629..e58e0890 100644 --- a/test/unit/Sql/Platform/AbstractPlatformTest.php +++ b/test/unit/Sql/Platform/AbstractPlatformTest.php @@ -16,6 +16,7 @@ use PhpDb\Sql\SqlInterface; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use function sprintf; @@ -31,7 +32,7 @@ final class AbstractPlatformTest extends TestCase { private AbstractPlatform $platform; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringDelegatesToDecoratorSubject(): void { $select = new Select('foo'); @@ -43,7 +44,7 @@ public function getSqlStringDelegatesToDecoratorSubject(): void static::assertStringContainsString('"foo"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $subject = $this->createMock(PreparableSqlInterface::class); @@ -58,7 +59,7 @@ public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void $this->platform->getSqlString(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorLoopMatchesByInstanceof(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); @@ -72,7 +73,7 @@ public function getTypeDecoratorLoopMatchesByInstanceof(): void static::assertSame($decorator, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorReturnsSubjectWhenNoMatch(): void { $subject = $this->createMock(SqlInterface::class); @@ -82,7 +83,7 @@ public function getTypeDecoratorReturnsSubjectWhenNoMatch(): void static::assertSame($subject, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementDelegatesToDecoratorSubject(): void { $select = new Select('foo'); @@ -109,7 +110,7 @@ public function prepareStatementDelegatesToDecoratorSubject(): void static::assertStringContainsString('SELECT', $statement->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $subject = $this->createMock(SqlInterface::class); @@ -127,7 +128,7 @@ public function prepareStatementThrowsWhenSubjectNotPreparable(): void $this->platform->prepareStatement($adapter, $statement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setAndGetTypeDecorator(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); @@ -139,7 +140,7 @@ public function setAndGetTypeDecorator(): void static::assertSame($decorator, $decorators[Select::class]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setSubjectReturnsStatic(): void { $subject = $this->createMock(SqlInterface::class); diff --git a/test/unit/Sql/Platform/PlatformTest.php b/test/unit/Sql/Platform/PlatformTest.php index 92501828..fdae8706 100644 --- a/test/unit/Sql/Platform/PlatformTest.php +++ b/test/unit/Sql/Platform/PlatformTest.php @@ -22,6 +22,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionException; @@ -40,7 +41,7 @@ #[CoversMethod(Platform::class, 'getDefaultPlatform')] class PlatformTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDefaultPlatformReturnsInstance(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -52,7 +53,7 @@ public function getDefaultPlatformReturnsInstance(): void static::assertSame($adapterPlatform, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringDelegatesToTypeDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -67,7 +68,7 @@ public function getSqlStringDelegatesToTypeDecorator(): void static::assertStringContainsString('"foo"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -80,7 +81,7 @@ public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void $platform->getSqlString($adapterPlatform); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorFallsThroughWhenNoMatch(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -95,7 +96,7 @@ public function getTypeDecoratorFallsThroughWhenNoMatch(): void static::assertSame($select, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorMatchesByInstanceofLoop(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -110,7 +111,7 @@ public function getTypeDecoratorMatchesByInstanceofLoop(): void static::assertSame($innerPlatform, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorMatchesExactClass(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -126,7 +127,7 @@ public function getTypeDecoratorMatchesExactClass(): void static::assertSame($decorator, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -138,7 +139,7 @@ public function getTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): void static::assertSame($select, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -157,7 +158,7 @@ public function prepareStatementThrowsWhenSubjectNotPreparable(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolveDefaultPlatform(): void { $adapter = $this->resolveAdapter('sql92'); @@ -171,7 +172,7 @@ public function resolveDefaultPlatform(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolvePlatformName(): void { $platform = new Platform($this->resolveAdapter('sql92')->getPlatform()); @@ -190,7 +191,7 @@ public function resolvePlatformName(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolvePlatformNameCachesResult(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -205,7 +206,7 @@ public function resolvePlatformNameCachesResult(): void static::assertSame('sql92', $first); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolvePlatformWithAdapterInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -223,7 +224,7 @@ public function resolvePlatformWithAdapterInterface(): void static::assertSame($mockPlatform, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resolvePlatformWithPlatformInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); @@ -237,7 +238,7 @@ public function resolvePlatformWithPlatformInterface(): void static::assertSame($mockPlatform, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setTypeDecoratorRegistersDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); diff --git a/test/unit/Sql/Predicate/BetweenTest.php b/test/unit/Sql/Predicate/BetweenTest.php index c9ebc8a1..1a4d2583 100644 --- a/test/unit/Sql/Predicate/BetweenTest.php +++ b/test/unit/Sql/Predicate/BetweenTest.php @@ -28,7 +28,7 @@ final class BetweenTest extends TestCase { protected Between $between; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorCanPassIdentifierMinimumAndMaximumValues(): void { $between = new Between('foo.bar', 1, 300); @@ -83,7 +83,7 @@ public function constructorCanPassIdentifierMinimumAndMaximumValues(): void static::assertEquals(ArgumentType::Value, $maxValue->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorYieldsNullIdentifierMinimumAndMaximumValues(): void { static::assertNull($this->between->getIdentifier()); @@ -104,7 +104,7 @@ public function getExpressionDataPrefersACustomSpecification(): void static::assertSame('%1$s IS INBETWEEN %2$s AND %3$s', $between->getExpressionData()['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $between = new Between(); @@ -115,7 +115,7 @@ public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $between->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenMaxValueNotSet(): void { $between = new Between(); @@ -126,7 +126,7 @@ public function getExpressionDataThrowsExceptionWhenMaxValueNotSet(): void $between->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenMinValueNotSet(): void { $between = new Between(); @@ -137,7 +137,7 @@ public function getExpressionDataThrowsExceptionWhenMinValueNotSet(): void $between->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function identifierIsMutable(): void { // First mutation @@ -162,7 +162,7 @@ public function identifierIsMutable(): void static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function maxValueIsMutable(): void { // First mutation @@ -187,7 +187,7 @@ public function maxValueIsMutable(): void static::assertEquals(ArgumentType::Value, $maxValue2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function minValueIsMutable(): void { // First mutation @@ -212,7 +212,7 @@ public function minValueIsMutable(): void static::assertEquals(ArgumentType::Value, $minValue2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $this->between @@ -274,14 +274,14 @@ public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValu static::assertEquals(ArgumentType::Identifier, $values[2]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationIsMutable(): void { $this->between->setSpecification('%1$s IS INBETWEEN %2$s AND %3$s'); static::assertSame('%1$s IS INBETWEEN %2$s AND %3$s', $this->between->getSpecification()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationIsNullByDefault(): void { static::assertNull($this->between->getSpecification()); diff --git a/test/unit/Sql/Predicate/ExpressionTest.php b/test/unit/Sql/Predicate/ExpressionTest.php index 0e74df87..f6bc50ab 100644 --- a/test/unit/Sql/Predicate/ExpressionTest.php +++ b/test/unit/Sql/Predicate/ExpressionTest.php @@ -12,11 +12,12 @@ use PhpDb\Sql\Predicate\Expression; use PhpDb\Sql\Predicate\IsNull; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; final class ExpressionTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfMultiNullsParameterToConstructor(): void { @@ -25,7 +26,7 @@ public function canPassArrayOfMultiNullsParameterToConstructor(): void static::assertEquals([$null, $null], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfMultiPredicatesParameterToConstructor(): void { @@ -35,7 +36,7 @@ public function canPassArrayOfMultiPredicatesParameterToConstructor(): void static::assertEquals([$isNull, $isNull], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfMultiScalarsParameterToConstructor(): void { @@ -45,7 +46,7 @@ public function canPassArrayOfMultiScalarsParameterToConstructor(): void static::assertEquals([$foo, $bar], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfOneNullParameterToConstructor(): void { @@ -54,7 +55,7 @@ public function canPassArrayOfOneNullParameterToConstructor(): void static::assertEquals([$null], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfOnePredicateParameterToConstructor(): void { @@ -64,7 +65,7 @@ public function canPassArrayOfOnePredicateParameterToConstructor(): void static::assertEquals([$isNull], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassArrayOfOneScalarParameterToConstructor(): void { @@ -73,7 +74,7 @@ public function canPassArrayOfOneScalarParameterToConstructor(): void static::assertEquals([$foo], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassLiteralAndSingleScalarParameterToConstructor(): void { @@ -83,7 +84,7 @@ public function canPassLiteralAndSingleScalarParameterToConstructor(): void static::assertEquals([$bar], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassMultiNullParametersToConstructor(): void { @@ -94,7 +95,7 @@ public function canPassMultiNullParametersToConstructor(): void static::assertEquals([$null, $null], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassMultiScalarParametersToConstructor(): void { @@ -106,7 +107,7 @@ public function canPassMultiScalarParametersToConstructor(): void static::assertEquals([$foo, $bar], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassNoParameterToConstructor(): void { @@ -114,7 +115,7 @@ public function canPassNoParameterToConstructor(): void static::assertEquals([], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassSingleNullParameterToConstructor(): void { @@ -123,7 +124,7 @@ public function canPassSingleNullParameterToConstructor(): void static::assertEquals([$null], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassSinglePredicateParameterToConstructor(): void { @@ -133,7 +134,7 @@ public function canPassSinglePredicateParameterToConstructor(): void static::assertEquals([$isNull], $expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6849')] public function canPassSingleZeroParameterValueToConstructor(): void { @@ -142,7 +143,7 @@ public function canPassSingleZeroParameterValueToConstructor(): void static::assertEquals([$expression], $predicate->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsEmptyLiteralAndParameter(): void { $expression = new Expression(); @@ -150,7 +151,7 @@ public function emptyConstructorYieldsEmptyLiteralAndParameter(): void static::assertEmpty($expression->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function literalIsMutable(): void { $expression = new Expression(); @@ -158,7 +159,7 @@ public function literalIsMutable(): void static::assertSame('foo.bar = ?', $expression->getExpression()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function parameterIsMutable(): void { $expression = new Expression(); @@ -200,7 +201,7 @@ public function parameterIsMutable(): void static::assertEquals(ArgumentType::Value, $parameters2[4]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes(): void { $expression = new Expression(); diff --git a/test/unit/Sql/Predicate/InTest.php b/test/unit/Sql/Predicate/InTest.php index 27742053..cc927901 100644 --- a/test/unit/Sql/Predicate/InTest.php +++ b/test/unit/Sql/Predicate/InTest.php @@ -14,6 +14,7 @@ use PhpDb\Sql\Select; use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(In::class, '__construct')] @@ -25,7 +26,7 @@ #[Group('unit')] final class InTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassIdentifierAndEmptyValueSetToConstructor(): void { $in = new In('foo.bar', []); @@ -43,7 +44,7 @@ public function canPassIdentifierAndEmptyValueSetToConstructor(): void static::assertEquals(ArgumentType::Values, $valueSet->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassIdentifierAndValueSetToConstructor(): void { $in = new In('foo.bar', [1, 2]); @@ -61,7 +62,7 @@ public function canPassIdentifierAndValueSetToConstructor(): void static::assertEquals(ArgumentType::Values, $valueSet->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsNullIdentifierAndValueSet(): void { $in = new In(); @@ -69,7 +70,7 @@ public function emptyConstructorYieldsNullIdentifierAndValueSet(): void static::assertNull($in->getValueSet()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $in = new In(); @@ -80,7 +81,7 @@ public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $in->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenValueSetNotSet(): void { $in = new In(); @@ -91,7 +92,7 @@ public function getExpressionDataThrowsExceptionWhenValueSetNotSet(): void $in->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithEmptyValues(): void { new Select(); @@ -102,7 +103,7 @@ public function getExpressionDataWithEmptyValues(): void static::assertSame('%s IN (NULL)', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselect(): void { $select = new Select(); @@ -128,7 +129,7 @@ public function getExpressionDataWithSubselect(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); @@ -154,7 +155,7 @@ public function getExpressionDataWithSubselectAndArrayIdentifier(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); @@ -180,7 +181,7 @@ public function getExpressionDataWithSubselectAndIdentifier(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function identifierIsMutable(): void { $in = new In(); @@ -207,7 +208,7 @@ public function identifierIsMutable(): void static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new In(); @@ -268,7 +269,7 @@ public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValu static::assertEquals(ArgumentType::Values, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setValueSetWithArgumentInterfacePassesThrough(): void { $in = new In(); @@ -279,7 +280,7 @@ public function setValueSetWithArgumentInterfacePassesThrough(): void static::assertSame($values, $in->getValueSet()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setValueSetWithSelectWrapsInArgumentSelect(): void { $in = new In(); @@ -292,7 +293,7 @@ public function setValueSetWithSelectWrapsInArgumentSelect(): void static::assertSame(ArgumentType::Select, $valueSet->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function valueSetIsMutable(): void { $in = new In(); diff --git a/test/unit/Sql/Predicate/IsNullTest.php b/test/unit/Sql/Predicate/IsNullTest.php index 8d1939be..08713269 100644 --- a/test/unit/Sql/Predicate/IsNullTest.php +++ b/test/unit/Sql/Predicate/IsNullTest.php @@ -24,7 +24,7 @@ #[Group('unit')] final class IsNullTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassIdentifierToConstructor(): void { $isnull = new IsNotNull('foo.bar'); @@ -36,7 +36,7 @@ public function canPassIdentifierToConstructor(): void static::assertEquals(ArgumentType::Identifier, $identifier->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsNullIdentifier(): void { $isNotNull = new IsNotNull(); @@ -56,7 +56,7 @@ public function getExpressionDataPrefersACustomSpecification(): void static::assertSame('%1$s NOT NULL', $isNotNull->getExpressionData()['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $isNull = new IsNull(); @@ -66,7 +66,7 @@ public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $isNull->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function identifierIsMutable(): void { $isNotNull = new IsNotNull(); @@ -93,7 +93,7 @@ public function identifierIsMutable(): void static::assertEquals(ArgumentType::Identifier, $identifier2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndArrayOfTypes(): void { $isNotNull = new IsNotNull(); @@ -114,7 +114,7 @@ public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndArra static::assertEquals(ArgumentType::Identifier, $values[0]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setIdentifierWithArgumentInterfacePassesThrough(): void { $isNull = new IsNull(); @@ -125,7 +125,7 @@ public function setIdentifierWithArgumentInterfacePassesThrough(): void static::assertSame($identifier, $isNull->getIdentifier()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setIdentifierWithStringConvertsToIdentifier(): void { $isNull = new IsNull(); @@ -137,7 +137,7 @@ public function setIdentifierWithStringConvertsToIdentifier(): void static::assertSame('foo', $identifier->getValue()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationIsMutable(): void { $isNotNull = new IsNotNull(); @@ -145,7 +145,7 @@ public function specificationIsMutable(): void static::assertSame('%1$s NOT NULL', $isNotNull->getSpecification()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationIsNullByDefault(): void { $isNotNull = new IsNotNull(); diff --git a/test/unit/Sql/Predicate/LikeTest.php b/test/unit/Sql/Predicate/LikeTest.php index 24b1019d..99de09fd 100644 --- a/test/unit/Sql/Predicate/LikeTest.php +++ b/test/unit/Sql/Predicate/LikeTest.php @@ -23,7 +23,7 @@ #[CoversMethod(Like::class, 'getExpressionData')] final class LikeTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function accessorsMutators(): void { $like = new Like(); @@ -76,7 +76,7 @@ public function accessorsMutators(): void static::assertSame('custom spec', $like->getSpecification()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructEmptyArgs(): void { $like = new Like(); @@ -84,7 +84,7 @@ public function constructEmptyArgs(): void static::assertNull($like->getLike()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructWithArgs(): void { $like = new Like('bar', 'Foo%'); @@ -100,7 +100,7 @@ public function constructWithArgs(): void static::assertEquals(ArgumentType::Value, $likeValue->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $like = new Like('bar', 'Foo%'); @@ -159,7 +159,7 @@ public function getExpressionDataPrefersACustomSpecification(): void static::assertSame('%1$s SOUNDS LIKE %2$s', $like->getExpressionData()['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $like = new Like(); @@ -170,7 +170,7 @@ public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $like->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenLikeNotSet(): void { $like = new Like(); @@ -181,7 +181,7 @@ public function getExpressionDataThrowsExceptionWhenLikeNotSet(): void $like->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function instanceOfPerSetters(): void { $like = new Like(); diff --git a/test/unit/Sql/Predicate/LiteralTest.php b/test/unit/Sql/Predicate/LiteralTest.php index 53e1e295..ab68f0c6 100644 --- a/test/unit/Sql/Predicate/LiteralTest.php +++ b/test/unit/Sql/Predicate/LiteralTest.php @@ -5,11 +5,12 @@ namespace PhpDbTest\Sql\Predicate; use PhpDb\Sql\Predicate\Literal; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class LiteralTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $literal = new Literal('bar'); @@ -19,14 +20,14 @@ public function getExpressionData(): void static::assertSame('bar', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLiteral(): void { $literal = new Literal('bar'); static::assertSame('bar', $literal->getLiteral()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setLiteral(): void { $literal = new Literal('bar'); diff --git a/test/unit/Sql/Predicate/NotBetweenTest.php b/test/unit/Sql/Predicate/NotBetweenTest.php index b3081260..cb3e7a60 100644 --- a/test/unit/Sql/Predicate/NotBetweenTest.php +++ b/test/unit/Sql/Predicate/NotBetweenTest.php @@ -10,6 +10,7 @@ use PhpDb\Sql\ArgumentType; use PhpDb\Sql\Predicate\NotBetween; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[CoversMethod(NotBetween::class, 'getSpecification')] @@ -18,7 +19,7 @@ final class NotBetweenTest extends TestCase { protected NotBetween $notBetween; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $this->notBetween @@ -80,7 +81,7 @@ public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValu static::assertEquals(ArgumentType::Identifier, $values[2]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function specificationIsNullByDefault(): void { static::assertNull($this->notBetween->getSpecification()); diff --git a/test/unit/Sql/Predicate/NotInTest.php b/test/unit/Sql/Predicate/NotInTest.php index d5a6e643..645c0cc4 100644 --- a/test/unit/Sql/Predicate/NotInTest.php +++ b/test/unit/Sql/Predicate/NotInTest.php @@ -9,11 +9,12 @@ use PhpDb\Sql\ArgumentType; use PhpDb\Sql\Predicate\NotIn; use PhpDb\Sql\Select; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; final class NotInTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselect(): void { $select = new Select(); @@ -39,7 +40,7 @@ public function getExpressionDataWithSubselect(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); @@ -65,7 +66,7 @@ public function getExpressionDataWithSubselectAndArrayIdentifier(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); @@ -91,7 +92,7 @@ public function getExpressionDataWithSubselectAndIdentifier(): void static::assertEquals(ArgumentType::Select, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new NotIn(); diff --git a/test/unit/Sql/Predicate/NotLikeTest.php b/test/unit/Sql/Predicate/NotLikeTest.php index 0f95112d..65740143 100644 --- a/test/unit/Sql/Predicate/NotLikeTest.php +++ b/test/unit/Sql/Predicate/NotLikeTest.php @@ -8,11 +8,12 @@ use PhpDb\Sql\ArgumentType; use PhpDb\Sql\Predicate\Like; use PhpDb\Sql\Predicate\NotLike; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; final class NotLikeTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function accessorsMutators(): void { $notLike = new NotLike(); @@ -65,7 +66,7 @@ public function accessorsMutators(): void static::assertSame('custom spec', $notLike->getSpecification()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructEmptyArgs(): void { $notLike = new NotLike(); @@ -73,7 +74,7 @@ public function constructEmptyArgs(): void static::assertNull($notLike->getLike()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructWithArgs(): void { $notLike = new NotLike('bar', 'Foo%'); @@ -89,7 +90,7 @@ public function constructWithArgs(): void static::assertEquals(ArgumentType::Value, $likeValue->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionData(): void { $notLike = new NotLike('bar', 'Foo%'); @@ -114,7 +115,7 @@ public function getExpressionData(): void static::assertEquals(ArgumentType::Value, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function instanceOfPerSetters(): void { $notLike = new NotLike(); diff --git a/test/unit/Sql/Predicate/OperatorTest.php b/test/unit/Sql/Predicate/OperatorTest.php index b4dfd534..f6510c68 100644 --- a/test/unit/Sql/Predicate/OperatorTest.php +++ b/test/unit/Sql/Predicate/OperatorTest.php @@ -28,7 +28,7 @@ #[Group('unit')] final class OperatorTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassAllValuesToConstructor(): void { $operator = new Operator('bar', '>=', 'foo.bar'); @@ -65,14 +65,14 @@ public function canPassAllValuesToConstructor(): void static::assertEquals(ArgumentType::Value, $right->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsDefaultsForOperatorAndLeftAndRightTypes(): void { $operator = new Operator(); static::assertEquals(Operator::OP_EQ, $operator->getOperator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsNullLeftAndRightValues(): void { $operator = new Operator(); @@ -93,7 +93,7 @@ public function getExpressionDataPrefersACustomSpecification(): void static::assertSame('%1$s IS NOT DISTINCT FROM %2$s', $operator->getExpressionData()['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenLeftNotSet(): void { $operator = new Operator(); @@ -104,7 +104,7 @@ public function getExpressionDataThrowsExceptionWhenLeftNotSet(): void $operator->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataThrowsExceptionWhenRightNotSet(): void { $operator = new Operator(); @@ -115,7 +115,7 @@ public function getExpressionDataThrowsExceptionWhenRightNotSet(): void $operator->getExpressionData(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function leftIsMutable(): void { $operator = new Operator(); @@ -142,7 +142,7 @@ public function leftIsMutable(): void static::assertEquals(ArgumentType::Identifier, $left2->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function operatorIsMutable(): void { $operator = new Operator(); @@ -150,7 +150,7 @@ public function operatorIsMutable(): void static::assertEquals(Operator::OP_LTE, $operator->getOperator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function retrievingWherePartsReturnsSpecificationArrayOfLeftAndRightAndArrayOfTypes(): void { $operator = new Operator(); @@ -178,7 +178,7 @@ public function retrievingWherePartsReturnsSpecificationArrayOfLeftAndRightAndAr static::assertEquals(ArgumentType::Identifier, $values[1]->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rightIsMutable(): void { $operator = new Operator(); @@ -214,7 +214,7 @@ public function rightIsMutable(): void static::assertEquals(ArgumentType::Value, $right3->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setLeftWithExpressionInterfaceWrapsInSelect(): void { $operator = new Operator(); @@ -227,7 +227,7 @@ public function setLeftWithExpressionInterfaceWrapsInSelect(): void static::assertSame(ArgumentType::Select, $left->getType()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setRightWithExpressionInterfaceWrapsInSelect(): void { $operator = new Operator(); diff --git a/test/unit/Sql/Predicate/PredicateSetTest.php b/test/unit/Sql/Predicate/PredicateSetTest.php index be0501c7..27a4eeb6 100644 --- a/test/unit/Sql/Predicate/PredicateSetTest.php +++ b/test/unit/Sql/Predicate/PredicateSetTest.php @@ -19,6 +19,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use ReflectionException; use TypeError; @@ -40,7 +41,7 @@ final class PredicateSetTest extends TestCase /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addPredicates(): void { $predicateSet = new PredicateSet(); @@ -93,7 +94,7 @@ public function addPredicates(): void $predicateSet->addPredicates(null); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): void { $predicateSet = new PredicateSet(); @@ -109,7 +110,7 @@ public function addPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): vo * * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addPredicatesWithExpression(): void { $predicateSet = new PredicateSet(); @@ -137,7 +138,7 @@ public function addPredicatesWithExpression(): void * * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addPredicatesWithMultipleExpressions(): void { $predicateSet = new PredicateSet(); @@ -154,7 +155,7 @@ public function addPredicatesWithMultipleExpressions(): void static::assertInstanceOf(Expression::class, $predicates[1][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function addPredicateThrowsOnInvalidCombination(): void { $predicateSet = new PredicateSet(); @@ -164,7 +165,7 @@ public function addPredicateThrowsOnInvalidCombination(): void $predicateSet->addPredicate(new IsNull('foo'), 'XOR'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassBothPredicateAndCombinationToAddPredicate(): void { $predicateSet = new PredicateSet(); @@ -183,7 +184,7 @@ public function canPassBothPredicateAndCombinationToAddPredicate(): void static::assertSame('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canPassPredicatesAndDefaultCombinationViaConstructor(): void { new PredicateSet(); @@ -200,7 +201,7 @@ public function canPassPredicatesAndDefaultCombinationViaConstructor(): void static::assertStringNotContainsString('AND', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canUseOrPredicateAndAndPredicateMethods(): void { $predicateSet = new PredicateSet(); @@ -219,7 +220,7 @@ public function canUseOrPredicateAndAndPredicateMethods(): void static::assertSame('%s IS NULL AND %s IS NULL OR %s IS NULL AND %s IS NULL', $spec); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function combinationIsAndByDefault(): void { $predicateSet = new PredicateSet(); @@ -234,14 +235,14 @@ public function combinationIsAndByDefault(): void static::assertStringNotContainsString('OR', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function emptyConstructorYieldsCountOfZero(): void { $predicateSet = new PredicateSet(); static::assertCount(0, $predicateSet); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getExpressionDataReturnsEmptyWhenNoPredicates(): void { $predicateSet = new PredicateSet(); diff --git a/test/unit/Sql/Predicate/PredicateTest.php b/test/unit/Sql/Predicate/PredicateTest.php index b96f92d6..98c261fb 100644 --- a/test/unit/Sql/Predicate/PredicateTest.php +++ b/test/unit/Sql/Predicate/PredicateTest.php @@ -14,13 +14,14 @@ use PhpDb\Sql\Predicate\PredicateInterface; use PhpDb\Sql\Select; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; #[Group('unit')] final class PredicateTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function betweenCreatesBetweenPredicate(): void { $predicate = new Predicate(); @@ -39,7 +40,7 @@ public function betweenCreatesBetweenPredicate(): void static::assertEquals($maxValue, $expressionData['values'][2]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function betweenCreatesNotBetweenPredicate(): void { $predicate = new Predicate(); @@ -58,7 +59,7 @@ public function betweenCreatesNotBetweenPredicate(): void static::assertEquals($maxValue, $expressionData['values'][2]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canChainPredicateFactoriesBetweenOperators(): void { $predicate = new Predicate(); @@ -82,7 +83,7 @@ public function canChainPredicateFactoriesBetweenOperators(): void static::assertEquals($expression3, $expressionData['values'][3]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function canNestPredicates(): void { $predicate = new Predicate(); @@ -110,7 +111,7 @@ public function canNestPredicates(): void static::assertEquals($expression3, $expressionData['values'][3]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function equalToCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -127,7 +128,7 @@ public function equalToCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('Unit test: Test expression() is chainable and returns proper values')] public function expression(): void { @@ -142,7 +143,7 @@ public function expression(): void static::assertEquals([$value], $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('Unit test: Test expression() allows null $parameters')] public function expressionNullParameters(): void { @@ -161,7 +162,7 @@ public function expressionNullParameters(): void } } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function greaterThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -178,7 +179,7 @@ public function greaterThanCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function greaterThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -195,7 +196,7 @@ public function greaterThanOrEqualToCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function inCreatesInPredicate(): void { $predicate = new Predicate(); @@ -212,7 +213,7 @@ public function inCreatesInPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isNotNullCreatesIsNotNullPredicate(): void { $predicate = new Predicate(); @@ -227,7 +228,7 @@ public function isNotNullCreatesIsNotNullPredicate(): void static::assertEquals($identifier, $expressionData['values'][0]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isNullCreatesIsNullPredicate(): void { $predicate = new Predicate(); @@ -242,7 +243,7 @@ public function isNullCreatesIsNullPredicate(): void static::assertEquals($identifier, $expressionData['values'][0]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function lessThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -259,7 +260,7 @@ public function lessThanCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function lessThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -276,7 +277,7 @@ public function lessThanOrEqualToCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function likeCreatesLikePredicate(): void { $predicate = new Predicate(); @@ -293,7 +294,7 @@ public function likeCreatesLikePredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('Unit test: Test literal() is chainable, returns proper values, and is backwards compatible with 2.0.*')] public function literal(): void { @@ -331,7 +332,7 @@ public function literal(): void static::assertEquals([$expression], $expressionData['values']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function literalCreatesLiteralPredicate(): void { $predicate = new Predicate(); @@ -343,7 +344,7 @@ public function literalCreatesLiteralPredicate(): void static::assertSame('foo.bar = ?', $expressionData['spec']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetNestReturnsNestedPredicate(): void { $predicate = new Predicate(); @@ -354,7 +355,7 @@ public function magicGetNestReturnsNestedPredicate(): void static::assertNotSame($predicate, $nested); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetUnnestReturnsParentPredicate(): void { $predicate = new Predicate(); @@ -365,7 +366,7 @@ public function magicGetUnnestReturnsParentPredicate(): void static::assertSame($predicate, $parent); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function notEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); @@ -382,7 +383,7 @@ public function notEqualToCreatesOperatorPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function notInCreatesNotInPredicate(): void { $predicate = new Predicate(); @@ -399,7 +400,7 @@ public function notInCreatesNotInPredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function notLikeCreatesLikePredicate(): void { $predicate = new Predicate(); @@ -416,7 +417,7 @@ public function notLikeCreatesLikePredicate(): void static::assertEquals($expression, $expressionData['values'][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function predicateMethodAddsCustomPredicateInterface(): void { $predicate = new Predicate(); @@ -428,7 +429,7 @@ public function predicateMethodAddsCustomPredicateInterface(): void static::assertCount(1, $predicate); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function unnestThrowsWhenNotNested(): void { $predicate = new Predicate(); @@ -444,7 +445,7 @@ public function unnestThrowsWhenNotNested(): void /** * @throws ErrorException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function willBindSqlParametersToExpressionsWithGivenParameter(): void { $where = new Predicate(); @@ -462,7 +463,7 @@ public function willBindSqlParametersToExpressionsWithGivenParameter(): void /** * @throws ErrorException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function willBindSqlParametersToExpressionsWithGivenStringParameter(): void { $where = new Predicate(); diff --git a/test/unit/Sql/SelectTest.php b/test/unit/Sql/SelectTest.php index 3bdf6cf9..eeabdc93 100644 --- a/test/unit/Sql/SelectTest.php +++ b/test/unit/Sql/SelectTest.php @@ -32,6 +32,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; use ReflectionException; @@ -833,7 +834,7 @@ public static function providerData(): array // phpcs:enable Generic.Files.LineLength.TooLong } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test join() exception with bad join')] public function badJoin(): void { @@ -843,7 +844,7 @@ public function badJoin(): void $select->join(['foo'], 'x = y'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneDeepCopiesAllSubObjects(): void { $select = new Select(); @@ -865,7 +866,7 @@ public function cloneDeepCopiesAllSubObjects(): void static::assertCount(2, $clone->joins); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test __clone() will clone the where object so that this select can be used in multiple contexts')] public function cloning(): void @@ -882,7 +883,7 @@ public function cloning(): void static::assertSame(1, $select1->having->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test columns() returns Select object (is chainable)')] public function columns(): void { @@ -904,7 +905,7 @@ public function columns(): void static::assertEquals(['baz', 'qux'], $select->getRawState('columns')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function columnsWithPrefixDisabled(): void { $select = new Select(); @@ -916,7 +917,7 @@ public function columnsWithPrefixDisabled(): void static::assertStringContainsString('"col"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function columnsWithPrefixDisabledOmitsTablePrefix(): void { $select = new Select(); @@ -928,7 +929,7 @@ public function columnsWithPrefixDisabledOmitsTablePrefix(): void static::assertStringNotContainsString('"a"."id"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test combine() returns same Select object (is chainable)')] public function combine(): void { @@ -959,7 +960,7 @@ public function combine(): void static::assertSame('DISTINCT', $state2['modifier']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function combineThrowsWhenAlreadyCombined(): void { $select = new Select(); @@ -970,7 +971,7 @@ public function combineThrowsWhenAlreadyCombined(): void $select->combine(new Select('t3')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function combineWrapsStatementInParentheses(): void { $select1 = new Select(); @@ -988,14 +989,14 @@ public function combineWrapsStatementInParentheses(): void static::assertStringContainsString(') UNION (', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function construct(): void { $select = new Select('foo'); static::assertSame('foo', $select->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test from() returns Select object (is chainable)')] public function from(): void { @@ -1017,7 +1018,7 @@ public function from(): void static::assertSame('bar', $select->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fromThrowsExceptionForInvalidArrayFormat(): void { $select = new Select(); @@ -1027,7 +1028,7 @@ public function fromThrowsExceptionForInvalidArrayFormat(): void $select->from(['foo', 'bar']); // Numeric array instead of associative } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fromThrowsExceptionForInvalidTableType(): void { $select = new Select(); @@ -1037,7 +1038,7 @@ public function fromThrowsExceptionForInvalidTableType(): void $select->from(123); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fromThrowsExceptionWhenTableReadOnly(): void { $select = new Select('foo'); // Creating with table makes it read-only @@ -1049,7 +1050,7 @@ public function fromThrowsExceptionWhenTableReadOnly(): void $select->from('bar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function fromWithAliasArrayResolvesTableAndAlias(): void { $select = new Select(); @@ -1061,7 +1062,7 @@ public function fromWithAliasArrayResolvesTableAndAlias(): void static::assertStringContainsString('"a"."id"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateInitializesLazyProperties(): void { $select = new Select(); @@ -1073,7 +1074,7 @@ public function getRawStateInitializesLazyProperties(): void } /** @noinspection PhpUnusedParameterInspection */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('providerData')] #[TestDox('unit test: Test getSqlString() will produce expected sql and parameters based on a variety of provided arguments [uses data provider]')] @@ -1082,7 +1083,7 @@ public function getSqlString(Select $select, mixed $unused, mixed $unused2, stri static::assertEquals($expectedSqlString, $select->getSqlString(new TrustingSql92Platform())); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getThrowsExceptionForInvalidProperty(): void { $select = new Select(); @@ -1093,7 +1094,7 @@ public function getThrowsExceptionForInvalidProperty(): void $value = $select->invalidProperty; /** @phpstan-ignore-line */ } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test group() returns same Select object (is chainable)')] public function group(): void { @@ -1115,7 +1116,7 @@ public function group(): void static::assertEquals(['col1', 'col2', 'col3'], $select->getRawState('group')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test having() returns same Select object (is chainable)')] public function having(): void { @@ -1139,7 +1140,7 @@ public function having(): void static::assertSame(2, $select->getRawState('having')->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test having() accepts Expression (ExpressionInterface) in array')] public function havingAcceptsExpressionInterface(): void { @@ -1155,7 +1156,7 @@ public function havingAcceptsExpressionInterface(): void static::assertSame(1, $having->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test having() returns same Select object (is chainable)')] public function havingArgument1IsHavingObject(): void { @@ -1166,7 +1167,7 @@ public function havingArgument1IsHavingObject(): void static::assertSame($having, $select->getRawState('having')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test isTableReadOnly() returns correct state for read only')] public function isTableReadOnly(): void { @@ -1177,7 +1178,7 @@ public function isTableReadOnly(): void static::assertFalse($select->isTableReadOnly()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test join() returns same Select object (is chainable)')] public function join(): void { @@ -1213,7 +1214,7 @@ public function join(): void static::assertSame('bar', $joins2->getJoins()[1]['name']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(': unit test: test limit()')] public function limit(): void { @@ -1237,7 +1238,7 @@ public function limit(): void static::assertSame(10, $select->getRawState(Select::LIMIT)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(': unit test: test limit() throws exception when invalid parameter passed')] public function limitExceptionOnInvalidParameter(): void { @@ -1247,7 +1248,7 @@ public function limitExceptionOnInvalidParameter(): void $select->limit('foobar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test __get() returns expected objects magically')] public function magicAccessor(): void { @@ -1255,7 +1256,7 @@ public function magicAccessor(): void static::assertInstanceOf(Where::class, $select->where); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetJoinsReturnsJoinInstance(): void { $select = new Select(); @@ -1263,7 +1264,7 @@ public function magicGetJoinsReturnsJoinInstance(): void static::assertInstanceOf(Join::class, $select->joins); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(': unit test: test offset()')] public function offset(): void { @@ -1287,7 +1288,7 @@ public function offset(): void static::assertSame(20, $select->getRawState(Select::OFFSET)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(': unit test: test offset() throws exception when invalid parameter passed')] public function offsetExceptionOnInvalidParameter(): void { @@ -1300,7 +1301,7 @@ public function offsetExceptionOnInvalidParameter(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test order()')] public function order(): void { @@ -1344,7 +1345,7 @@ public function order(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test order() correctly splits parameters.')] public function orderCorrectlySplitsParameter(): void { @@ -1356,7 +1357,7 @@ public function orderCorrectlySplitsParameter(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function orderWithAssociativeArray(): void { $select = new Select(); @@ -1367,7 +1368,7 @@ public function orderWithAssociativeArray(): void static::assertStringContainsString('ORDER BY "name" DESC', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function orderWithExpressionObject(): void { $select = new Select(); @@ -1378,7 +1379,7 @@ public function orderWithExpressionObject(): void static::assertStringContainsString('ORDER BY RAND()', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function orderWithStringContainingDirection(): void { $select = new Select(); @@ -1390,7 +1391,7 @@ public function orderWithStringContainingDirection(): void } /** @noinspection PhpUnusedParameterInspection */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('providerData')] #[TestDox('unit test: Test prepareStatement() will produce expected sql and parameters based on a variety of provided arguments [uses data provider]')] @@ -1426,7 +1427,7 @@ public function prepareStatement( * @throws ReflectionException * @noinspection PhpUnusedParameterInspection */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('providerData')] #[TestDox('unit test: Text process*() methods will return proper array when internally called, part of extension API')] @@ -1460,7 +1461,7 @@ public function processMethods( } } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test quantifier() returns Select object (is chainable)')] public function quantifier(): void { @@ -1482,7 +1483,7 @@ public function quantifier(): void static::assertEquals(Select::QUANTIFIER_ALL, $select->getRawState('quantifier')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test quantifier() accepts expression')] public function quantifierParameterExpressionInterface(): void { @@ -1496,7 +1497,7 @@ public function quantifierParameterExpressionInterface(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test reset() resets internal stat of Select object, based on input')] public function reset(): void { @@ -1574,7 +1575,7 @@ public function reset(): void static::assertEmpty($select->getRawState(Select::ORDER)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resetCombine(): void { $select = new Select(); @@ -1585,7 +1586,7 @@ public function resetCombine(): void static::assertEmpty($select->getRawState(Select::COMBINE)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resetQuantifier(): void { $select = new Select(); @@ -1595,7 +1596,7 @@ public function resetQuantifier(): void static::assertNull($select->getRawState(Select::QUANTIFIER)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resetTableThrowsWhenTableReadOnly(): void { $select = new Select('foo'); @@ -1605,7 +1606,7 @@ public function resetTableThrowsWhenTableReadOnly(): void $select->reset(Select::TABLE); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function resetThrowsOnInvalidPart(): void { $select = new Select(); @@ -1614,7 +1615,7 @@ public function resetThrowsOnInvalidPart(): void static::assertSame($select, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-5192')] public function selectUsingTableIdentifierWithEmptyScheme(): void { @@ -1628,7 +1629,7 @@ public function selectUsingTableIdentifierWithEmptyScheme(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setSpecificationStoresValidSpecification(): void { $select = new Select(); @@ -1638,7 +1639,7 @@ public function setSpecificationStoresValidSpecification(): void static::assertSame('CUSTOM %1$s FROM %2$s', $rawState->getValue($select)['Select']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setSpecificationThrowsExceptionForInvalidName(): void { $select = new Select(); @@ -1648,7 +1649,7 @@ public function setSpecificationThrowsExceptionForInvalidName(): void $select->setSpecification('invalid_spec', 'some spec'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] public function whereAcceptsExpressionInterface(): void { @@ -1663,7 +1664,7 @@ public function whereAcceptsExpressionInterface(): void static::assertSame(1, $where->count()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept an array with a string key (containing ?) used as an expression with placeholder')] public function whereArgument1IsAssociativeArrayContainingReplacementCharacter(): void @@ -1684,7 +1685,7 @@ public function whereArgument1IsAssociativeArrayContainingReplacementCharacter() static::assertEquals([$expression], $predicates[0][1]->getParameters()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox(' unit test: Test where() will accept any array with string key (without ?) with Predicate throw Exception ')] @@ -1700,7 +1701,7 @@ public function whereArgument1IsAssociativeArrayIsPredicate(): void $select->where($where); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept any array with string key (without ?) to be used as Operator predicate')] public function whereArgument1IsAssociativeArrayNotContainingReplacementCharacter(): void @@ -1740,7 +1741,7 @@ public function whereArgument1IsAssociativeArrayNotContainingReplacementCharacte static::assertInstanceOf(Literal::class, $predicates[0][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept a closure to be executed with Where object as argument')] public function whereArgument1IsClosure(): void { @@ -1753,7 +1754,7 @@ public function whereArgument1IsClosure(): void }); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept an indexed array to be used by joining string expressions')] public function whereArgument1IsIndexedArray(): void { @@ -1770,7 +1771,7 @@ public function whereArgument1IsIndexedArray(): void static::assertSame('name = "Ralph"', $predicates[0][1]->getLiteral()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept an indexed array to be used by joining string expressions, combined by OR')] public function whereArgument1IsIndexedArrayArgument2IsOr(): void @@ -1788,7 +1789,7 @@ public function whereArgument1IsIndexedArrayArgument2IsOr(): void static::assertSame('name = "Ralph"', $predicates[0][1]->getLiteral()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept any Predicate object as-is')] public function whereArgument1IsPredicate(): void { @@ -1806,7 +1807,7 @@ public function whereArgument1IsPredicate(): void static::assertSame($predicate, $predicates[0][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept a string for the predicate to create an expression predicate')] public function whereArgument1IsString(): void { @@ -1832,7 +1833,7 @@ public function whereArgument1IsString(): void static::assertInstanceOf(Literal::class, $predicates[0][1]); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() will accept a Where object')] public function whereArgument1IsWhereObject(): void { @@ -1841,7 +1842,7 @@ public function whereArgument1IsWhereObject(): void static::assertSame($newWhere, $select->getRawState('where')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() returns Select object (is chainable)')] public function whereReturnsSameSelectObject(): void { diff --git a/test/unit/Sql/SqlTest.php b/test/unit/Sql/SqlTest.php index 7f462ed6..42907641 100644 --- a/test/unit/Sql/SqlTest.php +++ b/test/unit/Sql/SqlTest.php @@ -22,6 +22,7 @@ use PhpDb\Sql\Update; use PhpDbTest\TestAsset; use PHPUnit\Framework\Attributes\CoversMethod; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; @@ -49,7 +50,7 @@ final class SqlTest extends TestCase protected Sql $sql; // @codingStandardsIgnoreStart - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function _construct(): void { // @codingStandardsIgnoreEnd @@ -65,7 +66,7 @@ public function _construct(): void $sql->setTable(null); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function buildSqlString(): void { $select = $this->sql->select()->where(['bar' => 'baz']); @@ -73,7 +74,7 @@ public function buildSqlString(): void static::assertSame('SELECT "foo".* FROM "foo" WHERE "bar" = \'baz\'', $sqlString); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function buildSqlStringThrowsWhenPlatformNotSqlInterface(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); @@ -95,7 +96,7 @@ public function buildSqlStringThrowsWhenPlatformNotSqlInterface(): void $sql->buildSqlString($this->sql->select()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delete(): void { $delete = $this->sql->delete(); @@ -110,7 +111,7 @@ public function delete(): void $this->sql->delete('bar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function deleteThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); @@ -120,13 +121,13 @@ public function deleteThrowsWhenTableConflicts(): void $this->sql->delete(new TableIdentifier('bar')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlPlatformReturnsPlatformDecorator(): void { static::assertInstanceOf(PlatformDecoratorInterface::class, $this->sql->getSqlPlatform()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function insert(): void { $insert = $this->sql->insert(); @@ -140,7 +141,7 @@ public function insert(): void $this->sql->insert('bar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function insertThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); @@ -150,7 +151,7 @@ public function insertThrowsWhenTableConflicts(): void $this->sql->insert(new TableIdentifier('bar')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementForSqlObject(): void { $insert = $this->sql->insert()->columns(['foo'])->values(['foo' => 'bar']); @@ -158,7 +159,7 @@ public function prepareStatementForSqlObject(): void static::assertInstanceOf(StatementInterface::class, $stmt); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatementThrowsWhenPlatformNotPreparable(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); @@ -180,7 +181,7 @@ public function prepareStatementThrowsWhenPlatformNotPreparable(): void $sql->prepareStatementForSqlObject($this->sql->select()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function select(): void { $select = $this->sql->select(); @@ -194,7 +195,7 @@ public function select(): void $this->sql->select('bar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); @@ -204,7 +205,7 @@ public function selectThrowsWhenTableConflicts(): void $this->sql->select(new TableIdentifier('bar')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function update(): void { $update = $this->sql->update(); @@ -218,7 +219,7 @@ public function update(): void $this->sql->update('bar'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function updateThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); diff --git a/test/unit/Sql/TableIdentifierFactoryTest.php b/test/unit/Sql/TableIdentifierFactoryTest.php index 08c80875..0fcf8a10 100644 --- a/test/unit/Sql/TableIdentifierFactoryTest.php +++ b/test/unit/Sql/TableIdentifierFactoryTest.php @@ -8,13 +8,14 @@ use PhpDb\Sql\TableIdentifierFactory; use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; #[Group('unit')] #[CoversClass(TableIdentifierFactory::class)] final class TableIdentifierFactoryTest extends TestCase { - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function callTimePrefixIsAppliedWhenNonePreconfigured(): void { $factory = new TableIdentifierFactory(); @@ -24,7 +25,7 @@ public function callTimePrefixIsAppliedWhenNonePreconfigured(): void static::assertSame('archive_users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function callTimePrefixOverridesConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -34,7 +35,7 @@ public function callTimePrefixOverridesConfiguredPrefix(): void static::assertSame('archive_users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function callTimeSeparatorIsAppliedWhenNonePreconfigured(): void { $factory = new TableIdentifierFactory(); @@ -44,7 +45,7 @@ public function callTimeSeparatorIsAppliedWhenNonePreconfigured(): void static::assertSame('archive__users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function callTimeSeparatorOverridesConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); @@ -54,7 +55,7 @@ public function callTimeSeparatorOverridesConfiguredSeparator(): void static::assertSame('backup_users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function configuredSeparatorIsCarriedButUnusedWhenNoPrefixApplies(): void { $factory = new TableIdentifierFactory(null, '__'); @@ -65,7 +66,7 @@ public function configuredSeparatorIsCarriedButUnusedWhenNoPrefixApplies(): void static::assertSame('users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createsIdentifierWithConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -76,7 +77,7 @@ public function createsIdentifierWithConfiguredPrefix(): void static::assertNull($tableIdentifier->getSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createsIdentifierWithConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); @@ -86,7 +87,7 @@ public function createsIdentifierWithConfiguredSeparator(): void static::assertSame('backup__users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createsIdentifierWithoutPrefixWhenNoneConfigured(): void { $factory = new TableIdentifierFactory(); @@ -96,7 +97,7 @@ public function createsIdentifierWithoutPrefixWhenNoneConfigured(): void static::assertSame('users', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function createsIdentifierWithSchema(): void { $factory = new TableIdentifierFactory('backup'); @@ -105,7 +106,7 @@ public function createsIdentifierWithSchema(): void static::assertSame(['backup_users', 'public'], $tableIdentifier->getTableAndSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prefixIsNullByDefault(): void { $factory = new TableIdentifierFactory(); @@ -113,7 +114,7 @@ public function prefixIsNullByDefault(): void static::assertNull($factory->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringCallTimePrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -123,7 +124,7 @@ public function rejectsEmptyStringCallTimePrefix(): void $factory('users', null, ''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringCallTimeSeparator(): void { $factory = new TableIdentifierFactory('backup'); @@ -133,7 +134,7 @@ public function rejectsEmptyStringCallTimeSeparator(): void $factory('users', null, null, ''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringPrefix(): void { self::expectException(InvalidArgumentException::class); @@ -141,7 +142,7 @@ public function rejectsEmptyStringPrefix(): void new TableIdentifierFactory(''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringSeparator(): void { self::expectException(InvalidArgumentException::class); @@ -149,7 +150,7 @@ public function rejectsEmptyStringSeparator(): void new TableIdentifierFactory('backup', ''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); @@ -157,7 +158,7 @@ public function rejectsEmptyStringSeparatorWithoutPrefix(): void new TableIdentifierFactory(null, ''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function returnsConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -165,7 +166,7 @@ public function returnsConfiguredPrefix(): void static::assertSame('backup', $factory->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function returnsConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); @@ -173,7 +174,7 @@ public function returnsConfiguredSeparator(): void static::assertSame('__', $factory->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function separatorDefaultsToUnderscore(): void { $factory = new TableIdentifierFactory('backup'); @@ -181,7 +182,7 @@ public function separatorDefaultsToUnderscore(): void static::assertSame('_', $factory->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function separatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void { $factory = new TableIdentifierFactory(); @@ -189,7 +190,7 @@ public function separatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void static::assertSame('_', $factory->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function separatorFallsBackToDefaultWhenPassedAsNull(): void { $factory = new TableIdentifierFactory('backup', null); diff --git a/test/unit/Sql/TableIdentifierTest.php b/test/unit/Sql/TableIdentifierTest.php index 0f33fcee..51db36a7 100644 --- a/test/unit/Sql/TableIdentifierTest.php +++ b/test/unit/Sql/TableIdentifierTest.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\Attributes\CoversClass; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use stdClass; use TypeError; @@ -48,7 +49,7 @@ public static function invalidTableProvider(): array ]; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDefaultPrefix(): void { $tableIdentifier = new TableIdentifier('foo'); @@ -56,7 +57,7 @@ public function getDefaultPrefix(): void static::assertNull($tableIdentifier->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDefaultSchema(): void { $tableIdentifier = new TableIdentifier('foo'); @@ -64,7 +65,7 @@ public function getDefaultSchema(): void static::assertNull($tableIdentifier->getSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getDefaultSeparator(): void { $tableIdentifier = new TableIdentifier('foo'); @@ -72,7 +73,7 @@ public function getDefaultSeparator(): void static::assertSame('_', $tableIdentifier->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getPrefix(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); @@ -80,7 +81,7 @@ public function getPrefix(): void static::assertSame('backup', $tableIdentifier->getPrefix()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSchema(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); @@ -91,7 +92,7 @@ public function getSchema(): void /** * @todo Review test to see if relevant? */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSchemaFromObjectStringCast(): void { $schema = new ObjectToString('castResult'); @@ -101,7 +102,7 @@ public function getSchemaFromObjectStringCast(): void static::assertSame('castResult', $tableIdentifier->getSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup', '__'); @@ -109,7 +110,7 @@ public function getSeparator(): void static::assertSame('__', $tableIdentifier->getSeparator()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTable(): void { $tableIdentifier = new TableIdentifier('foo'); @@ -117,7 +118,7 @@ public function getTable(): void static::assertSame('foo', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableAndSchemaAppliesPrefix(): void { $tableIdentifier = new TableIdentifier('foo', 'bar', 'backup'); @@ -125,7 +126,7 @@ public function getTableAndSchemaAppliesPrefix(): void static::assertSame(['backup_foo', 'bar'], $tableIdentifier->getTableAndSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableAndSchemaWithoutPrefix(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); @@ -133,7 +134,7 @@ public function getTableAndSchemaWithoutPrefix(): void static::assertSame(['foo', 'bar'], $tableIdentifier->getTableAndSchema()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableAppliesPrefixWithCustomSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup', '__'); @@ -141,7 +142,7 @@ public function getTableAppliesPrefixWithCustomSeparator(): void static::assertSame('backup__foo', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableAppliesPrefixWithDefaultSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); @@ -149,7 +150,7 @@ public function getTableAppliesPrefixWithDefaultSeparator(): void static::assertSame('backup_foo', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableFromObjectStringCast(): void { $table = new ObjectToString('castResult'); @@ -159,7 +160,7 @@ public function getTableFromObjectStringCast(): void static::assertSame('castResult', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTableIgnoresSeparatorWithoutPrefix(): void { $tableIdentifier = new TableIdentifier('foo', null, null, '__'); @@ -167,7 +168,7 @@ public function getTableIgnoresSeparatorWithoutPrefix(): void static::assertSame('foo', $tableIdentifier->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getUnprefixedTableReturnsTableAsGiven(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup'); @@ -175,7 +176,7 @@ public function getUnprefixedTableReturnsTableAsGiven(): void static::assertSame('foo', $tableIdentifier->getUnprefixedTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); @@ -183,7 +184,7 @@ public function rejectsEmptyStringSeparatorWithoutPrefix(): void new TableIdentifier('foo', null, null, ''); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidNameArgumentProvider')] public function rejectsInvalidPrefix(mixed $invalidPrefix): void { @@ -192,7 +193,7 @@ public function rejectsInvalidPrefix(mixed $invalidPrefix): void new TableIdentifier('foo', 'bar', $invalidPrefix); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidNameArgumentProvider')] public function rejectsInvalidSchema(mixed $invalidSchema): void { @@ -201,7 +202,7 @@ public function rejectsInvalidSchema(mixed $invalidSchema): void new TableIdentifier('foo', $invalidSchema); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidNameArgumentProvider')] public function rejectsInvalidSeparator(mixed $invalidSeparator): void { @@ -210,7 +211,7 @@ public function rejectsInvalidSeparator(mixed $invalidSeparator): void new TableIdentifier('foo', 'bar', 'backup', $invalidSeparator); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('invalidTableProvider')] public function rejectsInvalidTable(mixed $invalidTable): void { diff --git a/test/unit/Sql/UpdateTest.php b/test/unit/Sql/UpdateTest.php index 7df8d8ee..316c26d6 100644 --- a/test/unit/Sql/UpdateTest.php +++ b/test/unit/Sql/UpdateTest.php @@ -34,6 +34,7 @@ use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\Attributes\TestDox; use PHPUnit\Framework\TestCase; use ReflectionException; @@ -63,7 +64,7 @@ final class UpdateTest extends TestCase protected Update $update; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneDeepCopiesSetWhereAndJoins(): void { $this->update @@ -92,7 +93,7 @@ public function cloneDeepCopiesSetWhereAndJoins(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneUpdate(): void { $update1 = clone $this->update; @@ -115,14 +116,14 @@ public function cloneUpdate(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function construct(): void { $update = new Update('foo'); static::assertSame('foo', static::readAttribute($update, 'table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructWithTableIdentifier(): void { $tableIdentifier = new TableIdentifier('foo', 'bar'); @@ -131,7 +132,7 @@ public function constructWithTableIdentifier(): void static::assertEquals($tableIdentifier, $update->getRawState('table')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawState(): void { $this->update @@ -145,7 +146,7 @@ public function getRawState(): void static::assertInstanceOf(Where::class, $this->update->getRawState('where')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getRawStateReturnsAllState(): void { $this->update @@ -169,7 +170,7 @@ public function getRawStateReturnsAllState(): void static::assertTrue($rawState['emptyWhereProtection']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlString(): void { $this->update @@ -195,7 +196,7 @@ public function getSqlString(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6768')] #[Group('6773')] public function getSqlStringForFalseUpdateValueParameter(): void @@ -211,7 +212,7 @@ public function getSqlStringForFalseUpdateValueParameter(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSqlStringWithEmptyWhere(): void { $this->update->table('foo') @@ -223,14 +224,14 @@ public function getSqlStringWithEmptyWhere(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getUpdate(): void { $getWhere = $this->update->__get('where'); static::assertInstanceOf(Where::class, $getWhere); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getUpdateFails(): void { /** @psalm-suppress UndefinedThisPropertyFetch - Ensure non-existent property returns null */ @@ -238,7 +239,7 @@ public function getUpdateFails(): void static::assertNull($getWhat); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function join(): void { $this->update->table('Document'); @@ -262,7 +263,7 @@ public function join(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test join() returns Update object (is chainable)')] public function joinChainable(): void { @@ -275,7 +276,7 @@ public function joinChainable(): void * Important when we're updating fields that are existing in several tables in one query. * The same test as above but here we will specify table in update params */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function joinMultiUpdate(): void { $this->update->table('Document'); @@ -298,7 +299,7 @@ public function joinMultiUpdate(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function joinWithTableIdentifier(): void { $this->update @@ -310,7 +311,7 @@ public function joinWithTableIdentifier(): void static::assertStringContainsString('JOIN "schema"."bar"', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('Laminas-240')] public function passingMultipleKeyValueInWhereClause(): void { @@ -324,7 +325,7 @@ public function passingMultipleKeyValueInWhereClause(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); @@ -371,7 +372,7 @@ public function prepareStatement(): void $this->update->prepareStatement($mockAdapter, $mockStatement); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function processSetWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); @@ -393,14 +394,14 @@ public function processSetWithPdoDriverUsesDriverColumnQuoting(): void static::assertStringContainsString(':c_1', $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function set(): void { $this->update->set(['foo' => 'bar']); static::assertEquals(['foo' => 'bar'], $this->update->getRawState('set')); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setWithMergeFlag(): void { $this->update->set(['foo' => 'bar']); @@ -410,7 +411,7 @@ public function setWithMergeFlag(): void static::assertEquals(['foo' => 'bar', 'baz' => 'qux'], $set); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setWithNonStringKeyThrowsException(): void { self::expectException(InvalidArgumentException::class); @@ -420,7 +421,7 @@ public function setWithNonStringKeyThrowsException(): void $this->update->set([0 => 'value']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function setWithNumericPriority(): void { $this->update->set(['three' => 'c'], 30); @@ -431,7 +432,7 @@ public function setWithNumericPriority(): void static::assertEquals(['one' => 'a', 'two' => 'b', 'three' => 'c'], $set); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function sortableSet(): void { $this->update->set([ @@ -450,7 +451,7 @@ public function sortableSet(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { @@ -479,7 +480,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString( ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[CoversNothing] public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { @@ -508,7 +509,7 @@ public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatem /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function table(): void { $this->update->table('foo'); @@ -522,7 +523,7 @@ public function table(): void /** * @throws ReflectionException */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function where(): void { $this->update->where('x = y'); @@ -573,7 +574,7 @@ public function where(): void $this->update->where(null); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[TestDox('unit test: Test where() accepts Expression (ExpressionInterface) in array')] public function whereAcceptsExpressionInterface(): void { diff --git a/test/unit/TableGateway/AbstractTableGatewayTest.php b/test/unit/TableGateway/AbstractTableGatewayTest.php index 550fb6cf..568e31ba 100644 --- a/test/unit/TableGateway/AbstractTableGatewayTest.php +++ b/test/unit/TableGateway/AbstractTableGatewayTest.php @@ -26,6 +26,7 @@ use PHPUnit\Framework\Attributes\CoversMethod; use PHPUnit\Framework\Attributes\IgnoreDeprecations; use PHPUnit\Framework\Attributes\RequiresPhp; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionClass; @@ -74,14 +75,14 @@ final class AbstractTableGatewayTest extends TestCase protected MockObject&Update $mockUpdate; protected MockObject&Delete $mockDelete; - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneKeepsTheAdapter(): void { $cTable = clone $this->table; static::assertSame($this->mockAdapter, $cTable->getAdapter()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneWithAnAliasedTableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); @@ -99,7 +100,7 @@ public function cloneWithAnAliasedTableIdentifier(): void static::assertNotSame($tableIdentifier, $clonedTable['alias']); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function cloneWithATableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); @@ -115,7 +116,7 @@ public function cloneWithATableIdentifier(): void static::assertEquals($tableIdentifier->getTable(), $cloned->getTable()->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function delete(): void { $mockDelete = $this->mockDelete; @@ -129,7 +130,7 @@ public function delete(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function deleteWith(): void { $delete = $this->getMockBuilder(Delete::class) @@ -145,7 +146,7 @@ public function deleteWith(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function deleteWithClosure(): void { // The closure receives the Delete object created by $this->sql->delete() @@ -160,7 +161,7 @@ public function deleteWithClosure(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeDeleteThrowsExceptionWhenTableDoesNotMatch(): void { $delete = new Delete('bar'); @@ -172,7 +173,7 @@ public function executeDeleteThrowsExceptionWhenTableDoesNotMatch(): void $this->table->deleteWith($delete); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeInsertThrowsExceptionWhenTableDoesNotMatch(): void { $insert = new Insert('bar'); @@ -184,7 +185,7 @@ public function executeInsertThrowsExceptionWhenTableDoesNotMatch(): void $this->table->insertWith($insert); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void { $select = $this->getMockBuilder(Select::class) @@ -206,7 +207,7 @@ public function executeSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void $this->table->selectWith($select); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function executeUpdateThrowsExceptionWhenTableDoesNotMatch(): void { $update = new Update('bar'); @@ -218,13 +219,13 @@ public function executeUpdateThrowsExceptionWhenTableDoesNotMatch(): void $this->table->updateWith($update); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getAdapter(): void { static::assertSame($this->mockAdapter, $this->table->getAdapter()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getColumns(): void { $tgReflection = new ReflectionClass(AbstractTableGateway::class); @@ -234,38 +235,38 @@ public function getColumns(): void static::assertEquals(['id', 'name', 'email'], $this->table->getColumns()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getFeatureSet(): void { static::assertSame($this->mockFeatureSet, $this->table->getFeatureSet()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getLastInsertValue(): void { $this->table->insert(['foo' => 'bar']); static::assertSame(10, $this->table->getLastInsertValue()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSelectResultPrototype(): void { static::assertInstanceOf(ResultSet::class, $this->table->getResultSetPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getSql(): void { static::assertInstanceOf(Sql\Sql::class, $this->table->getSql()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function getTable(): void { static::assertSame('foo', $this->table->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeBuildsAResultSet(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) @@ -291,7 +292,7 @@ public function initializeBuildsAResultSet(): void static::assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeEarlyReturnWhenAlreadyInitialized(): void { // Create a fresh mock without initialization @@ -323,7 +324,7 @@ public function initializeEarlyReturnWhenAlreadyInitialized(): void static::assertSame($originalFeatureSet, $featureSetProp->getValue($stub)); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsExceptionWithoutAdapter(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) @@ -340,7 +341,7 @@ public function initializeThrowsExceptionWithoutAdapter(): void $stub->initialize(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function initializeThrowsExceptionWithoutTable(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) @@ -357,7 +358,7 @@ public function initializeThrowsExceptionWithoutTable(): void $stub->initialize(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function insert(): void { $mockInsert = $this->mockInsert; @@ -374,7 +375,7 @@ public function insert(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function insertWith(): void { $insert = new Insert('foo'); @@ -384,7 +385,7 @@ public function insertWith(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function isInitialized(): void { // Create a fresh mock without initialization @@ -408,7 +409,7 @@ public function isInitialized(): void static::assertTrue($stub->isInitialized()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicCallDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicCall @@ -434,7 +435,7 @@ public function magicCallDelegatesToTheFeatureSet(): void static::assertSame('customResult', $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicCallThrowsForUnknownMethod(): void { self::expectException(InvalidArgumentException::class); @@ -446,7 +447,7 @@ public function magicCallThrowsForUnknownMethod(): void $this->table->invalidMethod(); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetDelegatesToTheFeatureSet(): void { // Create a custom feature that can handle magic get @@ -476,19 +477,19 @@ public function magicGetDelegatesToTheFeatureSet(): void static::assertSame('customValue', $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsTheAdapter(): void { static::assertSame($this->mockAdapter, $this->table->adapter); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsTheLastInsertValue(): void { static::assertNull($this->table->lastInsertValue); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsTheLastInsertValueAndAdapter(): void { $this->table->insert(['foo']); // trigger last insert id update @@ -499,13 +500,13 @@ public function magicGetReturnsTheLastInsertValueAndAdapter(): void //self::assertEquals('foo', $this->table->table); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetReturnsTheTable(): void { static::assertSame('foo', $this->table->table); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicGetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); @@ -517,7 +518,7 @@ public function magicGetThrowsForUnknownProperty(): void $this->table->invalidProperty; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicSetDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicSet @@ -540,7 +541,7 @@ public function magicSetDelegatesToTheFeatureSet(): void $this->table->customProperty = 'customValue'; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function magicSetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); @@ -552,7 +553,7 @@ public function magicSetThrowsForUnknownProperty(): void $this->table->invalidProperty = 'value'; } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectAppliesColumnsWhenStarSelected(): void { // Set up columns on the table @@ -579,7 +580,7 @@ public function selectAppliesColumnsWhenStarSelected(): void $this->table->selectWith($select); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectWithArrayTable(): void { // Case 1 @@ -605,7 +606,7 @@ public function selectWithArrayTable(): void static::assertInstanceOf(ResultSet::class, $return); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectWithClosure(): void { $mockSelect = $this->mockSelect; @@ -626,7 +627,7 @@ public function selectWithClosure(): void static::assertInstanceOf(ResultSet::class, $result); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectWithNoWhere(): void { $resultSet = $this->table->select(); @@ -636,7 +637,7 @@ public function selectWithNoWhere(): void static::assertNotSame($this->table->getResultSetPrototype(), $resultSet); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function selectWithWhereString(): void { $mockSelect = $this->mockSelect; @@ -655,7 +656,7 @@ public function selectWithWhereString(): void $this->table->select('foo'); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function update(): void { $mockUpdate = $this->mockUpdate; @@ -669,7 +670,7 @@ public function update(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function updateWith(): void { $update = $this->getMockBuilder(Update::class) @@ -685,7 +686,7 @@ public function updateWith(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function updateWithJoin(): void { $mockUpdate = $this->mockUpdate; @@ -711,7 +712,7 @@ public function updateWithJoin(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function updateWithJoinDefaultType(): void { $mockUpdate = $this->mockUpdate; @@ -736,7 +737,7 @@ public function updateWithJoinDefaultType(): void static::assertSame(5, $affectedRows); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function updateWithNoCriteria(): void { /** @phpstan-ignore expr.resultUnused */ diff --git a/test/unit/TableGateway/TableGatewayTest.php b/test/unit/TableGateway/TableGatewayTest.php index 9a6ec199..961ea07a 100644 --- a/test/unit/TableGateway/TableGatewayTest.php +++ b/test/unit/TableGateway/TableGatewayTest.php @@ -23,6 +23,7 @@ use PhpDb\TableGateway\TableGateway; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Group; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use ReflectionProperty; @@ -53,7 +54,7 @@ public static function aliasedTables(): array /** * Beside other tests checks for plain string table identifier */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructor(): void { // constructor with only required args @@ -92,7 +93,7 @@ public function constructor(): void ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -105,7 +106,7 @@ public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new TableGateway('foo', $this->mockAdapter, null, null, $sql); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithArrayOfFeatures(): void { $feature1 = new Feature\SequenceFeature('id', 'foo_seq'); @@ -126,7 +127,7 @@ public function constructorWithArrayOfFeatures(): void $reflection->setValue(null, []); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithCustomResultSetPrototype(): void { $resultSet = new ResultSet(); @@ -136,7 +137,7 @@ public function constructorWithCustomResultSetPrototype(): void static::assertSame($resultSet, $table->getResultSetPrototype()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithFeatureSet(): void { $feature = new Feature\SequenceFeature('id', 'foo_seq'); @@ -147,7 +148,7 @@ public function constructorWithFeatureSet(): void static::assertSame($featureSet, $table->getFeatureSet()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] public function constructorWithSingleFeature(): void { $feature = new Feature\SequenceFeature('id', 'foo_seq'); @@ -162,7 +163,7 @@ public function constructorWithSingleFeature(): void /** * @param AliasedTable $tableValue */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('aliasedTables')] public function deleteShouldResetTableToUnaliasedTable( array $tableValue, @@ -229,7 +230,7 @@ public function deleteShouldResetTableToUnaliasedTable( /** * @param AliasedTable $tableValue */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('aliasedTables')] #[Group('7311')] public function insertShouldResetTableToUnaliasedTable( @@ -293,7 +294,7 @@ public function insertShouldResetTableToUnaliasedTable( ); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6726')] #[Group('6740')] public function tableAsAliasedTableIdentifierObject(): void @@ -311,7 +312,7 @@ public function tableAsAliasedTableIdentifierObject(): void // phpcs:enable WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6726')] #[Group('6740')] public function tableAsString(): void @@ -326,7 +327,7 @@ public function tableAsString(): void static::assertEquals($ti, $table->getTable()); } - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[Group('6726')] #[Group('6740')] public function tableAsTableIdentifierObject(): void @@ -344,7 +345,7 @@ public function tableAsTableIdentifierObject(): void /** * @param AliasedTable $tableValue */ - #[\PHPUnit\Framework\Attributes\Test] + #[Test] #[DataProvider('aliasedTables')] public function updateShouldResetTableToUnaliasedTable( array $tableValue,