Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#166: Automatically add .json extension #113

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading