3 namespace Tests\Unit\TwitchBot;
5 use App\TwitchBot\TokenizedMessage;
6 use PHPUnit\Framework\TestCase;
8 class TokenizedMessageTest extends TestCase {
10 public function test_classification() {
11 $this->assertEquals('cmd', TokenizedMessage::fromString('!start')->classify());
13 $this->assertEquals('eyes', TokenizedMessage::fromString(':eyes:')->classify());
14 $this->assertEquals('eyes', TokenizedMessage::fromString('holysm3Eyes', ['emotes' => 'blah:0-11'])->classify());
16 $this->assertEquals('gg', TokenizedMessage::fromString('gg')->classify());
17 $this->assertEquals('gg', TokenizedMessage::fromString('GG')->classify());
18 $this->assertEquals('gg', TokenizedMessage::fromString('Gg')->classify());
19 $this->assertEquals('gg', TokenizedMessage::fromString('ggs')->classify());
20 $this->assertEquals('gg', TokenizedMessage::fromString('gg monkaS')->classify());
21 $this->assertEquals('gg', TokenizedMessage::fromString('ja gg dann, ne')->classify());
22 $this->assertEquals('gg', TokenizedMessage::fromString('duden2Gg', ['emotes' => 'blah:0-7'])->classify());
23 $this->assertEquals('gg', TokenizedMessage::fromString('ticknaGg2', ['emotes' => 'blah:0-8'])->classify());
24 $this->assertNotEquals('gg', TokenizedMessage::fromString('Eggnog')->classify());
26 $this->assertEquals('gl', TokenizedMessage::fromString('glhf')->classify());
27 $this->assertEquals('gl', TokenizedMessage::fromString('gl & hf')->classify());
29 $this->assertEquals('hi', TokenizedMessage::fromString('hi')->classify());
30 $this->assertEquals('hi', TokenizedMessage::fromString('hallo')->classify());
31 $this->assertEquals('hi', TokenizedMessage::fromString('Hallo zusammen :)')->classify());
32 $this->assertEquals('hi', TokenizedMessage::fromString('osora9Hello', ['emotes' => 'blah:0-10'])->classify());
33 $this->assertEquals('hi', TokenizedMessage::fromString('hallo ihr lieben ticknaHi2 ticknaHerz', ['emotes' => 'blah:17-25/blubb:27-36'])->classify());
34 $this->assertNotEquals('hi', TokenizedMessage::fromString('hier steht was')->classify());
36 $this->assertEquals('hype', TokenizedMessage::fromString('122 Hype!')->classify());
37 $this->assertEquals('hype', TokenizedMessage::fromString('Sarühlalü KomodoHype', ['emotes' => '81273:10-19'])->classify());
39 $this->assertEquals('kappa', TokenizedMessage::fromString('Kappa', ['emotes' => 'blah:0-4'])->classify());
40 $this->assertEquals('kappa', TokenizedMessage::fromString('KappaClaus', ['emotes' => 'blah:0-9'])->classify());
41 $this->assertEquals('kappa', TokenizedMessage::fromString('Keepo', ['emotes' => 'blah:0-4'])->classify());
42 $this->assertNotEquals('kappa', TokenizedMessage::fromString('I keep order')->classify());
44 $this->assertEquals('number', TokenizedMessage::fromString('13')->classify());
45 $this->assertEquals('number', TokenizedMessage::fromString('22')->classify());
47 $this->assertEquals('lol', TokenizedMessage::fromString('haha')->classify());
48 $this->assertEquals('lol', TokenizedMessage::fromString('KEKW')->classify());
49 $this->assertEquals('lol', TokenizedMessage::fromString('LUL', ['emotes' => 'blah:0-2'])->classify());
50 $this->assertEquals('lol', TokenizedMessage::fromString(':D')->classify());
51 $this->assertEquals('lol', TokenizedMessage::fromString('xD')->classify());
52 $this->assertEquals('lol', TokenizedMessage::fromString('denkst du LUL', ['emotes' => 'blah:10-12'])->classify());
53 $this->assertNotEquals('lol', TokenizedMessage::fromString('holy nynyxDiscoLove', ['emotes' => 'blah:5-18'])->classify());
55 $this->assertEquals('o7', TokenizedMessage::fromString('o7')->classify());
56 $this->assertEquals('o7', TokenizedMessage::fromString('ticknaSalutieren', ['emotes' => 'blah:0-15'])->classify());
58 $this->assertEquals('pog', TokenizedMessage::fromString('Pog')->classify());
59 $this->assertNotEquals('pog', TokenizedMessage::fromString('wo war der')->classify());
61 $this->assertEquals('rage', TokenizedMessage::fromString('duden2Rage', ['emotes' => 'blah:0-10'])->classify());
63 $this->assertEquals('question', TokenizedMessage::fromString('Joaaa geht so ...und selbst?')->classify());
65 $this->assertEquals('sad', TokenizedMessage::fromString(':(')->classify());
66 $this->assertEquals('sad', TokenizedMessage::fromString('PoroSad', ['emotes' => 'blah:0-7'])->classify());
68 $this->assertEquals('sweat', TokenizedMessage::fromString('monkaS')->classify());
70 $this->assertEquals('thx', TokenizedMessage::fromString('danke für den tipp')->classify());
72 $this->assertEquals('wtf', TokenizedMessage::fromString('wtf? lol')->classify());
73 $this->assertNotEquals('wtf', TokenizedMessage::fromString('ein waterwalk aufgesetzt')->classify());
75 $this->assertEquals('yes', TokenizedMessage::fromString('ja geht SeemsGood')->classify());
76 $this->assertEquals('yes', TokenizedMessage::fromString('also ich würde sagen ja LUL', ['emotes' => 'blah:24-26'])->classify());
77 $this->assertNotEquals('yes', TokenizedMessage::fromString('find ich ja gut')->classify());
79 $this->assertEquals('unclassified', TokenizedMessage::fromString('')->classify());
80 $this->assertEquals('unclassified', TokenizedMessage::fromString('bitte boots locked in desert und bib')->classify());
83 public function test_spam() {
84 $this->assertTrue(TokenizedMessage::fromString('!start')->isSpammy());
85 $this->assertTrue(TokenizedMessage::fromString('@LocalhorstTV')->isSpammy());
87 $this->assertTrue(TokenizedMessage::fromString('just 50€')->isSpammy());
88 $this->assertTrue(TokenizedMessage::fromString('hello would you like some followers?')->isSpammy());
89 $this->assertTrue(TokenizedMessage::fromString('get view ers for free')->isSpammy());
91 $this->assertTrue(TokenizedMessage::fromString('yayklaygaming verschwindet für \'ne Weile in den Lurk. Cool, dass Du vorbeigeschaut hast xallggCheers PogChamp')->isSpammy());
92 $this->assertTrue(TokenizedMessage::fromString('XallGG is now live! Streaming The Legend of Zelda: A Link to the Past: Casual Boots Seed zum Spaß/Practice')->isSpammy());
93 $this->assertTrue(TokenizedMessage::fromString('also bitte, horstie')->isSpammy());
95 $this->assertTrue(TokenizedMessage::fromString('hey maengi, vielen dank für den raid')->isSpammy());
96 $this->assertTrue(TokenizedMessage::fromString('Willkommen auf Starbase 47')->isSpammy());