Skip to content

Commit

Permalink
fix tests & add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pvsaintpe committed Aug 23, 2019
1 parent 8a000d3 commit 67c9bb0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 11 deletions.
24 changes: 16 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ script:
fi
- |
if [ "x$COVERAGE" == "xyes" ]; then
./vendor/bin/phpunit --configuration phpunit.travis.xml --coverage-clover build/logs/clover.xml
if [[ -z "${EXCLUDE_GROUP}" ]]; then
./vendor/bin/phpunit --configuration phpunit.travis.xml --exclude-group $EXCLUDE_GROUP --coverage-clover build/logs/clover.xml
else
./vendor/bin/phpunit --configuration phpunit.travis.xml --coverage-clover build/logs/clover.xml
fi
else
if [[ -z "${EXCLUDE_GROUP}" ]]; then
./vendor/bin/phpunit --configuration phpunit.travis.xml --group $EXCLUDEGROUP
else
./vendor/bin/phpunit --configuration phpunit.travis.xml
fi
fi
after_success:
Expand All @@ -46,48 +54,48 @@ matrix:
include:
- stage: Test
php: "7.2"
env: DB=pgsql POSTGRESQL_VERSION=11.0
env: DB=pgsql POSTGRESQL_VERSION=11.0 EXCLUDE_GROUP=php73-pg10
sudo: required
services:
- docker
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=9.2 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=9.2 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
services:
- postgresql
addons:
postgresql: "9.2"
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=9.3 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
services:
- postgresql
addons:
postgresql: "9.3"
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=9.4 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
services:
- postgresql
addons:
postgresql: "9.4"
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=9.5 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=9.5 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
services:
- postgresql
addons:
postgresql: "9.5"
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=9.6 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=9.6 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
services:
- postgresql
addons:
postgresql: "9.6"
- stage: Test
php: "7.3"
env: DB=pgsql POSTGRESQL_VERSION=10.0 COVERAGE=yes
env: DB=pgsql POSTGRESQL_VERSION=10.0 COVERAGE=yes EXCLUDE_GROUP=php73-pg10
sudo: required
services:
- postgresql
Expand Down
1 change: 0 additions & 1 deletion src/Helpers/ColumnAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

/**
* @mixin TestCase
* @codeCoverageIgnore
*/
trait ColumnAssertions
{
Expand Down
25 changes: 25 additions & 0 deletions tests/Functional/Schema/CreateIndexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,32 @@ public function createIndexIfNotExists(): void
});

$this->seeIndex('test_table_name_unique');
}

/**
* @test
* @group php73-pg10
*/
public function createIndexDefinition(): void
{
Schema::create('test_table', function (Blueprint $table) {
$table->increments('id');
$table->string('name');

if (!$table->hasIndex(['name'], true)) {
$table->unique(['name']);
}
});

$this->seeTable('test_table');

Schema::table('test_table', function (Blueprint $table) {
if (!$table->hasIndex(['name'], true)) {
$table->unique(['name']);
}
});

$this->seeIndex('test_table_name_unique');
$this->assertSameIndex(
'test_table_name_unique',
'CREATE UNIQUE INDEX test_table_name_unique ON public.test_table USING btree (name)'
Expand Down
14 changes: 12 additions & 2 deletions tests/Functional/Schema/CreateTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,34 @@

use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Schema;
use Umbrellio\Postgres\Helpers\ColumnAssertions;
use Umbrellio\Postgres\Helpers\TableAssertions;
use Umbrellio\Postgres\Schema\Blueprint;
use Umbrellio\Postgres\Tests\FunctionalTestCase;

class CreateTableTest extends FunctionalTestCase
{
use DatabaseTransactions, TableAssertions;
use DatabaseTransactions, TableAssertions, ColumnAssertions;

/** @test */
public function createSimple(): void
{
Schema::create('test_table', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('field_comment')->comment('test');
$table->integer('field_default')->default(123);
});

$this->seeTable('test_table');
$this->assertSameTable(['id', 'name'], 'test_table');

$this->assertSameTable(['id', 'name', 'field_comment', 'field_default'], 'test_table');

$this->assertTypeColumn('test_table', 'id', 'integer');
$this->assertTypeColumn('test_table', 'name', 'string');

$this->assertDefaultOnColumn('test_table', 'field_default', '123');
$this->assertCommentOnColumn('test_table', 'field_comment', 'test');
}

/** @test */
Expand Down

0 comments on commit 67c9bb0

Please sign in to comment.