<commit_before><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace Tests\Libraries\Search;

use App\Libraries\Search\UserSearch;
use App\Libraries\Search\UserSearchParams;
use App\Models\User;
use Tests\TestCase;

class UserSearchTest extends TestCase
{
    public function testQueryString()
    {
        $searchUser1 = User::factory()->create(['username' => 'hello']);
        $searchUser1->esIndexDocument();
        $searchUser2 = User::factory()->create(['username' => 'hello world']);
        $searchUser2->esIndexDocument();
        $user3 = User::factory()->create(['username' => 'aaaaaa']);
        $user3->esIndexDocument();
        (new UserSearch())->refresh();

        $params = new UserSearchParams();
        $params->queryString = $searchUser1->username;
        $search = new UserSearch($params);
        $userIds = array_map('intval', $search->response()->ids());
        sort($userIds);

        $this->assertSame(2, count($userIds));
        $this->assertSame($searchUser1->getKey(), $userIds[0]);
        $this->assertSame($searchUser2->getKey(), $userIds[1]);
    }

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

        (new UserSearch())->deleteAll();
    }
}<commit_msg>More group for es using test<commit_after><?php

// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

namespace Tests\Libraries\Search;

use App\Libraries\Search\UserSearch;
use App\Libraries\Search\UserSearchParams;
use App\Models\User;
use Tests\TestCase;

class UserSearchTest extends TestCase
{
    /**
     * @group EsDefault
     */
    public function testQueryString()
    {
        $searchUser1 = User::factory()->create(['username' => 'hello']);
        $searchUser1->esIndexDocument();
        $searchUser2 = User::factory()->create(['username' => 'hello world']);
        $searchUser2->esIndexDocument();
        $user3 = User::factory()->create(['username' => 'aaaaaa']);
        $user3->esIndexDocument();
        (new UserSearch())->refresh();

        $params = new UserSearchParams();
        $params->queryString = $searchUser1->username;
        $search = new UserSearch($params);
        $userIds = array_map('intval', $search->response()->ids());
        sort($userIds);

        $this->assertSame(2, count($userIds));
        $this->assertSame($searchUser1->getKey(), $userIds[0]);
        $this->assertSame($searchUser2->getKey(), $userIds[1]);
    }

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

        (new UserSearch())->deleteAll();
    }
}
{'fraction_non_alphanumeric': 0.16467607672819398, 'fraction_numerical': 0.010133912414042706, 'mean_word_length': 3.325508607198748, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, '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': '6634678', 'n_tokens_mistral': 797, 'n_tokens_neox': 791, 'n_words': 177}