Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/AuthTest.php
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | public function tearDown(): void | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test fetching current user info (/api/auth/info) | * Test fetching current user info (/api/auth/info) | ||||
*/ | */ | ||||
public function testInfo(): void | public function testInfo(): void | ||||
{ | { | ||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | $user = $this->getTestUser('UsersControllerTest1@userscontroller.com', ['status' => User::STATUS_NEW]); | ||||
$domain = $this->getTestDomain('userscontroller.com', [ | $domain = $this->getTestDomain('userscontroller.com', [ | ||||
'status' => Domain::STATUS_NEW, | 'status' => Domain::STATUS_NEW, | ||||
'type' => Domain::TYPE_PUBLIC, | 'type' => Domain::TYPE_PUBLIC, | ||||
]); | ]); | ||||
$response = $this->get("api/auth/info"); | $response = $this->get("api/auth/info"); | ||||
$response->assertStatus(401); | $response->assertStatus(401); | ||||
$response = $this->actingAs($user)->get("api/auth/info"); | $response = $this->actingAs($user)->get("api/auth/info"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertEquals($user->id, $json['id']); | $this->assertEquals($user->id, $json['id']); | ||||
$this->assertEquals($user->email, $json['email']); | $this->assertEquals($user->email, $json['email']); | ||||
$this->assertEquals(User::STATUS_NEW | User::STATUS_ACTIVE, $json['status']); | $this->assertEquals(User::STATUS_NEW, $json['status']); | ||||
$this->assertTrue(is_array($json['statusInfo'])); | $this->assertTrue(is_array($json['statusInfo'])); | ||||
$this->assertTrue(is_array($json['settings'])); | $this->assertTrue(is_array($json['settings'])); | ||||
$this->assertTrue(!isset($json['access_token'])); | $this->assertTrue(!isset($json['access_token'])); | ||||
// Note: Details of the content are tested in testUserResponse() | // Note: Details of the content are tested in testUserResponse() | ||||
// Test token refresh via the info request | // Test token refresh via the info request | ||||
// First we log in to get the refresh token | // First we log in to get the refresh token | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |