From 170492b39d74f1c58927537dcbec1826748662d6 Mon Sep 17 00:00:00 2001 From: shibafu Date: Sun, 15 Dec 2019 20:07:25 +0900 Subject: [PATCH] =?UTF-8?q?=E6=9C=AC=E6=9D=A5=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=81=AB=E3=81=84=E3=82=89=E3=81=AA=E3=81=84=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E6=B6=88=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/Feature/SettingTest.php | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/tests/Feature/SettingTest.php b/tests/Feature/SettingTest.php index c54fd84..a7a79ec 100644 --- a/tests/Feature/SettingTest.php +++ b/tests/Feature/SettingTest.php @@ -30,13 +30,9 @@ class SettingTest extends TestCase 'ejaculation_id' => $ejaculation->id, ]); - $token = $this->getCsrfToken($user, '/setting/deactivate'); $response = $this->actingAs($user) ->followingRedirects() - ->post('/setting/deactivate', [ - '_token' => $token, - 'password' => 'secret', - ]); + ->post('/setting/deactivate', ['password' => 'secret']); $response->assertStatus(200) ->assertViewIs('setting.deactivated'); @@ -47,18 +43,4 @@ class SettingTest extends TestCase $this->assertDatabaseMissing('likes', ['id' => $anotherLike->id]); $this->assertDatabaseHas('deactivated_users', ['name' => $user->name]); } - - /** - * テスト対象を呼び出す前にGETリクエストを行い、CSRFトークンを得る - * @param Authenticatable $user 認証情報 - * @param string $uri リクエスト先 - * @return string CSRFトークン - */ - private function getCsrfToken(Authenticatable $user, string $uri): string - { - $response = $this->actingAs($user)->get($uri); - $crawler = new Crawler($response->getContent()); - - return $crawler->filter('input[name=_token]')->attr('value'); - } }