From 76d34f3fafc92a643dd813d449077f958bf0caf7 Mon Sep 17 00:00:00 2001 From: asrar Date: Sun, 28 Jan 2024 10:34:40 +0100 Subject: [PATCH 1/3] deps: Upgrades to dbal v3 and fix tests + Update phpunit and php version reqs + Remove cache file + Remove branch alias + Use php-coverallas from new pkg + Add inflector since it's directly used in DefaultNamingStrategy --- .gitignore | 3 +- .phpunit.result.cache | 1 - composer.json | 17 ++-- phpunit.xml.dist | 51 ++++++------ src/TdbmFluidColumn.php | 9 +++ src/TdbmFluidColumnGraphqlOptions.php | 4 +- tests/TdbmFluidColumnGraphqlOptionsTest.php | 9 +-- tests/TdbmFluidColumnOptionsTest.php | 9 +-- tests/TdbmFluidColumnTest.php | 80 +++++++++---------- .../TdbmFluidJunctionTableJsonOptionsTest.php | 25 +++--- tests/TdbmFluidTableTest.php | 27 +++---- 11 files changed, 117 insertions(+), 118 deletions(-) delete mode 100644 .phpunit.result.cache diff --git a/.gitignore b/.gitignore index f238d47..d6bb38e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ /composer.lock /build/ -/phpunit.xml \ No newline at end of file +/phpunit.xml +.phpunit.result.cache \ No newline at end of file diff --git a/.phpunit.result.cache b/.phpunit.result.cache deleted file mode 100644 index 09c9796..0000000 --- a/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -C:30:"PHPUnit\Runner\TestResultCache":2345:{a:2:{s:7:"defects";a:4:{s:62:"TheCodingMachine\FluidSchema\CommentTest::testRemoveAnnotation";i:3;s:57:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testUuid";i:4;s:65:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testGetDbalTable";i:4;s:75:"TheCodingMachine\FluidSchema\TdbmFluidColumnGraphqlOptionsTest::testGraphql";i:3;}s:5:"times";a:25:{s:62:"TheCodingMachine\FluidSchema\CommentTest::testRemoveAnnotation";d:0.004;s:59:"TheCodingMachine\FluidSchema\CommentTest::testAddAnnotation";d:0.001;s:68:"TheCodingMachine\FluidSchema\TdbmFluidColumnOptionsTest::testOptions";d:0.002;s:66:"TheCodingMachine\FluidSchema\TdbmFluidColumnOptionsTest::testIndex";d:0.003;s:71:"TheCodingMachine\FluidSchema\TdbmFluidColumnOptionsTest::testPrimaryKey";d:0.002;s:59:"TheCodingMachine\FluidSchema\TdbmFluidColumnTest::testTypes";d:0.017;s:63:"TheCodingMachine\FluidSchema\TdbmFluidColumnTest::testReference";d:0.006;s:72:"TheCodingMachine\FluidSchema\TdbmFluidColumnTest::testReferenceException";d:0.006;s:59:"TheCodingMachine\FluidSchema\TdbmFluidSchemaTest::testTable";d:0.001;s:67:"TheCodingMachine\FluidSchema\TdbmFluidSchemaTest::testExistingTable";d:0.002;s:67:"TheCodingMachine\FluidSchema\TdbmFluidSchemaTest::testJunctionTable";d:0.014;s:67:"TheCodingMachine\FluidSchema\TdbmFluidSchemaTest::testGetDbalSchema";d:0.001;s:59:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testColumn";d:0.002;s:67:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testExistingColumn";d:0.003;s:58:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testIndex";d:0.003;s:59:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testUnique";d:0.002;s:63:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testPrimaryKey";d:0.002;s:55:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testId";d:0.003;s:57:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testUuid";d:0.004;s:63:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testTimestamps";d:0.003;s:61:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testInherits";d:0.008;s:65:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testGetDbalTable";d:0.001;s:64:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testUuidBadType";d:0.002;s:67:"TheCodingMachine\FluidSchema\TdbmFluidTableTest::testCustomBeanName";d:0.002;s:75:"TheCodingMachine\FluidSchema\TdbmFluidColumnGraphqlOptionsTest::testGraphql";d:0.007;}}} \ No newline at end of file diff --git a/composer.json b/composer.json index 7ac14f7..0d51565 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ } ], "require": { - "php": ">=7.1", - "thecodingmachine/dbal-fluid-schema-builder": "^1.6.1", - "doctrine/dbal": "^2.5" + "php": "^7.4 || ^8.0", + "thecodingmachine/dbal-fluid-schema-builder": "^2.0", + "doctrine/dbal": "^3.0" }, "require-dev": { - "phpunit/phpunit": "^7.5.6", - "satooshi/php-coveralls": "^1.1" + "phpunit/phpunit": "^9.6.16", + "php-coveralls/php-coveralls": "^2.7.0" }, "autoload": { "psr-4": { @@ -28,10 +28,5 @@ } }, "minimum-stability": "dev", - "prefer-stable": true, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } + "prefer-stable": true } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2979a16..8c0d9ba 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,28 +1,31 @@ - - - - - ./tests/ - - + + + ./tests/ + + - - - src/ - - - - - - + + + src/ + + + + + + + diff --git a/src/TdbmFluidColumn.php b/src/TdbmFluidColumn.php index c25d616..7ef8ac1 100644 --- a/src/TdbmFluidColumn.php +++ b/src/TdbmFluidColumn.php @@ -154,6 +154,9 @@ public function dateInterval(): TdbmFluidColumnOptions return $this->getOptions($options); } + /** + * @deprecated Use json() instead + */ public function array(): TdbmFluidColumnOptions { $options = $this->fluidColumn->array(); @@ -172,12 +175,18 @@ public function json(): TdbmFluidColumnOptions return $this->getOptions($options); } + /** + * @deprecated Use json() instead + */ public function jsonArray(): TdbmFluidColumnOptions { $options = $this->fluidColumn->jsonArray(); return $this->getOptions($options); } + /** + * @deprecated Use json() instead + */ public function object(): TdbmFluidColumnOptions { $options = $this->fluidColumn->object(); diff --git a/src/TdbmFluidColumnGraphqlOptions.php b/src/TdbmFluidColumnGraphqlOptions.php index 8407378..037da96 100644 --- a/src/TdbmFluidColumnGraphqlOptions.php +++ b/src/TdbmFluidColumnGraphqlOptions.php @@ -6,6 +6,8 @@ use function addslashes; use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; + use function var_export; class TdbmFluidColumnGraphqlOptions @@ -62,7 +64,7 @@ private function generateFieldAnnotation(): void $outputType = null; if ($this->outputType !== null) { $outputType = $this->outputType; - } elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Type::GUID)) { + } elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Types::GUID)) { // are we part of a foreign key or not? $fks = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getForeignKeys(); $isPartOfFk = false; diff --git a/tests/TdbmFluidColumnGraphqlOptionsTest.php b/tests/TdbmFluidColumnGraphqlOptionsTest.php index 9300a36..1c9b9ab 100644 --- a/tests/TdbmFluidColumnGraphqlOptionsTest.php +++ b/tests/TdbmFluidColumnGraphqlOptionsTest.php @@ -3,7 +3,6 @@ namespace TheCodingMachine\FluidSchema; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; class TdbmFluidColumnGraphqlOptionsTest extends TestCase @@ -43,19 +42,19 @@ public function testGraphql() $column2 = $graphqlOptions->column('foo'); $this->assertSame($column2, $column); - $this->assertContains('@TheCodingMachine\GraphQLite\Annotations\Type', $schema->getTable('posts')->getOptions()['comment']); + $this->assertStringContainsString('@TheCodingMachine\GraphQLite\Annotations\Type', $schema->getTable('posts')->getOptions()['comment']); $idColumn = $posts->id()->graphqlField(); - $this->assertContains('outputType = "ID"', $schema->getTable('posts')->getColumn('id')->getComment()); + $this->assertStringContainsString('outputType = "ID"', $schema->getTable('posts')->getColumn('id')->getComment()); $users = $fluid->table('users'); $uuidColumn = $users->uuid()->graphqlField(); - $this->assertContains('outputType = "ID"', $schema->getTable('users')->getColumn('uuid')->getComment()); + $this->assertStringContainsString('outputType = "ID"', $schema->getTable('users')->getColumn('uuid')->getComment()); $products = $fluid->table('products'); $graphqlField = $products->uuid() ->column('user_id')->references('users')->graphqlField(); - $this->assertNotContains('outputType = "ID"', $schema->getTable('products')->getColumn('user_id')->getComment()); + $this->assertStringNotContainsString('outputType = "ID"', $schema->getTable('products')->getColumn('user_id')->getComment()); $this->assertSame('products', $graphqlField->then()->getDbalTable()->getName()); } diff --git a/tests/TdbmFluidColumnOptionsTest.php b/tests/TdbmFluidColumnOptionsTest.php index 4017a14..4800ebe 100644 --- a/tests/TdbmFluidColumnOptionsTest.php +++ b/tests/TdbmFluidColumnOptionsTest.php @@ -3,7 +3,6 @@ namespace TheCodingMachine\FluidSchema; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; class TdbmFluidColumnOptionsTest extends TestCase @@ -39,13 +38,13 @@ public function testOptions() $this->assertSame(42, $dbalColumn->getDefault()); $columnOptions->protectedGetter(); - $this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedGetter', $dbalColumn->getComment()); + $this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedGetter', $dbalColumn->getComment()); $columnOptions->protectedSetter(); - $this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedSetter', $dbalColumn->getComment()); + $this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedSetter', $dbalColumn->getComment()); $columnOptions->protectedOneToMany(); - $this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedOneToMany', $dbalColumn->getComment()); + $this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedOneToMany', $dbalColumn->getComment()); $this->assertSame($posts, $columnOptions->then()); @@ -74,7 +73,7 @@ public function testPrimaryKey() $posts->column('id')->integer()->primaryKey('pkname'); - $this->assertTrue($schema->getTable('posts')->hasPrimaryKey()); + $this->assertNotNull($schema->getTable('posts')->getPrimaryKey()); $this->assertTrue($schema->getTable('posts')->hasIndex('pkname')); } } diff --git a/tests/TdbmFluidColumnTest.php b/tests/TdbmFluidColumnTest.php index c2e35cd..db3b986 100644 --- a/tests/TdbmFluidColumnTest.php +++ b/tests/TdbmFluidColumnTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use PHPUnit\Framework\TestCase; class TdbmFluidColumnTest extends TestCase @@ -20,95 +21,90 @@ public function testTypes() $dbalColumn = $schema->getTable('posts')->getColumn('foo'); $column->integer(); - $this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::INTEGER), $dbalColumn->getType()); $column->smallInt(); - $this->assertSame(Type::getType(Type::SMALLINT), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::SMALLINT), $dbalColumn->getType()); $column->bigInt(); - $this->assertSame(Type::getType(Type::BIGINT), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::BIGINT), $dbalColumn->getType()); $column->decimal(12, 32); - $this->assertSame(Type::getType(Type::DECIMAL), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::DECIMAL), $dbalColumn->getType()); $this->assertSame(12, $dbalColumn->getPrecision()); $this->assertSame(32, $dbalColumn->getScale()); $column->float(32, 12); - $this->assertSame(Type::getType(Type::FLOAT), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::FLOAT), $dbalColumn->getType()); $this->assertSame(32, $dbalColumn->getPrecision()); $this->assertSame(12, $dbalColumn->getScale()); $column->string(42, true); - $this->assertSame(Type::getType(Type::STRING), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::STRING), $dbalColumn->getType()); $this->assertSame(42, $dbalColumn->getLength()); $this->assertSame(true, $dbalColumn->getFixed()); $column->text(); - $this->assertSame(Type::getType(Type::TEXT), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::TEXT), $dbalColumn->getType()); $column->guid(); - $this->assertSame(Type::getType(Type::GUID), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::GUID), $dbalColumn->getType()); $column->blob(); - $this->assertSame(Type::getType(Type::BLOB), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::BLOB), $dbalColumn->getType()); $column->boolean(); - $this->assertSame(Type::getType(Type::BOOLEAN), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::BOOLEAN), $dbalColumn->getType()); $column->date(); - $this->assertSame(Type::getType(Type::DATE), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::DATE_MUTABLE), $dbalColumn->getType()); $column->datetime(); - $this->assertSame(Type::getType(Type::DATETIME), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::DATETIME_MUTABLE), $dbalColumn->getType()); $column->datetimeTz(); - $this->assertSame(Type::getType(Type::DATETIMETZ), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::DATETIMETZ_MUTABLE), $dbalColumn->getType()); $column->time(); - $this->assertSame(Type::getType(Type::TIME), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType()); $column->array(); - $this->assertSame(Type::getType(Type::TARRAY), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::ARRAY), $dbalColumn->getType()); $column->simpleArray(); - $this->assertSame(Type::getType(Type::SIMPLE_ARRAY), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::SIMPLE_ARRAY), $dbalColumn->getType()); $column->jsonArray(); - $this->assertSame(Type::getType(Type::JSON_ARRAY), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType()); $column->object(); - $this->assertSame(Type::getType(Type::OBJECT), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::OBJECT), $dbalColumn->getType()); - if (defined('Doctrine\\DBAL\\Types\\Type::BINARY')) { - $column->binary(43); - $this->assertSame(Type::getType(Type::BINARY), $dbalColumn->getType()); - $this->assertSame(43, $dbalColumn->getLength()); - $this->assertSame(false, $dbalColumn->getFixed()); - } + $column->binary(43); + $this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType()); + $this->assertSame(43, $dbalColumn->getLength()); + $this->assertSame(false, $dbalColumn->getFixed()); - if (defined('Doctrine\\DBAL\\Types\\Type::DATE_IMMUTABLE')) { - // Doctrine DBAL 2.6+ - $column->dateImmutable(); - $this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType()); + $column->dateImmutable(); + $this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType()); - $column->datetimeImmutable(); - $this->assertSame(Type::getType(Type::DATETIME_IMMUTABLE), $dbalColumn->getType()); + $column->datetimeImmutable(); + $this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType()); - $column->datetimeTzImmutable(); - $this->assertSame(Type::getType(Type::DATETIMETZ_IMMUTABLE), $dbalColumn->getType()); + $column->datetimeTzImmutable(); + $this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType()); - $column->time(); - $this->assertSame(Type::getType(Type::TIME), $dbalColumn->getType()); + $column->time(); + $this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType()); - $column->timeImmutable(); - $this->assertSame(Type::getType(Type::TIME_IMMUTABLE), $dbalColumn->getType()); + $column->timeImmutable(); + $this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType()); - $column->dateInterval(); - $this->assertSame(Type::getType(Type::DATEINTERVAL), $dbalColumn->getType()); + $column->dateInterval(); + $this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType()); - $column->json(); - $this->assertSame(Type::getType(Type::JSON), $dbalColumn->getType()); - } + $column->json(); + $this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType()); $this->assertSame('foo', $column->getDbalColumn()->getName()); } @@ -126,7 +122,7 @@ public function testReference() $dbalColumn = $schema->getTable('users')->getColumn('country_id'); - $this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::INTEGER), $dbalColumn->getType()); $fk = $schema->getTable('users')->getForeignKey('myfk'); $this->assertSame('users', $fk->getLocalTableName()); $this->assertSame('countries', $fk->getForeignTableName()); diff --git a/tests/TdbmFluidJunctionTableJsonOptionsTest.php b/tests/TdbmFluidJunctionTableJsonOptionsTest.php index af4805b..486c5f8 100644 --- a/tests/TdbmFluidJunctionTableJsonOptionsTest.php +++ b/tests/TdbmFluidJunctionTableJsonOptionsTest.php @@ -3,7 +3,6 @@ namespace TheCodingMachine\FluidSchema; use Doctrine\DBAL\Schema\Schema; -use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; class TdbmFluidJunctionTableJsonOptionsTest extends TestCase @@ -27,24 +26,24 @@ public function testJson() ->column('another_parent')->references('nodes')->comment('@JsonCollection("entries") @JsonFormat(property="entry")'); $nodesTable = $schema->getTable('nodes'); - $this->assertContains('@JsonIgnore', $nodesTable->getColumn('id')->getComment()); - $this->assertContains('@JsonRecursive', $nodesTable->getColumn('alias_id')->getComment()); - $this->assertContains('@JsonInclude', $nodesTable->getColumn('parent_id')->getComment()); - $this->assertContains('@JsonIgnore', $nodesTable->getColumn('root_id')->getComment()); - $this->assertContains('@JsonFormat(property = "name")', $nodesTable->getColumn('owner_id')->getComment()); - $this->assertContains('@JsonFormat(method = "myMethod")', $nodesTable->getColumn('owner_country')->getComment()); - $this->assertContains('@JsonKey(key = "basename")', $nodesTable->getColumn('name')->getComment()); - $this->assertContains('@JsonFormat(unit = " o")', $nodesTable->getColumn('size')->getComment()); - $this->assertContains('@JsonFormat(decimals = 2, point = ",", separator = ".", unit = "g")', $nodesTable->getColumn('weight')->getComment()); - $this->assertContains('@JsonFormat(date = "Y-m-d")', $nodesTable->getColumn('created_at')->getComment()); - $this->assertContains('@JsonCollection("entries")', $nodesTable->getColumn('another_parent')->getComment()); + $this->assertStringContainsString('@JsonIgnore', $nodesTable->getColumn('id')->getComment()); + $this->assertStringContainsString('@JsonRecursive', $nodesTable->getColumn('alias_id')->getComment()); + $this->assertStringContainsString('@JsonInclude', $nodesTable->getColumn('parent_id')->getComment()); + $this->assertStringContainsString('@JsonIgnore', $nodesTable->getColumn('root_id')->getComment()); + $this->assertStringContainsString('@JsonFormat(property = "name")', $nodesTable->getColumn('owner_id')->getComment()); + $this->assertStringContainsString('@JsonFormat(method = "myMethod")', $nodesTable->getColumn('owner_country')->getComment()); + $this->assertStringContainsString('@JsonKey(key = "basename")', $nodesTable->getColumn('name')->getComment()); + $this->assertStringContainsString('@JsonFormat(unit = " o")', $nodesTable->getColumn('size')->getComment()); + $this->assertStringContainsString('@JsonFormat(decimals = 2, point = ",", separator = ".", unit = "g")', $nodesTable->getColumn('weight')->getComment()); + $this->assertStringContainsString('@JsonFormat(date = "Y-m-d")', $nodesTable->getColumn('created_at')->getComment()); + $this->assertStringContainsString('@JsonCollection("entries")', $nodesTable->getColumn('another_parent')->getComment()); $fluid->table('node_entries') ->column('id')->integer()->primaryKey()->autoIncrement() ->column('node_id')->references('nodes')->jsonSerialize()->collection("entries") ->column('entry')->string()->null(); - $this->assertContains('@JsonCollection(key = "entries")', $schema->getTable('node_entries')->getColumn('node_id')->getComment()); + $this->assertStringContainsString('@JsonCollection(key = "entries")', $schema->getTable('node_entries')->getColumn('node_id')->getComment()); $anotherColumn = $fluid->table('nodes')->column('another_column')->integer(); $this->assertSame($anotherColumn, $anotherColumn->jsonSerialize()->endJsonSerialize()); diff --git a/tests/TdbmFluidTableTest.php b/tests/TdbmFluidTableTest.php index c94da73..9266d7b 100644 --- a/tests/TdbmFluidTableTest.php +++ b/tests/TdbmFluidTableTest.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Types\Type; +use Doctrine\DBAL\Types\Types; use PHPUnit\Framework\TestCase; class TdbmFluidTableTest extends TestCase @@ -33,7 +34,7 @@ public function testExistingColumn() $posts->column('foo')->integer(); - $this->assertSame(Type::getType(Type::INTEGER), $schema->getTable('posts')->getColumn('foo')->getType()); + $this->assertSame(Type::getType(Types::INTEGER), $schema->getTable('posts')->getColumn('foo')->getType()); } public function testIndex() @@ -69,7 +70,7 @@ public function testPrimaryKey() $posts->column('id')->integer()->then()->primaryKey(['id'], 'pkname'); - $this->assertTrue($schema->getTable('posts')->hasPrimaryKey()); + $this->assertNotNull($schema->getTable('posts')->getPrimaryKey()); $this->assertTrue($schema->getTable('posts')->hasIndex('pkname')); } @@ -82,7 +83,7 @@ public function testId() $posts->id(); - $this->assertTrue($schema->getTable('posts')->hasPrimaryKey()); + $this->assertNotNull($schema->getTable('posts')->getPrimaryKey()); $this->assertTrue($schema->getTable('posts')->hasColumn('id')); } @@ -95,7 +96,7 @@ public function testUuid() $posts->uuid(); - $this->assertTrue($schema->getTable('posts')->hasPrimaryKey()); + $this->assertNotNull($schema->getTable('posts')->getPrimaryKey()); $this->assertTrue($schema->getTable('posts')->hasColumn('uuid')); $this->assertSame("\n@UUID(\"v4\")", $schema->getTable('posts')->getColumn('uuid')->getComment()); } @@ -175,19 +176,15 @@ public function testUseTraitOnDao() public function testTimestamps() { - if (defined('Doctrine\\DBAL\\Types\\Type::DATE_IMMUTABLE')) { - $schema = new Schema(); - $fluid = new TdbmFluidSchema($schema); + $schema = new Schema(); + $fluid = new TdbmFluidSchema($schema); - $posts = $fluid->table('posts'); + $posts = $fluid->table('posts'); - $posts->timestamps(); + $posts->timestamps(); - $this->assertTrue($schema->getTable('posts')->hasColumn('created_at')); - $this->assertTrue($schema->getTable('posts')->hasColumn('updated_at')); - } else { - $this->markTestSkipped("Only available from Doctrine DBAL 2.6"); - } + $this->assertTrue($schema->getTable('posts')->hasColumn('created_at')); + $this->assertTrue($schema->getTable('posts')->hasColumn('updated_at')); } public function testInherits() @@ -202,7 +199,7 @@ public function testInherits() $dbalColumn = $schema->getTable('users')->getColumn('id'); - $this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType()); + $this->assertSame(Type::getType(Types::INTEGER), $dbalColumn->getType()); $fks = $schema->getTable('users')->getForeignKeys(); $this->assertCount(1, $fks); $fk = array_pop($fks); From bba910c0fee81053901b1c95e0c091878cff8def Mon Sep 17 00:00:00 2001 From: asrar Date: Sun, 28 Jan 2024 10:34:49 +0100 Subject: [PATCH 2/3] ci: Adds github ci, removing travis --- .github/workflows/ci.yml | 56 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 17 ------------ 2 files changed, 56 insertions(+), 17 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cfa3ee1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,56 @@ +name: "Continuous Integration" + +on: + pull_request: + push: + branches: + - master +jobs: + test: + name: "Test" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.4" + - "8.0" + - "8.1" + - "8.2" + - "8.3" + dependencies: + - "lowest" + - "highest" + + steps: + - name: "Checkout" + uses: "actions/checkout@v4" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + coverage: "xdebug" + php-version: "${{ matrix.php-version }}" + ini-values: "zend.assertions=1" + + - uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + + # dbal-fluid-schema-builder doesn't support v1.0 only v1.4 + - name: Update doctrine/inflector to v1.4 from v1.0 + if: "${{ 'lowest' == matrix.dependencies }}" + run: | + composer update doctrine/inflector:1.4 --ignore-platform-reqs + + - name: "Run PHPUnit" + run: "vendor/bin/phpunit -c phpunit.xml.dist" + + - name: Upload coverage results to Coveralls + # skip php-coversalls for lowest deps + # it fails on lowest depedencies because old versions of guzzle doesn't work well with newer php versions + if: "${{ 'highest' == matrix.dependencies }}" + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index be98b14..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php -php: -- 7.1 -- 7.3 -cache: - directories: - - $HOME/.composer/cache -env: - matrix: - - PREFER_LOWEST="--prefer-lowest" - - PREFER_LOWEST="" -before_script: -- composer update --prefer-dist $PREFER_LOWEST -script: -- "./vendor/bin/phpunit" -after_script: -- if [ -z "$PREFER_LOWEST" ]; then ./vendor/bin/coveralls -v; fi From 47f031ae872b120e2af6d8dad9d79177a24d3066 Mon Sep 17 00:00:00 2001 From: asrar Date: Sun, 28 Jan 2024 10:48:13 +0100 Subject: [PATCH 3/3] ci: Fix php version --- .scrutinizer.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index d3d1d06..13f33c7 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,7 +1,9 @@ build: environment: php: - version: 7.1 + version: 8.1 + ini: + xdebug.mode: coverage checks: php: