nWidart /
laravel-menus
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Nwidart\Menus\Tests; |
||
| 4 | |||
| 5 | use Nwidart\Menus\Menu; |
||
| 6 | use Nwidart\Menus\MenuBuilder; |
||
| 7 | |||
| 8 | class MenuTest extends BaseTestCase |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var Menu |
||
| 12 | */ |
||
| 13 | private $menu; |
||
| 14 | |||
| 15 | public function setUp() : void |
||
| 16 | { |
||
| 17 | parent::setUp(); |
||
| 18 | $this->menu = app(Menu::class); |
||
| 19 | } |
||
| 20 | /** @test */ |
||
| 21 | View Code Duplication | public function it_generates_an_empty_menu() |
|
| 22 | { |
||
| 23 | $this->menu->create('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 24 | }); |
||
| 25 | |||
| 26 | $expected = <<<TEXT |
||
| 27 | |||
| 28 | <ul class="nav navbar-nav"> |
||
| 29 | |||
| 30 | </ul> |
||
| 31 | |||
| 32 | TEXT; |
||
| 33 | |||
| 34 | self::assertEquals($expected, $this->menu->get('test')); |
||
| 35 | } |
||
| 36 | |||
| 37 | /** @test */ |
||
| 38 | View Code Duplication | public function it_makes_is_an_alias_for_create() |
|
| 39 | { |
||
| 40 | $this->menu->make('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 41 | }); |
||
| 42 | |||
| 43 | $expected = <<<TEXT |
||
| 44 | |||
| 45 | <ul class="nav navbar-nav"> |
||
| 46 | |||
| 47 | </ul> |
||
| 48 | |||
| 49 | TEXT; |
||
| 50 | |||
| 51 | self::assertEquals($expected, $this->menu->get('test')); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** @test */ |
||
| 55 | View Code Duplication | public function it_render_is_an_alias_of_get() |
|
| 56 | { |
||
| 57 | $this->menu->make('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 58 | }); |
||
| 59 | |||
| 60 | $expected = <<<TEXT |
||
| 61 | |||
| 62 | <ul class="nav navbar-nav"> |
||
| 63 | |||
| 64 | </ul> |
||
| 65 | |||
| 66 | TEXT; |
||
| 67 | |||
| 68 | self::assertEquals($expected, $this->menu->render('test')); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** @test */ |
||
| 72 | public function it_can_get_the_instance_of_a_menu() |
||
| 73 | { |
||
| 74 | $this->menu->create('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 75 | }); |
||
| 76 | |||
| 77 | $this->assertInstanceOf(MenuBuilder::class, $this->menu->instance('test')); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** @test */ |
||
| 81 | public function it_can_modify_a_menu_instance() |
||
| 82 | { |
||
| 83 | $this->menu->create('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 84 | }); |
||
| 85 | |||
| 86 | $this->menu->modify('test', function (MenuBuilder $builder) { |
||
| 87 | $builder->url('hello', 'world'); |
||
| 88 | }); |
||
| 89 | |||
| 90 | $this->assertCount(1, $this->menu->instance('test')); |
||
|
0 ignored issues
–
show
$this->menu->instance('test') is of type string|null, but the function expects a object<Countable>|object...nit\Framework\iterable>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 91 | } |
||
| 92 | |||
| 93 | /** @test */ |
||
| 94 | public function it_gets_a_partial_for_dropdown_styles() |
||
| 95 | { |
||
| 96 | $this->menu->create('test', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 97 | }); |
||
| 98 | |||
| 99 | $this->assertStringContainsString('.dropdown-submenu', $this->menu->style()); |
||
| 100 | } |
||
| 101 | |||
| 102 | /** @test */ |
||
| 103 | public function it_can_get_all_menus() |
||
| 104 | { |
||
| 105 | $this->menu->create('main', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 106 | }); |
||
| 107 | $this->menu->create('footer', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 108 | }); |
||
| 109 | |||
| 110 | $this->assertCount(2, $this->menu->all()); |
||
|
0 ignored issues
–
show
$this->menu->all() is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 111 | } |
||
| 112 | |||
| 113 | /** @test */ |
||
| 114 | public function it_can_count_menus() |
||
| 115 | { |
||
| 116 | $this->menu->create('main', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 117 | }); |
||
| 118 | $this->menu->create('footer', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 119 | }); |
||
| 120 | |||
| 121 | $this->assertEquals(2, $this->menu->count()); |
||
| 122 | } |
||
| 123 | |||
| 124 | /** @test */ |
||
| 125 | public function it_can_destroy_all_menus() |
||
| 126 | { |
||
| 127 | $this->menu->create('main', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 128 | }); |
||
| 129 | $this->menu->create('footer', function (MenuBuilder $menu) { |
||
|
0 ignored issues
–
show
|
|||
| 130 | }); |
||
| 131 | |||
| 132 | $this->assertCount(2, $this->menu->all()); |
||
|
0 ignored issues
–
show
$this->menu->all() is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 133 | $this->menu->destroy(); |
||
| 134 | $this->assertCount(0, $this->menu->all()); |
||
|
0 ignored issues
–
show
$this->menu->all() is of type array, but the function expects a object<Countable>|object...nit\Framework\iterable>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 135 | } |
||
| 136 | } |
||
| 137 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.