Skip to content

Commit 2b971c1

Browse files
authored
Merge pull request #6 from yokai-php/tests-multiple-doctrine-versions
Run tests on different Doctrine versions
2 parents eec14b3 + 1203f16 commit 2b971c1

File tree

8 files changed

+86
-56
lines changed

8 files changed

+86
-56
lines changed

.github/actions/install/action.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
php-version:
77
required: true
88
type: string
9+
dbal-version:
10+
required: true
11+
type: string
12+
orm-version:
13+
required: true
14+
type: string
915
coverage-mode:
1016
required: false
1117
type: string
@@ -25,4 +31,6 @@ runs:
2531
- name: "Install dependencies with composer"
2632
shell: bash
2733
run: |
34+
composer require --quiet --no-update "doctrine/orm:${{ inputs.orm-version }}"
35+
composer require --quiet --no-update "doctrine/dbal:${{ inputs.dbal-version }}"
2836
composer update --no-interaction --no-progress --no-suggest

.github/workflows/tests.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,20 @@ jobs:
1414
matrix:
1515
include:
1616
- php-version: '8.0'
17+
dbal-version: '^3.8'
18+
orm-version: '^2.7'
1719
- php-version: '8.2'
20+
dbal-version: '^4.0'
21+
orm-version: '^3.1'
1822
steps:
1923
- name: "Checkout"
2024
uses: actions/checkout@v3
2125
- name: "Setup env & install dependencies"
2226
uses: ./.github/actions/install
2327
with:
2428
php-version: ${{ matrix.php-version }}
29+
dbal-version: ${{ matrix.dbal-version }}
30+
orm-version: ${{ matrix.orm-version }}
2531
- name: "Run tests with phpunit/phpunit"
2632
run: vendor/bin/phpunit
2733

@@ -35,6 +41,8 @@ jobs:
3541
uses: ./.github/actions/install
3642
with:
3743
php-version: '8.2'
44+
dbal-version: '^4.0'
45+
orm-version: '^3.1'
3846
- name: "Run static analyzis with phpstan/phpstan"
3947
run: vendor/bin/phpstan analyze
4048

@@ -48,6 +56,8 @@ jobs:
4856
uses: ./.github/actions/install
4957
with:
5058
php-version: '8.2'
59+
dbal-version: '^4.0'
60+
orm-version: '^3.1'
5161
- name: "Run checkstyle with squizlabs/php_codesniffer"
5262
run: vendor/bin/phpcs
5363

@@ -61,6 +71,8 @@ jobs:
6171
uses: ./.github/actions/install
6272
with:
6373
php-version: '8.2'
74+
dbal-version: '^4.0'
75+
orm-version: '^3.1'
6476
- name: "Run tests with phpunit/phpunit"
6577
env:
6678
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
}
1111
],
1212
"require": {
13-
"php": "^8",
14-
"doctrine/orm": "^2.7|^3.1",
13+
"php": "^8.0",
1514
"doctrine/dbal": "^3.8|^4.0",
15+
"doctrine/orm": "^2.7|^3.1",
1616
"webmozart/assert": "^1.11"
1717
},
1818
"autoload": {

src/Doctrine/Types/CollectionValueObjectType.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ final class CollectionValueObjectType extends Type
1717

1818
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
1919
{
20-
/** @var JsonType $typeInherit */
21-
$typeInherit = $this->getType(Types::JSON);
22-
return $typeInherit->getSQLDeclaration($column, $platform);
20+
return $this->getInheritedType()->getSQLDeclaration($column, $platform);
2321
}
2422

2523
/**
@@ -33,7 +31,7 @@ public static function getSupportedValueObjectType(): string
3331
/**
3432
* @inheritdoc
3533
*/
36-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
34+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
3735
{
3836
if ($value === null) {
3937
return null;
@@ -42,19 +40,15 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
4240
Assert::isInstanceOf($value, $this->class);
4341
/** @var CollectionValueObject $value */
4442

45-
/** @var JsonType $typeInherit */
46-
$typeInherit = $this->getType(Types::JSON);
47-
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
43+
return $this->getInheritedType()->convertToDatabaseValue($value->toValue(), $platform);
4844
}
4945

5046
/**
5147
* @inheritdoc
5248
*/
53-
public function convertToPHPValue($value, AbstractPlatform $platform): ?CollectionValueObject
49+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?CollectionValueObject
5450
{
55-
/** @var JsonType $typeInherit */
56-
$typeInherit = $this->getType(Types::JSON);
57-
$value = $typeInherit->convertToPHPValue($value, $platform);
51+
$value = $this->getInheritedType()->convertToPHPValue($value, $platform);
5852

5953
if ($value === null) {
6054
return null;
@@ -68,4 +62,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?Collecti
6862

6963
return $collection;
7064
}
65+
66+
private function getInheritedType(): JsonType
67+
{
68+
/** @var JsonType $type */
69+
$type = $this->getType(Types::JSON);
70+
71+
return $type;
72+
}
7173
}

src/Doctrine/Types/DateTimeValueObjectType.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ final class DateTimeValueObjectType extends Type
1818

1919
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
2020
{
21-
/** @var DateTimeTzImmutableType $typeInherit */
22-
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
23-
return $typeInherit->getSQLDeclaration($column, $platform);
21+
return $this->getInheritedType()->getSQLDeclaration($column, $platform);
2422
}
2523

2624
/**
@@ -34,7 +32,7 @@ public static function getSupportedValueObjectType(): string
3432
/**
3533
* @inheritdoc
3634
*/
37-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
35+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
3836
{
3937
if ($value === null) {
4038
return null;
@@ -43,19 +41,15 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
4341
Assert::isInstanceOf($value, $this->class);
4442
/** @var DateTimeValueObject $value */
4543

46-
/** @var DateTimeTzImmutableType $typeInherit */
47-
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
48-
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
44+
return $this->getInheritedType()->convertToDatabaseValue($value->toValue(), $platform);
4945
}
5046

5147
/**
5248
* @inheritdoc
5349
*/
5450
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?DateTimeValueObject
5551
{
56-
/** @var DateTimeTzImmutableType $typeInherit */
57-
$typeInherit = $this->getType(Types::DATETIMETZ_IMMUTABLE);
58-
$value = $typeInherit->convertToPHPValue($value, $platform);
52+
$value = $this->getInheritedType()->convertToPHPValue($value, $platform);
5953

6054
if ($value === null) {
6155
return null;
@@ -69,4 +63,12 @@ public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?Da
6963

7064
return $object;
7165
}
66+
67+
private function getInheritedType(): DateTimeTzImmutableType
68+
{
69+
/** @var DateTimeTzImmutableType $type */
70+
$type = $this->getType(Types::DATETIMETZ_IMMUTABLE);
71+
72+
return $type;
73+
}
7274
}

src/Doctrine/Types/IntegerValueObjectType.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ final class IntegerValueObjectType extends Type
1717

1818
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
1919
{
20-
/** @var IntegerType $typeInherit */
21-
$typeInherit = $this->getType(Types::INTEGER);
22-
return $typeInherit->getSQLDeclaration($column, $platform);
20+
return $this->getInheritedType()->getSQLDeclaration($column, $platform);
2321
}
2422

2523
/**
@@ -33,7 +31,7 @@ public static function getSupportedValueObjectType(): string
3331
/**
3432
* @inheritdoc
3533
*/
36-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int
34+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?int
3735
{
3836
if ($value === null) {
3937
return null;
@@ -42,19 +40,15 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?int
4240
Assert::isInstanceOf($value, $this->class);
4341
/** @var IntegerValueObject $value */
4442

45-
/** @var IntegerType $typeInherit */
46-
$typeInherit = $this->getType(Types::INTEGER);
47-
return $typeInherit->convertToPHPValue($value->toValue(), $platform);
43+
return $this->getInheritedType()->convertToPHPValue($value->toValue(), $platform);
4844
}
4945

5046
/**
5147
* @inheritdoc
5248
*/
53-
public function convertToPHPValue($value, AbstractPlatform $platform): ?IntegerValueObject
49+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?IntegerValueObject
5450
{
55-
/** @var IntegerType $typeInherit */
56-
$typeInherit = $this->getType(Types::INTEGER);
57-
$value = $typeInherit->convertToPHPValue($value, $platform);
51+
$value = $this->getInheritedType()->convertToPHPValue($value, $platform);
5852

5953
if ($value === null) {
6054
return null;
@@ -68,4 +62,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?IntegerV
6862

6963
return $object;
7064
}
65+
66+
private function getInheritedType(): IntegerType
67+
{
68+
/** @var IntegerType $type */
69+
$type = $this->getType(Types::INTEGER);
70+
71+
return $type;
72+
}
7173
}

src/Doctrine/Types/ObjectValueObjectType.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ final class ObjectValueObjectType extends Type
1717

1818
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
1919
{
20-
/** @var JsonType $typeInherit */
21-
$typeInherit = $this->getType(Types::JSON);
22-
return $typeInherit->getSQLDeclaration($column, $platform);
20+
return $this->getInheritedType()->getSQLDeclaration($column, $platform);
2321
}
2422

2523
/**
@@ -33,7 +31,7 @@ public static function getSupportedValueObjectType(): string
3331
/**
3432
* @inheritdoc
3533
*/
36-
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
34+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): ?string
3735
{
3836
if ($value === null) {
3937
return null;
@@ -42,19 +40,15 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str
4240
Assert::isInstanceOf($value, $this->class);
4341
/** @var ObjectValueObject $value */
4442

45-
/** @var JsonType $typeInherit */
46-
$typeInherit = $this->getType(Types::JSON);
47-
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
43+
return $this->getInheritedType()->convertToDatabaseValue($value->toValue(), $platform);
4844
}
4945

5046
/**
5147
* @inheritdoc
5248
*/
53-
public function convertToPHPValue($value, AbstractPlatform $platform): ?ObjectValueObject
49+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?ObjectValueObject
5450
{
55-
/** @var JsonType $typeInherit */
56-
$typeInherit = $this->getType(Types::JSON);
57-
$value = $typeInherit->convertToPHPValue($value, $platform);
51+
$value = $this->getInheritedType()->convertToPHPValue($value, $platform);
5852

5953
if ($value === null) {
6054
return null;
@@ -68,4 +62,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?ObjectVa
6862

6963
return $collection;
7064
}
65+
66+
private function getInheritedType(): JsonType
67+
{
68+
/** @var JsonType $type */
69+
$type = $this->getType(Types::JSON);
70+
71+
return $type;
72+
}
7173
}

src/Doctrine/Types/StringValueObjectType.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ final class StringValueObjectType extends Type
1717

1818
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
1919
{
20-
/** @var StringType $typeInherit */
21-
$typeInherit = $this->getType(Types::STRING);
22-
return $typeInherit->getSQLDeclaration($column, $platform);
20+
return $this->getInheritedType()->getSQLDeclaration($column, $platform);
2321
}
2422

2523
/**
@@ -33,7 +31,7 @@ public static function getSupportedValueObjectType(): string
3331
/**
3432
* @inheritdoc
3533
*/
36-
public function convertToDatabaseValue($value, AbstractPlatform $platform): mixed
34+
public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform): mixed
3735
{
3836
if ($value === null) {
3937
return null;
@@ -42,19 +40,15 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): mixe
4240
Assert::isInstanceOf($value, $this->class);
4341
/** @var StringValueObject $value */
4442

45-
/** @var StringType $typeInherit */
46-
$typeInherit = $this->getType(Types::STRING);
47-
return $typeInherit->convertToDatabaseValue($value->toValue(), $platform);
43+
return $this->getInheritedType()->convertToDatabaseValue($value->toValue(), $platform);
4844
}
4945

5046
/**
5147
* @inheritdoc
5248
*/
53-
public function convertToPHPValue($value, AbstractPlatform $platform): ?StringValueObject
49+
public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?StringValueObject
5450
{
55-
/** @var StringType $typeInherit */
56-
$typeInherit = $this->getType(Types::STRING);
57-
$value = $typeInherit->convertToPHPValue($value, $platform);
51+
$value = $this->getInheritedType()->convertToPHPValue($value, $platform);
5852

5953
if ($value === null) {
6054
return null;
@@ -68,4 +62,12 @@ public function convertToPHPValue($value, AbstractPlatform $platform): ?StringVa
6862

6963
return $object;
7064
}
65+
66+
private function getInheritedType(): StringType
67+
{
68+
/** @var StringType $type */
69+
$type = $this->getType(Types::STRING);
70+
71+
return $type;
72+
}
7173
}

0 commit comments

Comments
 (0)