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\Forum; 7 8use App\Models\Forum\Topic; 9use Tests\TestCase; 10 11class TopicTest extends TestCase 12{ 13 public function testTitleTrimOnAssignment() 14 { 15 $title = 'fine topic title'; 16 $topic = new Topic(['topic_title' => " {$title} "]); 17 $this->assertSame($title, $topic->topic_title); 18 19 $topic->topic_title = ' '; 20 $this->assertSame('', $topic->topic_title); 21 22 $topic->topic_title = ' '; // tabs 23 $this->assertSame('', $topic->topic_title); 24 25 $topic->topic_title = '  '; // double-width spaces 26 $this->assertSame('', $topic->topic_title); 27 } 28 29 public function testIssueTags() 30 { 31 $topic = new Topic(); 32 $topic->forum_id = $GLOBALS['cfg']['osu']['forum']['issue_forum_ids'][0]; 33 34 $topic->topic_title = '[invalid] herp a derp'; 35 $this->assertSame(['invalid'], $topic->issueTags()); 36 } 37 38 public function testIssueTagsWithKeywordAsTitle() 39 { 40 $topic = new Topic(); 41 $topic->forum_id = $GLOBALS['cfg']['osu']['forum']['issue_forum_ids'][0]; 42 43 $topic->topic_title = 'invalid herp a derp'; 44 $this->assertSame([], $topic->issueTags()); 45 } 46}