From ea092c24d75210bb422b2f4c7cae69eece43dbf3 Mon Sep 17 00:00:00 2001 From: Matias Navarro Carter Date: Fri, 20 Nov 2020 12:13:41 +0000 Subject: [PATCH] Fixed Github Workflow --- .github/workflows/pr.yml | 18 +++++++++--------- composer.json | 2 +- tests/Doctrine/NumericRutTypeTest.php | 16 +++++++++++----- tests/Doctrine/RutTypeTest.php | 18 ++++++++++++------ 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bb8c5a0..2c89a07 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -30,9 +30,9 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" - name: "Cache dependencies" uses: "actions/cache@v2" with: @@ -64,9 +64,9 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" - name: "Cache dependencies" uses: "actions/cache@v2" with: @@ -103,9 +103,9 @@ jobs: ini-values: memory_limit=-1 tools: composer:v2 - name: Get Composer Cache Directory - id: composer-cache - run: | - echo "::set-output name=dir::$(composer config cache-files-dir)" + id: composer-cache + run: | + echo "::set-output name=dir::$(composer config cache-files-dir)" - name: "Cache dependencies" uses: "actions/cache@v2" with: diff --git a/composer.json b/composer.json index 59c4d0e..f000b15 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", "phpunit/phpunit": "^9.0", - "doctrine/dbal": "^2.5", + "doctrine/dbal": "^2.10.1|^3.0", "symfony/var-dumper": "^5.1", "vimeo/psalm": "^4.2" }, diff --git a/tests/Doctrine/NumericRutTypeTest.php b/tests/Doctrine/NumericRutTypeTest.php index a4b687b..2ee2a1e 100644 --- a/tests/Doctrine/NumericRutTypeTest.php +++ b/tests/Doctrine/NumericRutTypeTest.php @@ -4,15 +4,21 @@ namespace MNC\ChileanRut\Doctrine; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\Type; use MNC\ChileanRut\Rut; use PHPUnit\Framework\TestCase; class NumericRutTypeTest extends TestCase { + public static function setUpBeforeClass(): void + { + Type::addType(NumericRutType::NAME, NumericRutType::class); + } + public function testItConvertsNullFromDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new NumericRutType(); + $type = Type::getType(NumericRutType::NAME); $result = $type->convertToPHPValue(null, $platform); self::assertNull($result); } @@ -20,7 +26,7 @@ class NumericRutTypeTest extends TestCase public function testItConvertsStringFromDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new NumericRutType(); + $type = Type::getType(NumericRutType::NAME); $result = $type->convertToPHPValue(16894365, $platform); self::assertInstanceOf(Rut::class, $result); } @@ -28,7 +34,7 @@ class NumericRutTypeTest extends TestCase public function testItConvertsNullToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new NumericRutType(); + $type = Type::getType(NumericRutType::NAME); $result = $type->convertToDatabaseValue(null, $platform); self::assertNull($result); } @@ -36,7 +42,7 @@ class NumericRutTypeTest extends TestCase public function testItConvertsRutToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new NumericRutType(); + $type = Type::getType(NumericRutType::NAME); $result = $type->convertToDatabaseValue(Rut::parse('168943652'), $platform); self::assertSame('16894365', $result); } @@ -44,7 +50,7 @@ class NumericRutTypeTest extends TestCase public function testItCannotConvertToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new NumericRutType(); + $type = Type::getType(NumericRutType::NAME); $this->expectException(ConversionException::class); $type->convertToDatabaseValue(new \DateTime(), $platform); } diff --git a/tests/Doctrine/RutTypeTest.php b/tests/Doctrine/RutTypeTest.php index 1a87215..edb469b 100644 --- a/tests/Doctrine/RutTypeTest.php +++ b/tests/Doctrine/RutTypeTest.php @@ -4,15 +4,21 @@ namespace MNC\ChileanRut\Doctrine; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\ConversionException; +use Doctrine\DBAL\Types\Type; use MNC\ChileanRut\Rut; use PHPUnit\Framework\TestCase; class RutTypeTest extends TestCase { + public static function setUpBeforeClass(): void + { + Type::addType(RutType::NAME, RutType::class); + } + public function testItConvertsNullFromDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $result = $type->convertToPHPValue(null, $platform); self::assertNull($result); } @@ -20,7 +26,7 @@ class RutTypeTest extends TestCase public function testItConvertsStringFromDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $result = $type->convertToPHPValue('16.894.365-2', $platform); self::assertInstanceOf(Rut::class, $result); } @@ -28,7 +34,7 @@ class RutTypeTest extends TestCase public function testItCannotConvertFromDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $this->expectException(ConversionException::class); $type->convertToPHPValue(true, $platform); } @@ -36,7 +42,7 @@ class RutTypeTest extends TestCase public function testItConvertsNullToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $result = $type->convertToDatabaseValue(null, $platform); self::assertNull($result); } @@ -44,7 +50,7 @@ class RutTypeTest extends TestCase public function testItConvertsRutToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $result = $type->convertToDatabaseValue(Rut::parse('168943652'), $platform); self::assertSame('16.894.365-2', $result); } @@ -52,7 +58,7 @@ class RutTypeTest extends TestCase public function testItCannotConvertToDatabaseValue(): void { $platform = $this->createMock(AbstractPlatform::class); - $type = new RutType(); + $type = Type::getType(RutType::NAME); $this->expectException(ConversionException::class); $type->convertToDatabaseValue(new \DateTime(), $platform); }