<commit_before><?php

namespace Code16\Sharp\Tests\Unit\Show\Fields;

use Code16\Sharp\Show\Fields\SharpShowEntityListField;
use Code16\Sharp\Tests\SharpTestCase;

class SharpShowEntityListFieldTest extends SharpTestCase
{
    /** @test */
    public function we_can_define_entity_list_field()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey');

        $this->assertEquals([
            'key' => 'entityListField',
            'type' => 'entityList',
            'entityListKey' => 'entityKey',
            'showEntityState' => true,
            'showCreateButton' => true,
            'showReorderButton' => true,
            'showSearchField' => true,
            'emptyVisible' => false,
            'hiddenCommands' => ['entity' => [], 'instance' => []],
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_hideFilterWithValue()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideFilterWithValue('f1', 'value1');

        $this->assertArraySubset([
            'hiddenFilters' => [
                'f1' => 'value1',
            ],
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_hideFilterWithValue_with_a_callable()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideFilterWithValue('f1', function ($instanceId) {
                return 'computed';
            });

        $this->assertArraySubset([
            'hiddenFilters' => [
                'f1' => 'computed',
            ],
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_showEntityState()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showEntityState(false);

        $this->assertArraySubset([
            'showEntityState' => false,
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_showReorderButton()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showReorderButton(false);

        $this->assertArraySubset([
            'showReorderButton' => false,
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_showCreateButton()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showCreateButton(false);

        $this->assertArraySubset([
            'showCreateButton' => false,
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_showSearchField()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showSearchField(false);

        $this->assertArraySubset([
            'showSearchField' => false,
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_hideEntityCommands()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideEntityCommand(['c1', 'c2']);

        $this->assertArraySubset([
            'hiddenCommands' => [
                'entity' => [
                    'c1', 'c2',
                ],
            ],
        ], $field->toArray());

        $field->hideEntityCommand('c3');

        $this->assertArraySubset([
            'hiddenCommands' => [
                'entity' => [
                    'c1', 'c2', 'c3',
                ],
            ],
        ], $field->toArray());
    }

    /** @test */
    public function we_can_define_hideInstanceCommands()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideInstanceCommand(['c1', 'c2']);

        $this->assertArraySubset([
            'hiddenCommands' => [
                'instance' => [
                    'c1', 'c2',
                ],
            ],
        ], $field->toArray());

        $field->hideInstanceCommand('c3');

        $this->assertArraySubset([
            'hiddenCommands' => [
                'instance' => [
                    'c1', 'c2', 'c3',
                ],
            ],
        ], $field->toArray());
    }
}<commit_msg>Add showCount test<commit_after><?php

namespace Code16\Sharp\Tests\Unit\Show\Fields;

use Code16\Sharp\Show\Fields\SharpShowEntityListField;
use Code16\Sharp\Tests\SharpTestCase;

class SharpShowEntityListFieldTest extends SharpTestCase
{
    /** @test */
    public function we_can_define_entity_list_field()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey');

        $this->assertEquals(
            [
                'key' => 'entityListField',
                'type' => 'entityList',
                'entityListKey' => 'entityKey',
                'showEntityState' => true,
                'showCreateButton' => true,
                'showReorderButton' => true,
                'showSearchField' => true,
                'emptyVisible' => false,
                'showCount' => false,
                'hiddenCommands' => ['entity' => [], 'instance' => []],
            ], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_hideFilterWithValue()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideFilterWithValue('f1', 'value1');

        $this->assertArraySubset(
            [
                'hiddenFilters' => [
                    'f1' => 'value1',
                ],
            ], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_hideFilterWithValue_with_a_callable()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideFilterWithValue('f1', function ($instanceId) {
                return 'computed';
            });

        $this->assertArraySubset(
            [
                'hiddenFilters' => [
                    'f1' => 'computed',
                ],
            ], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_showEntityState()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showEntityState(false);

        $this->assertArraySubset(
            ['showEntityState' => false,], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_showReorderButton()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showReorderButton(false);

        $this->assertArraySubset(
            ['showReorderButton' => false,], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_showCreateButton()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showCreateButton(false);

        $this->assertArraySubset(
            ['showCreateButton' => false,], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_showSearchField()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showSearchField(false);

        $this->assertArraySubset(
            ['showSearchField' => false,], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_showCount()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->showCount();

        $this->assertArraySubset(
            ['showCount' => true,],
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_hideEntityCommands()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideEntityCommand(['c1', 'c2']);

        $this->assertArraySubset(
            [
                'hiddenCommands' => [
                    'entity' => [
                        'c1', 'c2',
                    ],
                ],
            ], 
            $field->toArray()
        );

        $field->hideEntityCommand('c3');

        $this->assertArraySubset(
            [
                'hiddenCommands' => [
                    'entity' => [
                        'c1', 'c2', 'c3',
                    ],
                ],
            ], 
            $field->toArray()
        );
    }

    /** @test */
    public function we_can_define_hideInstanceCommands()
    {
        $field = SharpShowEntityListField::make('entityListField', 'entityKey')
            ->hideInstanceCommand(['c1', 'c2']);

        $this->assertArraySubset(
            [
                'hiddenCommands' => [
                    'instance' => [
                        'c1', 'c2',
                    ],
                ],
            ],
            $field->toArray()
        );

        $field->hideInstanceCommand('c3');

        $this->assertArraySubset(
            [
                'hiddenCommands' => [
                    'instance' => [
                        'c1', 'c2', 'c3',
                    ],
                ],
            ], 
            $field->toArray()
        );
    }
}
{'fraction_non_alphanumeric': 0.14663201212908816, 'fraction_numerical': 0.006064544076239983, 'mean_word_length': 1.6783642691415313, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 126, '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': '824014', 'n_tokens_mistral': 2631, 'n_tokens_neox': 2504, 'n_words': 344}