the browser-facing portion of osu!
at master 1.4 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace Tests\Models\UserStatistics; 7 8use App\Exceptions\ClassNotFoundException; 9use App\Models\Beatmap; 10use App\Models\UserStatistics\Model; 11use Tests\TestCase; 12 13class ModelTest extends TestCase 14{ 15 /** 16 * @dataProvider validModes 17 */ 18 public function testGetClass($mode, $variant) 19 { 20 $class = Model::getClass($mode, $variant); 21 $this->assertInstanceOf(Model::class, new $class()); 22 } 23 24 /** 25 * @dataProvider invalidModes 26 */ 27 public function testGetClassByThrowsExceptionIfModeDoesNotExist($mode, $variant) 28 { 29 $this->expectException(ClassNotFoundException::class); 30 Model::getClass($mode, $variant); 31 } 32 33 public static function invalidModes() 34 { 35 return [ 36 ['does', null], 37 ['not exist', null], 38 ['not_real', null], 39 ['best\\_osu', null], 40 ['osu', '4k'], 41 ]; 42 } 43 44 public static function validModes() 45 { 46 $modes = []; 47 48 foreach (Beatmap::MODES as $mode => $_modeInt) { 49 $modes[] = [$mode, null]; 50 51 foreach (Beatmap::VARIANTS[$mode] ?? [] as $variant) { 52 $modes[] = [$mode, $variant]; 53 } 54 } 55 56 return $modes; 57 } 58}