diff --git a/.github/workflows/platform-matrix-test.yml b/.github/workflows/platform-test.yml similarity index 56% rename from .github/workflows/platform-matrix-test.yml rename to .github/workflows/platform-test.yml index a74ec83c..22e867ea 100644 --- a/.github/workflows/platform-matrix-test.yml +++ b/.github/workflows/platform-test.yml @@ -1,6 +1,6 @@ # https://help.github.com/en/categories/automating-your-workflow-with-github-actions -name: "Platform matrix test" +name: "Platform test" on: pull_request: @@ -10,18 +10,31 @@ on: jobs: tests: - name: "Platform matrix test" + name: "Platform test" runs-on: "ubuntu-latest" env: MYSQL_HOST: '127.0.0.1' PGSQL_HOST: '127.0.0.1' + MSSQL_HOST: '127.0.0.1' strategy: fail-fast: false matrix: php-version: + - "7.4" - "8.0" - "8.1" + - "8.2" + - "8.3" + update-packages: + - "" + include: + - php-version: "8.1" + update-packages: doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 gedmo/doctrine-extensions:^3 + - php-version: "8.2" + update-packages: doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 gedmo/doctrine-extensions:^3 + - php-version: "8.3" + update-packages: doctrine/orm:^3.0 doctrine/dbal:^4.0 carbonphp/carbon-doctrine-types:^3 gedmo/doctrine-extensions:^3 steps: - name: "Checkout" @@ -38,6 +51,10 @@ jobs: - name: "Install dependencies" run: "composer install --no-interaction --no-progress" + - name: "Update packages" + if: ${{ matrix.update-packages != '' }} + run: composer require --dev ${{ matrix.update-packages }} -W + - name: "Run platform matrix test" run: vendor/bin/phpunit --group=platform @@ -59,3 +76,12 @@ jobs: MYSQL_DATABASE: foo ports: - "3306:3306" + + mssql: + image: mcr.microsoft.com/mssql/server:latest + env: + ACCEPT_EULA: Y + SA_PASSWORD: 'Secret.123' + MSSQL_PID: Developer + ports: + - 1433:1433 diff --git a/tests/Platform/MatrixEntity/TestEntity.php b/tests/Platform/Entity/PlatformEntity.php similarity index 55% rename from tests/Platform/MatrixEntity/TestEntity.php rename to tests/Platform/Entity/PlatformEntity.php index 74f2ae57..d0c1a5aa 100644 --- a/tests/Platform/MatrixEntity/TestEntity.php +++ b/tests/Platform/Entity/PlatformEntity.php @@ -1,6 +1,6 @@ setAutoGenerateProxyClasses(false); $config->setSecondLevelCacheEnabled(false); $config->setMetadataCache(new ArrayCachePool()); - $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [__DIR__ . '/MatrixEntity'])); + + if (InstalledVersions::satisfies(new VersionParser(), 'doctrine/orm', '3.*')) { + $config->setMetadataDriverImpl(new AttributeDriver([__DIR__ . '/Entity'])); + } else { + $config->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), [__DIR__ . '/Entity'])); + } + $entityManager = new EntityManager($connection, $config); } catch (DbalException $e) { @@ -104,7 +115,8 @@ public function testFetchedTypes( $schemaTool->dropSchema($classes); $schemaTool->createSchema($classes); - $entity = new TestEntity(); + $entity = new PlatformEntity(); + $entity->id = '1'; $entity->col_bool = true; $entity->col_float = 0.125; $entity->col_decimal = '0.1'; @@ -125,7 +137,7 @@ public function testFetchedTypes( if ($expectedType === null) { continue; // e.g. no such function } - $dql = sprintf($columnsQueryTemplate, $select, TestEntity::class); + $dql = sprintf($columnsQueryTemplate, $select, PlatformEntity::class); $query = $entityManager->createQuery($dql); $result = $query->getSingleResult(); @@ -214,7 +226,7 @@ public function provideCases(): iterable '1' => ['int', 'int', 'int', 'int', 'string', 'string'], '2147483648' => ['int', 'int', 'int', 'int', 'string', 'string'], 't.col_int' => ['int', 'int', 'int', 'int', 'int', 'int'], - 't.col_bigint' => ['string', 'string', 'string', 'string', 'string', 'string'], + 't.col_bigint' => self::hasDbal4() ? array_fill(0, 6, 'int') : array_fill(0, 6, 'string'), 'SUM(t.col_int)' => ['string', 'int', 'int', 'int', 'string', 'string'], 'SUM(t.col_bigint)' => ['string', 'int', 'string', 'string', 'string', 'string'], "LENGTH('')" => ['int', 'int', 'int', 'int', 'int', 'int'], @@ -408,4 +420,13 @@ private function getNativeConnection(Connection $connection) throw new LogicException('Unable to get native connection'); } + private static function hasDbal4(): bool + { + if (!class_exists(InstalledVersions::class)) { + return false; + } + + return InstalledVersions::satisfies(new VersionParser(), 'doctrine/dbal', '4.*'); + } + }