|
|
@ -7,6 +7,7 @@ use Engelsystem\Controllers\Metrics\Stats;
|
|
|
|
use Engelsystem\Models\LogEntry;
|
|
|
|
use Engelsystem\Models\LogEntry;
|
|
|
|
use Engelsystem\Models\Message;
|
|
|
|
use Engelsystem\Models\Message;
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
use Engelsystem\Models\News;
|
|
|
|
|
|
|
|
use Engelsystem\Models\NewsComment;
|
|
|
|
use Engelsystem\Models\Question;
|
|
|
|
use Engelsystem\Models\Question;
|
|
|
|
use Engelsystem\Models\User\PasswordReset;
|
|
|
|
use Engelsystem\Models\User\PasswordReset;
|
|
|
|
use Engelsystem\Models\User\PersonalData;
|
|
|
|
use Engelsystem\Models\User\PersonalData;
|
|
|
@ -112,13 +113,12 @@ class StatsTest extends TestCase
|
|
|
|
$themes = $stats->themes();
|
|
|
|
$themes = $stats->themes();
|
|
|
|
$this->assertCount(3, $themes);
|
|
|
|
$this->assertCount(3, $themes);
|
|
|
|
$this->assertEquals([
|
|
|
|
$this->assertEquals([
|
|
|
|
['theme' => 0, 'count' => 7],
|
|
|
|
['theme' => 0, 'count' => 6],
|
|
|
|
['theme' => 1, 'count' => 1],
|
|
|
|
['theme' => 1, 'count' => 2],
|
|
|
|
['theme' => 4, 'count' => 1],
|
|
|
|
['theme' => 4, 'count' => 1],
|
|
|
|
], $themes->toArray());
|
|
|
|
], $themes->toArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::announcements
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::announcements
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -137,6 +137,27 @@ class StatsTest extends TestCase
|
|
|
|
$this->assertEquals(1, $stats->announcements(true));
|
|
|
|
$this->assertEquals(1, $stats->announcements(true));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::comments
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testComments()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$user = $this->addUser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$news = new News(['title' => 'Test', 'text' => 'Foo Bar', 'user_id' => $user->id]);
|
|
|
|
|
|
|
|
$news->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (['Test', 'Another text!'] as $text) {
|
|
|
|
|
|
|
|
$comment = new NewsComment(['text' => $text]);
|
|
|
|
|
|
|
|
$comment->news()->associate($news);
|
|
|
|
|
|
|
|
$comment->user()->associate($user);
|
|
|
|
|
|
|
|
$comment->save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$stats = new Stats($this->database);
|
|
|
|
|
|
|
|
$this->assertEquals(2, $stats->comments());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::questions
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::questions
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -177,6 +198,19 @@ class StatsTest extends TestCase
|
|
|
|
$this->assertEquals(2, $stats->forceActiveUsers());
|
|
|
|
$this->assertEquals(2, $stats->forceActiveUsers());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::email
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function testEmail()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->addUsers();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$stats = new Stats($this->database);
|
|
|
|
|
|
|
|
$this->assertEquals(0, $stats->email('not-available-option'));
|
|
|
|
|
|
|
|
$this->assertEquals(2, $stats->email('system'));
|
|
|
|
|
|
|
|
$this->assertEquals(3, $stats->email('humans'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::messages
|
|
|
|
* @covers \Engelsystem\Controllers\Metrics\Stats::messages
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -267,12 +301,12 @@ class StatsTest extends TestCase
|
|
|
|
protected function addUsers()
|
|
|
|
protected function addUsers()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->addUser();
|
|
|
|
$this->addUser();
|
|
|
|
$this->addUser([], ['shirt_size' => 'L']);
|
|
|
|
$this->addUser([], ['shirt_size' => 'L'], ['email_human' => true, 'email_shiftinfo' => true]);
|
|
|
|
$this->addUser(['arrived' => 1]);
|
|
|
|
$this->addUser(['arrived' => 1], [], ['email_human' => true]);
|
|
|
|
$this->addUser(['arrived' => 1], [], ['language' => 'lo_RM']);
|
|
|
|
$this->addUser(['arrived' => 1], [], ['language' => 'lo_RM', 'email_shiftinfo' => true]);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 2], ['shirt_size' => 'XXL'], ['language' => 'lo_RM']);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 2], ['shirt_size' => 'XXL'], ['language' => 'lo_RM']);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 9, 'force_active' => true], [], ['theme' => 1]);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 9, 'force_active' => true], [], ['theme' => 1]);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 3], ['theme' => 10]);
|
|
|
|
$this->addUser(['arrived' => 1, 'got_voucher' => 3], [], ['theme' => 1, 'email_human' => true]);
|
|
|
|
$this->addUser(['arrived' => 1, 'active' => 1, 'got_shirt' => true, 'force_active' => true]);
|
|
|
|
$this->addUser(['arrived' => 1, 'active' => 1, 'got_shirt' => true, 'force_active' => true]);
|
|
|
|
$this->addUser(['arrived' => 1, 'active' => 1, 'got_shirt' => true], ['shirt_size' => 'L'], ['theme' => 4]);
|
|
|
|
$this->addUser(['arrived' => 1, 'active' => 1, 'got_shirt' => true], ['shirt_size' => 'L'], ['theme' => 4]);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -281,8 +315,10 @@ class StatsTest extends TestCase
|
|
|
|
* @param array $state
|
|
|
|
* @param array $state
|
|
|
|
* @param array $personalData
|
|
|
|
* @param array $personalData
|
|
|
|
* @param array $settings
|
|
|
|
* @param array $settings
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @return User
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function addUser(array $state = [], $personalData = [], $settings = [])
|
|
|
|
protected function addUser(array $state = [], $personalData = [], $settings = []): User
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$name = 'user_' . Str::random(5);
|
|
|
|
$name = 'user_' . Str::random(5);
|
|
|
|
|
|
|
|
|
|
|
@ -307,12 +343,14 @@ class StatsTest extends TestCase
|
|
|
|
$settings = new Settings(array_merge([
|
|
|
|
$settings = new Settings(array_merge([
|
|
|
|
'language' => 'te_ST',
|
|
|
|
'language' => 'te_ST',
|
|
|
|
'theme' => 0,
|
|
|
|
'theme' => 0,
|
|
|
|
'email_human' => '',
|
|
|
|
'email_human' => false,
|
|
|
|
'email_shiftinfo' => '',
|
|
|
|
'email_shiftinfo' => false,
|
|
|
|
], $settings));
|
|
|
|
], $settings));
|
|
|
|
$settings->user()
|
|
|
|
$settings->user()
|
|
|
|
->associate($user)
|
|
|
|
->associate($user)
|
|
|
|
->save();
|
|
|
|
->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $user;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|