Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.10.x' into 2.11.x
Browse files Browse the repository at this point in the history
  • Loading branch information
greg0ire committed May 7, 2020
2 parents 0a2e2f1 + f20ba14 commit a8544ca
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 26 deletions.
93 changes: 82 additions & 11 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
10 changes: 0 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ jobs:
- stage: Smoke Testing
php: 7.3
env: DB=sqlite COVERAGE=yes
- stage: Smoke Testing
php: 7.3
env: PHPStan
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpstan analyse
- stage: Smoke Testing
php: 7.3
env: PHP_CodeSniffer
install: travis_retry composer install --prefer-dist
script: vendor/bin/phpcs

- stage: Test
php: 7.2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function acceptTable(Table $table)
*/
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{
if (! $this->platform->supportsForeignKeyConstraints()) {
if (! $this->platform->supportsCreateDropForeignKeyConstraints()) {
return;
}

Expand Down
37 changes: 37 additions & 0 deletions tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\DBAL\Functional\Schema;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Tests\DbalFunctionalTestCase;

class ForeignKeyTest extends DbalFunctionalTestCase
{
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')
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function setUp() : void
'getCreateSchemaSQL',
'getCreateSequenceSQL',
'getCreateTableSQL',
'supportsForeignKeyConstraints',
'supportsCreateDropForeignKeyConstraints',
'supportsSchemas',
]
)
Expand Down Expand Up @@ -76,11 +76,11 @@ public function testAcceptsTable() : void
public function testAcceptsForeignKey() : void
{
$this->platformMock->expects($this->at(0))
->method('supportsForeignKeyConstraints')
->method('supportsCreateDropForeignKeyConstraints')
->will($this->returnValue(false));

$this->platformMock->expects($this->at(1))
->method('supportsForeignKeyConstraints')
->method('supportsCreateDropForeignKeyConstraints')
->will($this->returnValue(true));

$table = $this->createTableMock();
Expand All @@ -106,7 +106,7 @@ public function testAcceptsSequences() : void

public function testResetsQueries() : void
{
foreach (['supportsSchemas', 'supportsForeignKeyConstraints'] as $method) {
foreach (['supportsSchemas', 'supportsCreateDropForeignKeyConstraints'] as $method) {
$this->platformMock->expects($this->any())
->method($method)
->will($this->returnValue(true));
Expand Down

0 comments on commit a8544ca

Please sign in to comment.