<commit_before><?php
namespace App\Test\TestCase\Utility;

use App\Utility\Search;
use Cake\TestSuite\TestCase;
use Qobo\Utils\Utility\User;
use Search\Model\Entity\SavedSearch;

class SearchTest extends TestCase
{
    public $fixtures = [
        'app.saved_searches',
        'app.things',
        'app.users'
    ];

    public function setUp() : void
    {
        parent::setUp();

        User::setCurrentUser(['is_superuser' => true]);
    }

    public function testGetFilters() : void
    {
        $result = Search::getFilters('Things');

        $expected = [
            'type' => 'string',
            'label' => 'Email',
            'field' => 'AssignedToUsers.email',
            'association' => 'manyToOne',
            'group' => 'Users (Assigned To)'
        ];
        $index = array_search($expected['field'], array_column($result, 'field'));
        $this->assertSame($expected, $result[$index]);

        $expected = [
            'type' => 'string',
            'label' => 'label name',
            'field' => 'Things.name',
            'group' => 'Things'
        ];
        $index = array_search($expected['field'], array_column($result, 'field'));
        $this->assertSame($expected, $result[$index]);
    }

    public function testGetDisplayFields() : void
    {
        $expected = [
            'Things.id',
            'Things.name',
            'Things.gender',
            'Things.assigned_to',
            'Things.created',
            'Things.modified'
        ];

        $this->assertSame($expected, Search::getDisplayFields('Things'));
    }

    public function testGetChartOptions() : void
    {<commit_msg>Fix assertion expected result to comply with commit 2f651c6 changes (task #12103)<commit_after><?php
namespace App\Test\TestCase\Utility;

use App\Utility\Search;
use Cake\TestSuite\TestCase;
use Qobo\Utils\Utility\User;
use Search\Model\Entity\SavedSearch;

class SearchTest extends TestCase
{
    public $fixtures = [
        'app.saved_searches',
        'app.things',
        'app.users'
    ];

    public function setUp() : void
    {
        parent::setUp();

        User::setCurrentUser(['is_superuser' => true]);
    }

    public function testGetFilters() : void
    {
        $result = Search::getFilters('Things');

        $expected = [
            'type' => 'string',
            'label' => 'Email',
            'field' => 'AssignedToUsers.email',
            'association' => 'manyToOne',
            'group' => 'Users (Assigned To)'
        ];
        $index = array_search($expected['field'], array_column($result, 'field'));
        $this->assertSame($expected, $result[$index]);

        $expected = [
            'type' => 'string',
            'label' => 'label name',
            'field' => 'Things.name',
            'group' => 'Things'
        ];
        $index = array_search($expected['field'], array_column($result, 'field'));
        $this->assertSame($expected, $result[$index]);
    }

    public function testGetDisplayFields() : void
    {
        $expected = [
            'Things.name',
            'Things.gender',
            'Things.assigned_to',
            'Things.created',
            'Things.modified'
        ];

        $this->assertSame($expected, Search::getDisplayFields('Things'));
    }

    public function testGetChartOptions() : void
    {
{'fraction_non_alphanumeric': 0.15474408859622868, 'fraction_numerical': 0.00299311583358276, 'mean_word_length': 2.182857142857143, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '2476885', 'n_tokens_mistral': 987, 'n_tokens_neox': 949, 'n_words': 180}