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..a167d2d1 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" @@ -997,7393 +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 +file = "test/unit/Adapter/AdapterTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." +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 `testConnection`." +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/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDriverDisconnectAfterQuoteWithPlatform`." +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/Driver/Pdo/ConnectionTest.php" +code = "no-empty-catch-clause" +message = "Do not use empty `catch` blocks." 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." +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/integration/Adapter/Driver/Pdo/AdapterTrait.php" -code = "strict-types" -message = "Missing `declare(strict_types=1);` statement at the beginning of the file." +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/AdapterAwareTraitTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 3 +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/ConnectionTransactionsTest.php" +code = "no-redundant-variable" +message = "Variable `$nested` is assigned but never used." +count = 2 [[issues]] -file = "test/unit/Adapter/AdapterAwareTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDbAdapterSetsProperty`." +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/AdapterAwareTraitTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetDbAdapter`." +file = "test/unit/Adapter/Driver/Pdo/ResultTest.php" +code = "assert-description" +message = "Missing description in assert function." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 33 +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/AdapterTest.php" +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/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithProfilerDelegatesToSetProfiler`." -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/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCreateStatementDelegatesToDriver`." +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/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryReturnsRawResultWithoutWrappingQueryResults`." +file = "test/unit/Adapter/Driver/Pdo/TestAsset/TestConnection.php" +code = "no-else-clause" +message = "Avoid `elseif` clauses." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryThrowsWhenExecutionDoesNotProduceAResult`." +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/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryWithRawSqlDelegatesToConnectionExecute`." -count = 1 +file = "test/unit/Adapter/ParameterContainerTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteQueryWithStatementExecutesStatement`." -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/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testFluentSetProfiler`." +file = "test/unit/ResultSet/AbstractResultSetTest.php" +code = "assert-description" +message = "Missing description in assert function." 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 +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/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetDriverReturnsDriver`." +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/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersQuoteIdentifierClosureCallsPlatform`." -count = 1 +file = "test/unit/RowGateway/AbstractRowGatewayTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 4 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersQuoteValueClosureCallsPlatform`." +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "halstead" +message = "Method has a high halstead volume" 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 +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 3 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetHelpersReturnsQuoteIdentifierFunction`." +file = "test/unit/Sql/AbstractSqlFunctionalTestCase.php" +code = "tagged-todo" +message = "TODO should be tagged with (@username) or (#issue)." 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 +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/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetPlatformReturnsPlatform`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_get` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetProfilerReturnsProfiler`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_isset` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetQueryResultSetPrototypeReturnsResultSet`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_set` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicGetReturnsDriverAndPlatformCaseInsensitively`." +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "method-name" +message = "Method name `_unset` should be in camel case." 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 +file = "test/unit/Sql/InsertIgnoreTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareQueryBindsParameterContainerDirectly`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_get` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testPrepareQueryPreparesStatementWithoutExecuting`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_isset` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testProducedResultSetPrototypeIsDifferentForEachQuery`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_set` should be in camel case." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryThrowsOnInvalidParameterType`." +file = "test/unit/Sql/InsertTest.php" +code = "method-name" +message = "Method name `_unset` should be in camel case." 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 +file = "test/unit/Sql/InsertTest.php" +code = "no-isset" +message = "Use of the `isset` construct." +count = 2 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenExecutedProducesAResult`." +file = "test/unit/Sql/InsertTest.php" +code = "no-redundant-variable" +message = "Variable `$value` is assigned but never used." 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 +file = "test/unit/Sql/Platform/AbstractPlatformTest.php" +code = "string-style" +message = "String concatenation can be replaced with interpolation." +count = 2 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenPreparedWithParameterArrayProducesResult`." +file = "test/unit/Sql/Predicate/PredicateTest.php" +code = "no-else-clause" +message = "Avoid `else` clauses." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testQueryWhenPreparedWithParameterContainerProducesResult`." +file = "test/unit/Sql/Predicate/PredicateTest.php" +code = "no-isset" +message = "Use of the `isset` construct." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSetProfilerDelegatesToDriverWhenProfilerAware`." +file = "test/unit/Sql/SelectTest.php" +code = "excessive-parameter-list" +message = "Parameter list is too long." count = 1 [[issues]] -file = "test/unit/Adapter/AdapterTest.php" -code = "strict-assertions" -message = "Use strict assertions in PHPUnit tests." +file = "test/unit/Sql/SelectTest.php" +code = "halstead" +message = "Method has a high halstead volume and effort" count = 1 [[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "assertion-style" -message = "Inconsistent assertions style." -count = 6 +file = "test/unit/Sql/SelectTest.php" +code = "no-assign-in-argument" +message = "Avoid assignments in function call arguments." +count = 1 [[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.''' +file = "test/unit/Sql/SelectTest.php" +code = "no-boolean-flag-parameter" +message = "Avoid boolean flag parameters." 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 +file = "test/unit/Sql/SelectTest.php" +code = "no-redundant-variable" +message = "Variable `$value` is assigned but never used." +count = 1 [[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 +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select32subselect` should be in camel case." +count = 1 [[issues]] -file = "test/unit/Adapter/Container/AbstractAdapterInterfaceFactoryTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testCanCreateReturnsFalseForEmptyConfig`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select39subselect` should be in camel case." 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`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select44b` should be in camel case." 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`." +file = "test/unit/Sql/SelectTest.php" +code = "variable-name" +message = "Variable name `$select48b` should be in camel case." 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 `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 = "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 `testMagicGetReturnsTheColumnValue`." -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 = "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 = 7 - -[[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`." +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/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSet`." +file = "test/unit/Sql/SqlTest.php" +code = "method-name" +message = "Method name `_construct` should be in camel case." 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 +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/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString`." +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/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement`." +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/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTable`." -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/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhereAcceptsExpressionInterface`." -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/Sql/UpdateTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testWhere`." -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/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 `testDeleteWithClosure`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDelete`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteDeleteThrowsExceptionWhenTableDoesNotMatch`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteInsertThrowsExceptionWhenTableDoesNotMatch`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetColumns`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetFeatureSet`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetLastInsertValue`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetSql`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testGetTable`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeEarlyReturnWhenAlreadyInitialized`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInitializeThrowsExceptionWithoutTable`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsert`." -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 - -[[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`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testUpdateWithJoinDefaultType`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testUpdateWithNoCriteria`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testUpdate`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testMagicCallDelegatesToTheFeatureSet`." -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" -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 `testCloneKeepsTheAdapter`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testMagicGetReturnsTheLastInsertValue`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testMagicGetThrowsForUnknownProperty`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -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 `testMagicGetReturnsTheLastInsertValueAndAdapter`." -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 - -[[issues]] -file = "test/unit/TableGateway/AbstractTableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testMagicSetDelegatesToTheFeatureSet`." +code = "no-fully-qualified-global-class-like" +message = "Fully-qualified class-like reference detected." 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`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithArrayOfFeatures`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithCustomResultSetPrototype`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithFeatureSet`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testConstructorWithSingleFeature`." -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 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testDeleteShouldResetTableToUnaliasedTable`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testInsertShouldResetTableToUnaliasedTable`." -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 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableAsString`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testTableAsTableIdentifierObject`." -count = 1 - -[[issues]] -file = "test/unit/TableGateway/TableGatewayTest.php" -code = "prefer-test-attribute" -message = "Use `#[Test]` attribute instead of `test` prefix on method `testUpdateShouldResetTableToUnaliasedTable`." -count = 1 - -[[issues]] -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 diff --git a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php index 6b533d0f..3133b11e 100644 --- a/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php +++ b/test/integration/Adapter/Driver/Pdo/AbstractAdapterTestCase.php @@ -1,9 +1,12 @@ assertInstanceOf(AdapterInterface::class, $this->adapter); + static::assertInstanceOf(AdapterInterface::class, $this->adapter); } - public function testDriverDisconnectAfterQuoteWithPlatform(): void + #[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 +33,11 @@ public function testSetDbAdapter(): void $object->setDbAdapter($adapter); - self::assertSame($adapter, $object->getAdapter()); + static::assertSame($adapter, $object->getAdapter()); } - public function testSetDbAdapterSetsProperty(): void + #[Test] + public function setDbAdapterSetsProperty(): void { $object = new ConcreteAdapterAwareObject(); @@ -46,6 +49,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..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,8 @@ final class AdapterTest extends TestCase protected Adapter $adapter; - public function testConstructorWithProfilerDelegatesToSetProfiler(): void + #[Test] + public function constructorWithProfilerDelegatesToSetProfiler(): void { $profilerMock = $this->createMock(Profiler\ProfilerInterface::class); $driverMock = $this->createMock(DriverInterface::class); @@ -63,17 +65,19 @@ public function testConstructorWithProfilerDelegatesToSetProfiler(): void profiler: $profilerMock, ); - self::assertSame($profilerMock, $adapter->getProfiler()); + static::assertSame($profilerMock, $adapter->getProfiler()); } + #[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()); } + #[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 +86,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)); } + #[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 +102,53 @@ public function testExecuteQueryThrowsWhenExecutionDoesNotProduceAResult(): void $this->adapter->executeQuery($sql); } + #[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)); } + #[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)); } + #[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); } + #[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()); } + #[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 + #[Test] + public function getHelpersQuoteIdentifierClosureCallsPlatform(): void { $this->mockPlatform ->method('quoteIdentifier') @@ -147,10 +158,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 + #[Test] + public function getHelpersQuoteValueClosureCallsPlatform(): void { $this->mockPlatform ->method('quoteValue') @@ -163,68 +175,75 @@ public function testGetHelpersQuoteValueClosureCallsPlatform(): void $functions[0]('test'); } - public function testGetHelpersReturnsBothFunctions(): void + #[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 + #[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 + #[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]); } + #[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()); } + #[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()); } + #[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 + #[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 +251,23 @@ public function testMagicGetReturnsDriverAndPlatformCaseInsensitively(): void $this->adapter->foo; } + #[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']); } + #[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 +279,25 @@ public function testPrepareQueryBindsParameterContainerDirectly(): void $this->adapter->prepareQuery('SELECT foo, :bar', $parameterContainer); } + #[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 */ + #[Test] #[Group('#210')] - public function testProducedResultSetPrototypeIsDifferentForEachQuery(): void + public function producedResultSetPrototypeIsDifferentForEachQuery(): void { $statement = $this->createMock(StatementInterface::class); $result = $this->createMock(ResultInterface::class); @@ -286,13 +309,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 + #[Test] + public function queryThrowsOnInvalidParameterType(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::INCORRECT_FLAG); @@ -303,22 +327,24 @@ public function testQueryThrowsOnInvalidParameterType(): void /** * @throws \Exception */ + #[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 */ + #[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 +362,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 */ + #[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 */ + #[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 +398,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 */ + #[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 +421,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 + #[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..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,17 +49,19 @@ public static function providerValidService(): array ]; } - public function testCanCreateReturnsFalseForEmptyConfig(): void + #[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 + #[Test] + public function getConfigCachesResult(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -76,28 +79,31 @@ public function testGetConfigCachesResult(): void $factory->canCreate($container, 'anything'); } - public function testGetConfigReturnsEmptyWhenContainerHasNoConfig(): void + #[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 */ + #[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 + #[Test] + public function invokeThrowsWhenDriverNotConfigured(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -116,7 +122,8 @@ public function testInvokeThrowsWhenDriverNotConfigured(): void $factory($container, 'PhpDb\Adapter\NoDriver'); } - public function testInvokeUsesResultSetFromContainer(): void + #[Test] + public function invokeUsesResultSetFromContainer(): void { $resultSet = new ResultSet(); $profiler = $this->createMock(ProfilerInterface::class); @@ -148,20 +155,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 */ + #[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 +183,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..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,8 @@ #[CoversMethod(AdapterInterfaceDelegator::class, '__invoke')] final class AdapterInterfaceDelegatorTest extends TestCase { - public function testDelegatorWithPluginManager(): void + #[Test] + public function delegatorWithPluginManager(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -74,11 +76,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 +88,8 @@ public function validate(mixed $instance): void {} * @throws NotFoundExceptionInterface * @throws Exception */ - public function testDelegatorWithServiceManager(): void + #[Test] + public function delegatorWithServiceManager(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -110,7 +113,7 @@ public function testDelegatorWithServiceManager(): void $result = $container->get(ConcreteAdapterAwareObject::class); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -121,7 +124,8 @@ public function testDelegatorWithServiceManager(): void * @throws NotFoundExceptionInterface * @throws Exception */ - public function testDelegatorWithServiceManagerAndCustomAdapterName(): void + #[Test] + public function delegatorWithServiceManagerAndCustomAdapterName(): void { $databaseAdapter = new Adapter( $this->createMock(DriverInterface::class), @@ -145,13 +149,14 @@ public function testDelegatorWithServiceManagerAndCustomAdapterName(): void $result = $container->get(ConcreteAdapterAwareObject::class); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); } - public function testInvokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void + #[Test] + public function invokeReturnsInstanceWhenAdapterIsNotAdapterInterface(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -171,14 +176,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 + #[Test] + public function setAdapterShouldBeCalledForExistingAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -199,7 +205,7 @@ public function testSetAdapterShouldBeCalledForExistingAdapter(): void $callback, ); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -208,7 +214,8 @@ public function testSetAdapterShouldBeCalledForExistingAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void + #[Test] + public function setAdapterShouldBeCalledForOnlyConcreteAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -230,7 +237,7 @@ public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void $callback, ); - $this->assertInstanceOf( + static::assertInstanceOf( AdapterInterface::class, $result->getAdapter(), ); @@ -239,7 +246,8 @@ public function testSetAdapterShouldBeCalledForOnlyConcreteAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldNotBeCalledForMissingAdapter(): void + #[Test] + public function setAdapterShouldNotBeCalledForMissingAdapter(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::once()) @@ -264,7 +272,8 @@ public function testSetAdapterShouldNotBeCalledForMissingAdapter(): void /** * @throws Exception */ - public function testSetAdapterShouldNotBeCalledForWrongClassInstance(): void + #[Test] + public function setAdapterShouldNotBeCalledForWrongClassInstance(): void { $container = $this->createMock(ContainerInterface::class); $container->expects(self::never()) @@ -286,11 +295,12 @@ public function testSetAdapterShouldNotBeCalledForWrongClassInstance(): void ); } - public function testSetStateWithCustomAdapterName(): void + #[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 +318,11 @@ public function testSetStateWithCustomAdapterName(): void ); } - public function testSetStateWithDefaultAdapterName(): void + #[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..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,93 +23,103 @@ #[Group('unit')] final class AbstractConnectionTest extends TestCase { - public function testDisconnectIsNoOpWhenNotConnected(): void + #[Test] + public function disconnectIsNoOpWhenNotConnected(): void { $connection = new TestConnection(); $result = $connection->disconnect(); - self::assertSame($connection, $result); + static::assertSame($connection, $result); } - public function testDisconnectNullsResourceWhenConnected(): void + #[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 + #[Test] + public function getConnectionParametersReturnsEmptyByDefault(): void { $connection = new TestConnection(); - self::assertSame([], $connection->getConnectionParameters()); + static::assertSame([], $connection->getConnectionParameters()); } - public function testGetDriverNameReturnsNullByDefault(): void + #[Test] + public function getDriverNameReturnsNullByDefault(): void { $connection = new TestConnection(); - self::assertNull($connection->getDriverName()); + static::assertNull($connection->getDriverName()); } - public function testGetDriverNameReturnsValueWhenSet(): void + #[Test] + public function getDriverNameReturnsValueWhenSet(): void { $connection = new TestConnection('sqlite'); - self::assertSame('sqlite', $connection->getDriverName()); + static::assertSame('sqlite', $connection->getDriverName()); } - public function testGetProfilerReturnsNullByDefault(): void + #[Test] + public function getProfilerReturnsNullByDefault(): void { $connection = new TestConnection(); - self::assertNull($connection->getProfiler()); + static::assertNull($connection->getProfiler()); } - public function testGetResourceAutoConnectsWhenNotConnected(): void + #[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 + #[Test] + public function inTransactionReturnsFalseByDefault(): void { $connection = new TestConnection(); - self::assertFalse($connection->inTransaction()); + static::assertFalse($connection->inTransaction()); } - public function testSetConnectionParametersStoresAndReturnsConnection(): void + #[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 + #[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..f21d9a26 100644 --- a/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php +++ b/test/unit/Adapter/Driver/Feature/AbstractFeatureTest.php @@ -10,20 +10,22 @@ 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 { - public function testSetDriverStoresDriverAndReturnsInstance(): void + #[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..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,8 @@ #[CoversMethod(DriverFeatureProviderTrait::class, 'getFeature')] final class DriverFeatureProviderTraitTest extends TestCase { - public function testAddFeaturesAddsMultipleFeatures(): void + #[Test] + public function addFeaturesAddsMultipleFeatures(): void { $driver = new TestFeatureDriver(); $feature1 = $this->createMock(DriverFeatureInterface::class); @@ -30,10 +32,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 + #[Test] + public function addFeatureSetsDriverAndStoresFeature(): void { $driver = new TestFeatureDriver(); $feature = $this->createMock(DriverFeatureInterface::class); @@ -41,10 +44,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 + #[Test] + public function addFeatureThrowsWhenUsedOutsideDriverInterface(): void { $nonDriver = new class implements DriverFeatureProviderInterface { use DriverFeatureProviderTrait; @@ -62,20 +66,22 @@ public function testAddFeatureThrowsWhenUsedOutsideDriverInterface(): void $nonDriver->addFeature($feature); } - public function testGetFeatureReturnsFalseWhenNotFound(): void + #[Test] + public function getFeatureReturnsFalseWhenNotFound(): void { $driver = new TestFeatureDriver(); - self::assertFalse($driver->getFeature('NonExistent')); + static::assertFalse($driver->getFeature('NonExistent')); } - public function testGetFeatureReturnsFeatureByClassName(): void + #[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..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,60 +37,66 @@ final class ConnectionTest extends TestCase { protected TestConnection $connection; - public function testBeginTransactionAutoConnectsWhenNotConnected(): void + #[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 + #[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 + #[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 + #[Test] + public function constructorWithPdoResourceSetsConnected(): void { $pdo = new SqliteMemoryPdo(); $connection = new TestConnection($pdo); - self::assertTrue($connection->isConnected()); + static::assertTrue($connection->isConnected()); } - public function testExecuteAutoConnectsWhenNotConnected(): void + #[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 + #[Test] + public function executeCallsProfilerFinishBeforeThrowingOnError(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -105,7 +112,8 @@ public function testExecuteCallsProfilerFinishBeforeThrowingOnError(): void @$connection->execute('INVALID SQL STATEMENT HERE %%%'); } - public function testExecuteCallsProfilerStartAndFinish(): void + #[Test] + public function executeCallsProfilerStartAndFinish(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -119,19 +127,21 @@ public function testExecuteCallsProfilerStartAndFinish(): void $connection->execute('SELECT 1'); } - public function testFluentSetDriver(): void + #[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 + #[Test] + public function getDsnReturnsDsnAfterConnect(): void { $dsn = 'sqlite::memory:'; $this->connection->setConnectionParameters(['dsn' => $dsn]); @@ -141,10 +151,11 @@ public function testGetDsnReturnsDsnAfterConnect(): void } $responseString = $this->connection->getDsn(); - self::assertEquals($dsn, $responseString); + static::assertEquals($dsn, $responseString); } - public function testGetDsnThrowsWhenDsnIsNull(): void + #[Test] + public function getDsnThrowsWhenDsnIsNull(): void { $connection = new TestConnection(['dsn' => 'sqlite::memory:']); $connection->connect(); @@ -158,35 +169,38 @@ public function testGetDsnThrowsWhenDsnIsNull(): void $connection->getDsn(); } - public function testPrepareAutoConnectsAndReturnsStatement(): void + #[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 + #[Test] + public function resource(): void { $resource = $this->connection->getResource(); - self::assertNotNull($resource); + static::assertNotNull($resource); } - public function testSetConnectionParametersStoresParams(): void + #[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..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,88 +28,96 @@ final class ConnectionTransactionsTest extends TestCase { protected ConnectionWrapper $wrapper; - public function testBeginTransactionReturnsInstanceOfConnection(): void + #[Test] + public function beginTransactionReturnsInstanceOfConnection(): void { - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->beginTransaction()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->beginTransaction()); } - public function testBeginTransactionSetsInTransactionAtTrue(): void + #[Test] + public function beginTransactionSetsInTransactionAtTrue(): void { $this->wrapper->beginTransaction(); - self::assertTrue($this->wrapper->inTransaction()); + static::assertTrue($this->wrapper->inTransaction()); } - public function testCommitReturnsInstanceOfConnection(): void + #[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 + #[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 + #[Test] + public function commitWithoutBeginReturnsInstanceOfConnection(): void { - self::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); + static::assertInstanceOf(ConnectionInterface::class, $this->wrapper->commit()); } - public function testNestedTransactionsCommit(): void + #[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 + #[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 + #[Test] + public function rollbackDisconnectedThrowsException(): void { $this->wrapper->disconnect(); @@ -117,20 +126,23 @@ public function testRollbackDisconnectedThrowsException(): void $this->wrapper->rollback(); } - public function testRollbackReturnsInstanceOfConnection(): void + #[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 + #[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 + #[Test] + public function rollbackWithoutBeginThrowsException(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::ROLLBACK_WITHOUT_TRANSACTION); @@ -140,15 +152,16 @@ public function testRollbackWithoutBeginThrowsException(): void /** * Standalone commit after a SET autocommit=0; */ - public function testStandaloneCommit(): void + #[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..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,40 +67,45 @@ public static function getParamsAndType(): array ]; } - public function testCheckEnvironmentReturnsTrue(): void + #[Test] + public function checkEnvironmentReturnsTrue(): void { - self::assertTrue($this->pdo->checkEnvironment()); + static::assertTrue($this->pdo->checkEnvironment()); } - public function testConstructorAddsFeaturesWhenDriverSupportsFeatures(): void + #[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 + #[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 + #[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 + #[Test] + public function createStatementWithPdoStatementResource(): void { $connection = new TestConnection(new SqliteMemoryPdo()); $pdo = new TestPdo($connection); @@ -107,72 +113,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 + #[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()); } + #[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 + #[Test] + public function formatParameterNameReturnsQuestionMarkForNumericWithoutType(): void { - self::assertSame('?', $this->pdo->formatParameterName(42)); + static::assertSame('?', $this->pdo->formatParameterName(42)); } + #[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 + #[Test] + public function getConnectionReturnsConnectionInstance(): void { $connection = $this->pdo->getConnection(); - self::assertInstanceOf(TestConnection::class, $connection); + static::assertInstanceOf(TestConnection::class, $connection); } - public function testGetLastGeneratedValueDelegatesToConnection(): void + #[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 + #[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 + #[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 + #[Test] + public function getProfilerThrowsWhenNotInitialized(): void { $pdo = new TestPdo([]); @@ -181,14 +196,16 @@ public function testGetProfilerThrowsWhenNotInitialized(): void $unused = $pdo->getProfiler(); } - public function testGetResultPrototypeReturnsResult(): void + #[Test] + public function getResultPrototypeReturnsResult(): void { $resultPrototype = $this->pdo->getResultPrototype(); - self::assertInstanceOf(Result::class, $resultPrototype); + static::assertInstanceOf(Result::class, $resultPrototype); } - public function testSetProfilerPropagatesProfilerToConnectionAndStatement(): void + #[Test] + public function setProfilerPropagatesProfilerToConnectionAndStatement(): void { $profiler = $this->createMock(ProfilerInterface::class); $connection = new TestConnection(new SqliteMemoryPdo()); @@ -197,9 +214,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..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,15 +43,17 @@ #[Group('unit')] final class ResultTest extends TestCase { - public function testBufferIsCallableWithNoEffect(): void + #[Test] + public function bufferIsCallableWithNoEffect(): void { $result = new Result(); $result->buffer(); - self::assertFalse($result->isBuffered()); + static::assertFalse($result->isBuffered()); } - public function testCountCachesResultFromClosure(): void + #[Test] + public function countCachesResultFromClosure(): void { $callCount = 0; $rowCount = static function () use (&$callCount): int { @@ -66,10 +69,11 @@ public function testCountCachesResultFromClosure(): void $result->count(); $result->count(); - self::assertSame(1, $callCount); + static::assertSame(1, $callCount); } - public function testCountCachesResultFromStatementRowCount(): void + #[Test] + public function countCachesResultFromStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->once())->method('rowCount')->willReturn(3); @@ -80,10 +84,11 @@ public function testCountCachesResultFromStatementRowCount(): void $result->count(); $result->count(); - self::assertSame(3, $result->count()); + static::assertSame(3, $result->count()); } - public function testCountWithClosureInvokesClosureAndReturnsValue(): void + #[Test] + public function countWithClosureInvokesClosureAndReturnsValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->never())->method('rowCount'); @@ -93,10 +98,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 + #[Test] + public function countWithIntReturnsProvidedValue(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->never())->method('rowCount'); @@ -104,10 +110,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 + #[Test] + public function countWithNoRowCountFallsBackToStatementRowCount(): void { $stub = $this->getMockBuilder(PDOStatement::class)->getMock(); $stub->expects($this->once()) @@ -117,13 +124,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 + #[Test] + public function currentReturnsSameDataOnConsecutiveCalls(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -133,13 +141,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 + #[Test] + public function fetchModeAcceptsNamedMode(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -148,14 +157,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 + #[Test] + public function fetchModeObjReturnsStdClass(): void { $stub = $this->getMockBuilder('PDOStatement')->getMock(); $stub->expects($this->any()) @@ -166,11 +176,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 + #[Test] + public function getAffectedRowsDelegatesToRowCount(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('rowCount')->willReturn(5); @@ -178,17 +189,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 + #[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 + #[Test] + public function getFieldCountDelegatesToColumnCount(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -196,26 +209,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 + #[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 + #[Test] + public function getGeneratedValueReturnsNullByDefault(): void { $result = new Result(); - self::assertNull($result->getGeneratedValue()); + static::assertNull($result->getGeneratedValue()); } - public function testGetQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void + #[Test] + public function getQueryResultClonesGivenPrototypeRatherThanMutatingIt(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -226,11 +242,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 + #[Test] + public function getQueryResultInitializesReturnedResultSetWithThisResult(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -238,10 +255,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 + #[Test] + public function getQueryResultReturnsDefaultResultSetPrototypeWhenNoneGiven(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -249,10 +267,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 + #[Test] + public function getQueryResultThrowsWhenResultIsNotAQueryResult(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(0); @@ -264,34 +283,38 @@ public function testGetQueryResultThrowsWhenResultIsNotAQueryResult(): void $result->getQueryResult(); } - public function testGetResourceReturnsPdoStatement(): void + #[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 + #[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 + #[Test] + public function isBufferedReturnsFalse(): void { $result = new Result(); - self::assertFalse($result->isBuffered()); + static::assertFalse($result->isBuffered()); } - public function testIsQueryResultReturnsFalseWhenNoColumns(): void + #[Test] + public function isQueryResultReturnsFalseWhenNoColumns(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(0); @@ -299,10 +322,11 @@ public function testIsQueryResultReturnsFalseWhenNoColumns(): void $result = new Result(); $result->initialize($stub, null); - self::assertFalse($result->isQueryResult()); + static::assertFalse($result->isQueryResult()); } - public function testIsQueryResultReturnsTrueWhenColumnsExist(): void + #[Test] + public function isQueryResultReturnsTrueWhenColumnsExist(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('columnCount')->willReturn(3); @@ -310,10 +334,11 @@ public function testIsQueryResultReturnsTrueWhenColumnsExist(): void $result = new Result(); $result->initialize($stub, null); - self::assertTrue($result->isQueryResult()); + static::assertTrue($result->isQueryResult()); } - public function testNextAdvancesPositionAndFetchesData(): void + #[Test] + public function nextAdvancesPositionAndFetchesData(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['name' => 'test']); @@ -322,13 +347,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 + #[Test] + public function rewindResetsIterationToStart(): void { $data = [ ['test' => 1], @@ -349,17 +375,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 + #[Test] + public function rewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['id' => 1]); @@ -375,15 +402,17 @@ public function testRewindThrowsExceptionOnForwardOnlyAfterAdvancing(): void $result->rewind(); } - public function testSetFetchModeStoresValidMode(): void + #[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 + #[Test] + public function setFetchModeThrowsOnInvalidFetchMode(): void { $result = new Result(); @@ -393,7 +422,8 @@ public function testSetFetchModeThrowsOnInvalidFetchMode(): void $result->setFetchMode(9999); } - public function testSetFetchModeThrowsOnInvalidMode(): void + #[Test] + public function setFetchModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -401,7 +431,8 @@ public function testSetFetchModeThrowsOnInvalidMode(): void $result->setFetchMode(13); } - public function testSetStatementModeThrowsOnInvalidMode(): void + #[Test] + public function setStatementModeThrowsOnInvalidMode(): void { $result = new Result(); @@ -409,25 +440,28 @@ public function testSetStatementModeThrowsOnInvalidMode(): void $result->setStatementMode('invalid'); } - public function testSetStatementModeToForward(): void + #[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 + #[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 + #[Test] + public function validReturnsFalseWhenCurrentDataIsFalse(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(false); @@ -436,10 +470,11 @@ public function testValidReturnsFalseWhenCurrentDataIsFalse(): void $result->initialize($stub, null); $result->rewind(); - self::assertFalse($result->valid()); + static::assertFalse($result->valid()); } - public function testValidReturnsTrueWhenCurrentDataExists(): void + #[Test] + public function validReturnsTrueWhenCurrentDataExists(): void { $stub = $this->createMock(PDOStatement::class); $stub->method('fetch')->willReturn(['id' => 1]); @@ -448,6 +483,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..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,54 +19,58 @@ final class StatementIntegrationTest extends TestCase protected PDOStatement|MockObject $pdoStatementMock; - public function testStatementExecuteWillConvertPhpBoolToPdoBoolWhenBinding(): void + #[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 + #[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 + #[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 + #[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..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,8 @@ public static function invalidParameterNameProvider(): array ]; } - public function testBindParametersDetectsBooleanValueType(): void + #[Test] + public function bindParametersDetectsBooleanValueType(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -72,10 +74,11 @@ public function testBindParametersDetectsBooleanValueType(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersDetectsNullValueType(): void + #[Test] + public function bindParametersDetectsNullValueType(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -88,10 +91,11 @@ public function testBindParametersDetectsNullValueType(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersFromContainerSkipsWhenAlreadyBound(): void + #[Test] + public function bindParametersFromContainerSkipsWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -100,10 +104,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 + #[Test] + public function bindParametersWithErrataTypeDefaultsToString(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -116,10 +121,11 @@ public function testBindParametersWithErrataTypeDefaultsToString(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeInteger(): void + #[Test] + public function bindParametersWithErrataTypeInteger(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -132,10 +138,11 @@ public function testBindParametersWithErrataTypeInteger(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeLob(): void + #[Test] + public function bindParametersWithErrataTypeLob(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -148,10 +155,11 @@ public function testBindParametersWithErrataTypeLob(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithErrataTypeNull(): void + #[Test] + public function bindParametersWithErrataTypeNull(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -164,10 +172,11 @@ public function testBindParametersWithErrataTypeNull(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testBindParametersWithPositionalIntegers(): void + #[Test] + public function bindParametersWithPositionalIntegers(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -182,21 +191,23 @@ public function testBindParametersWithPositionalIntegers(): void $result = $this->statement->execute(); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testCloneClonesParameterContainerWhenSet(): void + #[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 + #[Test] + public function cloneResetsState(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -206,38 +217,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 + #[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 + #[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 + #[Test] + public function executeCallsProfilerFinishOnFailure(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -261,7 +275,8 @@ public function testExecuteCallsProfilerFinishOnFailure(): void $this->statement->execute(); } - public function testExecuteCallsProfilerOnSuccess(): void + #[Test] + public function executeCallsProfilerOnSuccess(): void { $profiler = $this->createMock(ProfilerInterface::class); $profiler->expects($this->once())->method('profilerStart')->willReturnSelf(); @@ -276,7 +291,8 @@ public function testExecuteCallsProfilerOnSuccess(): void $this->statement->execute(); } - public function testExecuteCastsNonIntErrorCodeToZero(): void + #[Test] + public function executeCastsNonIntErrorCodeToZero(): void { $pdoException = new PDOException('fail'); $ref = new ReflectionProperty($pdoException, 'code'); @@ -297,21 +313,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 + #[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 + #[Test] + public function executeThrowsInvalidQueryExceptionOnPdoException(): void { $pdoStmt = $this->createMock(PDOStatement::class); $pdoStmt->method('execute')->willThrowException(new PDOException('execute failed')); @@ -330,8 +348,9 @@ public function testExecuteThrowsInvalidQueryExceptionOnPdoException(): void $this->statement->execute(); } + #[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 +361,8 @@ public function testExecuteThrowsOnInvalidParameterName(string $name): void $this->statement->execute([$name => 'value']); } - public function testExecuteWithArrayParametersMergesIntoContainer(): void + #[Test] + public function executeWithArrayParametersMergesIntoContainer(): void { $pdo = new SqliteMemoryPdo(); $statement = new Statement(); @@ -352,10 +372,11 @@ public function testExecuteWithArrayParametersMergesIntoContainer(): void $result = $statement->execute(['name' => 'test']); - self::assertInstanceOf(Result::class, $result); + static::assertInstanceOf(Result::class, $result); } - public function testExecuteWithParameterContainerSetsContainer(): void + #[Test] + public function executeWithParameterContainerSetsContainer(): void { $pdo = new SqliteMemoryPdo(); $statement = new Statement(); @@ -368,56 +389,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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function getProfilerReturnsNullByDefault(): void { - self::assertNull($this->statement->getProfiler()); + static::assertNull($this->statement->getProfiler()); } - public function testGetResourceReturnsPdoStatement(): void + #[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 + #[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 + #[Test] + public function initializeSetsPdoResource(): void { $pdo = new SqliteMemoryPdo(); @@ -425,18 +454,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 + #[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 + #[Test] + public function prepareThrowsRuntimeExceptionOnPdoFailure(): void { $pdo = $this->createMock(PDO::class); $pdo->method('prepare')->willReturn(false); @@ -449,7 +480,8 @@ public function testPrepareThrowsRuntimeExceptionOnPdoFailure(): void $this->statement->prepare(); } - public function testPrepareThrowsWhenAlreadyPrepared(): void + #[Test] + public function prepareThrowsWhenAlreadyPrepared(): void { $this->statement->initialize(new SqliteMemoryPdo()); $this->statement->prepare('SELECT 1'); @@ -460,7 +492,8 @@ public function testPrepareThrowsWhenAlreadyPrepared(): void $this->statement->prepare('SELECT 2'); } - public function testSecondExecuteSkipsBindingWhenAlreadyBound(): void + #[Test] + public function secondExecuteSkipsBindingWhenAlreadyBound(): void { $pdo = new SqliteMemoryPdo(); $this->statement->setDriver(new TestPdo(new TestConnection($pdo))); @@ -469,34 +502,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 + #[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 + #[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 + #[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..e363cb0f 100644 --- a/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php +++ b/test/unit/Adapter/Exception/InvalidConnectionParametersExceptionTest.php @@ -7,16 +7,18 @@ 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 { - public function testConstructorStoresMessageAndParameters(): void + #[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..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,108 +43,122 @@ final class ParameterContainerTest extends TestCase { protected ParameterContainer $parameterContainer; - public function testConstructorWithDataPopulatesContainer(): void + #[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')); } + #[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()); } + #[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); } + #[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); } + #[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); } + #[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 + #[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()); } + #[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()); } + #[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()); } + #[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'])); } + #[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 } + #[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 + #[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 + #[Test] + public function offsetGetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -153,15 +168,17 @@ public function testOffsetGetErrataThrowsWhenNameDoesNotExist(): void $container->offsetGetErrata('nonexistent'); } - public function testOffsetGetMaxLengthByPositionalIndex(): void + #[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 + #[Test] + public function offsetGetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(); @@ -171,59 +188,64 @@ public function testOffsetGetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetGetMaxLength('nonexistent'); } + #[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 + #[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)); } + #[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 + #[Test] + public function offsetHasMaxLengthByPositionalIndex(): void { $container = new ParameterContainer(['foo' => 'bar']); $container->offsetSetMaxLength('foo', 50); - self::assertTrue($container->offsetHasMaxLength(0)); + static::assertTrue($container->offsetHasMaxLength(0)); } + #[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 +254,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 +265,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(), ); } + #[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')); } + #[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 + #[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 + #[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 + #[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 + #[Test] + public function offsetSetThrowsOnInvalidKeyType(): void { $container = new ParameterContainer(); @@ -300,60 +328,67 @@ public function testOffsetSetThrowsOnInvalidKeyType(): void $container->offsetSet(1.5, 'value'); } - public function testOffsetSetWithIntNotInPositionsCastsToString(): void + #[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 + #[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')); } + #[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 + #[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')); } + #[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 + #[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 + #[Test] + public function offsetUnsetErrataThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -363,24 +398,27 @@ public function testOffsetUnsetErrataThrowsWhenNameDoesNotExist(): void $container->offsetUnsetErrata('foo'); } + #[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 + #[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 + #[Test] + public function offsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void { $container = new ParameterContainer(['foo' => 'bar']); @@ -390,21 +428,23 @@ public function testOffsetUnsetMaxLengthThrowsWhenNameDoesNotExist(): void $container->offsetUnsetMaxLength('foo'); } + #[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()); } + #[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 +452,22 @@ public function testSetFromArray(): void * * @see Insert::procesInsert as example */ - public function testSetFromArrayNamed(): void + #[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']); } + #[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..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,14 +40,16 @@ final class Sql92Test extends TestCase { protected Sql92 $platform; - public function testAbstractPlatformQuoteValueEscapesWithDriver(): void + #[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 + #[Test] + public function abstractPlatformQuoteValueThrowsWithoutDriver(): void { $platform = new TestPlatform(); @@ -54,51 +57,58 @@ public function testAbstractPlatformQuoteValueThrowsWithoutDriver(): void $platform->quoteValue('value'); } - public function testGetIdentifierSeparator(): void + #[Test] + public function getIdentifierSeparator(): void { - self::assertEquals('.', $this->platform->getIdentifierSeparator()); + static::assertSame('.', $this->platform->getIdentifierSeparator()); } - public function testGetName(): void + #[Test] + public function getName(): void { - self::assertEquals('SQL92', $this->platform->getName()); + static::assertSame('SQL92', $this->platform->getName()); } - public function testGetQuoteIdentifierSymbol(): void + #[Test] + public function getQuoteIdentifierSymbol(): void { - self::assertEquals('"', $this->platform->getQuoteIdentifierSymbol()); + static::assertSame('"', $this->platform->getQuoteIdentifierSymbol()); } - public function testGetQuoteValueSymbol(): void + #[Test] + public function getQuoteValueSymbol(): void { - self::assertEquals("'", $this->platform->getQuoteValueSymbol()); + static::assertSame("'", $this->platform->getQuoteValueSymbol()); } - public function testQuoteIdentifier(): void + #[Test] + public function quoteIdentifier(): void { - self::assertEquals('"identifier"', $this->platform->quoteIdentifier('identifier')); + static::assertSame('"identifier"', $this->platform->quoteIdentifier('identifier')); } - public function testQuoteIdentifierChain(): void + #[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 + #[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 +117,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 +126,76 @@ public function testQuoteIdentifierInFragment(): void ); } - public function testQuoteIdentifierInFragmentReturnsUnquotedWhenQuotingDisabled(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function quoteValueRaisesNoticeWithoutPlatformSupport(): void { $this->expectException(RuntimeException::class); $this->platform->quoteValue('value'); } - public function testQuoteValueThrowsWithoutDriver(): void + #[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..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,33 +25,36 @@ final class ProfilerTest extends TestCase { protected Profiler $profiler; - public function testGetLastProfileReturnsSqlAndTimings(): void + #[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 + #[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 + #[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 +62,8 @@ public function testProfilerFinishThrowsWithoutStart(): void $profiler->profilerFinish(); } - public function testProfilerStartClonesParameterContainerFromStatementContainer(): void + #[Test] + public function profilerStartClonesParameterContainerFromStatementContainer(): void { $parameterContainer = new ParameterContainer(['key' => 'value']); $statementContainer = new StatementContainer('SELECT ?', $parameterContainer); @@ -68,21 +73,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 + #[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 + #[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..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,38 +19,42 @@ #[CoversMethod(StatementContainer::class, 'getParameterContainer')] final class StatementContainerTest extends TestCase { - public function testConstructorWithoutSqlDoesNotSetSql(): void + #[Test] + public function constructorWithoutSqlDoesNotSetSql(): void { $container = new StatementContainer(); - self::assertSame('', $container->getSql()); + static::assertSame('', $container->getSql()); } - public function testConstructorWithSqlSetsSql(): void + #[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 + #[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 + #[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..a8a325ca 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 + #[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..3d390e01 100644 --- a/test/unit/Container/AdapterInterfaceFactoryTest.php +++ b/test/unit/Container/AdapterInterfaceFactoryTest.php @@ -16,13 +16,15 @@ 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 { - public function testInvokeCreatesAdapterWithAllDependencies(): void + #[Test] + public function invokeCreatesAdapterWithAllDependencies(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -46,10 +48,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 + #[Test] + public function invokeCreatesAdapterWithDefaultResultSet(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -69,10 +72,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 + #[Test] + public function invokeCreatesAdapterWithoutOptionalProfiler(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -92,11 +96,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 + #[Test] + public function invokeThrowsWhenAdapterConfigIsEmpty(): void { $driverMock = $this->createMock(DriverInterface::class); $platformMock = $this->createMock(PlatformInterface::class); @@ -116,7 +121,8 @@ public function testInvokeThrowsWhenAdapterConfigIsEmpty(): void $factory($container, AdapterInterface::class); } - public function testInvokeThrowsWhenContainerHasNoConfig(): void + #[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..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,8 @@ #[CoversMethod(TableIdentifierFactoryFactory::class, '__invoke')] final class TableIdentifierFactoryFactoryTest extends TestCase { - public function testInvokeCreatesFactoryWithConfiguredPrefix(): void + #[Test] + public function invokeCreatesFactoryWithConfiguredPrefix(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -29,10 +31,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 + #[Test] + public function invokeCreatesFactoryWithConfiguredSeparator(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -45,10 +48,11 @@ public function testInvokeCreatesFactoryWithConfiguredSeparator(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertSame('__', $result->getSeparator()); + static::assertSame('__', $result->getSeparator()); } - public function testInvokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void + #[Test] + public function invokeCreatesFactoryWithConfiguredSeparatorWithoutPrefix(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -60,11 +64,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 + #[Test] + public function invokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void { $container = new ServiceManager(); $container->setService('config', []); @@ -72,10 +77,11 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenConfigIsEmpty(): void $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void + #[Test] + public function invokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): void { $container = $this->createMock(ContainerInterface::class); $container->method('has')->with('config')->willReturn(true); @@ -84,20 +90,22 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenConfigServiceIsNull(): $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeCreatesFactoryWithoutPrefixWhenContainerHasNoConfig(): void + #[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 + #[Test] + public function invokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -107,10 +115,11 @@ public function testInvokeCreatesFactoryWithoutPrefixWhenPrefixKeyIsAbsent(): vo $factory = new TableIdentifierFactoryFactory(); $result = $factory($container); - self::assertNull($result->getPrefix()); + static::assertNull($result->getPrefix()); } - public function testInvokeRejectsEmptyStringSeparatorFromConfig(): void + #[Test] + public function invokeRejectsEmptyStringSeparatorFromConfig(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -126,7 +135,8 @@ public function testInvokeRejectsEmptyStringSeparatorFromConfig(): void $factory($container); } - public function testInvokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void + #[Test] + public function invokeUsesDefaultSeparatorWhenSeparatorKeyIsAbsent(): void { $container = new ServiceManager(); $container->setService('config', [ @@ -138,6 +148,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..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,8 @@ final class AbstractResultSetIntegrationTest extends TestCase /** * @throws \Exception */ - public function testCurrentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void + #[Test] + public function currentCallsDataSourceCurrentAsManyTimesWithoutBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); $this->resultSet->initialize($result); @@ -29,13 +31,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 + #[Test] + public function currentCallsDataSourceCurrentOnceWithBuffer(): void { $result = $this->getMockBuilder(ResultInterface::class)->getMock(); $this->resultSet->buffer(); @@ -45,7 +48,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..83bd3b7c 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 + #[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 */ + #[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 + #[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 + #[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 + #[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 + */ + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function getFieldCountReturnsZeroWithNoDataSource(): void { $resultSet = $this->createResultSetMock(); - self::assertSame(0, $resultSet->getFieldCount()); + static::assertSame(0, $resultSet->getFieldCount()); } - public function testGetFieldCountWithCountableRow(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 */ + #[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 + #[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 + #[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 + #[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 + #[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()); } + #[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()); } + #[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..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,8 @@ class HydratingResultSetIntegrationTest extends TestCase /** * @throws Exception */ - public function testCurrentWillReturnBufferedRow(): void + #[Test] + public function currentWillReturnBufferedRow(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -29,6 +31,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..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,14 +34,16 @@ final class HydratingResultSetTest extends TestCase private string $classMethodsHydratorClass; - public function testConstructorDefaultsToArraySerializableHydrator(): void + #[Test] + public function constructorDefaultsToArraySerializableHydrator(): void { $hydratingRs = new HydratingResultSet(); - self::assertInstanceOf(ArraySerializableHydrator::class, $hydratingRs->getHydrator()); + static::assertInstanceOf(ArraySerializableHydrator::class, $hydratingRs->getHydrator()); } - public function testCurrentDisablesBufferingImplicitly(): void + #[Test] + public function currentDisablesBufferingImplicitly(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -56,20 +59,22 @@ public function testCurrentDisablesBufferingImplicitly(): void /** * @throws Exception */ - public function testCurrentDoesnotHasData(): void + #[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 + #[Test] + public function currentHasData(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -77,10 +82,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 + #[Test] + public function currentWithBufferReturnsBufferedObject(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize(new ArrayIterator([ @@ -93,31 +99,35 @@ public function testCurrentWithBufferReturnsBufferedObject(): void $hydratingRs->rewind(); $buffered = $hydratingRs->current(); - self::assertSame($first, $buffered); + static::assertSame($first, $buffered); } - public function testGetHydrator(): void + #[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 + #[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 + #[Test] + public function getRowPrototypeReturnsDefaultArrayObject(): void { $hydratingRs = new HydratingResultSet(); - self::assertInstanceOf(ArrayObject::class, $hydratingRs->getRowPrototype()); + static::assertInstanceOf(ArrayObject::class, $hydratingRs->getRowPrototype()); } - public function testSetHydrator(): void + #[Test] + public function setHydrator(): void { $hydratingRs = new HydratingResultSet(); $hydratorClass1 = $this->classMethodsHydratorClass; @@ -130,20 +140,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 + #[Test] + public function setObjectPrototype(): void { $prototype1 = new stdClass(); $prototype1->property1 = 'value1'; @@ -155,35 +166,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 + #[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 + #[Test] + public function toArray(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -191,10 +204,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 + #[Test] + public function toArrayUsesHydratorExtract(): void { $hydratingRs = new HydratingResultSet(); $hydratingRs->initialize([ @@ -203,9 +217,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..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; @@ -54,24 +55,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 + #[Test] + public function bufferCalledAfterIterationThrowsException(): void { $this->resultSet->initialize($this->createMock(ResultInterface::class)); $this->resultSet->current(); @@ -85,26 +74,28 @@ public function testBufferCalledAfterIterationThrowsException(): void /** * @throws \Exception */ - public function testCanProvideArrayAsDataSource(): void + #[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 + #[Test] + public function canProvideIteratorAggregateAsDataSource(): void { $iteratorAggregate = $this->getMockBuilder('IteratorAggregate') ->onlyMethods(['getIterator']) @@ -112,34 +103,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 + #[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 + #[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 + #[Test] + public function currentClonesRowPrototypeOnEachCall(): void { $resultSet = new ResultSet(ResultSetReturnType::ArrayObject); $resultSet->initialize([ @@ -151,36 +145,39 @@ public function testCurrentClonesRowPrototypeOnEachCall(): void $resultSet->next(); $second = $resultSet->current(); - self::assertNotSame($first, $second); + static::assertNotSame($first, $second); } - public function testCurrentReturnsArrayObjectWhenReturnTypeIsArrayObject(): void + #[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 + #[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 + #[Test] + public function currentReturnsNullForNonExistingValues(): void { $mockResult = $this->createMock(ResultInterface::class); $mockResult->expects($this->once())->method('current')->willReturn('Not an Array'); @@ -189,13 +186,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 + #[Test] + public function currentWithBufferingCallsDataSourceCurrentOnce(): void { $mockResult = $this->getMockBuilder(ResultInterface::class)->getMock(); $mockResult->expects($this->once())->method('current')->willReturn(['foo' => 'bar']); @@ -209,50 +207,69 @@ public function testCurrentWithBufferingCallsDataSourceCurrentOnce(): void $this->resultSet->current(); } - public function testDataSourceIsNullByDefault(): void + #[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 + #[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 + #[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 + #[Test] + public function getArrayObjectPrototypeDelegatesToGetRowPrototype(): void { - self::assertSame( + static::assertSame( $this->resultSet->getRowPrototype(), $this->resultSet->getArrayObjectPrototype(), ); } - public function testGetReturnTypeReturnsArrayWhenSetToArray(): void + #[Test] + public function getReturnTypeReturnsArrayWhenSetToArray(): void { $resultSet = new ResultSet(ResultSetReturnType::Array); - self::assertSame(ResultSetReturnType::Array, $resultSet->getReturnType()); + static::assertSame(ResultSetReturnType::Array, $resultSet->getReturnType()); } /** * @throws \Exception */ + #[Test] #[DataProvider('invalidReturnTypes')] - public function testInvalidDataSourceRaisesException(mixed $dataSource): void + public function invalidDataSourceRaisesException(mixed $dataSource): void { if (is_array($dataSource)) { $this->expectNotToPerformAssertions(); @@ -265,13 +282,15 @@ public function testInvalidDataSourceRaisesException(mixed $dataSource): void $this->resultSet->initialize($dataSource); } - public function testReturnTypeIsObjectByDefault(): void + #[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 + #[Test] + public function rowObjectPrototypeIsMutable(): void { $row1 = new ArrayObject(['test1' => 'value1']); $row2 = new ArrayObject(['test2' => 'value2']); @@ -280,33 +299,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 + #[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 + #[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()); } + #[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 +339,44 @@ public function testSettingInvalidReturnTypeRaisesException(mixed $type): void * @throws RandomException * @throws \Exception */ - public function testToArrayCreatesArrayOfArraysRepresentingRows(): void + #[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 + #[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 + #[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..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,37 +58,41 @@ final class AbstractRowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - public function testCount(): void + #[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 + #[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 + #[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 + #[Test] + public function initializeCreatesFeatureSetIfNotSet(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -103,14 +108,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 + #[Test] + public function initializeEarlyReturnWhenAlreadyInitialized(): void { $rowGateway = new RowGateway('id', 'test_table', $this->mockAdapter); @@ -119,28 +125,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 + #[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 + #[Test] + public function initializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void { $rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -158,7 +166,8 @@ public function testInitializeThrowsExceptionWhenPrimaryKeyColumnIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testInitializeThrowsExceptionWhenSqlIsNull(): void + #[Test] + public function initializeThrowsExceptionWhenSqlIsNull(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_SQL_OBJECT); @@ -176,7 +185,8 @@ public function testInitializeThrowsExceptionWhenSqlIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testInitializeThrowsExceptionWhenTableIsNull(): void + #[Test] + public function initializeThrowsExceptionWhenTableIsNull(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_TABLE); @@ -193,14 +203,16 @@ public function testInitializeThrowsExceptionWhenTableIsNull(): void $rowGateway->populate(['name' => 'test']); } - public function testMagicGetReturnsTheColumnValue(): void + #[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 + #[Test] + public function magicGetThrowsForUnknownColumn(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(sprintf(InvalidArgumentException::INVALID_COLUMN, 'nonExistentColumn')); @@ -209,71 +221,80 @@ public function testMagicGetThrowsForUnknownColumn(): void $this->rowGateway->nonExistentColumn; } - public function testMagicIssetReportsWhetherAColumnIsSet(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function processPrimaryKeyData(): void { $this->rowGateway->populate(['id' => 5, 'name' => 'foo'], true); @@ -282,34 +303,38 @@ public function testProcessPrimaryKeyData(): void $this->rowGateway->populate(['boo' => 5, 'name' => 'foo'], true); } - public function testRowExistsInDatabaseReturnsFalseWhenNew(): void + #[Test] + public function rowExistsInDatabaseReturnsFalseWhenNew(): void { $this->rowGateway->populate(['name' => 'foo']); - self::assertFalse($this->rowGateway->rowExistsInDatabase()); + static::assertFalse($this->rowGateway->rowExistsInDatabase()); } - public function testRowExistsInDatabaseReturnsTrueAfterPopulateWithTrue(): void + #[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 + #[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 */ + #[Test] #[RequiresPhp('<= 8.6')] - public function testSaveInsertMultiKey(): void + public function saveInsertMultiKey(): void { $this->rowGateway = $this->getMockBuilder(AbstractRowGateway::class)->onlyMethods([])->getMock(); @@ -334,29 +359,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 + #[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 + #[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 +404,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 + #[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..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,8 @@ final class RowGatewayTest extends TestCase /** @var ResultInterface&MockObject */ protected ResultInterface|MockObject $mockResult; - public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void + #[Test] + public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -40,18 +42,20 @@ public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new RowGateway('id', 'foo', $sql); } - public function testConstructorWithArrayPrimaryKey(): void + #[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 + #[Test] + public function constructorWithNullPrimaryKey(): void { self::expectException(RuntimeException::class); self::expectExceptionMessage(RuntimeException::MISSING_PRIMARY_KEY_COLUMN); @@ -59,7 +63,8 @@ public function testConstructorWithNullPrimaryKey(): void new RowGateway(null, 'foo', $this->mockAdapter); } - public function testConstructorWithSqlObject(): void + #[Test] + public function constructorWithSqlObject(): void { $sql = new Sql($this->mockAdapter, 'foo'); $rowGateway = new RowGateway('id', 'foo', $sql); @@ -67,50 +72,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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function initializeThrowsWhenSqlIsNull(): void { $rowGateway = new RowGateway('id', 'foo', $this->mockAdapter); @@ -126,7 +136,8 @@ public function testInitializeThrowsWhenSqlIsNull(): void $rowGateway->initialize(); } - public function testInitializeThrowsWhenTableIsNull(): void + #[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..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,6 +290,7 @@ protected static function update(string|TableIdentifier|null $sqlString): Sql\Up return new Sql\Update($sqlString); } + #[Test] #[DataProvider('dataProvider')] public function test(PreparableSqlInterface|SqlInterface $sqlObject, string $platform, string|array $expected): void { @@ -351,7 +353,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 +364,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..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,8 @@ final class AbstractSqlTest extends TestCase /** * @throws ReflectionException */ - public function testCreateSqlFromSpecificationThrowsOnParameterCountMismatch(): void + #[Test] + public function createSqlFromSpecificationThrowsOnParameterCountMismatch(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -87,7 +89,8 @@ public function testCreateSqlFromSpecificationThrowsOnParameterCountMismatch(): /** * @throws ReflectionException */ - public function testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void + #[Test] + public function createSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -106,7 +109,8 @@ public function testCreateSqlFromSpecNonCombinedByThrowsOnUnsupportedCount(): vo /** * @throws ReflectionException */ - public function testCreateSqlFromSpecWithCombinedByScalarParam(): void + #[Test] + public function createSqlFromSpecWithCombinedByScalarParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -120,13 +124,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 + #[Test] + public function createSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -146,7 +151,8 @@ public function testCreateSqlFromSpecWithCombinedByThrowsOnUnsupportedCount(): v /** * @throws ReflectionException */ - public function testCreateSqlFromSpecWithNonCombinedByParam(): void + #[Test] + public function createSqlFromSpecWithNonCombinedByParam(): void { $method = new ReflectionMethod($this->abstractSql, 'createSqlFromSpecificationAndParameters'); @@ -159,20 +165,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 + #[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 + #[Test] + public function flattenExpressionValuesViaInPredicateWithParameterContainer(): void { $select = new Select('users'); $select->where(new Predicate\In('id', [1, 2, 3])); @@ -193,10 +201,11 @@ public function testFlattenExpressionValuesViaInPredicateWithParameterContainer( $select->prepareStatement($adapter, $mockStatement); - self::assertSame(3, $parameterContainer->count()); + static::assertSame(3, $parameterContainer->count()); } - public function testLocalizeVariablesCopiesSubjectProperties(): void + #[Test] + public function localizeVariablesCopiesSubjectProperties(): void { $decorator = new SelectDecorator(); $select = new Select('users'); @@ -205,11 +214,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 + #[Test] + public function processExpressionThrowsOnUnknownArgumentType(): void { $unknownArg = new class implements ArgumentInterface { public function getSpecification(): string @@ -238,7 +248,8 @@ public function getValue(): string /** * @throws ReflectionException */ - public function testProcessExpressionWithIdentifiersArgument(): void + #[Test] + public function processExpressionWithIdentifiersArgument(): void { $expression = new Expression('? IN (SELECT col1, col2 FROM bar)', [ Argument::identifiers(['col1', 'col2']), @@ -246,25 +257,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 + #[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 + #[Test] + public function processExpressionWithParameterContainerAndParameterizationTypeNamed(): void { $parameterContainer = new ParameterContainer(); $expression = new Expression('? > ? AND y < ?', [new Identifier('x'), 5, 10]); @@ -273,17 +286,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 +307,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 + #[Test] + public function processExpressionWithValuesArgument(): void { $expression = new Expression( '? IN (?, ?, ?)', @@ -314,16 +328,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 + #[Test] + public function processExpressionWorksWithExpressionContainingExpressionObject(): void { $expression = new Predicate\Operator( 'release_date', @@ -332,13 +347,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 + #[Test] + public function processExpressionWorksWithExpressionContainingSelectObject(): void { $select = new Select(); $select->from('x')->where->like('bar', 'Foo%'); @@ -347,65 +363,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 + #[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 */ + #[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 + #[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 + #[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 + #[Test] + public function processJoinReturnsNullWhenEmpty(): void { $method = new ReflectionMethod($this->abstractSql, 'processJoin'); $result = $method->invoke( @@ -416,13 +437,14 @@ public function testProcessJoinReturnsNullWhenEmpty(): void null, ); - self::assertNull($result); + static::assertNull($result); } /** * @throws ReflectionException */ - public function testProcessJoinWithArrayAlias(): void + #[Test] + public function processJoinWithArrayAlias(): void { $join = new Join(); $join->join(['b' => 'bar'], 'foo.id = b.foo_id'); @@ -436,14 +458,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 + #[Test] + public function processJoinWithExpressionNameViaArray(): void { $join = new Join(); $join->join(['x' => new Expression('LATERAL(SELECT 1)')], 'true'); @@ -457,13 +480,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 + #[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 +501,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 + #[Test] + public function processJoinWithSelectSubqueryViaArray(): void { $subselect = new Select('bar'); $join = new Join(); @@ -499,14 +524,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 + #[Test] + public function processJoinWithTableIdentifier(): void { $join = new Join(); $join->join(new TableIdentifier('bar', 'myschema'), 'foo.id = bar.foo_id'); @@ -520,12 +546,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 + #[Test] + public function processSubSelectUsesDecoratorWhenPlatformDecorator(): void { $decorator = new SelectDecorator(); $outer = new Select('foo'); @@ -535,14 +562,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 + #[Test] + public function processSubSelectWithoutParameterContainer(): void { $select = new Select('foo'); @@ -556,13 +584,14 @@ public function testProcessSubSelectWithoutParameterContainer(): void null, ); - self::assertStringContainsString('SELECT', $result); + static::assertStringContainsString('SELECT', $result); } /** * @throws ReflectionException */ - public function testProcessSubSelectWithParameterContainer(): void + #[Test] + public function processSubSelectWithParameterContainer(): void { $select = new Select('foo'); $select->where(['id' => 5]); @@ -578,25 +607,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 + #[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 + #[Test] + public function resolveColumnValueWithArrayAndFromTable(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -613,11 +644,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 + #[Test] + public function resolveColumnValueWithNamedParameterPrefix(): void { $select = new Select('users'); $select->columns(['id']); @@ -640,13 +672,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 + #[Test] + public function resolveColumnValueWithNull(): void { $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -659,13 +692,14 @@ public function testResolveColumnValueWithNull(): void null, ); - self::assertEquals('NULL', $result); + static::assertSame('NULL', $result); } /** * @throws ReflectionException */ - public function testResolveColumnValueWithSelect(): void + #[Test] + public function resolveColumnValueWithSelect(): void { $select = new Select('foo'); $method = new ReflectionMethod($this->abstractSql, 'resolveColumnValue'); @@ -679,15 +713,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 + #[Test] + public function resolveTableWithSelect(): void { $select = new Select('foo'); $method = new ReflectionMethod($this->abstractSql, 'resolveTable'); @@ -700,15 +735,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 + #[Test] + public function resolveTableWithTableIdentifierAndSchema(): void { $table = new TableIdentifier('users', 'public'); $method = new ReflectionMethod($this->abstractSql, 'resolveTable'); @@ -721,8 +757,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..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,24 +18,27 @@ #[CoversMethod(Literal::class, 'getSpecification')] final class LiteralTest extends TestCase { - public function testGetSpecificationReturnsPlaceholder(): void + #[Test] + public function getSpecificationReturnsPlaceholder(): void { $literal = new Literal('test'); - self::assertSame('%s', $literal->getSpecification()); + static::assertSame('%s', $literal->getSpecification()); } - public function testGetTypeReturnsLiteral(): void + #[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 + #[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..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,8 @@ #[CoversMethod(Argument::class, 'select')] final class ArgumentTest extends TestCase { - public function testConstructorThrowsExceptionForInvalidSelectType(): void + #[Test] + public function constructorThrowsExceptionForInvalidSelectType(): void { self::expectException(TypeError::class); /** @noinspection PhpParamsInspection */ @@ -30,105 +32,118 @@ public function testConstructorThrowsExceptionForInvalidSelectType(): void new ArgumentSelect('simple_value'); /** @phpstan-ignore-line */ } - public function testConstructorWithArrayContainingArgumentType(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..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,8 @@ final class CombineTest extends TestCase protected Combine $combine; - public function testAlignColumns(): void + #[Test] + public function alignColumns(): void { $select1 = new Select('t1'); $select1->columns([ @@ -52,7 +54,7 @@ public function testAlignColumns(): void ->alignColumns(); // Verify first select has NULL for missing c2 - self::assertEquals( + static::assertEquals( [ 'c0' => 'c0', 'c1' => 'c1', @@ -62,7 +64,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 +74,8 @@ public function testAlignColumns(): void ); } - public function testAlignColumnsAppendsNullExpressionsForMissingColumns(): void + #[Test] + public function alignColumnsAppendsNullExpressionsForMissingColumns(): void { $select1 = new Select('t1'); $select1->columns(['a' => 'a']); @@ -83,47 +86,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 + #[Test] + public function alignColumnsReturnsEarlyWhenEmpty(): void { $combine = new Combine(); $result = $combine->alignColumns(); - self::assertSame($combine, $result); + static::assertSame($combine, $result); } - public function testCombineWithArrayOfSelectAndModifier(): void + #[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 + #[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 + #[Test] + public function getRawState(): void { $select = new Select('t1'); $this->combine->combine($select); - self::assertSame( + static::assertSame( [ 'combine' => [ [ @@ -140,7 +147,8 @@ public function testGetRawState(): void ); } - public function testGetSqlString(): void + #[Test] + public function getSqlString(): void { $this->combine ->union(new Select('t1')) @@ -148,7 +156,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 +164,14 @@ public function testGetSqlString(): void ); } - public function testGetSqlStringEmpty(): void + #[Test] + public function getSqlStringEmpty(): void { - self::assertEmpty($this->combine->getSqlString()); + static::assertEmpty($this->combine->getSqlString()); } - public function testGetSqlStringFromArray(): void + #[Test] + public function getSqlStringFromArray(): void { $this->combine->combine([ [new Select('t1')], @@ -169,7 +179,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 +191,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 + #[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 + #[Test] + public function prepareStatementWithModifier(): void { $select1 = new Select('t1'); $select1->where(['x1' => 10]); @@ -215,14 +227,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 + #[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..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,37 +39,41 @@ #[CoversMethod(AlterTable::class, 'processTableOptions')] class AlterTableTest extends TestCase { - public function testAddColumn(): void + #[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 + #[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 + #[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 + #[Test] + public function chainedOperations(): void { $at = new AlterTable(); $col = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -81,101 +86,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 + #[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 + #[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 + #[Test] + public function constructorWithEmptyTable(): void { $at = new AlterTable(); - self::assertEquals('', $at->getRawState('table')); + static::assertSame('', $at->getRawState('table')); } - public function testConstructorWithTable(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function getOptionsReturnsEmpty(): void { $at = new AlterTable('foo'); - self::assertEquals([], $at->getOptions()); + static::assertEquals([], $at->getOptions()); } - public function testGetRawStateIncludesTableOptions(): void + #[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 + #[Test] + public function getRawStateReturnsAllState(): void { $at = new AlterTable('test'); $colMock = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -190,49 +207,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 + #[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 + #[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 + #[Test] + public function getSqlString(): void { $at = new AlterTable('foo'); $at->addColumn(new Column\Varchar('another', 255)); @@ -253,80 +273,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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function mixedOperationsInCorrectOrder(): void { $at = new AlterTable('complex_table'); @@ -341,26 +368,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 + #[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 + #[Test] + public function multipleColumnsAndConstraints(): void { $at = new AlterTable('users'); @@ -372,15 +401,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 + #[Test] + public function multipleConstraints(): void { $at = new AlterTable('orders'); $fk1 = new Constraint\ForeignKey('fk_user', 'user_id', 'users', 'id'); @@ -390,11 +420,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 + #[Test] + public function multipleDropOperations(): void { $at = new AlterTable('products'); @@ -404,46 +435,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 + #[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 + #[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 + #[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 + #[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..839271e4 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 + */ + #[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 @@ -81,92 +105,71 @@ public function getExpressionDataOmitsLengthPlaceholderWhenLengthIsNotSet(): voi * @throws Exception */ #[Test] - public function rendersLengthDirectlyAfterType(): void + 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 + #[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..eb0190f0 100644 --- a/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php +++ b/test/unit/Sql/Ddl/Column/AbstractPrecisionColumnTest.php @@ -28,35 +28,38 @@ final class AbstractPrecisionColumnTest extends TestCase * @throws Exception */ #[Test] - public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void + 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 + public function getDigits(): void { $column = $this->getMockBuilder(AbstractPrecisionColumn::class) ->setConstructorArgs(['foo', 10]) ->onlyMethods([]) ->getMock(); + static::assertSame(10, $column->getDigits()); + } + + /** + * @throws Exception + */ + #[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 + #[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 + #[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..861484b1 100644 --- a/test/unit/Sql/Ddl/Column/BigIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/BigIntegerTest.php @@ -21,25 +21,17 @@ 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 + 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 + #[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..db473a28 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; + #[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..243c1449 100644 --- a/test/unit/Sql/Ddl/Column/BlobTest.php +++ b/test/unit/Sql/Ddl/Column/BlobTest.php @@ -20,9 +20,11 @@ final class BlobTest extends TestCase use ColumnAssertionsTrait; #[Test] - public function getExpressionDataOmitsConfiguredLength(): void + 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..32beca95 100644 --- a/test/unit/Sql/Ddl/Column/BooleanTest.php +++ b/test/unit/Sql/Ddl/Column/BooleanTest.php @@ -9,20 +9,22 @@ 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 { - public function testGetExpressionData(): void + #[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 +33,16 @@ public function testGetExpressionData(): void ); } + #[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..32d1f8e6 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; + #[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..d542a38b 100644 --- a/test/unit/Sql/Ddl/Column/ColumnTest.php +++ b/test/unit/Sql/Ddl/Column/ColumnTest.php @@ -30,43 +30,35 @@ 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 + 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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..842f379d 100644 --- a/test/unit/Sql/Ddl/Column/DateTest.php +++ b/test/unit/Sql/Ddl/Column/DateTest.php @@ -7,19 +7,21 @@ 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 { - public function testGetExpressionData(): void + #[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..244dd7ac 100644 --- a/test/unit/Sql/Ddl/Column/DatetimeTest.php +++ b/test/unit/Sql/Ddl/Column/DatetimeTest.php @@ -7,19 +7,21 @@ 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 { - public function testGetExpressionData(): void + #[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..01d5c6aa 100644 --- a/test/unit/Sql/Ddl/Column/DecimalTest.php +++ b/test/unit/Sql/Ddl/Column/DecimalTest.php @@ -30,64 +30,49 @@ final class DecimalTest extends TestCase use ColumnAssertionsTrait; #[Test] - public function getExpressionDataOmitsLengthPlaceholderWhenPrecisionIsNotSet(): void + 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()); + } + + #[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 + #[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 + #[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)); } - public function testSetDecimalAndGetDecimal(): void + #[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')); + } + + #[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 + #[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..17821db1 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; + #[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..8ce1af9c 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; + #[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..7841b8f7 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 ); } + #[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'], + ); + } + + #[Test] + public function getExpressionDataExcludesLengthWhenNotSet(): void + { + $column = new Integer('id'); + + $expressionData = $column->getExpressionData(); + + static::assertStringNotContainsString('(', $expressionData['spec']); + } + + #[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 ); } + #[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..ef544808 100644 --- a/test/unit/Sql/Ddl/Column/JsonTest.php +++ b/test/unit/Sql/Ddl/Column/JsonTest.php @@ -7,19 +7,21 @@ 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 { - public function testGetExpressionData(): void + #[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..d0f6ec51 100644 --- a/test/unit/Sql/Ddl/Column/SmallIntegerTest.php +++ b/test/unit/Sql/Ddl/Column/SmallIntegerTest.php @@ -21,25 +21,17 @@ 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 + 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 + #[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..804b8735 100644 --- a/test/unit/Sql/Ddl/Column/TextTest.php +++ b/test/unit/Sql/Ddl/Column/TextTest.php @@ -19,9 +19,11 @@ final class TextTest extends TestCase use ColumnAssertionsTrait; #[Test] - public function getExpressionDataOmitsConfiguredLength(): void + 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..65e4de1b 100644 --- a/test/unit/Sql/Ddl/Column/TimeTest.php +++ b/test/unit/Sql/Ddl/Column/TimeTest.php @@ -8,19 +8,21 @@ 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 { - public function testGetExpressionData(): void + #[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..1c1f938c 100644 --- a/test/unit/Sql/Ddl/Column/TimestampTest.php +++ b/test/unit/Sql/Ddl/Column/TimestampTest.php @@ -11,20 +11,22 @@ 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 { - public function testGetExpressionData(): void + #[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 +35,16 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataWithCurrentTimestampDefault(): void + #[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 +54,8 @@ public function testGetExpressionDataWithCurrentTimestampDefault(): void ); } - public function testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void + #[Test] + public function getExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): void { $column = new Timestamp('updated_at'); $column->setDefault(new Literal('CURRENT_TIMESTAMP')); @@ -59,8 +63,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 +75,8 @@ public function testGetExpressionDataWithCurrentTimestampDefaultAndOnUpdate(): v ); } - public function testGetExpressionDataWithOnUpdateOption(): void + #[Test] + public function getExpressionDataWithOnUpdateOption(): void { $column = new Timestamp('created_at'); $column->setOption('on_update', true); @@ -80,22 +85,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 + #[Test] + public function getExpressionDataWithoutOnUpdateOption(): void { $column = new Timestamp('updated_at'); @@ -103,14 +109,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 + #[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..12d44326 100644 --- a/test/unit/Sql/Ddl/Column/VarbinaryTest.php +++ b/test/unit/Sql/Ddl/Column/VarbinaryTest.php @@ -24,19 +24,14 @@ 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 + 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..8fb0ca20 100644 --- a/test/unit/Sql/Ddl/Column/VarcharTest.php +++ b/test/unit/Sql/Ddl/Column/VarcharTest.php @@ -28,25 +28,14 @@ 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 + 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 + #[Test] + public function inheritanceFromAbstractLengthColumn(): void { $column = new Varchar('test'); - self::assertInstanceOf(AbstractLengthColumn::class, $column); + static::assertInstanceOf(AbstractLengthColumn::class, $column); } - public function testSetLengthAndGetLength(): void + #[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)); + } + + #[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..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,22 +19,25 @@ final class AbstractConstraintTest extends TestCase { protected MockObject $ac; - public function testAddColumn(): void + #[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 + #[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 + #[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..2f501fd5 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 ); } + #[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..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,54 +33,56 @@ #[CoversMethod(ForeignKey::class, 'getExpressionData')] final class ForeignKeyTest extends TestCase { - public function testGetExpressionData(): void + #[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 + #[Test] + public function setName(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -87,19 +90,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 + #[Test] + public function setOnDeleteRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -107,19 +111,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 + #[Test] + public function setOnUpdateRule(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -127,19 +132,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 + #[Test] + public function setReferenceColumn(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -147,19 +153,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 + #[Test] + public function setReferenceTable(): void { $fk = new ForeignKey('foo', 'bar', 'baz', 'bam'); @@ -167,15 +174,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..b656a204 100644 --- a/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/PrimaryKeyTest.php @@ -7,19 +7,21 @@ 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 { - public function testGetExpressionData(): void + #[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..8eeef080 100644 --- a/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php +++ b/test/unit/Sql/Ddl/Constraint/UniqueKeyTest.php @@ -7,19 +7,21 @@ 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 { - public function testGetExpressionData(): void + #[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..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,8 @@ #[CoversMethod(CreateTable::class, 'processTableOptions')] class CreateTableTest extends TestCase { - public function testAddColumn(): void + #[Test] + public function addColumn(): void { $column = $this->getMockBuilder(ColumnInterface::class)->getMock(); $ct = new CreateTable(); @@ -44,13 +46,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 +60,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 + #[Test] + public function addConstraint(): void { $constraint = $this->getMockBuilder(ConstraintInterface::class)->getMock(); $ct = new CreateTable(); @@ -71,13 +74,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 +88,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 + #[Test] + public function chainedOperations(): void { $ct = new CreateTable(); $col1 = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -102,59 +106,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 + #[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 + #[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 + #[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 + #[Test] + public function getOptionsReturnsEmpty(): void { $ct = new CreateTable('foo'); - self::assertEquals([], $ct->getOptions()); + static::assertEquals([], $ct->getOptions()); } - public function testGetRawStateIncludesTableOptions(): void + #[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 + #[Test] + public function getRawStateReturnsAllState(): void { $ct = new CreateTable('users'); $col = $this->getMockBuilder(ColumnInterface::class)->getMock(); @@ -165,47 +175,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 + #[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 + #[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 +225,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 +233,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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function multipleColumns(): void { $ct = new CreateTable('users'); $ct->addColumn(new Column('id')); @@ -355,104 +378,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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..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,47 +17,51 @@ #[CoversMethod(DropTable::class, 'processTable')] class DropTableTest extends TestCase { - public function testGetSqlString(): void + #[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 + #[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 + #[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 + #[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..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,14 +17,15 @@ #[CoversMethod(Index::class, 'getExpressionData')] final class IndexTest extends TestCase { - public function testGetExpressionData(): void + #[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 +34,16 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataWithBtreeType(): void + #[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 +53,16 @@ public function testGetExpressionDataWithBtreeType(): void ); } - public function testGetExpressionDataWithHashType(): void + #[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 +72,15 @@ public function testGetExpressionDataWithHashType(): void ); } - public function testGetExpressionDataWithLength(): void + #[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 +90,15 @@ public function testGetExpressionDataWithLength(): void ); } - public function testGetExpressionDataWithLengthUnmatched(): void + #[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 +108,16 @@ public function testGetExpressionDataWithLengthUnmatched(): void ); } - public function testGetExpressionDataWithTypeAndLengths(): void + #[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 +128,14 @@ public function testGetExpressionDataWithTypeAndLengths(): void ); } - public function testSetTypeAndGetType(): void + #[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..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,91 +48,101 @@ final class DeleteTest extends TestCase protected Delete $delete; - public function testConstructorWithTable(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function magicGetReturnsWhereClause(): void { $where = $this->delete->where; - self::assertInstanceOf(Where::class, $where); + static::assertInstanceOf(Where::class, $where); } - public function testPrepareStatement(): void + #[Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockAdapter = $this->createMockAdapter($mockDriver); @@ -139,7 +150,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 +165,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); } + #[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()); } + #[Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $deleteIgnore = new DeleteIgnore(); @@ -188,7 +201,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 +217,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 +229,8 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt * @throws ReflectionException * @todo REMOVE THIS IN 3.x */ - public function testWhere(): void + #[Test] + public function where(): void { $this->delete->where('x = y'); $this->delete->where(['foo > ?' => 5]); @@ -229,45 +243,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); }); } + #[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 +291,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..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,37 +44,41 @@ public static function falsyExpressionParametersProvider(): array ]; } + #[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 + #[Test] + public function constructorWithInvalidParameter(): void { self::expectException(TypeError::class); new Expression('?', (object) []); } - public function testConstructorWithLiteralZero(): void + #[Test] + public function constructorWithLiteralZero(): void { $expression = new Expression('0'); - self::assertSame('0', $expression->getExpression()); + static::assertSame('0', $expression->getExpression()); } - public function testConstructorWithMultipleArguments(): void + #[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 +88,8 @@ public function testConstructorWithMultipleArguments(): void ); } - public function testGetExpressionData(): void + #[Test] + public function getExpressionData(): void { $expression = new Expression( 'X SAME AS ? AND Y = ? BUT LITERALLY ?', @@ -96,8 +102,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 +113,8 @@ public function testGetExpressionData(): void ); } - public function testGetExpressionDataThrowsExceptionWhenParameterCountMismatch(): void + #[Test] + public function getExpressionDataThrowsExceptionWhenParameterCountMismatch(): void { $expression = new Expression('? AND ?', [1]); // Two placeholders but only one parameter @@ -118,52 +125,57 @@ public function testGetExpressionDataThrowsExceptionWhenParameterCountMismatch() $expression->getExpressionData(); } - public function testGetExpressionDataUsesRegexWhenPlaceholderCountMismatches(): void + #[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 + #[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']); } + #[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 + #[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 + #[Test] + public function numberOfReplacementsForExpressionWithParameters(): void { $expression = new Expression(':a + :b', ['a' => 1, 'b' => 2]); $value1 = Argument::value(1); @@ -171,11 +183,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 + #[Test] + public function setExpression(): void { $expression = new Expression(); @@ -183,19 +196,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 + #[Test] + public function setExpressionException(): void { $expression = new Expression(); self::expectException(TypeError::class); @@ -208,7 +222,8 @@ public function testSetExpressionException(): void $expression->setExpression(''); } - public function testSetExpressionThrowsOnEmptyString(): void + #[Test] + public function setExpressionThrowsOnEmptyString(): void { $expression = new Expression(); @@ -216,7 +231,8 @@ public function testSetExpressionThrowsOnEmptyString(): void $expression->setExpression(''); } - public function testSetParameters(): void + #[Test] + public function setParameters(): void { $expression = new Expression(); @@ -224,25 +240,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 + #[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..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,78 +37,85 @@ final class InsertIgnoreTest extends TestCase protected InsertIgnore $insert; // @codingStandardsIgnoreStart - public function test__get(): void + #[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 + #[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 + #[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 + #[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 + #[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 */ + #[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 + #[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 +126,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 +136,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 + #[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 + #[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 + #[Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -176,7 +187,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 +206,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 +215,8 @@ public function testPrepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - public function testPrepareStatementWithSelect(): void + #[Test] + public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -220,21 +232,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 + #[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 +257,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 + #[Test] + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $replace = new Replace(); @@ -264,7 +278,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 +298,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 +306,40 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $replace->prepareStatement($mockAdapter, $mockStatement); } - public function testValues(): void + #[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')); } + #[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 + #[Test] + public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -334,13 +351,15 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - public function testValuesThrowsExceptionWhenNotArrayOrSelect(): void + #[Test] + public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); $this->insert->values(5); } - public function testValuesThrowsExceptionWhenSelectMergeOverArray(): void + #[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..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,87 +55,94 @@ final class InsertTest extends TestCase protected Insert $insert; // @codingStandardsIgnoreStart - public function test__get(): void + #[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 + #[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 + #[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 + #[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 + #[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 */ + #[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 + #[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 +153,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 +163,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 + #[Test] + public function getSqlStringThrowsExceptionWhenNoValuesOrSelect(): void { $this->insert->into('foo'); @@ -177,37 +186,41 @@ public function testGetSqlStringThrowsExceptionWhenNoValuesOrSelect(): void $this->insert->getSqlString(new TrustingSql92Platform()); } - public function testGetSqlStringUsingColumnsAndValuesMethods(): void + #[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 + #[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 + #[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 + #[Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -219,7 +232,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 +251,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 +260,8 @@ public function testPrepareStatement(): void $this->insert->prepareStatement($mockAdapter, $mockStatement); } - public function testPrepareStatementCreatesParameterContainerWhenNotPresent(): void + #[Test] + public function prepareStatementCreatesParameterContainerWhenNotPresent(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -260,21 +274,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 + #[Test] + public function prepareStatementWithSelect(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -290,18 +305,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 + #[Test] + public function processInsertWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -317,18 +333,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); } + #[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 +355,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()), ); } + #[Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $replace = new Replace(); @@ -359,7 +377,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 +397,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 +405,48 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt $replace->prepareStatement($mockAdapter, $mockStatement); } - public function testUnsetThrowsExceptionForNonExistentColumn(): void + #[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 + #[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')); } + #[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 + #[Test] + public function valuesThrowsExceptionWhenArrayMergeOverSelect(): void { $this->insert->values(new Select()); @@ -436,14 +458,16 @@ public function testValuesThrowsExceptionWhenArrayMergeOverSelect(): void $this->insert->values(['foo' => 'bar'], Insert::VALUES_MERGE); } - public function testValuesThrowsExceptionWhenNotArrayOrSelect(): void + #[Test] + public function valuesThrowsExceptionWhenNotArrayOrSelect(): void { self::expectException(TypeError::class); /** @psalm-suppress InvalidArgument */ $this->insert->values(5); } - public function testValuesThrowsExceptionWhenSelectMergeOverArray(): void + #[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..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,18 +32,20 @@ class JoinTest extends TestCase { use DeprecatedAssertionsTrait; + #[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 + #[Test] + public function currentReturnsTheCurrentJoinSpecification(): void { $name = 'baz'; $on = 'foo.id = baz.id'; @@ -57,35 +60,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 + #[Test] + public function initialPositionIsZero(): void { $join = new Join(); - self::assertAttributeEquals(0, 'position', $join); + static::assertAttributeSame(0, 'position', $join); } + #[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 + #[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 + #[Test] + public function joinThrowsOnInvalidMultiElementArray(): void { $join = new Join(); @@ -94,7 +101,8 @@ public function testJoinThrowsOnInvalidMultiElementArray(): void $join->join(['a' => 'b', 'c' => 'd'], 'on'); } - public function testJoinWillThrowAnExceptionIfNameIsNoValid(): void + #[Test] + public function joinWillThrowAnExceptionIfNameIsNoValid(): void { $join = new Join(); @@ -103,7 +111,8 @@ public function testJoinWillThrowAnExceptionIfNameIsNoValid(): void $join->join([], false); } - public function testKeyReturnsTheCurrentPosition(): void + #[Test] + public function keyReturnsTheCurrentPosition(): void { $join = new Join(); @@ -111,56 +120,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 + #[Test] + public function nextIncrementsThePosition(): void { $join = new Join(); $join->next(); - self::assertAttributeEquals(1, 'position', $join); + static::assertAttributeSame(1, 'position', $join); } + #[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 + #[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 + #[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..f88cd104 100644 --- a/test/unit/Sql/LiteralTest.php +++ b/test/unit/Sql/LiteralTest.php @@ -5,49 +5,54 @@ namespace PhpDbTest\Sql; use PhpDb\Sql\Literal; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class LiteralTest extends TestCase { - public function testGetExpressionData(): void + #[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 + #[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 + #[Test] + public function getLiteral(): void { $literal = new Literal('bar'); - self::assertEquals('bar', $literal->getLiteral()); + static::assertSame('bar', $literal->getLiteral()); } - public function testSetLiteral(): void + #[Test] + public function setLiteral(): void { $literal = new Literal('bar'); @@ -55,15 +60,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..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,18 +32,20 @@ final class AbstractPlatformTest extends TestCase { private AbstractPlatform $platform; - public function testGetSqlStringDelegatesToDecoratorSubject(): void + #[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 + #[Test] + public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $subject = $this->createMock(PreparableSqlInterface::class); $this->platform->setSubject($subject); @@ -56,7 +59,8 @@ public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void $this->platform->getSqlString(); } - public function testGetTypeDecoratorLoopMatchesByInstanceof(): void + #[Test] + public function getTypeDecoratorLoopMatchesByInstanceof(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $decorator->method('setSubject')->willReturnSelf(); @@ -66,19 +70,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 + #[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 + #[Test] + public function prepareStatementDelegatesToDecoratorSubject(): void { $select = new Select('foo'); $select->where(['id' => 1]); @@ -100,11 +106,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 + #[Test] + public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $subject = $this->createMock(SqlInterface::class); $this->platform->setSubject($subject); @@ -121,23 +128,25 @@ public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void $this->platform->prepareStatement($adapter, $statement); } - public function testSetAndGetTypeDecorator(): void + #[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 + #[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..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,8 @@ #[CoversMethod(Platform::class, 'getDefaultPlatform')] class PlatformTest extends TestCase { - public function testGetDefaultPlatformReturnsInstance(): void + #[Test] + public function getDefaultPlatformReturnsInstance(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -48,10 +50,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 + #[Test] + public function getSqlStringDelegatesToTypeDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -61,11 +64,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 + #[Test] + public function getSqlStringThrowsWhenSubjectNotSqlInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -77,7 +81,8 @@ public function testGetSqlStringThrowsWhenSubjectNotSqlInterface(): void $platform->getSqlString($adapterPlatform); } - public function testGetTypeDecoratorFallsThroughWhenNoMatch(): void + #[Test] + public function getTypeDecoratorFallsThroughWhenNoMatch(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -88,10 +93,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 + #[Test] + public function getTypeDecoratorMatchesByInstanceofLoop(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -102,10 +108,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 + #[Test] + public function getTypeDecoratorMatchesExactClass(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -117,10 +124,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 + #[Test] + public function getTypeDecoratorReturnsSubjectWhenNoDecoratorRegistered(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -128,10 +136,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 + #[Test] + public function prepareStatementThrowsWhenSubjectNotPreparable(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -149,38 +158,41 @@ public function testPrepareStatementThrowsWhenSubjectNotPreparable(): void /** * @throws ReflectionException */ - public function testResolveDefaultPlatform(): void + #[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 + #[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 + #[Test] + public function resolvePlatformNameCachesResult(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -190,11 +202,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 + #[Test] + public function resolvePlatformWithAdapterInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -208,10 +221,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 + #[Test] + public function resolvePlatformWithPlatformInterface(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -221,10 +235,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 + #[Test] + public function setTypeDecoratorRegistersDecorator(): void { $adapterPlatform = new TestAsset\TrustingSql92Platform(); $platform = new Platform($adapterPlatform); @@ -233,8 +248,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..1a4d2583 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 + 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 + #[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()); } - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + /** + * 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']); + } + + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..f6bc50ab 100644 --- a/test/unit/Sql/Predicate/ExpressionTest.php +++ b/test/unit/Sql/Predicate/ExpressionTest.php @@ -12,138 +12,155 @@ 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 { + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[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()); } + #[Test] #[Group('6849')] - public function testCanPassNoParameterToConstructor(): void + public function canPassNoParameterToConstructor(): void { $expression = new Expression('foo.bar'); - self::assertEquals([], $expression->getParameters()); + static::assertEquals([], $expression->getParameters()); } + #[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()); } + #[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()); } + #[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 + #[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 + #[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 + #[Test] + public function parameterIsMutable(): void { $expression = new Expression(); @@ -151,40 +168,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 + #[Test] + public function retrievingWherePartsReturnsSpecificationArrayOfLiteralAndParametersAndArrayOfTypes(): void { $expression = new Expression(); $expression->setExpression('foo.bar = ? AND id != ?') @@ -195,7 +213,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..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,48 +26,52 @@ #[Group('unit')] final class InTest extends TestCase { - public function testCanPassIdentifierAndEmptyValueSetToConstructor(): void + #[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 + #[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 + #[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 + #[Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $in = new In(); $in->setValueSet([1, 2]); @@ -76,7 +81,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $in->getExpressionData(); } - public function testGetExpressionDataThrowsExceptionWhenValueSetNotSet(): void + #[Test] + public function getExpressionDataThrowsExceptionWhenValueSetNotSet(): void { $in = new In(); $in->setIdentifier('foo'); @@ -86,17 +92,19 @@ public function testGetExpressionDataThrowsExceptionWhenValueSetNotSet(): void $in->getExpressionData(); } - public function testGetExpressionDataWithEmptyValues(): void + #[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 + #[Test] + public function getExpressionDataWithSubselect(): void { $select = new Select(); $in = new In(Argument::value('foo'), $select); @@ -104,24 +112,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 + #[Test] + public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); $in = new In(Argument::identifiers(['foo', 'bar']), $select); @@ -129,24 +138,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 + #[Test] + public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); $in = new In(Argument::identifier('foo'), $select); @@ -154,24 +164,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 + #[Test] + public function identifierIsMutable(): void { $in = new In(); @@ -179,25 +190,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 + #[Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new In(); $in->setIdentifier('foo.bar') @@ -206,21 +218,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 +245,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 +266,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 + #[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 + #[Test] + public function setValueSetWithSelectWrapsInArgumentSelect(): void { $in = new In(); $select = new Select('users'); @@ -275,11 +289,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 + #[Test] + public function valueSetIsMutable(): void { $in = new In(); @@ -287,21 +302,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..08713269 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 { + #[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()); + } + + #[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 + #[Test] + public function getExpressionDataThrowsExceptionWhenIdentifierNotSet(): void { $isNull = new IsNull(); @@ -63,7 +66,8 @@ public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void $isNull->getExpressionData(); } - public function testIdentifierIsMutable(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..99de09fd 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 + 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 + #[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 + #[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 + #[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()); } - public function testGetExpressionDataThrowsExceptionWhenIdentifierNotSet(): void + /** + * 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']); + } + + #[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 + #[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 + #[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..ab68f0c6 100644 --- a/test/unit/Sql/Predicate/LiteralTest.php +++ b/test/unit/Sql/Predicate/LiteralTest.php @@ -5,26 +5,30 @@ namespace PhpDbTest\Sql\Predicate; use PhpDb\Sql\Predicate\Literal; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; class LiteralTest extends TestCase { - public function testGetExpressionData(): void + #[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 + #[Test] + public function getLiteral(): void { $literal = new Literal('bar'); - self::assertEquals('bar', $literal->getLiteral()); + static::assertSame('bar', $literal->getLiteral()); } - public function testSetLiteral(): void + #[Test] + public function setLiteral(): void { $literal = new Literal('bar'); @@ -32,15 +36,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..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,8 @@ final class NotBetweenTest extends TestCase { protected NotBetween $notBetween; - public function testRetrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void + #[Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $this->notBetween ->setIdentifier('foo.bar') @@ -28,26 +30,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 +59,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 + #[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..645c0cc4 100644 --- a/test/unit/Sql/Predicate/NotInTest.php +++ b/test/unit/Sql/Predicate/NotInTest.php @@ -9,11 +9,13 @@ 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 { - public function testGetExpressionDataWithSubselect(): void + #[Test] + public function getExpressionDataWithSubselect(): void { $select = new Select(); $in = new NotIn('foo', $select); @@ -21,24 +23,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 + #[Test] + public function getExpressionDataWithSubselectAndArrayIdentifier(): void { $select = new Select(); $in = new NotIn(Argument::identifiers(['foo', 'bar']), $select); @@ -46,24 +49,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 + #[Test] + public function getExpressionDataWithSubselectAndIdentifier(): void { $select = new Select(); $in = new NotIn('foo', $select); @@ -71,24 +75,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 + #[Test] + public function retrievingWherePartsReturnsSpecificationArrayOfIdentifierAndValuesAndArrayOfTypes(): void { $in = new NotIn(); $in->setIdentifier('foo.bar') @@ -97,20 +102,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..65740143 100644 --- a/test/unit/Sql/Predicate/NotLikeTest.php +++ b/test/unit/Sql/Predicate/NotLikeTest.php @@ -8,11 +8,13 @@ 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 { - public function testAccessorsMutators(): void + #[Test] + public function accessorsMutators(): void { $notLike = new NotLike(); @@ -20,101 +22,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 + #[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 + #[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 + #[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 + #[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..f6510c68 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 + 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 + #[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 + #[Test] + public function emptyConstructorYieldsNullLeftAndRightValues(): void { $operator = new Operator(); - self::assertNull($operator->getLeft()); - self::assertNull($operator->getRight()); + static::assertNull($operator->getLeft()); + static::assertNull($operator->getRight()); } - public function testGetExpressionDataThrowsExceptionWhenLeftNotSet(): void + /** + * 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']); + } + + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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..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,8 @@ final class PredicateSetTest extends TestCase /** * @throws ReflectionException */ - public function testAddPredicates(): void + #[Test] + public function addPredicates(): void { $predicateSet = new PredicateSet(); @@ -52,36 +54,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 +94,8 @@ public function testAddPredicates(): void $predicateSet->addPredicates(null); } - public function testAddPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): void + #[Test] + public function addPredicatesThrowsWhenStringKeyUsedWithPredicateInterface(): void { $predicateSet = new PredicateSet(); $mock = $this->createMock(PredicateInterface::class); @@ -107,7 +110,8 @@ public function testAddPredicatesThrowsWhenStringKeyUsedWithPredicateInterface() * * @throws ReflectionException */ - public function testAddPredicatesWithExpression(): void + #[Test] + public function addPredicatesWithExpression(): void { $predicateSet = new PredicateSet(); @@ -116,17 +120,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 +138,8 @@ public function testAddPredicatesWithExpression(): void * * @throws ReflectionException */ - public function testAddPredicatesWithMultipleExpressions(): void + #[Test] + public function addPredicatesWithMultipleExpressions(): void { $predicateSet = new PredicateSet(); @@ -143,14 +148,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 + #[Test] + public function addPredicateThrowsOnInvalidCombination(): void { $predicateSet = new PredicateSet(); @@ -159,7 +165,8 @@ public function testAddPredicateThrowsOnInvalidCombination(): void $predicateSet->addPredicate(new IsNull('foo'), 'XOR'); } - public function testCanPassBothPredicateAndCombinationToAddPredicate(): void + #[Test] + public function canPassBothPredicateAndCombinationToAddPredicate(): void { $predicateSet = new PredicateSet(); $predicateSet->addPredicate(new IsNull('foo'), 'OR') @@ -170,14 +177,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 + #[Test] + public function canPassPredicatesAndDefaultCombinationViaConstructor(): void { new PredicateSet(); $predicateSet = new PredicateSet([ @@ -188,12 +196,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 + #[Test] + public function canUseOrPredicateAndAndPredicateMethods(): void { $predicateSet = new PredicateSet(); $predicateSet->orPredicate(new IsNull('foo')) @@ -204,14 +213,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 + #[Test] + public function combinationIsAndByDefault(): void { $predicateSet = new PredicateSet(); $predicateSet->addPredicate(new IsNull('foo')) @@ -220,24 +230,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 + #[Test] + public function emptyConstructorYieldsCountOfZero(): void { $predicateSet = new PredicateSet(); - self::assertCount(0, $predicateSet); + static::assertCount(0, $predicateSet); } - public function testGetExpressionDataReturnsEmptyWhenNoPredicates(): void + #[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..98c261fb 100644 --- a/test/unit/Sql/Predicate/PredicateTest.php +++ b/test/unit/Sql/Predicate/PredicateTest.php @@ -14,13 +14,15 @@ 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 { - public function testBetweenCreatesBetweenPredicate(): void + #[Test] + public function betweenCreatesBetweenPredicate(): void { $predicate = new Predicate(); $predicate->between('foo.bar', 1, 10); @@ -31,14 +33,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 + #[Test] + public function betweenCreatesNotBetweenPredicate(): void { $predicate = new Predicate(); $predicate->notBetween('foo.bar', 1, 10); @@ -49,14 +52,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 + #[Test] + public function canChainPredicateFactoriesBetweenOperators(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar')->or->isNotNull('bar.baz') @@ -70,16 +74,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 + #[Test] + public function canNestPredicates(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar') @@ -97,16 +102,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 + #[Test] + public function equalToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->equalTo('foo.bar', 'bar'); @@ -116,28 +122,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]); } + #[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']); } + #[Test] #[TestDox('Unit test: Test expression() allows null $parameters')] - public function testExpressionNullParameters(): void + public function expressionNullParameters(): void { $predicate = new Predicate(); @@ -147,14 +155,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 + #[Test] + public function greaterThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->greaterThan('foo.bar', 'bar'); @@ -164,13 +173,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 + #[Test] + public function greaterThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->greaterThanOrEqualTo('foo.bar', 'bar'); @@ -180,13 +190,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 + #[Test] + public function inCreatesInPredicate(): void { $predicate = new Predicate(); $predicate->in('foo.bar', ['foo', 'bar']); @@ -196,13 +207,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 + #[Test] + public function isNotNullCreatesIsNotNullPredicate(): void { $predicate = new Predicate(); $predicate->isNotNull('foo.bar'); @@ -211,12 +223,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 + #[Test] + public function isNullCreatesIsNullPredicate(): void { $predicate = new Predicate(); $predicate->isNull('foo.bar'); @@ -225,12 +238,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 + #[Test] + public function lessThanCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->lessThan('foo.bar', 'bar'); @@ -240,13 +254,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 + #[Test] + public function lessThanOrEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->lessThanOrEqualTo('foo.bar', 'bar'); @@ -256,13 +271,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 + #[Test] + public function likeCreatesLikePredicate(): void { $predicate = new Predicate(); $predicate->like('foo.bar', 'bar%'); @@ -272,25 +288,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]); } + #[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 +317,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 +328,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 + #[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 + #[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 + #[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 + #[Test] + public function notEqualToCreatesOperatorPredicate(): void { $predicate = new Predicate(); $predicate->notEqualTo('foo.bar', 'bar'); @@ -356,13 +377,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 + #[Test] + public function notInCreatesNotInPredicate(): void { $predicate = new Predicate(); $predicate->notIn('foo.bar', ['foo', 'bar']); @@ -372,13 +394,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 + #[Test] + public function notLikeCreatesLikePredicate(): void { $predicate = new Predicate(); $predicate->notLike('foo.bar', 'bar%'); @@ -388,24 +411,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 + #[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 + #[Test] + public function unnestThrowsWhenNotNested(): void { $predicate = new Predicate(); @@ -420,7 +445,8 @@ public function testUnnestThrowsWhenNotNested(): void /** * @throws ErrorException */ - public function testWillBindSqlParametersToExpressionsWithGivenParameter(): void + #[Test] + public function willBindSqlParametersToExpressionsWithGivenParameter(): void { $where = new Predicate(); @@ -428,7 +454,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 +463,8 @@ public function testWillBindSqlParametersToExpressionsWithGivenParameter(): void /** * @throws ErrorException */ - public function testWillBindSqlParametersToExpressionsWithGivenStringParameter(): void + #[Test] + public function willBindSqlParametersToExpressionsWithGivenStringParameter(): void { $where = new Predicate(); @@ -445,7 +472,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..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,8 +834,9 @@ public static function providerData(): array // phpcs:enable Generic.Files.LineLength.TooLong } + #[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 +844,8 @@ public function testBadJoin(): void $select->join(['foo'], 'x = y'); } - public function testCloneDeepCopiesAllSubObjects(): void + #[Test] + public function cloneDeepCopiesAllSubObjects(): void { $select = new Select(); $select->from('foo'); @@ -855,32 +858,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); } + #[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()); } + #[Test] #[TestDox('unit test: Test columns() returns Select object (is chainable)')] - public function testColumns(): void + public function columns(): void { $select = new Select(); @@ -888,42 +893,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 + #[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 + #[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); } + #[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 +940,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 +956,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 + #[Test] + public function combineThrowsWhenAlreadyCombined(): void { $select = new Select(); $select->from('t1'); @@ -962,7 +971,8 @@ public function testCombineThrowsWhenAlreadyCombined(): void $select->combine(new Select('t3')); } - public function testCombineWrapsStatementInParentheses(): void + #[Test] + public function combineWrapsStatementInParentheses(): void { $select1 = new Select(); $select1->from('t1'); @@ -974,19 +984,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 + #[Test] + public function construct(): void { $select = new Select('foo'); - self::assertEquals('foo', $select->getRawState('table')); + static::assertSame('foo', $select->getRawState('table')); } + #[Test] #[TestDox('unit test: Test from() returns Select object (is chainable)')] - public function testFrom(): void + public function from(): void { $select = new Select(); @@ -994,19 +1006,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 + #[Test] + public function fromThrowsExceptionForInvalidArrayFormat(): void { $select = new Select(); @@ -1015,7 +1028,8 @@ public function testFromThrowsExceptionForInvalidArrayFormat(): void $select->from(['foo', 'bar']); // Numeric array instead of associative } - public function testFromThrowsExceptionForInvalidTableType(): void + #[Test] + public function fromThrowsExceptionForInvalidTableType(): void { $select = new Select(); @@ -1024,7 +1038,8 @@ public function testFromThrowsExceptionForInvalidTableType(): void $select->from(123); } - public function testFromThrowsExceptionWhenTableReadOnly(): void + #[Test] + public function fromThrowsExceptionWhenTableReadOnly(): void { $select = new Select('foo'); // Creating with table makes it read-only @@ -1035,37 +1050,41 @@ public function testFromThrowsExceptionWhenTableReadOnly(): void $select->from('bar'); } - public function testFromWithAliasArrayResolvesTableAndAlias(): void + #[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 + #[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 */ + #[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 + #[Test] + public function getThrowsExceptionForInvalidProperty(): void { $select = new Select(); @@ -1075,8 +1094,9 @@ public function testGetThrowsExceptionForInvalidProperty(): void $value = $select->invalidProperty; /** @phpstan-ignore-line */ } + #[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 +1104,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')); } + #[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 +1126,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()); } + #[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 +1152,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()); } + #[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')); } + #[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()); } + #[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 +1188,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 +1210,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']); } + #[Test] #[TestDox(': unit test: test limit()')] - public function testLimit(): void + public function limit(): void { $select = new Select(); @@ -1198,22 +1224,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)); } + #[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 +1248,25 @@ public function testLimitExceptionOnInvalidParameter(): void $select->limit('foobar'); } + #[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 + #[Test] + public function magicGetJoinsReturnsJoinInstance(): void { $select = new Select(); - self::assertInstanceOf(Join::class, $select->joins); + static::assertInstanceOf(Join::class, $select->joins); } + #[Test] #[TestDox(': unit test: test offset()')] - public function testOffset(): void + public function offset(): void { $select = new Select(); @@ -1244,22 +1274,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)); } + #[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 +1301,30 @@ public function testOffsetExceptionOnInvalidParameter(): void /** * @throws ReflectionException */ + #[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 +1339,63 @@ public function testOrder(): void ); $sr = new ReflectionObject($select); $method = $sr->getMethod('processOrder'); - self::assertEquals( + static::assertEquals( [[['"rating" < \'10\'']]], $method->invokeArgs($select, [new TrustingSql92Platform()]), ); } + #[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 + #[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 + #[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 + #[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 */ + #[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 +1414,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 +1427,11 @@ public function testPrepareStatement( * @throws ReflectionException * @noinspection PhpUnusedParameterInspection */ + #[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 +1457,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); } } + #[Test] #[TestDox('unit test: Test quantifier() returns Select object (is chainable)')] - public function testQuantifier(): void + public function quantifier(): void { $select = new Select(); @@ -1432,128 +1471,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')); } + #[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), ); } + #[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 + #[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 + #[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 + #[Test] + public function resetTableThrowsWhenTableReadOnly(): void { $select = new Select('foo'); @@ -1562,37 +1606,41 @@ public function testResetTableThrowsWhenTableReadOnly(): void $select->reset(Select::TABLE); } - public function testResetThrowsOnInvalidPart(): void + #[Test] + public function resetThrowsOnInvalidPart(): void { $select = new Select(); $result = $select->reset('invalid'); - self::assertSame($select, $result); + static::assertSame($select, $result); } + #[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 + #[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 + #[Test] + public function setSpecificationThrowsExceptionForInvalidName(): void { $select = new Select(); @@ -1601,8 +1649,9 @@ public function testSetSpecificationThrowsExceptionForInvalidName(): void $select->setSpecification('invalid_spec', 'some spec'); } + #[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 +1660,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()); } + #[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 +1677,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()); } + #[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 +1701,10 @@ public function testWhereArgument1IsAssociativeArrayIsPredicate(): void $select->where($where); } + #[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 +1717,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 +1737,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]); } + #[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 +1754,9 @@ public function testWhereArgument1IsClosure(): void }); } + #[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 +1764,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()); } + #[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 +1782,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()); } + #[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 +1803,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]); } + #[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 +1817,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 +1829,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]); } + #[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')); } + #[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..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,29 +50,32 @@ final class SqlTest extends TestCase protected Sql $sql; // @codingStandardsIgnoreStart - public function test__construct(): void + #[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 + #[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 + #[Test] + public function buildSqlStringThrowsWhenPlatformNotSqlInterface(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $platform = $this->createMock(PlatformInterface::class); @@ -92,12 +96,13 @@ public function testBuildSqlStringThrowsWhenPlatformNotSqlInterface(): void $sql->buildSqlString($this->sql->select()); } - public function testDelete(): void + #[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 +111,8 @@ public function testDelete(): void $this->sql->delete('bar'); } - public function testDeleteThrowsWhenTableConflicts(): void + #[Test] + public function deleteThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -115,16 +121,18 @@ public function testDeleteThrowsWhenTableConflicts(): void $this->sql->delete(new TableIdentifier('bar')); } - public function testGetSqlPlatformReturnsPlatformDecorator(): void + #[Test] + public function getSqlPlatformReturnsPlatformDecorator(): void { - self::assertInstanceOf(PlatformDecoratorInterface::class, $this->sql->getSqlPlatform()); + static::assertInstanceOf(PlatformDecoratorInterface::class, $this->sql->getSqlPlatform()); } - public function testInsert(): void + #[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 +141,8 @@ public function testInsert(): void $this->sql->insert('bar'); } - public function testInsertThrowsWhenTableConflicts(): void + #[Test] + public function insertThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -142,14 +151,16 @@ public function testInsertThrowsWhenTableConflicts(): void $this->sql->insert(new TableIdentifier('bar')); } - public function testPrepareStatementForSqlObject(): void + #[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 + #[Test] + public function prepareStatementThrowsWhenPlatformNotPreparable(): void { $decorator = $this->createMock(PlatformDecoratorInterface::class); $platform = $this->createMock(PlatformInterface::class); @@ -170,11 +181,12 @@ public function testPrepareStatementThrowsWhenPlatformNotPreparable(): void $sql->prepareStatementForSqlObject($this->sql->select()); } - public function testSelect(): void + #[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 +195,8 @@ public function testSelect(): void $this->sql->select('bar'); } - public function testSelectThrowsWhenTableConflicts(): void + #[Test] + public function selectThrowsWhenTableConflicts(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -192,11 +205,12 @@ public function testSelectThrowsWhenTableConflicts(): void $this->sql->select(new TableIdentifier('bar')); } - public function testUpdate(): void + #[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 +219,8 @@ public function testUpdate(): void $this->sql->update('bar'); } - public function testUpdateThrowsWhenTableConflicts(): void + #[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..0fcf8a10 100644 --- a/test/unit/Sql/TableIdentifierFactoryTest.php +++ b/test/unit/Sql/TableIdentifierFactoryTest.php @@ -8,102 +8,114 @@ 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 { - public function testCallTimePrefixIsAppliedWhenNonePreconfigured(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function prefixIsNullByDefault(): void { $factory = new TableIdentifierFactory(); - self::assertNull($factory->getPrefix()); + static::assertNull($factory->getPrefix()); } - public function testRejectsEmptyStringCallTimePrefix(): void + #[Test] + public function rejectsEmptyStringCallTimePrefix(): void { $factory = new TableIdentifierFactory('backup'); @@ -112,7 +124,8 @@ public function testRejectsEmptyStringCallTimePrefix(): void $factory('users', null, ''); } - public function testRejectsEmptyStringCallTimeSeparator(): void + #[Test] + public function rejectsEmptyStringCallTimeSeparator(): void { $factory = new TableIdentifierFactory('backup'); @@ -121,59 +134,67 @@ public function testRejectsEmptyStringCallTimeSeparator(): void $factory('users', null, null, ''); } - public function testRejectsEmptyStringPrefix(): void + #[Test] + public function rejectsEmptyStringPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_PREFIX); new TableIdentifierFactory(''); } - public function testRejectsEmptyStringSeparator(): void + #[Test] + public function rejectsEmptyStringSeparator(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifierFactory('backup', ''); } - public function testRejectsEmptyStringSeparatorWithoutPrefix(): void + #[Test] + public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifierFactory(null, ''); } - public function testReturnsConfiguredPrefix(): void + #[Test] + public function returnsConfiguredPrefix(): void { $factory = new TableIdentifierFactory('backup'); - self::assertSame('backup', $factory->getPrefix()); + static::assertSame('backup', $factory->getPrefix()); } - public function testReturnsConfiguredSeparator(): void + #[Test] + public function returnsConfiguredSeparator(): void { $factory = new TableIdentifierFactory('backup', '__'); - self::assertSame('__', $factory->getSeparator()); + static::assertSame('__', $factory->getSeparator()); } - public function testSeparatorDefaultsToUnderscore(): void + #[Test] + public function separatorDefaultsToUnderscore(): void { $factory = new TableIdentifierFactory('backup'); - self::assertSame('_', $factory->getSeparator()); + static::assertSame('_', $factory->getSeparator()); } - public function testSeparatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void + #[Test] + public function separatorDefaultsToUnderscoreWhenNoPrefixConfigured(): void { $factory = new TableIdentifierFactory(); - self::assertSame('_', $factory->getSeparator()); + static::assertSame('_', $factory->getSeparator()); } - public function testSeparatorFallsBackToDefaultWhenPassedAsNull(): void + #[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..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,151 +49,171 @@ public static function invalidTableProvider(): array ]; } - public function testGetDefaultPrefix(): void + #[Test] + public function getDefaultPrefix(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertNull($tableIdentifier->getPrefix()); + static::assertNull($tableIdentifier->getPrefix()); } - public function testGetDefaultSchema(): void + #[Test] + public function getDefaultSchema(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertNull($tableIdentifier->getSchema()); + static::assertNull($tableIdentifier->getSchema()); } - public function testGetDefaultSeparator(): void + #[Test] + public function getDefaultSeparator(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertSame('_', $tableIdentifier->getSeparator()); + static::assertSame('_', $tableIdentifier->getSeparator()); } - public function testGetPrefix(): void + #[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 + #[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 + #[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 + #[Test] + public function getSeparator(): void { $tableIdentifier = new TableIdentifier('foo', null, 'backup', '__'); - self::assertSame('__', $tableIdentifier->getSeparator()); + static::assertSame('__', $tableIdentifier->getSeparator()); } - public function testGetTable(): void + #[Test] + public function getTable(): void { $tableIdentifier = new TableIdentifier('foo'); - self::assertSame('foo', $tableIdentifier->getTable()); + static::assertSame('foo', $tableIdentifier->getTable()); } - public function testGetTableAndSchemaAppliesPrefix(): void + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[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 + #[Test] + public function rejectsEmptyStringSeparatorWithoutPrefix(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::EMPTY_SEPARATOR); new TableIdentifier('foo', null, null, ''); } + #[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); } + #[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); } + #[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); } + #[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..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,8 @@ final class UpdateTest extends TestCase protected Update $update; - public function testCloneDeepCopiesSetWhereAndJoins(): void + #[Test] + public function cloneDeepCopiesSetWhereAndJoins(): void { $this->update ->table('foo') @@ -77,21 +79,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 + #[Test] + public function cloneUpdate(): void { $update1 = clone $this->update; $update1->table('foo') @@ -104,7 +107,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 +116,38 @@ public function testCloneUpdate(): void /** * @throws ReflectionException */ - public function testConstruct(): void + #[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 + #[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 + #[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 + #[Test] + public function getRawStateReturnsAllState(): void { $this->update ->table('foo') @@ -149,28 +156,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 + #[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 +190,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()), ); } + #[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 + #[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 + #[Test] + public function getUpdate(): void { $getWhere = $this->update->__get('where'); - self::assertInstanceOf(Where::class, $getWhere); + static::assertInstanceOf(Where::class, $getWhere); } - public function testGetUpdateFails(): void + #[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 + #[Test] + public function join(): void { $this->update->table('Document'); $this->update @@ -243,18 +256,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()), ); } + #[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 +276,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 + #[Test] + public function joinMultiUpdate(): void { $this->update->table('Document'); $this->update @@ -277,14 +292,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 + #[Test] + public function joinWithTableIdentifier(): void { $this->update ->table('foo') @@ -292,23 +308,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); } + #[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 + #[Test] + public function prepareStatement(): void { $mockDriver = $this->getMockBuilder(DriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -321,7 +339,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 +362,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 +372,8 @@ public function testPrepareStatement(): void $this->update->prepareStatement($mockAdapter, $mockStatement); } - public function testProcessSetWithPdoDriverUsesDriverColumnQuoting(): void + #[Test] + public function processSetWithPdoDriverUsesDriverColumnQuoting(): void { $mockDriver = $this->getMockBuilder(PdoDriverInterface::class)->getMock(); $mockDriver->expects($this->any())->method('getPrepareType')->willReturn('positional'); @@ -371,26 +390,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 + #[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 + #[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 + #[Test] + public function setWithNonStringKeyThrowsException(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage(InvalidArgumentException::NON_STRING_VALUE_KEY); @@ -399,17 +421,19 @@ public function testSetWithNonStringKeyThrowsException(): void $this->update->set([0 => 'value']); } - public function testSetWithNumericPriority(): void + #[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 + #[Test] + public function sortableSet(): void { $this->update->set([ 'two' => 'с_two', @@ -417,7 +441,7 @@ public function testSortableSet(): void ]); $this->update->set(['one' => 'с_one'], '10'); - self::assertEquals( + static::assertEquals( [ 'one' => 'с_one', 'two' => 'с_two', @@ -427,8 +451,9 @@ public function testSortableSet(): void ); } + #[Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void + public function specificationconstantsCouldBeOverridedByExtensionInGetSqlString(): void { $this->update = new UpdateIgnore(); @@ -437,7 +462,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 +474,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()), ); } + #[Test] #[CoversNothing] - public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void + public function specificationconstantsCouldBeOverridedByExtensionInPrepareStatement(): void { $updateIgnore = new UpdateIgnore(); @@ -471,7 +497,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 +509,22 @@ public function testSpecificationconstantsCouldBeOverridedByExtensionInPrepareSt /** * @throws ReflectionException */ - public function testTable(): void + #[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 + #[Test] + public function where(): void { $this->update->where('x = y'); $this->update->where(['foo > ?' => 5]); @@ -508,34 +536,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 +574,9 @@ public function testWhere(): void $this->update->where(null); } + #[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 +586,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..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,13 +75,15 @@ final class AbstractTableGatewayTest extends TestCase protected MockObject&Update $mockUpdate; protected MockObject&Delete $mockDelete; - public function testCloneKeepsTheAdapter(): void + #[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 + #[Test] + public function cloneWithAnAliasedTableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); $aliasedTable = ['alias' => $tableIdentifier]; @@ -92,12 +95,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 + #[Test] + public function cloneWithATableIdentifier(): void { $tableIdentifier = new Sql\TableIdentifier('bar', 'schema'); @@ -108,24 +112,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 + #[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 + #[Test] + public function deleteWith(): void { $delete = $this->getMockBuilder(Delete::class) ->onlyMethods(['getRawState']) @@ -137,10 +143,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 + #[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 +157,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 + #[Test] + public function executeDeleteThrowsExceptionWhenTableDoesNotMatch(): void { $delete = new Delete('bar'); $delete->where(['id' => 1]); @@ -165,7 +173,8 @@ public function testExecuteDeleteThrowsExceptionWhenTableDoesNotMatch(): void $this->table->deleteWith($delete); } - public function testExecuteInsertThrowsExceptionWhenTableDoesNotMatch(): void + #[Test] + public function executeInsertThrowsExceptionWhenTableDoesNotMatch(): void { $insert = new Insert('bar'); $insert->values(['name' => 'test']); @@ -176,7 +185,8 @@ public function testExecuteInsertThrowsExceptionWhenTableDoesNotMatch(): void $this->table->insertWith($insert); } - public function testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void + #[Test] + public function executeSelectThrowsExceptionWhenArrayTableDoesNotMatch(): void { $select = $this->getMockBuilder(Select::class) ->onlyMethods(['getRawState']) @@ -197,7 +207,8 @@ public function testExecuteSelectThrowsExceptionWhenArrayTableDoesNotMatch(): vo $this->table->selectWith($select); } - public function testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch(): void + #[Test] + public function executeUpdateThrowsExceptionWhenTableDoesNotMatch(): void { $update = new Update('bar'); $update->set(['name' => 'test']); @@ -208,47 +219,55 @@ public function testExecuteUpdateThrowsExceptionWhenTableDoesNotMatch(): void $this->table->updateWith($update); } - public function testGetAdapter(): void + #[Test] + public function getAdapter(): void { - self::assertSame($this->mockAdapter, $this->table->getAdapter()); + static::assertSame($this->mockAdapter, $this->table->getAdapter()); } - public function testGetColumns(): void + #[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 + #[Test] + public function getFeatureSet(): void { - self::assertSame($this->mockFeatureSet, $this->table->getFeatureSet()); + static::assertSame($this->mockFeatureSet, $this->table->getFeatureSet()); } - public function testGetLastInsertValue(): void + #[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 + #[Test] + public function getSelectResultPrototype(): void { - self::assertInstanceOf(ResultSet::class, $this->table->getResultSetPrototype()); + static::assertInstanceOf(ResultSet::class, $this->table->getResultSetPrototype()); } - public function testGetSql(): void + #[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 + #[Test] + public function getTable(): void { - self::assertEquals('foo', $this->table->getTable()); + static::assertSame('foo', $this->table->getTable()); } - public function testInitializeBuildsAResultSet(): void + #[Test] + public function initializeBuildsAResultSet(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -270,10 +289,11 @@ public function testInitializeBuildsAResultSet(): void } $stub->initialize(); - $this->assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype()); + static::assertInstanceOf(ResultSet::class, $stub->getResultSetPrototype()); } - public function testInitializeEarlyReturnWhenAlreadyInitialized(): void + #[Test] + public function initializeEarlyReturnWhenAlreadyInitialized(): void { // Create a fresh mock without initialization $stub = $this->getMockBuilder(AbstractTableGateway::class) @@ -291,7 +311,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 +321,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 + #[Test] + public function initializeThrowsExceptionWithoutAdapter(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -320,7 +341,8 @@ public function testInitializeThrowsExceptionWithoutAdapter(): void $stub->initialize(); } - public function testInitializeThrowsExceptionWithoutTable(): void + #[Test] + public function initializeThrowsExceptionWithoutTable(): void { $stub = $this->getMockBuilder(AbstractTableGateway::class) ->onlyMethods([]) @@ -336,7 +358,8 @@ public function testInitializeThrowsExceptionWithoutTable(): void $stub->initialize(); } - public function testInsert(): void + #[Test] + public function insert(): void { $mockInsert = $this->mockInsert; @@ -346,29 +369,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 + #[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 + #[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 +406,11 @@ public function testIsInitialized(): void $stub->initialize(); - self::assertTrue($stub->isInitialized()); + static::assertTrue($stub->isInitialized()); } - public function testMagicCallDelegatesToTheFeatureSet(): void + #[Test] + public function magicCallDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicCall $featureSet = $this->getMockBuilder(FeatureSet::class) @@ -406,10 +432,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 + #[Test] + public function magicCallThrowsForUnknownMethod(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -420,7 +447,8 @@ public function testMagicCallThrowsForUnknownMethod(): void $this->table->invalidMethod(); } - public function testMagicGetDelegatesToTheFeatureSet(): void + #[Test] + public function magicGetDelegatesToTheFeatureSet(): void { // Create a custom feature that can handle magic get $feature = new TestTableGatewayFeature(); @@ -446,35 +474,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 + #[Test] + public function magicGetReturnsTheAdapter(): void { - self::assertSame($this->mockAdapter, $this->table->adapter); + static::assertSame($this->mockAdapter, $this->table->adapter); } - public function testMagicGetReturnsTheLastInsertValue(): void + #[Test] + public function magicGetReturnsTheLastInsertValue(): void { - self::assertNull($this->table->lastInsertValue); + static::assertNull($this->table->lastInsertValue); } - public function testMagicGetReturnsTheLastInsertValueAndAdapter(): void + #[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 + #[Test] + public function magicGetReturnsTheTable(): void { - self::assertEquals('foo', $this->table->table); + static::assertSame('foo', $this->table->table); } - public function testMagicGetThrowsForUnknownProperty(): void + #[Test] + public function magicGetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -485,7 +518,8 @@ public function testMagicGetThrowsForUnknownProperty(): void $this->table->invalidProperty; } - public function testMagicSetDelegatesToTheFeatureSet(): void + #[Test] + public function magicSetDelegatesToTheFeatureSet(): void { // Create a FeatureSet mock that returns true for canCallMagicSet $featureSet = $this->getMockBuilder(FeatureSet::class) @@ -507,7 +541,8 @@ public function testMagicSetDelegatesToTheFeatureSet(): void $this->table->customProperty = 'customValue'; } - public function testMagicSetThrowsForUnknownProperty(): void + #[Test] + public function magicSetThrowsForUnknownProperty(): void { self::expectException(InvalidArgumentException::class); self::expectExceptionMessage( @@ -518,7 +553,8 @@ public function testMagicSetThrowsForUnknownProperty(): void $this->table->invalidProperty = 'value'; } - public function testSelectAppliesColumnsWhenStarSelected(): void + #[Test] + public function selectAppliesColumnsWhenStarSelected(): void { // Set up columns on the table $tgReflection = new ReflectionClass(AbstractTableGateway::class); @@ -544,7 +580,8 @@ public function testSelectAppliesColumnsWhenStarSelected(): void $this->table->selectWith($select); } - public function testSelectWithArrayTable(): void + #[Test] + public function selectWithArrayTable(): void { // Case 1 $select1 = $this->getMockBuilder(Select::class)->onlyMethods(['getRawState'])->getMock(); @@ -555,7 +592,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 +603,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 + #[Test] + public function selectWithClosure(): void { $mockSelect = $this->mockSelect; $mockSelect->expects($this->any()) @@ -585,20 +623,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 + #[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 + #[Test] + public function selectWithWhereString(): void { $mockSelect = $this->mockSelect; $mockSelect->expects($this->any()) @@ -611,25 +651,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 + #[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 + #[Test] + public function updateWith(): void { $update = $this->getMockBuilder(Update::class) ->onlyMethods(['getRawState']) @@ -641,10 +683,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 + #[Test] + public function updateWithJoin(): void { $mockUpdate = $this->mockUpdate; @@ -659,17 +702,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 + #[Test] + public function updateWithJoinDefaultType(): void { $mockUpdate = $this->mockUpdate; @@ -683,23 +727,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 + #[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..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,8 @@ public static function aliasedTables(): array /** * Beside other tests checks for plain string table identifier */ - public function testConstructor(): void + #[Test] + public function constructor(): void { // constructor with only required args $table = new TableGateway( @@ -61,11 +63,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 +78,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 +93,8 @@ public function testConstructor(): void ); } - public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void + #[Test] + public function constructorThrowsExceptionWhenSqlTableDoesNotMatch(): void { $sql = new Sql($this->mockAdapter, 'bar'); @@ -103,7 +106,8 @@ public function testConstructorThrowsExceptionWhenSqlTableDoesNotMatch(): void new TableGateway('foo', $this->mockAdapter, null, null, $sql); } - public function testConstructorWithArrayOfFeatures(): void + #[Test] + public function constructorWithArrayOfFeatures(): void { $feature1 = new Feature\SequenceFeature('id', 'foo_seq'); $feature2 = new Feature\GlobalAdapterFeature(); @@ -114,50 +118,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 + #[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 + #[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 + #[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 */ + #[Test] #[DataProvider('aliasedTables')] - public function testDeleteShouldResetTableToUnaliasedTable( + public function deleteShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -194,7 +202,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 +219,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 +230,10 @@ public function testDeleteShouldResetTableToUnaliasedTable( /** * @param AliasedTable $tableValue */ + #[Test] #[DataProvider('aliasedTables')] #[Group('7311')] - public function testInsertShouldResetTableToUnaliasedTable( + public function insertShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -261,7 +270,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 +286,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'], ); } + #[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 +307,15 @@ public function testTableAsAliasedTableIdentifierObject(): void $this->mockAdapter, ); - self::assertEquals($aliasedTI, $table->getTable()); + static::assertEquals($aliasedTI, $table->getTable()); // phpcs:enable WebimpressCodingStandard.NamingConventions.ValidVariableName.NotCamelCaps } + #[Test] #[Group('6726')] #[Group('6740')] - public function testTableAsString(): void + public function tableAsString(): void { $ti = 'fooTable.barSchema'; // constructor with only required args @@ -313,12 +324,13 @@ public function testTableAsString(): void $this->mockAdapter, ); - self::assertEquals($ti, $table->getTable()); + static::assertEquals($ti, $table->getTable()); } + #[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 +339,15 @@ public function testTableAsTableIdentifierObject(): void $this->mockAdapter, ); - self::assertEquals($ti, $table->getTable()); + static::assertEquals($ti, $table->getTable()); } /** * @param AliasedTable $tableValue */ + #[Test] #[DataProvider('aliasedTables')] - public function testUpdateShouldResetTableToUnaliasedTable( + public function updateShouldResetTableToUnaliasedTable( array $tableValue, string|TableIdentifier $expected, ): void { @@ -371,7 +384,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 +402,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'], );