You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

<?php
namespace Tests\Generators;
use Tests\TestCase;
class RouteWebGeneratorTest extends TestCase
{
/** @test */
public function it_creates_correct_web_route_content()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--no-interaction' => true]);
$routeWebPath = base_path('routes/web.php');
$this->assertFileExists($routeWebPath);
$routeWebFileContent = "<?php
/*
* {$this->plural_model_name} Routes
*/
Route::resource('{$this->table_name}', App\\Http\\Controllers\\{$this->model_name}Controller::class);
";
$this->assertEquals($routeWebFileContent, file_get_contents($routeWebPath));
}
/** @test */
public function it_creates_correct_web_route_content_with_parent_command_option()
{
$this->artisan('make:crud', ['name' => $this->model_name, '--parent' => 'Projects', '--no-interaction' => true]);
$routeWebPath = base_path('routes/web.php');
$this->assertFileExists($routeWebPath);
$routeWebFileContent = "<?php
/*
* {$this->plural_model_name} Routes
*/
Route::resource('{$this->table_name}', App\\Http\\Controllers\\Projects\\{$this->model_name}Controller::class);
";
$this->assertEquals($routeWebFileContent, file_get_contents($routeWebPath));
}
}