-
-
-
-
-
-
-
-
-
-
-
-
@lang('user.used.players')
-
{{ $statistics['players']['used'] }}/ {{ $statistics['players']['total'] }}
-
-
-
-
@lang('user.used.storage')
-
- @php
- $used = $statistics['storage']['used'];
- $total = $statistics['storage']['total'];
- @endphp
-
-
- @if ($used > 1024)
- {{ round($used / 1024, 1) }}/ {{ is_string($total) ? $total : round($total / 1024, 1) }} MB
- @else
- {{ $used }}/ {{ $total }} KB
- @endif
-
-
-
-
-
-
-
- @lang('user.cur-score')
-
-
- {{ $user->getScore() }}
-
-
@lang('user.score-notice')
-
-
-
-
-
+
diff --git a/routes/web.php b/routes/web.php
index ba02ed2a..a7caaf4a 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -45,6 +45,7 @@ Route::group(['prefix' => 'auth'], function ()
Route::group(['middleware' => ['web', 'auth'], 'prefix' => 'user'], function ()
{
Route::any ('', 'UserController@index');
+ Route::get ('/score-info', 'UserController@scoreInfo');
Route::post('/sign', 'UserController@sign');
// Profile
diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php
index 1fab32ad..28c301d4 100644
--- a/tests/UserControllerTest.php
+++ b/tests/UserControllerTest.php
@@ -15,17 +15,43 @@ class UserControllerTest extends TestCase
$user = factory(User::class)->create();
factory(\App\Models\Player::class)->create(['uid' => $user->uid]);
- $players_count = option('score_per_player') / option('user_initial_score');
$this->actAs($user)
->get('/user')
->assertViewHas('user')
->assertViewHas('statistics')
- ->assertSee((string) (1 / $players_count * 100)) // Players
- ->assertSee('0') // Storage
->assertSee((new Parsedown())->text(option_localized('announcement')))
->assertSee((string) $user->score);
}
+ public function testScoreInfo()
+ {
+ $user = factory(User::class)->create();
+ factory(\App\Models\Player::class)->create(['uid' => $user->uid]);
+
+ $this->actingAs($user)
+ ->get('/user/score-info')
+ ->assertJson([
+ 'user' => [
+ 'score' => $user->score,
+ 'lastSignAt' => $user->last_sign_at
+ ],
+ 'stats' => [
+ 'players' => [
+ 'used' => 1,
+ 'total' => 11,
+ 'percentage' => 1 / 11 * 100
+ ],
+ 'storage' => [
+ 'used' => 0,
+ 'total' => $user->score,
+ 'percentage' => 0
+ ]
+ ],
+ 'signAfterZero' => option('sign_after_zero'),
+ 'signGapTime' => option('sign_gap_time')
+ ]);
+ }
+
public function testSign()
{
option(['sign_score' => '50,50']);