Skip to content

Commit 5a8382e

Browse files
committed
add basic tests on types and tools
add ci
1 parent c45663b commit 5a8382e

19 files changed

+446
-34
lines changed

.github/workflows/ci.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
on:
3+
push:
4+
branches: [ dev, master ]
5+
pull_request:
6+
branches: [ dev, master ]
7+
jobs:
8+
tests:
9+
runs-on: 'Ubuntu-20.04'
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
php: ['8.1', '8.2']
14+
15+
name: Tests PHP ${{ matrix.php }}
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: '${{ matrix.php }}'
21+
coverage: none
22+
ini-values: 'memory_limit=-1'
23+
- uses: "ramsey/composer-install@v2"
24+
- name: Run Unit tests
25+
run: vendor/bin/phpunit
26+
style:
27+
runs-on: 'Ubuntu-20.04'
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
php: [ '8.2' ]
32+
name: Style PHP ${{ matrix.php }}
33+
steps:
34+
- uses: actions/checkout@v2
35+
- uses: shivammathur/setup-php@v2
36+
with:
37+
php-version: '${{ matrix.php }}'
38+
coverage: none
39+
ini-values: 'memory_limit=-1'
40+
- uses: "ramsey/composer-install@v2"
41+
- name: Run Style checks
42+
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php -v --dry-run --stop-on-violation

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"doctrine/orm": "^2.13",
4040
"symfony/serializer": ">=5.4",
4141
"symfony/property-info": ">=5.4",
42-
"phpunit/phpunit": "^10.0"
42+
"phpunit/phpunit": "^10.0",
43+
"symfony/property-access": ">=5.4"
4344
}
4445
}

phpunit.xml.dist

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?xml version="1.0"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd">
3-
<testsuites>
4-
<testsuite name="PostgreSQLDoctrine">
5-
<directory suffix="Test.php">./tests</directory>
6-
</testsuite>
7-
</testsuites>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd">
3+
<testsuites>
4+
<testsuite name="PostgreSQLDoctrine">
5+
<directory suffix="Test.php">./tests</directory>
6+
</testsuite>
7+
</testsuites>
88

9-
<coverage>
10-
<include>
11-
<directory>./src</directory>
12-
</include>
13-
</coverage>
14-
</phpunit>
9+
<source>
10+
<include>
11+
<directory>./src</directory>
12+
</include>
13+
</source>
14+
</phpunit>

src/DBAL/Platform/PostgreSQLPlatform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Pfilsx\PostgreSQLDoctrine\DBAL\Type\EnumType;
1515
use Pfilsx\PostgreSQLDoctrine\DBAL\Type\JsonModelType;
1616

17-
final class PostgreSQLPlatform extends BasePlatform
17+
class PostgreSQLPlatform extends BasePlatform
1818
{
1919
public function createSchemaManager(Connection $connection): PostgreSQLSchemaManager
2020
{

src/DBAL/Schema/EnumTypeUsageAsset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class EnumTypeUsageAsset
1212

1313
private ?string $default;
1414

15-
public function __construct(string $table, string $column, ?string $default = null)
15+
public function __construct(string $table, string $column, string $default = null)
1616
{
1717
$this->table = $table;
1818
$this->column = $column;

src/DBAL/Schema/PostgreSQLSchemaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function createComparator(): Comparator
6161
return new Comparator($this->_platform);
6262
}
6363

64-
protected function selectTableColumns(string $databaseName, ?string $tableName = null): Result
64+
protected function selectTableColumns(string $databaseName, string $tableName = null): Result
6565
{
6666
$sql = 'SELECT';
6767

src/DBAL/Schema/Schema.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class Schema extends BaseSchema
1818
public function __construct(
1919
array $tables = [],
2020
array $sequences = [],
21-
?SchemaConfig $schemaConfig = null,
21+
SchemaConfig $schemaConfig = null,
2222
array $namespaces = [],
2323
array $types = []
2424
) {

src/DBAL/Schema/SchemaDiff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(
2222
array $createdTables = [],
2323
array $alteredTables = [],
2424
array $droppedTables = [],
25-
?Schema $fromSchema = null,
25+
Schema $fromSchema = null,
2626
array $createdSchemas = [],
2727
array $droppedSchemas = [],
2828
array $createdSequences = [],

src/DBAL/Schema/Table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function addColumn($name, $typeName, array $options = []): Column
2727
*
2828
* @return self
2929
*/
30-
public function modifyColumn($name, array $options, ?string $enumClass = null): self
30+
public function modifyColumn($name, array $options, string $enumClass = null): self
3131
{
3232
$column = $this->getColumn($name);
3333
$column->setOptions($options);

src/DBAL/Type/JsonModelType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function convertToDatabaseValue(mixed $value, AbstractPlatform $platform)
3232
return null;
3333
}
3434

35-
if (!\is_object($value)) {
35+
if (!\is_object($value) || get_class($value) !== static::getModelClass()) {
3636
throw ConversionException::conversionFailed($value, $this->getName());
3737
}
3838

0 commit comments

Comments
 (0)