Skip to content

Commit

Permalink
Support PHP8 #41
Browse files Browse the repository at this point in the history
  • Loading branch information
brunobg committed Jan 2, 2021
1 parent 1b41f11 commit 2772d3e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 33 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ["7.2", "7.3", "7.4"]
php-versions: ["7.2", "7.3", "7.4", "8.0"]

name: PHP ${{ matrix.php-versions }} Test
steps:
Expand Down Expand Up @@ -101,7 +101,6 @@ jobs:

- name: Nojekyll
run: touch docs/coverage-report/.nojekyll

# - name: Deploy 🚀
# uses: JamesIves/[email protected]
# with:
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -463,4 +463,6 @@ composer.lock

docs/coverage-report
composer.local.json
node_modules
node_modules

.phpunit.result.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"zordius/lightncandy": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^7",
"phpunit/phpunit": "^8",
"phpstan/phpstan": "^0.12",
"symplify/easy-coding-standard": "^8.0",
"thecodingmachine/phpstan-safe-rule": "^1.0"
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/FormulariumScalarTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function testGet()
$scalarType = $parser->getScalarType('Year');
$this->assertInstanceOf(FormulariumScalarType::class, $scalarType);
$this->assertInstanceOf(Datatype::class, $scalarType->getDatatype());
$this->assertContains('INT', $scalarType->getSQLType());
$this->assertContains('year(', $scalarType->getLaravelSQLType('x'));
$this->assertContains('xxxx', $scalarType->getLaravelSQLType('xxxx'));
$this->assertStringContainsString('INT', $scalarType->getSQLType());
$this->assertStringContainsString('year(', $scalarType->getLaravelSQLType('x'));
$this->assertStringContainsString('xxxx', $scalarType->getLaravelSQLType('xxxx'));
}
}
52 changes: 26 additions & 26 deletions tests/Unit/Laravel/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ function (GeneratedItem $i) {
$this->assertStringNotContainsString('image_id', $userMigration->contents);
$this->assertStringNotContainsString('->references;', $userMigration->contents);

$this->assertContains('$table->bigIncrements("id");', $imageMigration->contents);
$this->assertContains('unsignedBigInteger("imageable_id")', $imageMigration->contents);
$this->assertContains('string("imageable_type")', $imageMigration->contents);
$this->assertStringContainsString('$table->bigIncrements("id");', $imageMigration->contents);
$this->assertStringContainsString('unsignedBigInteger("imageable_id")', $imageMigration->contents);
$this->assertStringContainsString('string("imageable_type")', $imageMigration->contents);

$userModel = $data->filter(
function (GeneratedItem $i) {
Expand All @@ -269,11 +269,11 @@ function (GeneratedItem $i) {
}
)->first();

$this->assertContains('public function image()', $userModel->contents);
$this->assertContains('return $this->morphOne(Image::class, \'imageable\');', $userModel->contents);
$this->assertStringContainsString('public function image()', $userModel->contents);
$this->assertStringContainsString('return $this->morphOne(Image::class, \'imageable\');', $userModel->contents);

$this->assertContains('public function imageable()', $imageModel->contents);
$this->assertContains('return $this->morphTo();', $imageModel->contents);
$this->assertStringContainsString('public function imageable()', $imageModel->contents);
$this->assertStringContainsString('return $this->morphTo();', $imageModel->contents);
}

public function testParseRelationshipMorphOneToMany()
Expand All @@ -299,9 +299,9 @@ function (GeneratedItem $i) {
$this->assertStringNotContainsString('image_id', $userMigration->contents);
$this->assertStringNotContainsString('->references;', $userMigration->contents);

$this->assertContains('$table->bigIncrements("id");', $imageMigration->contents);
$this->assertContains('unsignedBigInteger("imageable_id")', $imageMigration->contents);
$this->assertContains('string("imageable_type")', $imageMigration->contents);
$this->assertStringContainsString('$table->bigIncrements("id");', $imageMigration->contents);
$this->assertStringContainsString('unsignedBigInteger("imageable_id")', $imageMigration->contents);
$this->assertStringContainsString('string("imageable_type")', $imageMigration->contents);

$userModel = $data->filter(
function (GeneratedItem $i) {
Expand All @@ -317,11 +317,11 @@ function (GeneratedItem $i) {
}
)->first();

$this->assertContains('public function images()', $userModel->contents);
$this->assertContains('return $this->morphMany(Image::class, \'imageable\');', $userModel->contents);
$this->assertStringContainsString('public function images()', $userModel->contents);
$this->assertStringContainsString('return $this->morphMany(Image::class, \'imageable\');', $userModel->contents);

$this->assertContains('public function imageable()', $imageModel->contents);
$this->assertContains('return $this->morphTo();', $imageModel->contents);
$this->assertStringContainsString('public function imageable()', $imageModel->contents);
$this->assertStringContainsString('return $this->morphTo();', $imageModel->contents);
}

public function testParseRelationshipMorphManyToMany()
Expand Down Expand Up @@ -354,14 +354,14 @@ function (GeneratedItem $i) {
$this->assertStringNotContainsString('tag_id', $postMigration->contents);
$this->assertStringNotContainsString('->references;', $postMigration->contents);

$this->assertContains('$table->bigIncrements("id");', $tagMigration->contents);
$this->assertContains('string("name")', $tagMigration->contents);
$this->assertStringContainsString('$table->bigIncrements("id");', $tagMigration->contents);
$this->assertStringContainsString('string("name")', $tagMigration->contents);

$this->assertStringNotContainsString('increments', $taggablesMigration->contents);
$this->assertContains("create('taggables'", $taggablesMigration->contents);
$this->assertContains('unsignedBigInteger("tag_id")', $taggablesMigration->contents);
$this->assertContains('unsignedBigInteger("taggable_id")', $taggablesMigration->contents);
$this->assertContains('string("taggable_type")', $taggablesMigration->contents);
$this->assertStringContainsString("create('taggables'", $taggablesMigration->contents);
$this->assertStringContainsString('unsignedBigInteger("tag_id")', $taggablesMigration->contents);
$this->assertStringContainsString('unsignedBigInteger("taggable_id")', $taggablesMigration->contents);
$this->assertStringContainsString('string("taggable_type")', $taggablesMigration->contents);

$postModel = $data->filter(
function (GeneratedItem $i) {
Expand All @@ -377,12 +377,12 @@ function (GeneratedItem $i) {
}
)->first();

$this->assertContains('public function tags()', $postModel->contents);
$this->assertContains('return $this->morphToMany(Tag::class, \'taggable\');', $postModel->contents);
$this->assertStringContainsString('public function tags()', $postModel->contents);
$this->assertStringContainsString('return $this->morphToMany(Tag::class, \'taggable\');', $postModel->contents);

$this->assertContains('public function posts()', $tagModel->contents);
$this->assertContains('public function videos()', $tagModel->contents);
$this->assertContains('return $this->morphedByMany(Post::class, \'taggable\');', $tagModel->contents);
$this->assertContains('return $this->morphedByMany(Video::class, \'taggable\');', $tagModel->contents);
$this->assertStringContainsString('public function posts()', $tagModel->contents);
$this->assertStringContainsString('public function videos()', $tagModel->contents);
$this->assertStringContainsString('return $this->morphedByMany(Post::class, \'taggable\');', $tagModel->contents);
$this->assertStringContainsString('return $this->morphedByMany(Video::class, \'taggable\');', $tagModel->contents);
}
}

0 comments on commit 2772d3e

Please sign in to comment.