]> git.localhorst.tv Git - alttp.git/commitdiff
add simple unit test
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 24 Feb 2024 10:20:37 +0000 (11:20 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sat, 24 Feb 2024 10:20:37 +0000 (11:20 +0100)
ci.sh
tests/Unit/ExampleTest.php [deleted file]
tests/Unit/Models/ChatLogTest.php [new file with mode: 0644]

diff --git a/ci.sh b/ci.sh
index 602f7b54f576f4bc9510551038afc5f3404e5fb5..b57b3b57dd2645a1d8b263b642f5dc81fa7b998c 100755 (executable)
--- a/ci.sh
+++ b/ci.sh
@@ -5,5 +5,5 @@ php artisan key:generate
 php artisan migrate:fresh
 npm clean-install
 npm run production
-nice php artisan test --without-tty --coverage-html /var/www/coverage/alttp/php
+XDEBUG_MODE=coverage nice php artisan test --without-tty --coverage-html /var/www/coverage/alttp/php
 nice npm run test -- --coverage --coverageDirectory /var/www/coverage/alttp/js --coverageReporters html --collectCoverageFrom 'resources/js/**'
diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php
deleted file mode 100644 (file)
index e5c5fef..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-namespace Tests\Unit;
-
-use PHPUnit\Framework\TestCase;
-
-class ExampleTest extends TestCase
-{
-    /**
-     * A basic test example.
-     *
-     * @return void
-     */
-    public function test_that_true_is_true()
-    {
-        $this->assertTrue(true);
-    }
-}
diff --git a/tests/Unit/Models/ChatLogTest.php b/tests/Unit/Models/ChatLogTest.php
new file mode 100644 (file)
index 0000000..72fd172
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Tests\Unit\Models;
+
+use App\Models\ChatLog;
+use PHPUnit\Framework\TestCase;
+
+class ChatLogTest extends TestCase {
+
+       public function test_classification() {
+               $this->assertEquals('gg', ChatLog::classify('gg'));
+               $this->assertEquals('gg', ChatLog::classify('GG'));
+               $this->assertEquals('gg', ChatLog::classify('Gg'));
+
+               $this->assertEquals('gl', ChatLog::classify('glhf'));
+               $this->assertEquals('gl', ChatLog::classify('gl & hf'));
+
+               $this->assertEquals('hi', ChatLog::classify('hi'));
+               $this->assertEquals('hi', ChatLog::classify('hallo'));
+
+               $this->assertEquals('hype', ChatLog::classify('122 Hype!'));
+
+               $this->assertEquals('number', ChatLog::classify('13'));
+               $this->assertEquals('number', ChatLog::classify('22'));
+
+               $this->assertEquals('lol', ChatLog::classify('haha'));
+               $this->assertEquals('lol', ChatLog::classify('KEKW'));
+               $this->assertEquals('lol', ChatLog::classify('LUL'));
+
+               $this->assertEquals('o7', ChatLog::classify('o7'));
+
+               $this->assertEquals('pog', ChatLog::classify('Pog'));
+
+               $this->assertEquals('unclassified', ChatLog::classify(''));
+       }
+
+}