Skip to content

Commit

Permalink
Merge pull request #89 from canvural/laravel8
Browse files Browse the repository at this point in the history
Add Laravel 8 support
  • Loading branch information
calebporzio authored Sep 8, 2020
2 parents a963791 + 28a34f3 commit 33344da
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
}
],
"require": {
"illuminate/database": "~5.6.0|~5.7.0|~5.8.0|^6.0.0|^7.0.0",
"illuminate/events": "~5.6.0|~5.7.0|~5.8.0|^6.0.0|^7.0.0"
"illuminate/database": "~5.6.0|~5.7.0|~5.8.0|^6.0.0|^7.0.0|^8.0.0",
"illuminate/events": "~5.6.0|~5.7.0|~5.8.0|^6.0.0|^7.0.0|^8.0.0"
},
"require-dev": {
"orchestra/testbench": "~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0",
"orchestra/testbench": "~3.6.0|~3.7.0|~3.8.0|^4.0|^5.0|^6.0",
"phpunit/phpunit": "^7.0|^8.0"
},
"autoload": {
Expand All @@ -23,7 +23,8 @@
},
"autoload-dev": {
"psr-4": {
"Parental\\Tests\\": "tests/"
"Parental\\Tests\\": "tests/",
"Database\\Factories\\": "tests/factories/"
}
}
}
2 changes: 1 addition & 1 deletion tests/Features/TypeColumnGetsSetAutomaticallyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function type_column_gets_set_on_saving_from_has_many_relationship()
/** @test */
function type_column_gets_set_on_creation_from_a_model_factory()
{
$car = factory(Car::class)->create();
$car = Car::factory()->create();

$this->assertNotNull($car->type);
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Models/Car.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

namespace Parental\Tests\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Parental\HasParent;

class Car extends Vehicle
{
use HasParent;
use HasFactory;
}
5 changes: 4 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Parental\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\TestCase as BaseTestCase;

Expand All @@ -13,7 +14,9 @@ public function setUp(): void

$this->runMigrations();

$this->withFactories(__DIR__ . '/factories');
Factory::guessFactoryNamesUsing(static function (string $modelName) {
return sprintf("Database\\Factories\\%sFactory", class_basename($modelName));
});
}

protected function getEnvironmentSetUp($app)
Expand Down
18 changes: 13 additions & 5 deletions tests/factories/CarFactory.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<?php

namespace Database\Factories;

use Parental\Tests\Models\Car;
use Illuminate\Database\Eloquent\Factories\Factory;

class CarFactory extends Factory
{
protected $model = Car::class;


$factory->define(Car::class, function () {
return [
//
];
});
public function definition()
{
return [];
}
}

0 comments on commit 33344da

Please sign in to comment.