<commit_before><?php

namespace PhpSchool\CliMenuTest\Builder;

use PhpSchool\CliMenu\Builder\SplitItemBuilder;
use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\MenuItem\MenuMenuItem;
use PhpSchool\CliMenu\MenuItem\SelectableItem;
use PhpSchool\CliMenu\MenuItem\SplitItem;
use PhpSchool\CliMenu\MenuItem\StaticItem;
use PHPUnit\Framework\TestCase;

class SplitItemBuilderTest extends TestCase
{
    public function testAddItem() : void
    {
        $callable = function () {
        };

        $menu = new CliMenu(null, []);
        $builder = new SplitItemBuilder($menu);
        $builder->addItem('Item 1', $callable);
        $builder->addItem('Item 2', $callable);
        $item = $builder->build();

        $expected = [
            [
                'class' => SelectableItem::class,
                'text'  => 'Item 1',
            ],
            [
                'class' => SelectableItem::class,
                'text'  => 'Item 2',
            ],
        ];

        $this->checkItemItems($item, $expected);
    }

    public function testAddStaticItem() : void
    {

        $menu = new CliMenu(null, []);
        $builder = new SplitItemBuilder($menu);
        $builder->addStaticItem('Static Item 1');
        $item = $builder->build();

        $expected = [
            [
                'class' => StaticItem::class,
                'text'  => 'Static Item 1',
            ]
        ];

        $this->checkItemItems($item, $expected);<commit_msg>Tests for SplitItem + CheckableItem support<commit_after><?php

namespace PhpSchool\CliMenuTest\Builder;

use PhpSchool\CliMenu\Builder\SplitItemBuilder;
use PhpSchool\CliMenu\CliMenu;
use PhpSchool\CliMenu\MenuItem\CheckableItem;
use PhpSchool\CliMenu\MenuItem\MenuMenuItem;
use PhpSchool\CliMenu\MenuItem\SelectableItem;
use PhpSchool\CliMenu\MenuItem\SplitItem;
use PhpSchool\CliMenu\MenuItem\StaticItem;
use PHPUnit\Framework\TestCase;

class SplitItemBuilderTest extends TestCase
{
    public function testAddItem() : void
    {
        $callable = function () {
        };

        $menu = new CliMenu(null, []);
        $builder = new SplitItemBuilder($menu);
        $builder->addItem('Item 1', $callable);
        $builder->addItem('Item 2', $callable);
        $item = $builder->build();

        $expected = [
            [
                'class' => SelectableItem::class,
                'text'  => 'Item 1',
            ],
            [
                'class' => SelectableItem::class,
                'text'  => 'Item 2',
            ],
        ];

        $this->checkItemItems($item, $expected);
    }

    public function testAddCheckableItem() : void
    {
        $callable = function () {
        };

        $menu = new CliMenu(null, []);
        $builder = new SplitItemBuilder($menu);
        $builder->addCheckableItem('Item 1', $callable);
        $builder->addCheckableItem('Item 2', $callable);
        $item = $builder->build();

        $expected = [
            [
                'class' => CheckableItem::class,
                'text'  => 'Item 1',
            ],
            [
                'class' => CheckableItem::class,
                'text'  => 'Item 2',
            ],
        ];

        $this->checkItemItems($item, $expected);
    }

    public function testAddStaticItem() : void
    {

        $menu = new CliMenu(null, []);
        $builder = new SplitItemBuilder($menu);
        $builder->addStaticItem('Static Item 1');
        $item = $builder->build();

        $expected = [
            [
                'class' => StaticItem::class,
                'text'  => 'Static Item 1',
            ]
        ];

        $this->checkItemItems($item, $expected);
{'fraction_non_alphanumeric': 0.13835281326447404, 'fraction_numerical': 0.004349007882576787, 'mean_word_length': 1.977346278317152, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '1672944', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1037, 'n_words': 194}