Unverified Commit cc7bc1e7 authored by Grégoire Paris's avatar Grégoire Paris

Merge branch '3.0.x'

parents 3b6e69d4 9e9e32e0
...@@ -5,29 +5,100 @@ on: ...@@ -5,29 +5,100 @@ on:
pull_request: pull_request:
jobs: jobs:
static-analysis-phpstan:
name: "Static Analysis with PHPStan"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "7.4"
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"
- name: "Run a static analysis with phpstan/phpstan"
run: "vendor/bin/phpstan analyse --error-format=checkstyle | cs2pr"
static-analysis-psalm: static-analysis-psalm:
name: Static Analysis with Psalm name: "Static Analysis with Psalm"
runs-on: ubuntu-latest runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "7.4"
steps:
- name: "Checkout code"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "${{ matrix.php-version }}"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
- name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest"
- name: "Run a static analysis with vimeo/psalm"
run: "vendor/bin/psalm --show-info=false --stats --output-format=github --threads=4"
coding-standards:
name: "Coding Standards"
runs-on: "ubuntu-latest"
strategy:
matrix:
php-version:
- "7.4"
steps: steps:
- name: Checkout code - name: "Checkout"
uses: actions/checkout@v2 uses: "actions/checkout@v2"
- name: "Install PHP" - name: "Install PHP"
uses: "shivammathur/setup-php@1.8.1" uses: "shivammathur/setup-php@v2"
with: with:
coverage: "none" coverage: "none"
php-version: "7.4" php-version: "${{ matrix.php-version }}"
tools: "cs2pr"
- name: "Cache dependencies installed with composer" - name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3" uses: "actions/cache@v1"
with: with:
path: "~/.composer/cache" path: "~/.composer/cache"
key: "composer-${{ hashFiles('composer.lock') }}" key: "php-${{ matrix.php-version }}-composer-locked-${{ hashFiles('composer.lock') }}"
restore-keys: "composer-" restore-keys: "php-${{ matrix.php-version }}-composer-locked-"
- name: "Install dependencies with composer" - name: "Install dependencies with composer"
run: "composer install --no-interaction --no-progress --no-suggest" run: "composer install --no-interaction --no-progress --no-suggest"
- name: Psalm - name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/psalm" run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
...@@ -48,16 +48,6 @@ jobs: ...@@ -48,16 +48,6 @@ jobs:
- stage: Smoke Testing - stage: Smoke Testing
php: 7.4 php: 7.4
env: DB=sqlite COVERAGE=yes env: DB=sqlite COVERAGE=yes
- stage: Smoke Testing
php: 7.4
env: PHPStan
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpstan analyse
- stage: Smoke Testing
php: 7.4
env: PHP_CodeSniffer
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpcs
- stage: Test - stage: Test
php: 7.3 php: 7.3
......
...@@ -48,7 +48,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor ...@@ -48,7 +48,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{ {
if (! $this->platform->supportsForeignKeyConstraints()) { if (! $this->platform->supportsCreateDropForeignKeyConstraints()) {
return; return;
} }
......
<?php
declare(strict_types=1);
namespace Doctrine\DBAL\Tests\Functional\Schema;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Tests\FunctionalTestCase;
class ForeignKeyTest extends FunctionalTestCase
{
public function testCreatingATableWithAForeignKey() : void
{
$schema = new Schema();
$referencedTable = $schema->createTable('referenced_table');
$referencedTable->addColumn('id', 'integer');
$referencedTable->setPrimaryKey(['id']);
$referencingTable = $schema->createTable('referencing_table');
$referencingTable->addColumn('referenced_id', 'integer');
$referencingTable->addForeignKeyConstraint(
$referencedTable,
['referenced_id'],
['id']
);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
}
self::assertCount(
1,
$this->connection->getSchemaManager()->listTableForeignKeys('referencing_table')
);
}
}
...@@ -31,7 +31,7 @@ class CreateSchemaSqlCollectorTest extends TestCase ...@@ -31,7 +31,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
'getCreateSchemaSQL', 'getCreateSchemaSQL',
'getCreateSequenceSQL', 'getCreateSequenceSQL',
'getCreateTableSQL', 'getCreateTableSQL',
'supportsForeignKeyConstraints', 'supportsCreateDropForeignKeyConstraints',
'supportsSchemas', 'supportsSchemas',
] ]
) )
...@@ -78,11 +78,11 @@ class CreateSchemaSqlCollectorTest extends TestCase ...@@ -78,11 +78,11 @@ class CreateSchemaSqlCollectorTest extends TestCase
public function testAcceptsForeignKey() : void public function testAcceptsForeignKey() : void
{ {
$this->platformMock->expects(self::at(0)) $this->platformMock->expects(self::at(0))
->method('supportsForeignKeyConstraints') ->method('supportsCreateDropForeignKeyConstraints')
->will(self::returnValue(false)); ->will(self::returnValue(false));
$this->platformMock->expects(self::at(1)) $this->platformMock->expects(self::at(1))
->method('supportsForeignKeyConstraints') ->method('supportsCreateDropForeignKeyConstraints')
->will(self::returnValue(true)); ->will(self::returnValue(true));
$table = $this->createTableMock(); $table = $this->createTableMock();
...@@ -108,7 +108,7 @@ class CreateSchemaSqlCollectorTest extends TestCase ...@@ -108,7 +108,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
public function testResetsQueries() : void public function testResetsQueries() : void
{ {
foreach (['supportsSchemas', 'supportsForeignKeyConstraints'] as $method) { foreach (['supportsSchemas', 'supportsCreateDropForeignKeyConstraints'] as $method) {
$this->platformMock->expects(self::any()) $this->platformMock->expects(self::any())
->method($method) ->method($method)
->will(self::returnValue(true)); ->will(self::returnValue(true));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment