Skip to content

Commit

Permalink
Merge pull request #22 from aszenz/master
Browse files Browse the repository at this point in the history
deps: Upgrade to dbal v3 + fix tests/ci
  • Loading branch information
moufmouf authored Jan 28, 2024
2 parents 1aacb60 + 47f031a commit 77cd94f
Show file tree
Hide file tree
Showing 14 changed files with 176 additions and 136 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor/
/composer.lock
/build/
/phpunit.xml
/phpunit.xml
.phpunit.result.cache
1 change: 0 additions & 1 deletion .phpunit.result.cache

This file was deleted.

4 changes: 3 additions & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
build:
environment:
php:
version: 7.1
version: 8.1
ini:
xdebug.mode: coverage

checks:
php:
Expand Down
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

17 changes: 6 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -28,10 +28,5 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
}
"prefer-stable": true
}
51 changes: 27 additions & 24 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,28 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<testsuites>
<testsuite name="Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
</report>
</coverage>
<logging/>
</phpunit>
9 changes: 9 additions & 0 deletions src/TdbmFluidColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public function dateInterval(): TdbmFluidColumnOptions
return $this->getOptions($options);
}

/**
* @deprecated Use json() instead
*/
public function array(): TdbmFluidColumnOptions
{
$options = $this->fluidColumn->array();
Expand All @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/TdbmFluidColumnGraphqlOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use function addslashes;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;

use function var_export;

class TdbmFluidColumnGraphqlOptions
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions tests/TdbmFluidColumnGraphqlOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());
}
Expand Down
9 changes: 4 additions & 5 deletions tests/TdbmFluidColumnOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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'));
}
}
Loading

0 comments on commit 77cd94f

Please sign in to comment.