Metrics: Fixed message count
This commit is contained in:
parent
395f6706d6
commit
61977f5da9
|
@ -8,6 +8,7 @@ use Carbon\Carbon;
|
|||
use Engelsystem\Database\Database;
|
||||
use Engelsystem\Models\EventConfig;
|
||||
use Engelsystem\Models\LogEntry;
|
||||
use Engelsystem\Models\Message;
|
||||
use Engelsystem\Models\News;
|
||||
use Engelsystem\Models\Question;
|
||||
use Engelsystem\Models\User\PasswordReset;
|
||||
|
@ -239,13 +240,10 @@ class Stats
|
|||
|
||||
/**
|
||||
* @return int
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function messages(): int
|
||||
{
|
||||
return $this
|
||||
->getQuery('Messages')
|
||||
->count();
|
||||
return Message::query()->count();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Engelsystem\Test\Unit\Controllers\Metrics;
|
|||
use Carbon\Carbon;
|
||||
use Engelsystem\Controllers\Metrics\Stats;
|
||||
use Engelsystem\Models\LogEntry;
|
||||
use Engelsystem\Models\Message;
|
||||
use Engelsystem\Models\News;
|
||||
use Engelsystem\Models\Question;
|
||||
use Engelsystem\Models\User\PasswordReset;
|
||||
|
@ -131,6 +132,21 @@ class StatsTest extends TestCase
|
|||
$this->assertEquals(2, $stats->forceActiveUsers());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Engelsystem\Controllers\Metrics\Stats::messages
|
||||
*/
|
||||
public function testMessages()
|
||||
{
|
||||
$this->addUsers();
|
||||
|
||||
(new Message(['user_id' => 1, 'receiver_id' => 2, 'text' => 'Ohi?']))->save();
|
||||
(new Message(['user_id' => 4, 'receiver_id' => 1, 'text' => 'Testing stuff?']))->save();
|
||||
(new Message(['user_id' => 2, 'receiver_id' => 3, 'text' => 'Nope!', 'read' => true]))->save();
|
||||
|
||||
$stats = new Stats($this->database);
|
||||
$this->assertEquals(3, $stats->messages());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Engelsystem\Controllers\Metrics\Stats::sessions
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue