<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\Models\Solo;

use App\Exceptions\InvariantException;
use App\Models\Solo\Score;
use stdClass;
use Carbon\Carbon;
use Tests\TestCase;

class ScoreTest extends TestCase
{
    public function testCreateLegacyEntryIncompletePlay()
    {
        $score = new Score();

        $this->expectException(InvariantException::class);

        $score->createLegacyEntry();
    }

    public function testLegacyPassScoreRetainsRank()
    {
        $score = new Score([
            'mods' => [],
            'user_id' => 1,
            'beatmap_id' => 1,
            'ruleset_id' => 1,
        ]);

        $score->complete([
            'ended_at' => Carbon::now(),
            'passed' => true,
            'total_score' => 1000,
            'max_combo' => 100,
            'statistics' => ['great' => 10],
            'accuracy' => 1,
            'rank' => 'S', // lazer may send an incorrect rank for a failed score.
        ]);

        $this->assertTrue($score->passed);
        $this->assertEquals($score->rank, 'S');

        $legacy = $score->createLegacyEntry();

        $this->assertTrue($legacy->perfect);<commit_msg>Remove incorrect duplicate comment<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\Models\Solo;

use App\Exceptions\InvariantException;
use App\Models\Solo\Score;
use stdClass;
use Carbon\Carbon;
use Tests\TestCase;

class ScoreTest extends TestCase
{
    public function testCreateLegacyEntryIncompletePlay()
    {
        $score = new Score();

        $this->expectException(InvariantException::class);

        $score->createLegacyEntry();
    }

    public function testLegacyPassScoreRetainsRank()
    {
        $score = new Score([
            'mods' => [],
            'user_id' => 1,
            'beatmap_id' => 1,
            'ruleset_id' => 1,
        ]);

        $score->complete([
            'ended_at' => Carbon::now(),
            'passed' => true,
            'total_score' => 1000,
            'max_combo' => 100,
            'statistics' => ['great' => 10],
            'accuracy' => 1,
            'rank' => 'S',
        ]);

        $this->assertTrue($score->passed);
        $this->assertEquals($score->rank, 'S');

        $legacy = $score->createLegacyEntry();

        $this->assertTrue($legacy->perfect);
{'fraction_non_alphanumeric': 0.14121699196326062, 'fraction_numerical': 0.011481056257175661, 'mean_word_length': 2.292191435768262, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 51, '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': '2740215', 'n_tokens_mistral': 809, 'n_tokens_neox': 758, 'n_words': 186}