Skip to content

Commit ebb2df7

Browse files
committed
- Adding Laravel 13 support
1 parent 0538347 commit ebb2df7

File tree

4 files changed

+47
-74
lines changed

4 files changed

+47
-74
lines changed

.github/workflows/run-tests.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ jobs:
1717
matrix:
1818
os: [ ubuntu-latest ]
1919
php: [ 8.4, 8.3, 8.2, 8.1 ]
20-
laravel: [ 12.*, 11.*, 10.*, 9.* ]
20+
laravel: [ 13.*, 12.*, 11.*, 10.*, 9.* ]
2121
stability: [ prefer-lowest, prefer-stable ]
2222
include:
23+
- laravel: 13.*
24+
testbench: 10.*
25+
carbon: ^3.8.4
2326
- laravel: 12.*
2427
testbench: 10.*
2528
carbon: ^3.8.4
@@ -33,6 +36,10 @@ jobs:
3336
testbench: 7.*
3437
carbon: ^2.63
3538
exclude:
39+
- laravel: 13.*
40+
php: 8.2
41+
- laravel: 13.*
42+
php: 8.1
3643
- laravel: 12.*
3744
php: 8.1
3845
- laravel: 11.*
@@ -54,7 +61,7 @@ jobs:
5461
with:
5562
php-version: ${{ matrix.php }}
5663
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv
57-
coverage: ${{ startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.3' && matrix.laravel == '11.*' && matrix.stability == 'prefer-stable' && 'xdebug' || 'none' }}
64+
coverage: ${{ startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable' && 'xdebug' || 'none' }}
5865

5966
- name: Install dependencies
6067
run: |
@@ -63,10 +70,10 @@ jobs:
6370
6471
- name: Execute tests
6572
run: |
66-
vendor/bin/phpunit ${{ startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.3' && matrix.laravel == '11.*' && matrix.stability == 'prefer-stable' && '--coverage-clover=clover.xml' || '' }}
73+
vendor/bin/phpunit ${{ startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable' && '--coverage-clover=clover.xml' || '' }}
6774
6875
- name: Make code coverage badge
69-
if: startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.3' && matrix.laravel == '11.*' && matrix.stability == 'prefer-stable'
76+
if: startsWith(github.event.head_commit.message, 'coverage') && matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable'
7077
uses: timkrase/phpunit-coverage-badge@v1.2.1
7178
with:
7279
coverage_badge_path: .github/coverage.svg

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
],
1717
"require": {
1818
"php": "^8.1",
19-
"illuminate/support": "^9.0 || ^10.0 || ^11.0 || ^12.0"
19+
"illuminate/support": "^9.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0"
2020
},
2121
"require-dev": {
2222
"orchestra/testbench-browser-kit": "^7.0 || ^8.0 || ^9.0 || ^10.0",
23-
"phpunit/phpunit": "^9.5 || ^10.5 || ^11.5.3"
23+
"phpunit/phpunit": "^9.5 || ^10.5 || ^11.5.3 || ^12.5.8 || ^13.0.3"
2424
},
2525
"autoload": {
2626
"psr-4": {

tests/Feature/MenuTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ protected function setupTestPermissions(): void
3939
});
4040
}
4141

42-
/** @test */
43-
public function it_can_render_a_bootstrap_5_menu(): void
42+
public function test_it_can_render_a_bootstrap_5_menu(): void
4443
{
4544
$this->setupTestRoutes();
4645
$this->setupTestPermissions();
@@ -59,8 +58,7 @@ public function it_can_render_a_bootstrap_5_menu(): void
5958
$this->assertXmlStringEqualsXmlString($this->loadTestStub('bootstrap-5.blade.php'), $actual_content);
6059
}
6160

62-
/** @test */
63-
public function it_can_render_a_material_admin_26_menu(): void
61+
public function test_it_can_render_a_material_admin_26_menu(): void
6462
{
6563
$this->setupTestRoutes();
6664
$this->setupTestPermissions();

tests/Unit/MenuItemTest.php

Lines changed: 32 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -24,48 +24,42 @@ protected function setUp(): void
2424
$this->runMigrations();
2525
}
2626

27-
/** @test */
28-
public function it_can_set_the_menu_item_class(): void
27+
public function test_it_can_set_the_menu_item_class(): void
2928
{
3029
$menu_item = MenuItem::make('Dashboard')->cssClass('new');
3130

3231
$this->assertEquals('new', $menu_item->getCssClass());
3332
}
3433

35-
/** @test */
36-
public function it_can_set_the_menu_item_target(): void
34+
public function test_it_can_set_the_menu_item_target(): void
3735
{
3836
$menu_item = MenuItem::make('Dashboard')->target('_blank');
3937

4038
$this->assertEquals('_blank', $menu_item->getTarget());
4139
}
4240

43-
/** @test */
44-
public function it_can_set_the_menu_item_badge(): void
41+
public function test_it_can_set_the_menu_item_badge(): void
4542
{
4643
$menu_item = MenuItem::make('Dashboard')->badge('new');
4744

4845
$this->assertEquals('new', $menu_item->getBadge());
4946
}
5047

51-
/** @test */
52-
public function it_can_set_the_menu_item_badge_class(): void
48+
public function test_it_can_set_the_menu_item_badge_class(): void
5349
{
5450
$menu_item = MenuItem::make('Dashboard')->badge('new', 'primary');
5551

5652
$this->assertEquals('primary', $menu_item->getBadgeClass());
5753
}
5854

59-
/** @test */
60-
public function it_can_set_the_menu_item_label(): void
55+
public function test_it_can_set_the_menu_item_label(): void
6156
{
6257
$menu_item = MenuItem::make('Dashboard');
6358

6459
$this->assertEquals('Dashboard', $menu_item->getLabel());
6560
}
6661

67-
/** @test */
68-
public function it_can_set_the_menu_item_route(): void
62+
public function test_it_can_set_the_menu_item_route(): void
6963
{
7064
Route::get('/home')->name('web.home');
7165

@@ -76,8 +70,7 @@ public function it_can_set_the_menu_item_route(): void
7670
$this->assertEquals('http://localhost/home', $menu_item->getLink());
7771
}
7872

79-
/** @test */
80-
public function it_can_set_the_menu_item_route_with_a_parameter(): void
73+
public function test_it_can_set_the_menu_item_route_with_a_parameter(): void
8174
{
8275
Route::get('/users/{id}')->name('users.show');
8376

@@ -88,8 +81,7 @@ public function it_can_set_the_menu_item_route_with_a_parameter(): void
8881
$this->assertEquals('http://localhost/users/1', $menu_item->getLink());
8982
}
9083

91-
/** @test */
92-
public function it_can_determine_active_state_from_route(): void
84+
public function test_it_can_determine_active_state_from_route(): void
9385
{
9486
$active_item = MenuItem::make('Home')->route('web.home');
9587
$inactive_item = MenuItem::make('Settings')->route('web.settings');
@@ -103,8 +95,7 @@ public function it_can_determine_active_state_from_route(): void
10395
->dontSeeElement('a[href="http://localhost/settings"].active');
10496
}
10597

106-
/** @test */
107-
public function it_can_determine_active_state_from_string_route_pattern(): void
98+
public function test_it_can_determine_active_state_from_string_route_pattern(): void
10899
{
109100
$this->withoutExceptionHandling();
110101

@@ -120,8 +111,7 @@ public function it_can_determine_active_state_from_string_route_pattern(): void
120111
->seeElement('a[href="http://localhost/settings"].active');
121112
}
122113

123-
/** @test */
124-
public function it_can_determine_active_state_from_multi_route_pattern(): void
114+
public function test_it_can_determine_active_state_from_multi_route_pattern(): void
125115
{
126116
$this->withoutExceptionHandling();
127117

@@ -137,8 +127,7 @@ public function it_can_determine_active_state_from_multi_route_pattern(): void
137127
->seeElement('a[href="http://localhost/settings"].active');
138128
}
139129

140-
/** @test */
141-
public function it_can_determine_active_state_from_array_route_pattern(): void
130+
public function test_it_can_determine_active_state_from_array_route_pattern(): void
142131
{
143132
$this->withoutExceptionHandling();
144133

@@ -154,8 +143,7 @@ public function it_can_determine_active_state_from_array_route_pattern(): void
154143
->seeElement('a[href="http://localhost/settings"].active');
155144
}
156145

157-
/** @test */
158-
public function it_can_determine_active_state_from_route_with_parameters(): void
146+
public function test_it_can_determine_active_state_from_route_with_parameters(): void
159147
{
160148
$user_1 = User::factory()->create();
161149
$user_2 = User::factory()->create();
@@ -171,8 +159,7 @@ public function it_can_determine_active_state_from_route_with_parameters(): void
171159
->dontSeeElement('a[href="http://localhost/users/2/edit"].active');
172160
}
173161

174-
/** @test */
175-
public function it_can_set_the_menu_item_controller(): void
162+
public function test_it_can_set_the_menu_item_controller(): void
176163
{
177164
Route::get('/users', [UsersController::class, 'index']);
178165

@@ -183,8 +170,7 @@ public function it_can_set_the_menu_item_controller(): void
183170
$this->assertEquals('http://localhost/users', $menu_item->getLink());
184171
}
185172

186-
/** @test */
187-
public function it_can_set_menu_item_from_controller_with_params(): void
173+
public function test_it_can_set_menu_item_from_controller_with_params(): void
188174
{
189175
Route::get('/users/{user}', [UsersController::class, 'show']);
190176

@@ -200,8 +186,7 @@ public function it_can_set_menu_item_from_controller_with_params(): void
200186
->seeText("User: {$user->name}");
201187
}
202188

203-
/** @test */
204-
public function it_can_set_menu_item_for_index_method_from_controller_with_params(): void
189+
public function test_it_can_set_menu_item_for_index_method_from_controller_with_params(): void
205190
{
206191
Route::get('/{locale}/users', [HomeController::class, 'index']);
207192

@@ -219,8 +204,7 @@ public function it_can_set_menu_item_for_index_method_from_controller_with_param
219204
->seeText("Locale: jp");
220205
}
221206

222-
/** @test */
223-
public function it_can_determine_active_state_from_controller(): void
207+
public function test_it_can_determine_active_state_from_controller(): void
224208
{
225209
Route::get('/home')->name('web.home');
226210
Route::get('/users', [UsersController::class, 'index']);
@@ -231,8 +215,7 @@ public function it_can_determine_active_state_from_controller(): void
231215
->dontSeeElement('a[href="http://localhost/home"].active');
232216
}
233217

234-
/** @test */
235-
public function it_can_set_the_menu_item_url(): void
218+
public function test_it_can_set_the_menu_item_url(): void
236219
{
237220
Route::get('/home')->name('web.home');
238221

@@ -243,8 +226,7 @@ public function it_can_set_the_menu_item_url(): void
243226
$this->assertEquals('http://localhost/home', $menu_item->getLink());
244227
}
245228

246-
/** @test */
247-
public function it_can_determine_active_state_from_url(): void
229+
public function test_it_can_determine_active_state_from_url(): void
248230
{
249231
Route::get('/settings')->name('web.settings');
250232

@@ -259,8 +241,7 @@ public function it_can_determine_active_state_from_url(): void
259241
->dontSeeElement('a[href="http://localhost/settings"].active');
260242
}
261243

262-
/** @test */
263-
public function it_can_determine_active_state_from_url_with_parameters(): void
244+
public function test_it_can_determine_active_state_from_url_with_parameters(): void
264245
{
265246
$active_item = MenuItem::make('Home')->url('http://localhost/home?foo=bar');
266247
$inactive_item = MenuItem::make('Home 2')->url('http://localhost/home');
@@ -273,8 +254,7 @@ public function it_can_determine_active_state_from_url_with_parameters(): void
273254
->dontSeeElement('a[href="http://localhost/home"].active');
274255
}
275256

276-
/** @test */
277-
public function it_uses_the_last_set_method_to_generate_the_link(): void
257+
public function test_it_uses_the_last_set_method_to_generate_the_link(): void
278258
{
279259
Route::get('/users', [UsersController::class, 'index']);
280260
Route::get('/settings')->name('web.settings');
@@ -287,8 +267,7 @@ public function it_uses_the_last_set_method_to_generate_the_link(): void
287267
$this->assertEquals('http://localhost/settings', $menu_item->getLink());
288268
}
289269

290-
/** @test */
291-
public function it_can_determine_active_state_from_active_closure(): void
270+
public function test_it_can_determine_active_state_from_active_closure(): void
292271
{
293272
$active_item = MenuItem::make('Home')
294273
->url('http://localhost/home?foo=bar')
@@ -306,24 +285,21 @@ public function it_can_determine_active_state_from_active_closure(): void
306285
->dontSeeElement('a[href="http://localhost/home?foo=baz"].active');
307286
}
308287

309-
/** @test */
310-
public function it_can_set_the_menu_item_icon(): void
288+
public function test_it_can_set_the_menu_item_icon(): void
311289
{
312290
$menu_item = MenuItem::make('Dashboard')->icon('book');
313291

314292
$this->assertEquals('zmdi zmdi-book', $menu_item->getIcon('zmdi zmdi-'));
315293
}
316294

317-
/** @test */
318-
public function it_can_set_the_menu_item_permissions(): void
295+
public function test_it_can_set_the_menu_item_permissions(): void
319296
{
320297
$this->assertEquals(['view_users'], MenuItem::make('Users')->permissions('view_users')->getPermissions());
321298
$this->assertEquals(['view_users', 'edit_users'], MenuItem::make('Users')->permissions('view_users', 'edit_users')->getPermissions());
322299
$this->assertEquals(['view_users', 'edit_users'], MenuItem::make('Users')->permissions(['view_users', 'edit_users'])->getPermissions());
323300
}
324301

325-
/** @test */
326-
public function it_can_determine_if_a_user_can_view_the_menu_item_using_permissions(): void
302+
public function test_it_can_determine_if_a_user_can_view_the_menu_item_using_permissions(): void
327303
{
328304
Gate::define('view_users', function (User $user) {
329305
return $user->name == 'John';
@@ -349,8 +325,7 @@ public function it_can_determine_if_a_user_can_view_the_menu_item_using_permissi
349325
$this->assertFalse(MenuItem::make('Users')->permissions('edit_users')->canView($user));
350326
}
351327

352-
/** @test */
353-
public function it_can_determine_if_a_user_can_view_the_menu_item_using_can(): void
328+
public function test_it_can_determine_if_a_user_can_view_the_menu_item_using_can(): void
354329
{
355330
Gate::policy(User::class, UserPolicy::class);
356331

@@ -371,8 +346,7 @@ public function it_can_determine_if_a_user_can_view_the_menu_item_using_can(): v
371346
$this->assertFalse(MenuItem::make('Users')->can(function ($user) { return $user->name != 'John';})->canView($user));
372347
}
373348

374-
/** @test */
375-
public function it_can_determine_if_a_user_can_view_the_menu_item_using_both_can_and_permssions(): void
349+
public function test_it_can_determine_if_a_user_can_view_the_menu_item_using_both_can_and_permssions(): void
376350
{
377351
Gate::policy(User::class, UserPolicy::class);
378352

@@ -391,8 +365,7 @@ public function it_can_determine_if_a_user_can_view_the_menu_item_using_both_can
391365
$this->assertTrue(MenuItem::make('Users')->can('viewAny', User::class)->permissions('view_users')->canView($user));
392366
}
393367

394-
/** @test */
395-
public function it_can_set_the_menu_item_count(): void
368+
public function test_it_can_set_the_menu_item_count(): void
396369
{
397370
/** @var User $user */
398371
$user = User::factory() ->create(['name' => 'John']);
@@ -403,8 +376,7 @@ public function it_can_set_the_menu_item_count(): void
403376
$this->assertEquals(3, MenuItem::make('Users')->count(function ($user) { return 1 + 2;})->getCount());
404377
}
405378

406-
/** @test */
407-
public function it_can_determine_whether_to_show_the_menu_item_count(): void
379+
public function test_it_can_determine_whether_to_show_the_menu_item_count(): void
408380
{
409381
Gate::define('view_users', function (User $user) {
410382
return $user->name == 'John';
@@ -429,8 +401,7 @@ public function it_can_determine_whether_to_show_the_menu_item_count(): void
429401
$this->assertFalse(MenuItem::make('Users')->count(function ($user) { return 1 + 2;}, function ($user) { return $user->name != 'John';})->shouldShowCount($user));
430402
}
431403

432-
/** @test */
433-
public function it_can_set_the_menu_item_children(): void
404+
public function test_it_can_set_the_menu_item_children(): void
434405
{
435406
Gate::define('view_users', function (User $user) {
436407
return $user->name == 'John';
@@ -474,8 +445,7 @@ public function it_can_set_the_menu_item_children(): void
474445
$this->assertEquals(1, $other_main_item->getAggregatedCount($user));
475446
}
476447

477-
/** @test */
478-
public function it_hides_the_main_link_by_default_on_blank_links_if_no_children_are_visible(): void
448+
public function test_it_hides_the_main_link_by_default_on_blank_links_if_no_children_are_visible(): void
479449
{
480450
Gate::define('view_users', function (User $user) {
481451
return $user->name == 'John';
@@ -521,8 +491,7 @@ public function it_hides_the_main_link_by_default_on_blank_links_if_no_children_
521491
$this->assertEquals(1, $other_main_item->getAggregatedCount($user));
522492
}
523493

524-
/** @test */
525-
public function it_does_not_hide_the_main_link_by_default_on_non_blank_links_if_no_children_are_visible(): void
494+
public function test_it_does_not_hide_the_main_link_by_default_on_non_blank_links_if_no_children_are_visible(): void
526495
{
527496
Gate::define('view_users', function (User $user) {
528497
return $user->name == 'John';
@@ -569,8 +538,7 @@ public function it_does_not_hide_the_main_link_by_default_on_non_blank_links_if_
569538
$this->assertEquals(1, $other_main_item->getAggregatedCount($user));
570539
}
571540

572-
/** @test */
573-
public function it_does_hide_the_main_link_on_non_blank_links_if_no_children_are_visible_when_specified(): void
541+
public function test_it_does_hide_the_main_link_on_non_blank_links_if_no_children_are_visible_when_specified(): void
574542
{
575543
Gate::define('view_users', function (User $user) {
576544
return $user->name == 'John';

0 commit comments

Comments
 (0)