Skip to content

Commit 76d34f3

Browse files
committed
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
1 parent 1aacb60 commit 76d34f3

11 files changed

+117
-118
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor/
22
/composer.lock
33
/build/
4-
/phpunit.xml
4+
/phpunit.xml
5+
.phpunit.result.cache

.phpunit.result.cache

Lines changed: 0 additions & 1 deletion
This file was deleted.

composer.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
}
1010
],
1111
"require": {
12-
"php": ">=7.1",
13-
"thecodingmachine/dbal-fluid-schema-builder": "^1.6.1",
14-
"doctrine/dbal": "^2.5"
12+
"php": "^7.4 || ^8.0",
13+
"thecodingmachine/dbal-fluid-schema-builder": "^2.0",
14+
"doctrine/dbal": "^3.0"
1515
},
1616
"require-dev": {
17-
"phpunit/phpunit": "^7.5.6",
18-
"satooshi/php-coveralls": "^1.1"
17+
"phpunit/phpunit": "^9.6.16",
18+
"php-coveralls/php-coveralls": "^2.7.0"
1919
},
2020
"autoload": {
2121
"psr-4": {
@@ -28,10 +28,5 @@
2828
}
2929
},
3030
"minimum-stability": "dev",
31-
"prefer-stable": true,
32-
"extra": {
33-
"branch-alias": {
34-
"dev-master": "1.0.x-dev"
35-
}
36-
}
31+
"prefer-stable": true
3732
}

phpunit.xml.dist

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
bootstrap="vendor/autoload.php"
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
colors="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false"
13+
bootstrap="vendor/autoload.php"
1214
>
13-
<testsuites>
14-
<testsuite name="Test Suite">
15-
<directory>./tests/</directory>
16-
</testsuite>
17-
</testsuites>
15+
<testsuites>
16+
<testsuite name="Test Suite">
17+
<directory>./tests/</directory>
18+
</testsuite>
19+
</testsuites>
1820

19-
<filter>
20-
<whitelist processUncoveredFilesFromWhitelist="true">
21-
<directory suffix=".php">src/</directory>
22-
</whitelist>
23-
</filter>
24-
<logging>
25-
<log type="coverage-html" target="build/coverage"/>
26-
<log type="coverage-clover" target="build/logs/clover.xml"/>
27-
</logging>
21+
<coverage processUncoveredFiles="true">
22+
<include>
23+
<directory suffix=".php">src/</directory>
24+
</include>
25+
<report>
26+
<clover outputFile="build/logs/clover.xml"/>
27+
<html outputDirectory="build/coverage"/>
28+
</report>
29+
</coverage>
30+
<logging/>
2831
</phpunit>

src/TdbmFluidColumn.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ public function dateInterval(): TdbmFluidColumnOptions
154154
return $this->getOptions($options);
155155
}
156156

157+
/**
158+
* @deprecated Use json() instead
159+
*/
157160
public function array(): TdbmFluidColumnOptions
158161
{
159162
$options = $this->fluidColumn->array();
@@ -172,12 +175,18 @@ public function json(): TdbmFluidColumnOptions
172175
return $this->getOptions($options);
173176
}
174177

178+
/**
179+
* @deprecated Use json() instead
180+
*/
175181
public function jsonArray(): TdbmFluidColumnOptions
176182
{
177183
$options = $this->fluidColumn->jsonArray();
178184
return $this->getOptions($options);
179185
}
180186

187+
/**
188+
* @deprecated Use json() instead
189+
*/
181190
public function object(): TdbmFluidColumnOptions
182191
{
183192
$options = $this->fluidColumn->object();

src/TdbmFluidColumnGraphqlOptions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
use function addslashes;
88
use Doctrine\DBAL\Types\Type;
9+
use Doctrine\DBAL\Types\Types;
10+
911
use function var_export;
1012

1113
class TdbmFluidColumnGraphqlOptions
@@ -62,7 +64,7 @@ private function generateFieldAnnotation(): void
6264
$outputType = null;
6365
if ($this->outputType !== null) {
6466
$outputType = $this->outputType;
65-
} elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Type::GUID)) {
67+
} elseif ($this->fluidColumn->getDbalColumn()->getType() === Type::getType(Types::GUID)) {
6668
// are we part of a foreign key or not?
6769
$fks = $this->tdbmFluidColumnOptions->then()->getDbalTable()->getForeignKeys();
6870
$isPartOfFk = false;

tests/TdbmFluidColumnGraphqlOptionsTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace TheCodingMachine\FluidSchema;
44

55
use Doctrine\DBAL\Schema\Schema;
6-
use Doctrine\DBAL\Types\Type;
76
use PHPUnit\Framework\TestCase;
87

98
class TdbmFluidColumnGraphqlOptionsTest extends TestCase
@@ -43,19 +42,19 @@ public function testGraphql()
4342
$column2 = $graphqlOptions->column('foo');
4443
$this->assertSame($column2, $column);
4544

46-
$this->assertContains('@TheCodingMachine\GraphQLite\Annotations\Type', $schema->getTable('posts')->getOptions()['comment']);
45+
$this->assertStringContainsString('@TheCodingMachine\GraphQLite\Annotations\Type', $schema->getTable('posts')->getOptions()['comment']);
4746

4847
$idColumn = $posts->id()->graphqlField();
49-
$this->assertContains('outputType = "ID"', $schema->getTable('posts')->getColumn('id')->getComment());
48+
$this->assertStringContainsString('outputType = "ID"', $schema->getTable('posts')->getColumn('id')->getComment());
5049

5150
$users = $fluid->table('users');
5251
$uuidColumn = $users->uuid()->graphqlField();
53-
$this->assertContains('outputType = "ID"', $schema->getTable('users')->getColumn('uuid')->getComment());
52+
$this->assertStringContainsString('outputType = "ID"', $schema->getTable('users')->getColumn('uuid')->getComment());
5453

5554
$products = $fluid->table('products');
5655
$graphqlField = $products->uuid()
5756
->column('user_id')->references('users')->graphqlField();
58-
$this->assertNotContains('outputType = "ID"', $schema->getTable('products')->getColumn('user_id')->getComment());
57+
$this->assertStringNotContainsString('outputType = "ID"', $schema->getTable('products')->getColumn('user_id')->getComment());
5958

6059
$this->assertSame('products', $graphqlField->then()->getDbalTable()->getName());
6160
}

tests/TdbmFluidColumnOptionsTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace TheCodingMachine\FluidSchema;
44

55
use Doctrine\DBAL\Schema\Schema;
6-
use Doctrine\DBAL\Types\Type;
76
use PHPUnit\Framework\TestCase;
87

98
class TdbmFluidColumnOptionsTest extends TestCase
@@ -39,13 +38,13 @@ public function testOptions()
3938
$this->assertSame(42, $dbalColumn->getDefault());
4039

4140
$columnOptions->protectedGetter();
42-
$this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedGetter', $dbalColumn->getComment());
41+
$this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedGetter', $dbalColumn->getComment());
4342

4443
$columnOptions->protectedSetter();
45-
$this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedSetter', $dbalColumn->getComment());
44+
$this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedSetter', $dbalColumn->getComment());
4645

4746
$columnOptions->protectedOneToMany();
48-
$this->assertContains('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedOneToMany', $dbalColumn->getComment());
47+
$this->assertStringContainsString('@TheCodingMachine\\TDBM\\Utils\\Annotation\\ProtectedOneToMany', $dbalColumn->getComment());
4948

5049
$this->assertSame($posts, $columnOptions->then());
5150

@@ -74,7 +73,7 @@ public function testPrimaryKey()
7473

7574
$posts->column('id')->integer()->primaryKey('pkname');
7675

77-
$this->assertTrue($schema->getTable('posts')->hasPrimaryKey());
76+
$this->assertNotNull($schema->getTable('posts')->getPrimaryKey());
7877
$this->assertTrue($schema->getTable('posts')->hasIndex('pkname'));
7978
}
8079
}

tests/TdbmFluidColumnTest.php

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Doctrine\DBAL\Schema\Schema;
66
use Doctrine\DBAL\Types\Type;
7+
use Doctrine\DBAL\Types\Types;
78
use PHPUnit\Framework\TestCase;
89

910
class TdbmFluidColumnTest extends TestCase
@@ -20,95 +21,90 @@ public function testTypes()
2021
$dbalColumn = $schema->getTable('posts')->getColumn('foo');
2122

2223
$column->integer();
23-
$this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType());
24+
$this->assertSame(Type::getType(Types::INTEGER), $dbalColumn->getType());
2425

2526
$column->smallInt();
26-
$this->assertSame(Type::getType(Type::SMALLINT), $dbalColumn->getType());
27+
$this->assertSame(Type::getType(Types::SMALLINT), $dbalColumn->getType());
2728

2829
$column->bigInt();
29-
$this->assertSame(Type::getType(Type::BIGINT), $dbalColumn->getType());
30+
$this->assertSame(Type::getType(Types::BIGINT), $dbalColumn->getType());
3031

3132
$column->decimal(12, 32);
32-
$this->assertSame(Type::getType(Type::DECIMAL), $dbalColumn->getType());
33+
$this->assertSame(Type::getType(Types::DECIMAL), $dbalColumn->getType());
3334
$this->assertSame(12, $dbalColumn->getPrecision());
3435
$this->assertSame(32, $dbalColumn->getScale());
3536

3637
$column->float(32, 12);
37-
$this->assertSame(Type::getType(Type::FLOAT), $dbalColumn->getType());
38+
$this->assertSame(Type::getType(Types::FLOAT), $dbalColumn->getType());
3839
$this->assertSame(32, $dbalColumn->getPrecision());
3940
$this->assertSame(12, $dbalColumn->getScale());
4041

4142
$column->string(42, true);
42-
$this->assertSame(Type::getType(Type::STRING), $dbalColumn->getType());
43+
$this->assertSame(Type::getType(Types::STRING), $dbalColumn->getType());
4344
$this->assertSame(42, $dbalColumn->getLength());
4445
$this->assertSame(true, $dbalColumn->getFixed());
4546

4647
$column->text();
47-
$this->assertSame(Type::getType(Type::TEXT), $dbalColumn->getType());
48+
$this->assertSame(Type::getType(Types::TEXT), $dbalColumn->getType());
4849

4950
$column->guid();
50-
$this->assertSame(Type::getType(Type::GUID), $dbalColumn->getType());
51+
$this->assertSame(Type::getType(Types::GUID), $dbalColumn->getType());
5152

5253
$column->blob();
53-
$this->assertSame(Type::getType(Type::BLOB), $dbalColumn->getType());
54+
$this->assertSame(Type::getType(Types::BLOB), $dbalColumn->getType());
5455

5556
$column->boolean();
56-
$this->assertSame(Type::getType(Type::BOOLEAN), $dbalColumn->getType());
57+
$this->assertSame(Type::getType(Types::BOOLEAN), $dbalColumn->getType());
5758

5859
$column->date();
59-
$this->assertSame(Type::getType(Type::DATE), $dbalColumn->getType());
60+
$this->assertSame(Type::getType(Types::DATE_MUTABLE), $dbalColumn->getType());
6061

6162
$column->datetime();
62-
$this->assertSame(Type::getType(Type::DATETIME), $dbalColumn->getType());
63+
$this->assertSame(Type::getType(Types::DATETIME_MUTABLE), $dbalColumn->getType());
6364

6465
$column->datetimeTz();
65-
$this->assertSame(Type::getType(Type::DATETIMETZ), $dbalColumn->getType());
66+
$this->assertSame(Type::getType(Types::DATETIMETZ_MUTABLE), $dbalColumn->getType());
6667

6768
$column->time();
68-
$this->assertSame(Type::getType(Type::TIME), $dbalColumn->getType());
69+
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());
6970

7071
$column->array();
71-
$this->assertSame(Type::getType(Type::TARRAY), $dbalColumn->getType());
72+
$this->assertSame(Type::getType(Types::ARRAY), $dbalColumn->getType());
7273

7374
$column->simpleArray();
74-
$this->assertSame(Type::getType(Type::SIMPLE_ARRAY), $dbalColumn->getType());
75+
$this->assertSame(Type::getType(Types::SIMPLE_ARRAY), $dbalColumn->getType());
7576

7677
$column->jsonArray();
77-
$this->assertSame(Type::getType(Type::JSON_ARRAY), $dbalColumn->getType());
78+
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());
7879

7980
$column->object();
80-
$this->assertSame(Type::getType(Type::OBJECT), $dbalColumn->getType());
81+
$this->assertSame(Type::getType(Types::OBJECT), $dbalColumn->getType());
8182

82-
if (defined('Doctrine\\DBAL\\Types\\Type::BINARY')) {
83-
$column->binary(43);
84-
$this->assertSame(Type::getType(Type::BINARY), $dbalColumn->getType());
85-
$this->assertSame(43, $dbalColumn->getLength());
86-
$this->assertSame(false, $dbalColumn->getFixed());
87-
}
83+
$column->binary(43);
84+
$this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType());
85+
$this->assertSame(43, $dbalColumn->getLength());
86+
$this->assertSame(false, $dbalColumn->getFixed());
8887

89-
if (defined('Doctrine\\DBAL\\Types\\Type::DATE_IMMUTABLE')) {
90-
// Doctrine DBAL 2.6+
91-
$column->dateImmutable();
92-
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());
88+
$column->dateImmutable();
89+
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());
9390

94-
$column->datetimeImmutable();
95-
$this->assertSame(Type::getType(Type::DATETIME_IMMUTABLE), $dbalColumn->getType());
91+
$column->datetimeImmutable();
92+
$this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType());
9693

97-
$column->datetimeTzImmutable();
98-
$this->assertSame(Type::getType(Type::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
94+
$column->datetimeTzImmutable();
95+
$this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
9996

100-
$column->time();
101-
$this->assertSame(Type::getType(Type::TIME), $dbalColumn->getType());
97+
$column->time();
98+
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());
10299

103-
$column->timeImmutable();
104-
$this->assertSame(Type::getType(Type::TIME_IMMUTABLE), $dbalColumn->getType());
100+
$column->timeImmutable();
101+
$this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType());
105102

106-
$column->dateInterval();
107-
$this->assertSame(Type::getType(Type::DATEINTERVAL), $dbalColumn->getType());
103+
$column->dateInterval();
104+
$this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType());
108105

109-
$column->json();
110-
$this->assertSame(Type::getType(Type::JSON), $dbalColumn->getType());
111-
}
106+
$column->json();
107+
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());
112108

113109
$this->assertSame('foo', $column->getDbalColumn()->getName());
114110
}
@@ -126,7 +122,7 @@ public function testReference()
126122

127123
$dbalColumn = $schema->getTable('users')->getColumn('country_id');
128124

129-
$this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType());
125+
$this->assertSame(Type::getType(Types::INTEGER), $dbalColumn->getType());
130126
$fk = $schema->getTable('users')->getForeignKey('myfk');
131127
$this->assertSame('users', $fk->getLocalTableName());
132128
$this->assertSame('countries', $fk->getForeignTableName());

0 commit comments

Comments
 (0)