Skip to content

Commit

Permalink
Merge pull request #13 from aszenz/master
Browse files Browse the repository at this point in the history
ci: Improve tests + fix ci deps
  • Loading branch information
moufmouf authored Jan 28, 2024
2 parents d7155ca + eb7b229 commit e0b57b1
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 51 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@ jobs:
dependencies:
- "lowest"
- "highest"
exclude:
# Exclude lowest deps version as they don't support newer php versions
- dependencies: "lowest"
php-version: "8.3"
- dependencies: "lowest"
php-version: "8.2"
- dependencies: "lowest"
php-version: "8.1"

steps:
- name: "Checkout"
Expand All @@ -48,6 +40,9 @@ jobs:
run: "vendor/bin/phpunit -c phpunit.xml.dist"

- name: Upload coverage results to Coveralls
# skip php-coversalls for lowest deps
# it fails on lowest depedencies because old versions of guzzle doesn't work well with newer php versions
if: "${{ 'highest' == matrix.dependencies }}"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
Expand Down
11 changes: 3 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"require": {
"php": "^7.4 || ^8.0",
"doctrine/dbal": "^3.0",
"doctrine/inflector": "^1.0 || ^2.0"
"doctrine/inflector": "^1.4 || ^2.0"
},
"require-dev": {
"phpunit/phpunit": "^10.2",
"php-coveralls/php-coveralls": "^2.0.0"
"php-coveralls/php-coveralls": "^2.7.0"
},
"autoload": {
"psr-4": {
Expand All @@ -28,10 +28,5 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
}
}
"prefer-stable": true
}
4 changes: 2 additions & 2 deletions src/FluidColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public function dateInterval(): FluidColumnOptions
}

/**
* @depracated Use json() instead
* @deprecated Use json() instead
*/
public function array(): FluidColumnOptions
{
Expand Down Expand Up @@ -211,7 +211,7 @@ public function jsonArray(): FluidColumnOptions
}

/**
* @depracated Use json() instead
* @deprecated Use json() instead
*/
public function object(): FluidColumnOptions
{
Expand Down
41 changes: 18 additions & 23 deletions tests/FluidColumnTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,36 +80,31 @@ public function testTypes()
$column->object();
$this->assertSame(Type::getType(Types::OBJECT), $dbalColumn->getType());

if (defined('Doctrine\\DBAL\\Types\\Types::BINARY')) {
$column->binary(43);
$this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType());
$this->assertSame(43, $dbalColumn->getLength());
$this->assertSame(false, $dbalColumn->getFixed());
}
$column->binary(43);
$this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType());
$this->assertSame(43, $dbalColumn->getLength());
$this->assertSame(false, $dbalColumn->getFixed());

if (defined('Doctrine\\DBAL\\Types\\Types::DATE_IMMUTABLE')) {
// Doctrine DBAL 2.6+
$column->dateImmutable();
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());
$column->dateImmutable();
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());

$column->datetimeImmutable();
$this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType());
$column->datetimeImmutable();
$this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType());

$column->datetimeTzImmutable();
$this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
$column->datetimeTzImmutable();
$this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());

$column->time();
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());
$column->time();
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());

$column->timeImmutable();
$this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType());
$column->timeImmutable();
$this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType());

$column->dateInterval();
$this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType());
$column->dateInterval();
$this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType());

$column->json();
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());
}
$column->json();
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());

$this->assertSame('foo', $column->getDbalColumn()->getName());
}
Expand Down
31 changes: 21 additions & 10 deletions tests/FluidTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,15 @@ public function testUuid()

public function testTimestamps()
{
if (defined('Doctrine\\DBAL\\Types\\Types::DATE_IMMUTABLE')) {
$schema = new Schema();
$fluid = new FluidSchema($schema);
$schema = new Schema();
$fluid = new FluidSchema($schema);

$posts = $fluid->table('posts');
$posts = $fluid->table('posts');

$posts->timestamps();
$posts->timestamps();

$this->assertTrue($schema->getTable('posts')->hasColumn('created_at'));
$this->assertTrue($schema->getTable('posts')->hasColumn('updated_at'));
} else {
$this->markTestSkipped("Only available from Doctrine DBAL 2.6");
}
$this->assertTrue($schema->getTable('posts')->hasColumn('created_at'));
$this->assertTrue($schema->getTable('posts')->hasColumn('updated_at'));
}

public function testInherits()
Expand All @@ -138,6 +134,21 @@ public function testInherits()
$this->assertSame(['id'], $fk->getLocalColumns());
}

public function testCannotInheritFromATableWithMultiplePrimaryKeys()
{
$schema = new Schema();
$fluid = new FluidSchema($schema);

$contacts = $fluid->table('contacts');
$contacts->column('foo')->string();
$contacts->column('bar')->string();
$contacts->primaryKey(['foo', 'bar']);

$this->expectException(FluidSchemaException::class);

$fluid->table('users')->extends('contacts');
}

public function testGetDbalTable()
{
$schema = new Schema();
Expand Down

0 comments on commit e0b57b1

Please sign in to comment.