<commit_before><commit_msg>[Tests] Bolt\Menu\MenuEntry<commit_after><?php

namespace Bolt\Tests\Menu;

use Bolt\Menu\MenuEntry;
use Bolt\Tests\BoltUnitTest;

/**
 * Class to test src/Menu/MenuEntry.
 *
 * @author <NAME> <<EMAIL>>
 */
class MenuEntryTest extends BoltUnitTest
{
    public function testCreateRoot()
    {
        $app = $this->getApp();
        $rootEntry = new MenuEntry('root', $app['config']->get('general/branding/path'));
        $this->assertInstanceOf('Bolt\Menu\MenuEntry', $rootEntry);
        $this->assertSame('/bolt', $rootEntry->getUri());
        $this->assertSame('root', $rootEntry->getName());
        $this->assertNull($rootEntry->getIcon());
        $this->assertSame('everyone', $rootEntry->getPermission());
        $this->assertSame([], $rootEntry->getChildren());

        $app['config']->set('general/branding/path', '/koala/drop-bear');
        $rootEntry = new MenuEntry('root', $app['config']->get('general/branding/path'));
        $this->assertSame('/koala/drop-bear', $rootEntry->getUri());
    }

    public function testCreateChild()
    {
        $app = $this->getApp();
        $rootEntry = new MenuEntry('root', $app['config']->get('general/branding/path'));
        $extendEntry = (new MenuEntry('dropbear', 'drop-bears', $rootEntry))
            ->setLabel('Furry Animals')
            ->setIcon('fa:koala')
            ->setPermission('strict')
        ;
        $rootEntry->addChild($extendEntry);

        $this->assertSame('/bolt/drop-bears', $extendEntry->getUri());
        $this->assertSame('dropbear', $extendEntry->getName());
        $this->assertSame('Furry Animals', $extendEntry->getLabel());
        $this->assertSame('fa:koala', $extendEntry->getIcon());
        $this->assertSame('strict', $extendEntry->getPermission());
        $this->assertSame('/bolt/drop-bears', $extendEntry->getUri());

        $this->assertSame('/bolt/drop-bears', $rootEntry->getChild('dropbear')->getUri());
        $this->assertSame('dropbear', $rootEntry->getChild('dropbear')->getName());
        $this->assertSame('Furry Animals', $rootEntry->getChild('dropbear')->getLabel());
        $this->assertSame('fa:koala', $rootEntry->getChild('dropbear')->getIcon());
        $this->assertSame('strict', $rootEntry->getChild('dropbear')->getPermission());
        $this->assertSame('/bolt/drop-bears', $rootEntry->getChild('dropbear')->getUri());

        $firstBorn = $rootEntry->getChildren();
        $this->assertInstanceOf('Bolt\Menu\MenuEntry', $firstBorn['dropbear']);
        $this->assertSame('/bolt/drop-bears', $firstBorn['dropbear']->getUri());
        $this->assertSame('dropbear', $firstBorn['dropbear']->getName());
        $this->assertSame('Furry Animals', $firstBorn['dropbear']->getLabel());
        $this->assertSame('fa:koala', $firstBorn['dropbear']->getIcon());
        $this->assertSame('strict', $firstBorn['dropbear']->getPermission());
        $this->assertSame('/bolt/drop-bears', $firstBorn['dropbear']->getUri());
    }
}
{'fraction_non_alphanumeric': 0.21476285905143622, 'fraction_numerical': 0.0, 'mean_word_length': 3.942244224422442, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 73, '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': '2261016', 'n_tokens_mistral': 927, 'n_tokens_neox': 898, 'n_words': 109}