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:
pull_request:
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:
name: Static Analysis with Psalm
runs-on: ubuntu-latest
name: "Static Analysis with Psalm"
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:
- name: Checkout code
uses: actions/checkout@v2
- name: "Checkout"
uses: "actions/checkout@v2"
- name: "Install PHP"
uses: "shivammathur/setup-php@1.8.1"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "7.4"
php-version: "${{ matrix.php-version }}"
tools: "cs2pr"
- name: "Cache dependencies installed with composer"
uses: "actions/cache@v1.0.3"
uses: "actions/cache@v1"
with:
path: "~/.composer/cache"
key: "composer-${{ hashFiles('composer.lock') }}"
restore-keys: "composer-"
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: Psalm
run: "vendor/bin/psalm"
- name: "Run squizlabs/php_codesniffer"
run: "vendor/bin/phpcs -q --no-colors --report=checkstyle | cs2pr"
......@@ -48,16 +48,6 @@ jobs:
- stage: Smoke Testing
php: 7.4
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
php: 7.3
......
......@@ -48,7 +48,7 @@ class CreateSchemaSqlCollector extends AbstractVisitor
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) : void
{
if (! $this->platform->supportsForeignKeyConstraints()) {
if (! $this->platform->supportsCreateDropForeignKeyConstraints()) {
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
'getCreateSchemaSQL',
'getCreateSequenceSQL',
'getCreateTableSQL',
'supportsForeignKeyConstraints',
'supportsCreateDropForeignKeyConstraints',
'supportsSchemas',
]
)
......@@ -78,11 +78,11 @@ class CreateSchemaSqlCollectorTest extends TestCase
public function testAcceptsForeignKey() : void
{
$this->platformMock->expects(self::at(0))
->method('supportsForeignKeyConstraints')
->method('supportsCreateDropForeignKeyConstraints')
->will(self::returnValue(false));
$this->platformMock->expects(self::at(1))
->method('supportsForeignKeyConstraints')
->method('supportsCreateDropForeignKeyConstraints')
->will(self::returnValue(true));
$table = $this->createTableMock();
......@@ -108,7 +108,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
public function testResetsQueries() : void
{
foreach (['supportsSchemas', 'supportsForeignKeyConstraints'] as $method) {
foreach (['supportsSchemas', 'supportsCreateDropForeignKeyConstraints'] as $method) {
$this->platformMock->expects(self::any())
->method($method)
->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