Skip to content

Commit

Permalink
#166: Automatically add .json extension
Browse files Browse the repository at this point in the history
  • Loading branch information
yogyrton committed Dec 19, 2024
1 parent 4b3e9e9 commit 4009a43
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 55 deletions.
18 changes: 9 additions & 9 deletions tests/AuthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function setUp(): void
{
parent::setUp();

self::$users ??= $this->getJsonFixture('users.json');
self::$users ??= $this->getJsonFixture('users');
self::$admin ??= User::find(1);

self::$userState ??= new ModelTestState(User::class);
Expand Down Expand Up @@ -104,20 +104,20 @@ public function testRegisterAuthorizedUser()
{
$this->mockBcryptHasher();

$data = $this->getJsonFixture('new_user.json');
$data = $this->getJsonFixture('new_user');

$response = $this->actingAs(self::$admin)->json('post', '/register', $data);

$response->assertOk();

self::$userState->assertChangesEqualsFixture('register_authorized_user_users_state.json');
self::$userState->assertChangesEqualsFixture('register_authorized_user_users_state');
}

public function testRegisterFromGuestUser()
{
$this->mockBcryptHasher();

$data = $this->getJsonFixture('new_user.json');
$data = $this->getJsonFixture('new_user');

$response = $this->json('post', '/register', $data);

Expand All @@ -127,12 +127,12 @@ public function testRegisterFromGuestUser()
$response->assertCookie('token');
$this->assertEquals(0, $response->getCookie('token', false)->getExpiresTime());

self::$userState->assertChangesEqualsFixture('register_from_guest_user_users_state.json');
self::$userState->assertChangesEqualsFixture('register_from_guest_user_users_state');
}

public function testRegisterFromGuestUserWithRemember()
{
$data = $this->getJsonFixture('new_user.json');
$data = $this->getJsonFixture('new_user');

$response = $this->json('post', '/register', [
...$data,
Expand Down Expand Up @@ -292,13 +292,13 @@ public function testRestorePassword()
{
$this->mockBcryptHasher();

$data = $this->getJsonFixture('restore_password.json');
$data = $this->getJsonFixture('restore_password');

$response = $this->json('post', '/auth/restore-password', $data);

$response->assertNoContent();

self::$userState->assertChangesEqualsFixture('restore_password_users_state.json');
self::$userState->assertChangesEqualsFixture('restore_password_users_state');

$this->assertDatabaseMissing('password_reset_tokens', [
'email' => '[email protected]',
Expand All @@ -307,7 +307,7 @@ public function testRestorePassword()

public function testRestorePasswordWrongToken()
{
$data = $this->getJsonFixture('restore_password_wrong_token.json');
$data = $this->getJsonFixture('restore_password_wrong_token');

$response = $this->json('post', '/auth/restore-password', $data);

Expand Down
8 changes: 4 additions & 4 deletions tests/RoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ public static function getSearchFilters(): array
return [
[
'filter' => ['all' => 1],
'fixture' => 'search_by_all.json',
'fixture' => 'search_by_all',
],
[
'filter' => [
'page' => 2,
'per_page' => 1,
],
'fixture' => 'search_by_page_per.json',
'fixture' => 'search_by_page_per',
],
[
'filter' => ['query' => 'us'],
'fixture' => 'get_roles_by_name.json',
'fixture' => 'get_roles_by_name',
],
[
'filter' => [
'desc' => true,
'order_by' => 'name',
],
'fixture' => 'get_roles_check_order.json',
'fixture' => 'get_roles_check_order',
],
];
}
Expand Down
32 changes: 16 additions & 16 deletions tests/SettingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setUp(): void

public function testUpdate()
{
$setting = $this->getJsonFixture('update_setting.json');
$setting = $this->getJsonFixture('update_setting');

$response = $this->actingAs(self::$admin)->json('put', "/settings/{$setting['name']}", $setting['value']);

Expand All @@ -35,7 +35,7 @@ public function testUpdate()

public function testUpdateNotExists()
{
$setting = $this->getJsonFixture('update_setting.json');
$setting = $this->getJsonFixture('update_setting');

$response = $this->actingAs(self::$admin)->json('put', '/settings/not-exists', $setting['value']);

Expand All @@ -44,7 +44,7 @@ public function testUpdateNotExists()

public function testUpdateNoAuth()
{
$setting = $this->getJsonFixture('update_setting.json');
$setting = $this->getJsonFixture('update_setting');

$response = $this->json('put', "/settings/{$setting['name']}", $setting['value']);

Expand All @@ -58,7 +58,7 @@ public function testUpdateNoAuth()

public function testUpdateNoPermission()
{
$setting = $this->getJsonFixture('update_setting.json');
$setting = $this->getJsonFixture('update_setting');

$response = $this->actingAs(self::$user)->json('put', "/settings/{$setting['name']}", $setting['value']);

Expand Down Expand Up @@ -95,7 +95,7 @@ public function testGetCheckResponse()
{
$response = $this->actingAs(self::$admin)->json('get', '/settings/states');

$this->assertEqualsFixture('get_setting.json', $response->json());
$this->assertEqualsFixture('get_setting', $response->json());
}

public function testGetNotExists()
Expand All @@ -110,33 +110,33 @@ public static function getSearchFilters(): array
return [
[
'filter' => ['query' => 'states'],
'fixture' => 'get_setting_by_key.json',
'fixture' => 'get_setting_by_key',
],
[
'filter' => [
'order_by' => 'name',
'desc' => false,
],
'fixture' => 'get_settings_check_order.json',
'fixture' => 'get_settings_check_order',
],
[
'filter' => [
'per_page' => 2,
],
'fixture' => 'search_per_page.json',
'fixture' => 'search_per_page',
],
[
'filter' => [
'all' => 1,
],
'fixture' => 'search_all.json',
'fixture' => 'search_all',
],
[
'filter' => [
'per_page' => 1,
'query' => 'states',
],
'fixture' => 'search_complex.json',
'fixture' => 'search_complex',
],
];
}
Expand All @@ -156,7 +156,7 @@ public static function getUserSearchFilters(): array
return [
[
'filter' => [],
'fixture' => 'get_public_settings.json',
'fixture' => 'get_public_settings',
],
];
}
Expand All @@ -180,7 +180,7 @@ public function testSetNotExistsSetting()

$result = app(SettingService::class)->set($setting['name'], $setting['value']);

$this->assertEqualsFixture('setting_set_not_exists.json', $result->jsonSerialize());
$this->assertEqualsFixture('setting_set_not_exists', $result->jsonSerialize());

$this->assertDatabaseHas('settings', [
'name' => $setting['name'],
Expand All @@ -197,7 +197,7 @@ public function testSetExistsSetting()

$result = app(SettingService::class)->set($setting['name'], $setting['value']);

$this->assertEqualsFixture('setting_set_exists.json', $result->jsonSerialize());
$this->assertEqualsFixture('setting_set_exists', $result->jsonSerialize());

$this->assertDatabaseHas('settings', [
'name' => $setting['name'],
Expand All @@ -209,20 +209,20 @@ public function testGetExistsSetting()
{
$result = app(SettingService::class)->get('attribute');

$this->assertEqualsFixture('setting_get_exists.json', $result);
$this->assertEqualsFixture('setting_get_exists', $result);
}

public function testGetExistsJsonSetting()
{
$result = app(SettingService::class)->get('settings.timezone');

$this->assertEqualsFixture('setting_get_exists_json.json', $result);
$this->assertEqualsFixture('setting_get_exists_json', $result);
}

public function testGetNotExistsSetting()
{
$result = app(SettingService::class)->get('not_exists_attribute');

$this->assertEqualsFixture('setting_get_not_exists.json', $result);
$this->assertEqualsFixture('setting_get_not_exists', $result);
}
}
Loading

0 comments on commit 4009a43

Please sign in to comment.