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.4 KiB
42 lines
1.4 KiB
<?php
|
|
|
|
namespace Tests\Generators\Api;
|
|
|
|
use Tests\TestCase;
|
|
|
|
class RouteApiGeneratorTest extends TestCase
|
|
{
|
|
/** @test */
|
|
public function it_creates_correct_api_route_content()
|
|
{
|
|
$this->artisan('make:crud-api', ['name' => $this->model_name, '--no-interaction' => true]);
|
|
|
|
$routeApiPath = base_path('routes/api.php');
|
|
$this->assertFileExists($routeApiPath);
|
|
$routeApiFileContent = "<?php
|
|
|
|
/*
|
|
* {$this->plural_model_name} Endpoints
|
|
*/
|
|
Route::middleware('auth:api')->resource('{$this->table_name}', App\\Http\\Controllers\\Api\\{$this->model_name}Controller::class)->names('api.{$this->table_name}');
|
|
";
|
|
$this->assertEquals($routeApiFileContent, file_get_contents($routeApiPath));
|
|
}
|
|
|
|
/** @test */
|
|
public function it_creates_correct_api_route_content_with_parent_command_option()
|
|
{
|
|
$this->artisan('make:crud-api', ['name' => $this->model_name, '--parent' => 'Projects', '--no-interaction' => true]);
|
|
|
|
$routeApiPath = base_path('routes/api.php');
|
|
$this->assertFileExists($routeApiPath);
|
|
$routeApiFileContent = "<?php
|
|
|
|
/*
|
|
* {$this->plural_model_name} Endpoints
|
|
*/
|
|
Route::middleware('auth:api')->resource('{$this->table_name}', App\\Http\\Controllers\\Api\\Projects\\{$this->model_name}Controller::class)->names('api.{$this->table_name}');
|
|
";
|
|
$this->assertEquals($routeApiFileContent, file_get_contents($routeApiPath));
|
|
}
|
|
}
|