<commit_before><?php

namespace Spatie\Menu\Test;

use Spatie\Menu\Link;
use Spatie\Menu\Menu;

class MenuSubmenuTest extends MenuTestCase
{
    /** @test */
    function it_can_add_a_submenu_with_a_menu()
    {
        $this->menu = Menu::new()->submenu(Menu::new());

        $this->assertRenders('<ul><li><ul></ul></li></ul>');
    }

    /** @test */
    function it_can_add_a_submenu_with_a_callable_menu()
    {
        $this->menu = Menu::new()->submenu(function (Menu $menu): Menu {
            return $menu;
        });

        $this->assertRenders('
            <ul>
                <li>
                    <ul></ul>
                </li>
            </ul>
        ');
    }

    /** @test */
    function it_preserves_filters_with_callable_menus()
    {
        $this->menu = Menu::new()
            ->prefixLinks('/bar')
            ->submenu(function (Menu $menu): Menu {
                return $menu->link('/baz', 'Baz');
            });

        $this->assertRenders('
            <ul>
                <li>
                    <ul>
                        <li><a href="/bar/baz">Baz</a></li>
                    </ul>
                </li>
            </ul>
     
        ');
    }

    /** @test */
    function it_can_add_a_submenu_with_a_string_header()
    {
        $this->menu = Menu::new()->submenu('Hi', Menu::new());

        $this->assertRenders('
            <ul>
                <li>Hi<ul></ul></li>
            </ul>
        ');
    }

    /** @test */
    function it_can_add_a_submenu_with_an_item_header()
    {
        $this->menu = Menu::new()->submenu(Link::to('#', 'Hi'), Menu::new());

        $this->assertRenders('
            <ul>
                <li>
                    <a href="#">Hi</a>
                    <ul></ul>
                </li>
            </ul>
        ');
    }
}<commit_msg>submenuIf test<commit_after><?php

namespace Spatie\Menu\Test;

use Spatie\Menu\Link;
use Spatie\Menu\Menu;

class MenuSubmenuTest extends MenuTestCase
{
    /** @test */
    function it_can_add_a_submenu_with_a_menu()
    {
        $this->menu = Menu::new()->submenu(Menu::new());

        $this->assertRenders('<ul><li><ul></ul></li></ul>');
    }

    /** @test */
    function it_can_add_a_submenu_with_a_callable_menu()
    {
        $this->menu = Menu::new()->submenu(function (Menu $menu): Menu {
            return $menu;
        });

        $this->assertRenders('
            <ul>
                <li>
                    <ul></ul>
                </li>
            </ul>
        ');
    }

    /** @test */
    function it_preserves_filters_with_callable_menus()
    {
        $this->menu = Menu::new()
            ->prefixLinks('/bar')
            ->submenu(function (Menu $menu): Menu {
                return $menu->link('/baz', 'Baz');
            });

        $this->assertRenders('
            <ul>
                <li>
                    <ul>
                        <li><a href="/bar/baz">Baz</a></li>
                    </ul>
                </li>
            </ul>
     
        ');
    }

    /** @test */
    function it_can_add_a_submenu_with_a_string_header()
    {
        $this->menu = Menu::new()->submenu('Hi', Menu::new());

        $this->assertRenders('
            <ul>
                <li>Hi<ul></ul></li>
            </ul>
        ');
    }

    /** @test */
    function it_can_add_a_submenu_with_an_item_header()
    {
        $this->menu = Menu::new()->submenu(Link::to('#', 'Hi'), Menu::new());

        $this->assertRenders('
            <ul>
                <li>
                    <a href="#">Hi</a>
                    <ul></ul>
                </li>
            </ul>
        ');
    }

    /** @test */
    function it_can_conditionally_add_a_submenu()
    {
        $this->menu = Menu::new()->submenuIf(false, Menu::new());

        $this->assertRenders('<ul></ul>');
    }
}
{'fraction_non_alphanumeric': 0.18122893440497798, 'fraction_numerical': 0.0, 'mean_word_length': 1.3814814814814815, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 114, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '326734', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1208, 'n_words': 168}