From b520a464cba973090e8383dcfde19b0237d01eb2 Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Sat, 14 Jul 2018 08:41:25 +0800 Subject: [PATCH] remove hack for test --- app/Http/Controllers/UserController.php | 5 ----- tests/UserControllerTest.php | 7 ++++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 9f52f8f7..9a83d085 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -69,11 +69,6 @@ class UserController extends Controller */ public function sign() { - // Hacking for testing - if (config('app.env') == 'testing') { - $this->user = User::find($this->user->uid); - } - if ($this->user->canSign()) { $acquiredScore = $this->user->sign(); diff --git a/tests/UserControllerTest.php b/tests/UserControllerTest.php index 147c8e2d..7920243b 100644 --- a/tests/UserControllerTest.php +++ b/tests/UserControllerTest.php @@ -88,9 +88,10 @@ class UserControllerTest extends TestCase ) ]); - $user->last_sign_at = \Carbon\Carbon::today()->toDateTimeString(); - $user->save(); - $this->postJson('/user/sign') + $user = factory(User::class)->create([ + 'last_sign_at' => \Carbon\Carbon::today()->toDateTimeString() + ]); + $this->actAs($user)->postJson('/user/sign') ->assertJson([ 'errno' => 0 ]);