1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
<?php
namespace Illuminate\Tests\Integration\Generators;
class CastMakeCommandTest extends TestCase
{
protected $files = [
'app/Casts/Foo.php',
];
public function testItCanGenerateCastFile()
{
$this->artisan('make:cast', ['name' => 'Foo'])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Casts;',
'use Illuminate\Contracts\Database\Eloquent\CastsAttributes;',
'class Foo implements CastsAttributes',
'public function get(Model $model, string $key, mixed $value, array $attributes): mixed',
'public function set(Model $model, string $key, mixed $value, array $attributes): mixed',
], 'app/Casts/Foo.php');
}
public function testItCanGenerateInboundCastFile()
{
$this->artisan('make:cast', ['name' => 'Foo', '--inbound' => true])
->assertExitCode(0);
$this->assertFileContains([
'namespace App\Casts;',
'use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;',
'class Foo implements CastsInboundAttributes',
'public function set(Model $model, string $key, mixed $value, array $attributes): mixed',
], 'app/Casts/Foo.php');
}
}
|