|
66 | 66 | expect(base_path('resources/js/ziggy.js'))->toEqualFile('./tests/fixtures/ziggy.js');
|
67 | 67 | });
|
68 | 68 |
|
| 69 | +test('generate file using --except option', function () { |
| 70 | + Route::get('posts/{post}/comments', fn () => '')->name('postComments.index'); |
| 71 | + Route::get('slashes/{slug}', fn () => '')->where('slug', '.*')->name('slashes'); |
| 72 | + Route::get('admin', fn () => '')->name('admin.dashboard'); // Excluded by options |
| 73 | + |
| 74 | + artisan('ziggy:generate --except=admin.*'); |
| 75 | + |
| 76 | + expect(base_path('resources/js/ziggy.js'))->toEqualFile('./tests/fixtures/ziggy.js'); |
| 77 | +}); |
| 78 | + |
| 79 | +test('generate file using --only option', function () { |
| 80 | + Route::get('posts/{post}/comments', fn () => '')->name('postComments.index'); |
| 81 | + Route::get('slashes/{slug}', fn () => '')->where('slug', '.*')->name('slashes'); |
| 82 | + Route::get('admin', fn () => '')->name('admin.dashboard'); // Excluded by options |
| 83 | + |
| 84 | + artisan('ziggy:generate --only=postComments.index,slashes'); |
| 85 | + |
| 86 | + expect(base_path('resources/js/ziggy.js'))->toEqualFile('./tests/fixtures/ziggy.js'); |
| 87 | +}); |
| 88 | + |
| 89 | +test('generate file using both --only and --except', function () { |
| 90 | + Route::get('posts/{post}/comments', fn () => '')->name('postComments.index'); |
| 91 | + Route::get('slashes/{slug}', fn () => '')->where('slug', '.*')->name('slashes'); |
| 92 | + |
| 93 | + artisan('ziggy:generate --only=slashes --except=postComments.index'); |
| 94 | + |
| 95 | + // Options cancel each other out and are ignored |
| 96 | + expect(base_path('resources/js/ziggy.js'))->toEqualFile('./tests/fixtures/ziggy.js'); |
| 97 | +}); |
| 98 | + |
69 | 99 | test('generate file with custom output formatter', function () {
|
70 | 100 | Route::get('posts/{post}/comments', fn () => '')->name('postComments.index');
|
71 | 101 | Route::get('admin', fn () => '')->name('admin.dashboard'); // Excluded by config
|
|
162 | 192 |
|
163 | 193 | class CustomFile extends File
|
164 | 194 | {
|
165 |
| - function __toString(): string |
| 195 | + public function __toString(): string |
166 | 196 | {
|
167 | 197 | return <<<JAVASCRIPT
|
168 | 198 | // This is a custom template
|
|
0 commit comments