-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
115 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Cone\Root\Tests\Http; | ||
|
||
use Cone\Root\Fields\MorphTo; | ||
use Cone\Root\Root; | ||
use Cone\Root\Tests\TestCase; | ||
use Cone\Root\Tests\User; | ||
|
||
class MorphToControllerTest extends TestCase | ||
{ | ||
protected MorphTo $field; | ||
|
||
protected User $admin; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->field = Root::instance() | ||
->resources | ||
->resolve('users') | ||
->resolveFields($this->app['request']) | ||
->first(function ($field) { | ||
return $field->getModelAttribute() === 'employer'; | ||
}); | ||
|
||
$this->admin = User::factory()->create(); | ||
} | ||
|
||
public function test_a_relation_controller_handles_request(): void | ||
{ | ||
$this->actingAs($this->admin) | ||
->get('/root/users/'.$this->admin->getKey().'/fields/employer') | ||
->assertOk() | ||
->assertViewIs('root::fields.morph-to') | ||
->assertViewHas($this->field->toInput($this->app['request'], $this->admin)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->after('id', function (Blueprint $table) { | ||
$table->nullableMorphs('employer'); | ||
}); | ||
$table->after('updated_at', function (Blueprint $table) { | ||
$table->softDeletes(); | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::table('users', function (Blueprint $table) { | ||
$table->dropMorphs('employer'); | ||
$table->dropSoftDeletes(); | ||
}); | ||
} | ||
}; |
File renamed without changes.