diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index 6120ad34e9..232b87a9fe 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -813,12 +813,12 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertEquals($eagerItemsCount, $lazyItemsCount); } - public function aliasMethodProvider() + public static function aliasMethodProvider(): array { return [ ['explicit'], // c -// ['querysyntax'], // {{@customer}} -// ['applyAlias'], // $query->applyAlias('customer', 'id') // _aliases are currently not being populated + // ['querysyntax'], // {{@customer}} + // ['applyAlias'], // $query->applyAlias('customer', 'id') // _aliases are currently not being populated // later getRelationAlias() could be added ]; } @@ -1129,7 +1129,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertInstanceOf('yiiunit\data\ar\Customer', $customerWithJoinIndexOrdered['user1']); } - public function tableNameProvider() + public static function tableNameProvider(): array { return [ ['order', 'order_item'], @@ -1895,7 +1895,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertEquals($expectedAliases, $aliases); } - public function filterTableNamesFromAliasesProvider() + public static function filterTableNamesFromAliasesProvider(): array { return [ 'table name as string' => ['customer', []], @@ -1907,7 +1907,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase ]; } - public function legalValuesForFindByCondition() + public static function legalValuesForFindByCondition(): array { return [ [Customer::class, ['id' => 1]], @@ -1938,7 +1938,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertTrue(true); } - public function illegalValuesForFindByCondition() + public static function illegalValuesForFindByCondition(): array { return [ [Customer::class, [['`id`=`id` and 1' => 1]]], @@ -2133,7 +2133,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase } } - public function providerForUnlinkDelete() + public static function providerForUnlinkDelete(): array { return [ 'with delete' => [true, 0], @@ -2180,7 +2180,7 @@ abstract class ActiveRecordTest extends DatabaseTestCase $this->assertNotNull($order->virtualCustomer); } - public function labelTestModelProvider() + public static function labelTestModelProvider(): array { $data = []; diff --git a/tests/framework/db/ColumnSchemaBuilderTest.php b/tests/framework/db/ColumnSchemaBuilderTest.php index 28b151cc22..059314baa8 100644 --- a/tests/framework/db/ColumnSchemaBuilderTest.php +++ b/tests/framework/db/ColumnSchemaBuilderTest.php @@ -27,7 +27,7 @@ abstract class ColumnSchemaBuilderTest extends DatabaseTestCase /** * @return array */ - public function typesProvider() + public static function typesProvider(): array { return [ ['integer NULL DEFAULT NULL', Schema::TYPE_INTEGER, null, [ diff --git a/tests/framework/db/CommandTest.php b/tests/framework/db/CommandTest.php index 029117c56e..8fb0bdb417 100644 --- a/tests/framework/db/CommandTest.php +++ b/tests/framework/db/CommandTest.php @@ -245,7 +245,7 @@ SQL; $this->assertEquals('user5@example.com', $command->queryScalar()); } - public function paramsNonWhereProvider() + public static function paramsNonWhereProvider(): array { return [ ['SELECT SUBSTR(name, :len) FROM {{customer}} WHERE [[email]] = :email GROUP BY SUBSTR(name, :len)'], @@ -380,7 +380,7 @@ SQL; setlocale(LC_NUMERIC, $locale); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { return [ 'issue11242' => [ @@ -615,7 +615,7 @@ SQL; * Data provider for testInsertSelectFailed. * @return array */ - public function invalidSelectColumns() + public static function invalidSelectColumns(): array { return [ [[]], @@ -805,7 +805,7 @@ SQL; $this->assertNotNull($db->getSchema()->getTableSchema($toTableName, true)); } - public function upsertProvider() + public static function upsertProvider(): array { return [ 'regular values' => [ @@ -1343,7 +1343,7 @@ SQL; * Data provider for [[testGetRawSql()]]. * @return array test data */ - public function dataProviderGetRawSql() + public static function dataProviderGetRawSql(): array { return [ [ diff --git a/tests/framework/db/SchemaTest.php b/tests/framework/db/SchemaTest.php index 3547ab4e2c..ac722ae062 100644 --- a/tests/framework/db/SchemaTest.php +++ b/tests/framework/db/SchemaTest.php @@ -28,7 +28,7 @@ abstract class SchemaTest extends DatabaseTestCase */ protected $expectedSchemas; - public function pdoAttributesProvider() + public static function pdoAttributesProvider(): array { return [ [[PDO::ATTR_EMULATE_PREPARES => true]], @@ -157,7 +157,7 @@ abstract class SchemaTest extends DatabaseTestCase $this->assertNotSame($noCacheTable, $refreshedTable); } - public function tableSchemaCachePrefixesProvider() + public static function tableSchemaCachePrefixesProvider(): array { $configs = [ [ @@ -558,7 +558,7 @@ abstract class SchemaTest extends DatabaseTestCase $this->assertSame($expected, $columnSchema->dbTypecast($value)); } - public function columnSchemaDbTypecastBooleanPhpTypeProvider() + public static function columnSchemaDbTypecastBooleanPhpTypeProvider(): array { return [ [1, true], @@ -646,7 +646,7 @@ abstract class SchemaTest extends DatabaseTestCase } } - public function constraintsProvider() + public static function constraintsProvider(): array { return [ '1: primary key' => ['T_constraints_1', 'primaryKey', new Constraint([ @@ -753,14 +753,14 @@ abstract class SchemaTest extends DatabaseTestCase ]; } - public function lowercaseConstraintsProvider() + public static function lowercaseConstraintsProvider(): array { - return $this->constraintsProvider(); + return static::constraintsProvider(); } - public function uppercaseConstraintsProvider() + public static function uppercaseConstraintsProvider(): array { - return $this->constraintsProvider(); + return static::constraintsProvider(); } /** diff --git a/tests/framework/db/cubrid/ColumnSchemaBuilderTest.php b/tests/framework/db/cubrid/ColumnSchemaBuilderTest.php index 162a655a56..e9b0314c23 100644 --- a/tests/framework/db/cubrid/ColumnSchemaBuilderTest.php +++ b/tests/framework/db/cubrid/ColumnSchemaBuilderTest.php @@ -33,7 +33,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT /** * @return array */ - public function typesProvider() + public static function typesProvider(): array { return [ ['integer UNSIGNED', Schema::TYPE_INTEGER, null, [ diff --git a/tests/framework/db/cubrid/CommandTest.php b/tests/framework/db/cubrid/CommandTest.php index 29b2add60f..1087344aed 100644 --- a/tests/framework/db/cubrid/CommandTest.php +++ b/tests/framework/db/cubrid/CommandTest.php @@ -85,7 +85,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertEquals('SELECT "id", "t"."name" FROM "customer" t', $command->sql); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { $data = parent::batchInsertSqlProvider(); $data['issue11242']['expected'] = 'INSERT INTO "type" ("int_col", "float_col", "char_col") VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')'; diff --git a/tests/framework/db/cubrid/SchemaTest.php b/tests/framework/db/cubrid/SchemaTest.php index 23f9a374f9..2855a6733a 100644 --- a/tests/framework/db/cubrid/SchemaTest.php +++ b/tests/framework/db/cubrid/SchemaTest.php @@ -87,11 +87,11 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest return $columns; } - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); foreach ($result as $name => $constraints) { - $result[$name][2] = $this->convertPropertiesToAnycase($constraints[2]); + $result[$name][2] = static::convertPropertiesToAnycase($constraints[2]); } $result['1: check'][2] = false; unset($result['1: index'][2][0]); @@ -108,27 +108,17 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest return $result; } - public function lowercaseConstraintsProvider(): void - { - $this->markTestSkipped('This test hangs on CUBRID.'); - } - - public function uppercaseConstraintsProvider(): void - { - $this->markTestSkipped('This test hangs on CUBRID.'); - } - /** * @param array|object|string $object * @param bool $isProperty * @return array|object|string */ - private function convertPropertiesToAnycase($object, $isProperty = false) + private static function convertPropertiesToAnycase($object, $isProperty = false) { if (!$isProperty && \is_array($object)) { $result = []; foreach ($object as $name => $value) { - $result[] = $this->convertPropertiesToAnycase($value); + $result[] = static::convertPropertiesToAnycase($value); } return $result; @@ -136,7 +126,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest if (\is_object($object)) { foreach (array_keys((array) $object) as $name) { - $object->$name = $this->convertPropertiesToAnycase($object->$name, true); + $object->$name = static::convertPropertiesToAnycase($object->$name, true); } } elseif (\is_array($object) || \is_string($object)) { $object = new AnyCaseValue($object); @@ -144,4 +134,26 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest return $object; } + + /** + * @dataProvider lowercaseConstraintsProvider + * @param string $tableName + * @param string $type + * @param mixed $expected + */ + public function testTableSchemaConstraintsWithPdoLowercase($tableName, $type, $expected): void + { + $this->markTestSkipped('This test hangs on CUBRID.'); + } + + /** + * @dataProvider uppercaseConstraintsProvider + * @param string $tableName + * @param string $type + * @param mixed $expected + */ + public function testTableSchemaConstraintsWithPdoUppercase($tableName, $type, $expected): void + { + $this->markTestSkipped('This test hangs on CUBRID.'); + } } diff --git a/tests/framework/db/mssql/CommandTest.php b/tests/framework/db/mssql/CommandTest.php index f161c9c001..9198054fa7 100644 --- a/tests/framework/db/mssql/CommandTest.php +++ b/tests/framework/db/mssql/CommandTest.php @@ -90,7 +90,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertEquals('user5@example.com', $command->queryScalar()); } - public function paramsNonWhereProvider() + public static function paramsNonWhereProvider(): array { return[ ['SELECT SUBSTRING(name, :len, 6) AS name FROM {{customer}} WHERE [[email]] = :email GROUP BY name'], @@ -122,7 +122,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertEmpty($schema->getTableDefaultValues($tableName, true)); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { $data = parent::batchInsertSqlProvider(); $data['issue11242']['expected'] = 'INSERT INTO [type] ([int_col], [float_col], [char_col]) VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')'; diff --git a/tests/framework/db/mssql/SchemaTest.php b/tests/framework/db/mssql/SchemaTest.php index 0414abaad5..8c409f9944 100644 --- a/tests/framework/db/mssql/SchemaTest.php +++ b/tests/framework/db/mssql/SchemaTest.php @@ -25,7 +25,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest 'dbo', ]; - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); $result['1: check'][2][0]->expression = '([C_check]<>\'\')'; @@ -100,7 +100,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertEquals($expectedName, $quotedName); } - public function quoteTableNameDataProvider() + public static function quoteTableNameDataProvider(): array { return [ ['test', '[test]'], @@ -127,7 +127,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertEquals($expectedName, $tableSchema->name); } - public function getTableSchemaDataProvider() + public static function getTableSchemaDataProvider(): array { return [ ['[dbo].[profile]', 'profile'], diff --git a/tests/framework/db/mysql/ColumnSchemaBuilderTest.php b/tests/framework/db/mysql/ColumnSchemaBuilderTest.php index d8b99e2fff..b6e31fe57c 100644 --- a/tests/framework/db/mysql/ColumnSchemaBuilderTest.php +++ b/tests/framework/db/mysql/ColumnSchemaBuilderTest.php @@ -33,7 +33,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT /** * @return array */ - public function typesProvider() + public static function typesProvider(): array { return [ ['integer UNSIGNED', Schema::TYPE_INTEGER, null, [ diff --git a/tests/framework/db/mysql/SchemaTest.php b/tests/framework/db/mysql/SchemaTest.php index 99352eb9e1..e6c178dad5 100644 --- a/tests/framework/db/mysql/SchemaTest.php +++ b/tests/framework/db/mysql/SchemaTest.php @@ -76,7 +76,7 @@ SQL; $this->markTestSkipped('Schemas are not supported in MySQL.'); } - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); diff --git a/tests/framework/db/oci/ColumnSchemaBuilderTest.php b/tests/framework/db/oci/ColumnSchemaBuilderTest.php index 2fdef80b09..2a673fba7d 100644 --- a/tests/framework/db/oci/ColumnSchemaBuilderTest.php +++ b/tests/framework/db/oci/ColumnSchemaBuilderTest.php @@ -33,7 +33,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT /** * @return array */ - public function typesProvider() + public static function typesProvider(): array { return [ ['integer UNSIGNED', Schema::TYPE_INTEGER, null, [ diff --git a/tests/framework/db/oci/CommandTest.php b/tests/framework/db/oci/CommandTest.php index d61e79ef24..4d881f9348 100644 --- a/tests/framework/db/oci/CommandTest.php +++ b/tests/framework/db/oci/CommandTest.php @@ -42,7 +42,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertSame('3', $db->getSchema()->getLastInsertID('profile_SEQ')); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { $data = parent::batchInsertSqlProvider(); $data['issue11242']['expected'] = 'INSERT ALL INTO "type" ("int_col", "float_col", "char_col") ' . @@ -161,7 +161,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest }, 10); } - public function paramsNonWhereProvider() + public static function paramsNonWhereProvider(): array { return [ ['SELECT SUBSTR([[name]], :len) FROM {{customer}} WHERE [[email]] = :email GROUP BY SUBSTR([[name]], :len)'], diff --git a/tests/framework/db/oci/SchemaTest.php b/tests/framework/db/oci/SchemaTest.php index cea1d2e478..d8b41cdb83 100644 --- a/tests/framework/db/oci/SchemaTest.php +++ b/tests/framework/db/oci/SchemaTest.php @@ -110,7 +110,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertFalse($table->columns['id']->autoIncrement); } - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); $result['1: check'][2][0]->expression = '"C_check" <> \'\''; diff --git a/tests/framework/db/pgsql/ActiveRecordTest.php b/tests/framework/db/pgsql/ActiveRecordTest.php index 126489e08c..545b680816 100644 --- a/tests/framework/db/pgsql/ActiveRecordTest.php +++ b/tests/framework/db/pgsql/ActiveRecordTest.php @@ -215,7 +215,7 @@ class ActiveRecordTest extends \yiiunit\framework\db\ActiveRecordTest $this->assertSame(1, $type->update(), 'The record got updated'); } - public function arrayValuesProvider() + public static function arrayValuesProvider(): array { return [ 'simple arrays values' => [[ diff --git a/tests/framework/db/pgsql/ArrayParserTest.php b/tests/framework/db/pgsql/ArrayParserTest.php index 6aa8d6ba3d..3f23a3530f 100644 --- a/tests/framework/db/pgsql/ArrayParserTest.php +++ b/tests/framework/db/pgsql/ArrayParserTest.php @@ -19,7 +19,7 @@ class ArrayParserTest extends TestCase $this->arrayParser = new ArrayParser(); } - public function convertProvider() + public static function convertProvider(): array { return [ ['{}', []], diff --git a/tests/framework/db/pgsql/CommandTest.php b/tests/framework/db/pgsql/CommandTest.php index 7e28dcfd30..9bad5028aa 100644 --- a/tests/framework/db/pgsql/CommandTest.php +++ b/tests/framework/db/pgsql/CommandTest.php @@ -80,7 +80,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertSame('3', $db->getSchema()->getLastInsertID('schema1.profile_id_seq')); } - public function dataProviderGetRawSql() + public static function dataProviderGetRawSql(): array { return array_merge(parent::dataProviderGetRawSql(), [ [ @@ -117,7 +117,7 @@ class CommandTest extends \yiiunit\framework\db\CommandTest $this->assertEquals(1, $command->execute()); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { $data = parent::batchInsertSqlProvider(); $data['issue11242']['expected'] = 'INSERT INTO "type" ("int_col", "float_col", "char_col") VALUES (NULL, NULL, \'Kyiv {{city}}, Ukraine\')'; diff --git a/tests/framework/db/pgsql/SchemaTest.php b/tests/framework/db/pgsql/SchemaTest.php index 1fe2655cd2..0148cee033 100644 --- a/tests/framework/db/pgsql/SchemaTest.php +++ b/tests/framework/db/pgsql/SchemaTest.php @@ -261,7 +261,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertCount(3, $schema->getSchemaNames()); } - public function bigintValueProvider() + public static function bigintValueProvider(): array { return [ [8817806877], @@ -402,7 +402,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertEquals(new Expression('timezone(\'UTC\'::text, \'1970-01-01 00:00:00+00\'::timestamp with time zone)'), $tableSchema->getColumn('timestamp')->defaultValue); } - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); $result['1: check'][2][0]->expression = 'CHECK ((("C_check")::text <> \'\'::text))'; diff --git a/tests/framework/db/sqlite/ColumnSchemaBuilderTest.php b/tests/framework/db/sqlite/ColumnSchemaBuilderTest.php index 8373af0ae2..6a0c05c18d 100644 --- a/tests/framework/db/sqlite/ColumnSchemaBuilderTest.php +++ b/tests/framework/db/sqlite/ColumnSchemaBuilderTest.php @@ -33,7 +33,7 @@ class ColumnSchemaBuilderTest extends \yiiunit\framework\db\ColumnSchemaBuilderT /** * @return array */ - public function typesProvider() + public static function typesProvider(): array { return [ ['integer UNSIGNED', Schema::TYPE_INTEGER, null, [ diff --git a/tests/framework/db/sqlite/CommandTest.php b/tests/framework/db/sqlite/CommandTest.php index 20ebbf789f..2d697b6b07 100644 --- a/tests/framework/db/sqlite/CommandTest.php +++ b/tests/framework/db/sqlite/CommandTest.php @@ -105,7 +105,7 @@ SQL; ])->queryAll()); } - public function batchInsertSqlProvider() + public static function batchInsertSqlProvider(): array { $parent = parent::batchInsertSqlProvider(); unset($parent['wrongBehavior']); // Produces SQL syntax error: General error: 1 near ".": syntax error diff --git a/tests/framework/db/sqlite/SchemaTest.php b/tests/framework/db/sqlite/SchemaTest.php index 2786e6c110..757add20ab 100644 --- a/tests/framework/db/sqlite/SchemaTest.php +++ b/tests/framework/db/sqlite/SchemaTest.php @@ -58,7 +58,7 @@ class SchemaTest extends \yiiunit\framework\db\SchemaTest $this->assertEquals('item_id', $table->foreignKeys[0]['item_id']); } - public function constraintsProvider() + public static function constraintsProvider(): array { $result = parent::constraintsProvider(); $result['1: primary key'][2]->name = null; diff --git a/tests/framework/db/sqlite/SqlTokenizerTest.php b/tests/framework/db/sqlite/SqlTokenizerTest.php index f1acd34ef8..62dc506612 100644 --- a/tests/framework/db/sqlite/SqlTokenizerTest.php +++ b/tests/framework/db/sqlite/SqlTokenizerTest.php @@ -18,7 +18,7 @@ use yiiunit\TestCase; */ class SqlTokenizerTest extends TestCase { - public function sqlProvider() + public static function sqlProvider(): array { return [ 'complex' => [