<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\Browser;

use App\Models\Country;
use DB;
use Route;
use Tests\Browser;
use Tests\DuskTestCase;

class SanityTest extends DuskTestCase
{
    protected static $scaffolding; // static so we only set up the scaffolding once

    protected $passed = 0;
    protected $failed = 0;
    protected $skipped = 0;

    public function createScaffolding()
    {
        if (!isset(self::$scaffolding)) {
            self::$scaffolding['country'] = Country::first() ?? factory(\App\Models\Country::class)->create();
            // user to login as and to use for requests
            self::$scaffolding['user'] = factory(\App\Models\User::class)->create([
                'country_acronym' => self::$scaffolding['country']->acronym,
            ]);

            // factories for /beatmapsets/*
            self::$scaffolding['beatmap_mirror'] = factory(\App\Models\BeatmapMirror::class)->create();
            self::$scaffolding['genre'] = factory(\App\Models\Genre::class)->create();
            self::$scaffolding['language'] = factory(\App\Models\Language::class)->create();
            self::$scaffolding['beatmapset'] = factory(\App\Models\Beatmapset::class)->create([
                'discussion_enabled' => true,
                'genre_id' => self::$scaffolding['genre']->genre_id,
                'language_id' => self::$scaffolding['language']->language_id,
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);
            self::$scaffolding['beatmap'] = factory(\App\Models\Beatmap::class)->create([
                'beatmapset_id' => self::$scaffolding['beatmapset']->getKey(),
            ]);
            self::$scaffolding['beatmap_discussion'] = factory(\App\Models\BeatmapDiscussion::class)->create([
                'beatmapset_id' => self::$scaffolding['beatmapset']->getKey(),
                'beatmap_id' => self::$scaffolding['beatmap']->getKey(),
            ]);
            self::$scaffolding['pack'] = factory(\App\Models\BeatmapPack::class)->create();

            // factories for /community/contests/*
            self::$scaffolding['contest'] = factory(\App\Models\Contest::class)->states('entry')->create();

            // factories for /community/tournaments/*
            self::$scaffolding['tournament'] = factory(\App\Models\Tournament::class)->create();

            // factories for /beatmaps/artists/*
            self::$scaffolding['artist'] = factory(\App\Models\Artist::class)->create();

            // factories for /store/*
            self::$scaffolding['product'] = factory(\App\Models\Store\Product::class, 'master_tshirt')->create();
            self::$scaffolding['order'] = factory(\App\Models\Store\Order::class)->states('checkout')->create([
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);
            self::$scaffolding['checkout'] = new ScaffoldDummy(self::$scaffolding['order']->getKey());
            self::$scaffolding['invoice'] = factory(\App\Models\Store\Order::class, 'paid')->create([
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);

            // factories for /community/forums/*
            self::$scaffolding['forum_parent'] = factory(\App\Models\Forum\Forum::class, 'parent')->create();
            self::$scaffolding['forum'] = factory(\App\Models\Forum\Forum::class, 'child')->create([
                'parent_id' => self::$scaffolding['forum_parent']->getKey(),
            ]);
            // satisfy group permissions required for posting in forum
            self::$scaffolding['_group'] = factory(\App\Models\Group::class)->create();
            self::$scaffolding['_forum_acl_post'] = factory(\App\Models\Forum\Authorize::class, 'post')->create([
                'forum_id' => self::$scaffolding['forum']->getKey(),
                'group_id' => self::$scaffolding['_group']->getKey(),
            ]);
            self::$scaffolding['_forum_acl_reply'] = factory(\App\Models\Forum\Authorize::class, 'reply')->create([
                'forum_id' => self::$scaffolding['forum']->getKey(),
                'group_id' => self::$scaffolding['_group']->getKey(),
            ]);<commit_msg>Fix default group in browser 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\Browser;

use App\Models\Country;
use DB;
use Route;
use Tests\Browser;
use Tests\DuskTestCase;

class SanityTest extends DuskTestCase
{
    protected static $scaffolding; // static so we only set up the scaffolding once

    protected $passed = 0;
    protected $failed = 0;
    protected $skipped = 0;

    public function createScaffolding()
    {
        if (!isset(self::$scaffolding)) {
            self::$scaffolding['country'] = Country::first() ?? factory(\App\Models\Country::class)->create();
            // user to login as and to use for requests
            self::$scaffolding['user'] = factory(\App\Models\User::class)->create([
                'country_acronym' => self::$scaffolding['country']->acronym,
            ]);

            // factories for /beatmapsets/*
            self::$scaffolding['beatmap_mirror'] = factory(\App\Models\BeatmapMirror::class)->create();
            self::$scaffolding['genre'] = factory(\App\Models\Genre::class)->create();
            self::$scaffolding['language'] = factory(\App\Models\Language::class)->create();
            self::$scaffolding['beatmapset'] = factory(\App\Models\Beatmapset::class)->create([
                'discussion_enabled' => true,
                'genre_id' => self::$scaffolding['genre']->genre_id,
                'language_id' => self::$scaffolding['language']->language_id,
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);
            self::$scaffolding['beatmap'] = factory(\App\Models\Beatmap::class)->create([
                'beatmapset_id' => self::$scaffolding['beatmapset']->getKey(),
            ]);
            self::$scaffolding['beatmap_discussion'] = factory(\App\Models\BeatmapDiscussion::class)->create([
                'beatmapset_id' => self::$scaffolding['beatmapset']->getKey(),
                'beatmap_id' => self::$scaffolding['beatmap']->getKey(),
            ]);
            self::$scaffolding['pack'] = factory(\App\Models\BeatmapPack::class)->create();

            // factories for /community/contests/*
            self::$scaffolding['contest'] = factory(\App\Models\Contest::class)->states('entry')->create();

            // factories for /community/tournaments/*
            self::$scaffolding['tournament'] = factory(\App\Models\Tournament::class)->create();

            // factories for /beatmaps/artists/*
            self::$scaffolding['artist'] = factory(\App\Models\Artist::class)->create();

            // factories for /store/*
            self::$scaffolding['product'] = factory(\App\Models\Store\Product::class, 'master_tshirt')->create();
            self::$scaffolding['order'] = factory(\App\Models\Store\Order::class)->states('checkout')->create([
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);
            self::$scaffolding['checkout'] = new ScaffoldDummy(self::$scaffolding['order']->getKey());
            self::$scaffolding['invoice'] = factory(\App\Models\Store\Order::class, 'paid')->create([
                'user_id' => self::$scaffolding['user']->getKey(),
            ]);

            // factories for /community/forums/*
            self::$scaffolding['forum_parent'] = factory(\App\Models\Forum\Forum::class, 'parent')->create();
            self::$scaffolding['forum'] = factory(\App\Models\Forum\Forum::class, 'child')->create([
                'parent_id' => self::$scaffolding['forum_parent']->getKey(),
            ]);
            // satisfy group permissions required for posting in forum
            self::$scaffolding['_group'] = app('groups')->byIdentifier('default');
            self::$scaffolding['_forum_acl_post'] = factory(\App\Models\Forum\Authorize::class, 'post')->create([
                'forum_id' => self::$scaffolding['forum']->getKey(),
                'group_id' => self::$scaffolding['_group']->getKey(),
            ]);
            self::$scaffolding['_forum_acl_reply'] = factory(\App\Models\Forum\Authorize::class, 'reply')->create([
                'forum_id' => self::$scaffolding['forum']->getKey(),
                'group_id' => self::$scaffolding['_group']->getKey(),
            ]);
{'fraction_non_alphanumeric': 0.18335053319573444, 'fraction_numerical': 0.0011466574934067195, 'mean_word_length': 2.8271171566476525, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 111, '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': '5540416', 'n_tokens_mistral': 2479, 'n_tokens_neox': 2460, 'n_words': 375}