-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestHelper.php
More file actions
60 lines (51 loc) · 1.52 KB
/
Copy pathTestHelper.php
File metadata and controls
60 lines (51 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace Modules\Cms\Tests;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Modules\Cms\Models\Module;
use Modules\User\Models\User;
use Modules\Xot\Actions\Filament\GetModulesNavigationItems;
use Modules\Xot\Tests\CreatesApplication;
abstract class TestHelper extends BaseTestCase
{
// use CreatesApplication;
// in User
public function getSuperAdminUser()
{
return User::role('super-admin')->first();
}
// in User
public function getNoSuperAdminUser()
{
return User::all()
->map(function ($item) {
if (! $item->hasRole('super-admin')) {
return $item;
}
})
->first();
}
// in Tenant o Cms
public function getModuleNameLists()
{
return collect(app(Module::class)->getRows())->pluck('name')->all();
}
// in Tenant o Cms
public function getMainAdminNavigationUrlItems()
{
return $item_navs = collect(app(GetModulesNavigationItems::class)->execute())
->map(fn ($item): ?string => $item->getUrl());
}
// in Tenant o Cms
public function getUserNavigationItemUrlRoles($user)
{
return $role_names = $user
->getRoleNames()
->map(function ($item) {
if ('super-admin' !== $item) {
return '/'.mb_substr($item, 0, -7).'/admin';
}
})
->filter(fn ($value): bool => ! is_null($value));
}
}