This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Keys shouldn't be mutually exclusive
- Loading branch information
Showing
2 changed files
with
91 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
|
||
namespace Halivert\JSRoutes\Tests; | ||
|
||
use Halivert\JSRoutes\Console\CreateJSRoutesCommand; | ||
use Illuminate\Routing\Router; | ||
use Orchestra\Testbench\TestCase; | ||
|
||
class CreateOnlyGETMethodsTest extends TestCase | ||
{ | ||
protected function getPackageProviders($app) | ||
{ | ||
return [ | ||
'Halivert\JSRoutes\Tests\Stubs\Providers\JSRoutesServiceProviderTest' | ||
]; | ||
} | ||
|
||
protected function getEnvironmentSetUp($app) | ||
{ | ||
$app['router']->get('get', ['as' => 'get', 'uses' => function () { | ||
return 'hello world'; | ||
}]); | ||
|
||
$app['router']->get('get/{id}', ['as' => 'hi', 'uses' => function () { | ||
return 'hello world'; | ||
}]); | ||
|
||
$app['router']->post('post', function () { | ||
return 'goodbye world'; | ||
})->name('bye'); | ||
|
||
$app['router']->group(['prefix' => 'boss'], function (Router $router) { | ||
$router->put('put', ['as' => 'boss.hi', 'uses' => function () { | ||
return 'hello boss'; | ||
}]); | ||
|
||
$router->delete('delete', function () { | ||
return 'goodbye boss'; | ||
})->name('boss.bye'); | ||
}); | ||
|
||
|
||
$app['router']->patch('patch', function () { | ||
return 'goodbye world'; | ||
})->name('patch'); | ||
|
||
$app['router']->options('options', function () { | ||
return 'goodbye world'; | ||
})->name('options'); | ||
|
||
$app['router']->get('bruh', function () { | ||
return 'goodbye world'; | ||
})->name('telescope'); | ||
|
||
$app['router']->get('bruh/get', function () { | ||
return 'Telescope get'; | ||
})->name('telescope.get'); | ||
|
||
|
||
$app['router']->get('multi/{id}/param/{id2}/url/{id}', function () { | ||
return 'goodbye world'; | ||
})->name('multiparam'); | ||
|
||
$app['config']->set('app.jsroutes.path', './'); | ||
$app['config']->set('app.jsroutes.methods', ['GET']); | ||
$app['config']->set('app.jsroutes.include', ['get']); | ||
$app['config']->set('app.jsroutes.exclude', ['telescope*']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_creates_file() | ||
{ | ||
if (file_exists(realpath('./routes.js'))) { | ||
$this->artisan('route:tojs')->expectsQuestion( | ||
"The [routes.js] file already exists. Do you want to replace it?", | ||
"yes" | ||
)->expectsOutput('routes.js created')->assertExitCode(0); | ||
} else { | ||
$this->artisan('route:tojs') | ||
->expectsOutput('routes.js created') | ||
->assertExitCode(0); | ||
} | ||
} | ||
} |