Simplify tests
This commit is contained in:
parent
acacd09253
commit
c4d26a4c10
|
|
@ -28,13 +28,11 @@ class AdminControllerTest extends BrowserKitTestCase
|
|||
public function testCustomize()
|
||||
{
|
||||
// Check if `color_scheme` is existed or not
|
||||
$this->get('/admin/customize?action=color', [
|
||||
'Accept' => 'application/json',
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->seeJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'color scheme']),
|
||||
]);
|
||||
$this->getJson('/admin/customize?action=color')
|
||||
->seeJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'color scheme']),
|
||||
]);
|
||||
|
||||
// Change color
|
||||
$this->get('/admin/customize?action=color&color_scheme=purple')
|
||||
|
|
|
|||
|
|
@ -35,21 +35,16 @@ class AuthControllerTest extends TestCase
|
|||
);
|
||||
|
||||
// Should return a warning if `identification` is empty
|
||||
$this->postJson(
|
||||
'/auth/login', [], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
$this->postJson('/auth/login')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => trans('validation.attributes.identification')]),
|
||||
]);
|
||||
|
||||
// Should return a warning if `password` is empty
|
||||
$this->postJson(
|
||||
'/auth/login', [
|
||||
'identification' => $user->email,
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'/auth/login', ['identification' => $user->email]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'password']),
|
||||
]);
|
||||
|
|
@ -59,8 +54,6 @@ class AuthControllerTest extends TestCase
|
|||
'/auth/login', [
|
||||
'identification' => $user->email,
|
||||
'password' => '123',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'password', 'min' => 6]),
|
||||
|
|
@ -71,8 +64,6 @@ class AuthControllerTest extends TestCase
|
|||
'/auth/login', [
|
||||
'identification' => $user->email,
|
||||
'password' => Str::random(80),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'password', 'max' => 32]),
|
||||
|
|
@ -186,20 +177,16 @@ class AuthControllerTest extends TestCase
|
|||
$this->expectsEvents(Events\UserRegistered::class);
|
||||
|
||||
// Should return a warning if `email` is empty
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
[],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'email']),
|
||||
]);
|
||||
$this->postJson('/auth/register')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'email']),
|
||||
]);
|
||||
|
||||
// Should return a warning if `email` is invalid
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
['email' => 'not_an_email'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['email' => 'not_an_email']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.email', ['attribute' => 'email']),
|
||||
|
|
@ -209,8 +196,7 @@ class AuthControllerTest extends TestCase
|
|||
$existedUser = factory(User::class)->create();
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
['email' => $existedUser->email],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['email' => $existedUser->email]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.unique', ['attribute' => 'email']),
|
||||
|
|
@ -219,8 +205,7 @@ class AuthControllerTest extends TestCase
|
|||
// Should return a warning if `password` is empty
|
||||
$this->postJson(
|
||||
'/auth/register',
|
||||
['email' => 'a@b.c'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['email' => 'a@b.c']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'password']),
|
||||
|
|
@ -232,8 +217,7 @@ class AuthControllerTest extends TestCase
|
|||
[
|
||||
'email' => 'a@b.c',
|
||||
'password' => '1',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'password', 'min' => 8]),
|
||||
|
|
@ -321,8 +305,7 @@ class AuthControllerTest extends TestCase
|
|||
'email' => 'a@b.c',
|
||||
'password' => '12345678',
|
||||
'captcha' => 'a',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'nickname']),
|
||||
|
|
@ -336,8 +319,7 @@ class AuthControllerTest extends TestCase
|
|||
'password' => '12345678',
|
||||
'nickname' => '\\',
|
||||
'captcha' => 'a',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'nickname']),
|
||||
|
|
@ -351,8 +333,7 @@ class AuthControllerTest extends TestCase
|
|||
'password' => '12345678',
|
||||
'nickname' => Str::random(256),
|
||||
'captcha' => 'a',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'nickname', 'max' => 255]),
|
||||
|
|
@ -365,8 +346,7 @@ class AuthControllerTest extends TestCase
|
|||
'email' => 'a@b.c',
|
||||
'password' => '12345678',
|
||||
'nickname' => 'nickname',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'captcha']),
|
||||
|
|
@ -381,8 +361,7 @@ class AuthControllerTest extends TestCase
|
|||
'password' => '12345678',
|
||||
'nickname' => 'nickname',
|
||||
'captcha' => 'a',
|
||||
],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
]
|
||||
)->assertJson([
|
||||
'errno' => 7,
|
||||
'msg' => trans('auth.register.close'),
|
||||
|
|
@ -544,20 +523,16 @@ class AuthControllerTest extends TestCase
|
|||
$url = URL::temporarySignedRoute('auth.reset', now()->addHour(), ['uid' => $user->uid]);
|
||||
|
||||
// Should return a warning if `password` is empty
|
||||
$this->postJson(
|
||||
$url, [], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'password']),
|
||||
]);
|
||||
$this->postJson($url)
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'password']),
|
||||
]);
|
||||
|
||||
// Should return a warning if `password` is too short
|
||||
$this->postJson(
|
||||
$url, [
|
||||
'password' => '123',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'password', 'min' => 8]),
|
||||
|
|
@ -567,8 +542,6 @@ class AuthControllerTest extends TestCase
|
|||
$this->postJson(
|
||||
$url, [
|
||||
'password' => Str::random(33),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'password', 'max' => 32]),
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class ClosetControllerTest extends TestCase
|
|||
option(['score_per_closet_item' => 10]);
|
||||
|
||||
// Missing `tid` field
|
||||
$this->postJson('/user/closet/add', [], ['X-Requested-With' => 'XMLHttpRequest'])
|
||||
$this->postJson('/user/closet/add')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'tid']),
|
||||
|
|
@ -100,8 +100,7 @@ class ClosetControllerTest extends TestCase
|
|||
// `tid` is not a integer
|
||||
$this->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => 'string'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 'string']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.integer', ['attribute' => 'tid']),
|
||||
|
|
@ -110,8 +109,7 @@ class ClosetControllerTest extends TestCase
|
|||
// Missing `name` field
|
||||
$this->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => 0],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 0]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'name']),
|
||||
|
|
@ -120,8 +118,7 @@ class ClosetControllerTest extends TestCase
|
|||
// `name` field has special characters
|
||||
$this->postJson(
|
||||
'/user/closet/add',
|
||||
['tid' => 0, 'name' => '\\'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 0, 'name' => '\\']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'name']),
|
||||
|
|
@ -177,7 +174,7 @@ class ClosetControllerTest extends TestCase
|
|||
$name = 'new';
|
||||
|
||||
// Missing `tid` field
|
||||
$this->postJson('/user/closet/rename', [], ['X-Requested-With' => 'XMLHttpRequest'])
|
||||
$this->postJson('/user/closet/rename')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'tid']),
|
||||
|
|
@ -186,8 +183,7 @@ class ClosetControllerTest extends TestCase
|
|||
// `tid` is not a integer
|
||||
$this->postJson(
|
||||
'/user/closet/rename',
|
||||
['tid' => 'string'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 'string']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.integer', ['attribute' => 'tid']),
|
||||
|
|
@ -196,8 +192,7 @@ class ClosetControllerTest extends TestCase
|
|||
// Missing `new_name` field
|
||||
$this->postJson(
|
||||
'/user/closet/rename',
|
||||
['tid' => 0],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 0]
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'new name']),
|
||||
|
|
@ -206,8 +201,7 @@ class ClosetControllerTest extends TestCase
|
|||
// `new_name` field has special characters
|
||||
$this->postJson(
|
||||
'/user/closet/rename',
|
||||
['tid' => 0, 'new_name' => '\\'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 0, 'new_name' => '\\']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'new name']),
|
||||
|
|
@ -244,7 +238,7 @@ class ClosetControllerTest extends TestCase
|
|||
$texture = factory(Texture::class)->create();
|
||||
|
||||
// Missing `tid` field
|
||||
$this->postJson('/user/closet/remove', [], ['X-Requested-With' => 'XMLHttpRequest'])
|
||||
$this->postJson('/user/closet/remove')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'tid']),
|
||||
|
|
@ -253,8 +247,7 @@ class ClosetControllerTest extends TestCase
|
|||
// `tid` is not a integer
|
||||
$this->postJson(
|
||||
'/user/closet/remove',
|
||||
['tid' => 'string'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['tid' => 'string']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.integer', ['attribute' => 'tid']),
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class PlayerControllerTest extends TestCase
|
|||
public function testAdd()
|
||||
{
|
||||
// Without player name
|
||||
$this->postJson('/user/player/add', [], ['X-Requested-With' => 'XMLHttpRequest'])
|
||||
$this->postJson('/user/player/add')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
|
|
@ -52,8 +52,7 @@ class PlayerControllerTest extends TestCase
|
|||
option(['player_name_rule' => 'official']);
|
||||
$this->postJson(
|
||||
'/user/player/add',
|
||||
['player_name' => '角色名'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['player_name' => '角色名']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.player_name', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
|
|
@ -64,8 +63,7 @@ class PlayerControllerTest extends TestCase
|
|||
option(['custom_player_name_regexp' => '/^([0-9]+)$/']);
|
||||
$this->postJson(
|
||||
'/user/player/add',
|
||||
['player_name' => 'yjsnpi'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['player_name' => 'yjsnpi']
|
||||
)->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.player_name', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
|
|
@ -76,8 +74,7 @@ class PlayerControllerTest extends TestCase
|
|||
$user = factory(User::class)->create(['score' => 0]);
|
||||
$this->actAs($user)->postJson(
|
||||
'/user/player/add',
|
||||
['player_name' => 'no_score'],
|
||||
['X-Requested-With' => 'XMLHttpRequest']
|
||||
['player_name' => 'no_score']
|
||||
)->assertJson([
|
||||
'errno' => 7,
|
||||
'msg' => trans('user.player.add.lack-score'),
|
||||
|
|
@ -164,9 +161,8 @@ class PlayerControllerTest extends TestCase
|
|||
$this->actAs($user)
|
||||
->postJson('/user/player/rename', [
|
||||
'pid' => $player->pid,
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
]);
|
||||
|
|
@ -176,8 +172,6 @@ class PlayerControllerTest extends TestCase
|
|||
$this->postJson('/user/player/rename', [
|
||||
'pid' => $player->pid,
|
||||
'new_player_name' => '角色名',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.player_name', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
|
|
@ -188,9 +182,8 @@ class PlayerControllerTest extends TestCase
|
|||
$this->postJson('/user/player/rename', [
|
||||
'pid' => $player->pid,
|
||||
'new_player_name' => '\\',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.player_name', ['attribute' => trans('validation.attributes.player_name')]),
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -403,29 +403,22 @@ class SkinlibControllerTest extends TestCase
|
|||
]);
|
||||
|
||||
// Without `name` field
|
||||
$this->postJson('/skinlib/upload', [], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
$this->postJson('/skinlib/upload')->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'name']),
|
||||
]);
|
||||
|
||||
// With some special chars
|
||||
$this->postJson('/skinlib/upload', [
|
||||
'name' => '\\',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'name']),
|
||||
]);
|
||||
$this->postJson('/skinlib/upload', ['name' => '\\'])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'name']),
|
||||
]);
|
||||
|
||||
// Specified regular expression for texture name
|
||||
option(['texture_name_regexp' => '/\\d+/']);
|
||||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'abc',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.regex', ['attribute' => 'name']),
|
||||
|
|
@ -435,8 +428,6 @@ class SkinlibControllerTest extends TestCase
|
|||
// Without file
|
||||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'texture',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'file']),
|
||||
|
|
@ -448,8 +439,6 @@ class SkinlibControllerTest extends TestCase
|
|||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'texture',
|
||||
'file' => $upload,
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.file', ['attribute' => 'file', 'max' => '2']),
|
||||
|
|
@ -460,8 +449,6 @@ class SkinlibControllerTest extends TestCase
|
|||
$this->postJson('/skinlib/upload', [
|
||||
'name' => 'texture',
|
||||
'file' => 'content', // Though it is not a file, it is OK
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'public']),
|
||||
|
|
@ -799,9 +786,7 @@ class SkinlibControllerTest extends TestCase
|
|||
|
||||
// Without `tid` field
|
||||
$this->actAs($uploader)
|
||||
->postJson('/skinlib/rename', [], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->postJson('/skinlib/rename')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'tid']),
|
||||
|
|
@ -810,8 +795,6 @@ class SkinlibControllerTest extends TestCase
|
|||
// `tid` is not a integer
|
||||
$this->postJson('/skinlib/rename', [
|
||||
'tid' => 'str',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
|
|
@ -821,8 +804,6 @@ class SkinlibControllerTest extends TestCase
|
|||
// Without `new_name` field
|
||||
$this->postJson('/skinlib/rename', [
|
||||
'tid' => $texture->tid,
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
|
|
@ -833,8 +814,6 @@ class SkinlibControllerTest extends TestCase
|
|||
$this->postJson('/skinlib/rename', [
|
||||
'tid' => $texture->tid,
|
||||
'new_name' => '\\',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
|
|
|
|||
|
|
@ -219,21 +219,16 @@ class UserControllerTest extends TestCase
|
|||
]);
|
||||
|
||||
// Change nickname without `new_nickname` field
|
||||
$this->postJson('/user/profile', [
|
||||
'action' => 'nickname',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'new nickname']),
|
||||
]);
|
||||
$this->postJson('/user/profile', ['action' => 'nickname'])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'new nickname']),
|
||||
]);
|
||||
|
||||
// Invalid nickname
|
||||
$this->postJson('/user/profile', [
|
||||
'action' => 'nickname',
|
||||
'new_nickname' => '\\',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.no_special_chars', ['attribute' => 'new nickname']),
|
||||
|
|
@ -243,8 +238,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'nickname',
|
||||
'new_nickname' => Str::random(256),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'new nickname', 'max' => 255]),
|
||||
|
|
@ -255,8 +248,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'nickname',
|
||||
'new_nickname' => 'nickname',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 0,
|
||||
'msg' => trans('user.profile.nickname.success', ['nickname' => 'nickname']),
|
||||
|
|
@ -264,22 +255,17 @@ class UserControllerTest extends TestCase
|
|||
$this->assertEquals('nickname', User::find($user->uid)->nickname);
|
||||
|
||||
// Change password without `current_password` field
|
||||
$this->postJson('/user/profile', [
|
||||
'action' => 'password',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'current password']),
|
||||
]);
|
||||
$this->postJson('/user/profile', ['action' => 'password'])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'current password']),
|
||||
]);
|
||||
|
||||
// Too short current password
|
||||
$this->postJson('/user/profile', [
|
||||
'action' => 'password',
|
||||
'current_password' => '1',
|
||||
'new_password' => '12345678',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'current password', 'min' => 6]),
|
||||
|
|
@ -290,8 +276,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'password',
|
||||
'current_password' => Str::random(33),
|
||||
'new_password' => '12345678',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'current password', 'max' => 32]),
|
||||
|
|
@ -302,8 +286,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'password',
|
||||
'current_password' => '12345678',
|
||||
'new_password' => '1',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'new password', 'min' => 8]),
|
||||
|
|
@ -314,8 +296,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'password',
|
||||
'current_password' => '12345678',
|
||||
'new_password' => Str::random(33),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'new password', 'max' => 32]),
|
||||
|
|
@ -326,8 +306,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'password',
|
||||
'current_password' => '1234567',
|
||||
'new_password' => '87654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('user.profile.password.wrong-password'),
|
||||
|
|
@ -339,8 +317,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'password',
|
||||
'current_password' => '12345678',
|
||||
'new_password' => '87654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 0,
|
||||
'msg' => trans('user.profile.password.success'),
|
||||
|
|
@ -354,8 +330,8 @@ class UserControllerTest extends TestCase
|
|||
$this->actAs($user)
|
||||
->postJson(
|
||||
'/user/profile',
|
||||
['action' => 'email'],
|
||||
['X-Requested-With' => 'XMLHttpRequest'])
|
||||
['action' => 'email']
|
||||
)
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'new email']),
|
||||
|
|
@ -365,8 +341,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'email',
|
||||
'new_email' => 'not_an_email',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.email', ['attribute' => 'new email']),
|
||||
|
|
@ -377,8 +351,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'email',
|
||||
'new_email' => 'a@b.c',
|
||||
'password' => '1',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'password', 'min' => 6]),
|
||||
|
|
@ -389,8 +361,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'email',
|
||||
'new_email' => 'a@b.c',
|
||||
'password' => Str::random(33),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'password', 'max' => 32]),
|
||||
|
|
@ -401,8 +371,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'email',
|
||||
'new_email' => $user->email,
|
||||
'password' => '87654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('user.profile.email.existed'),
|
||||
|
|
@ -413,8 +381,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'email',
|
||||
'new_email' => 'a@b.c',
|
||||
'password' => '7654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('user.profile.email.wrong-password'),
|
||||
|
|
@ -425,8 +391,6 @@ class UserControllerTest extends TestCase
|
|||
'action' => 'email',
|
||||
'new_email' => 'a@b.c',
|
||||
'password' => '87654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 0,
|
||||
'msg' => trans('user.profile.email.success'),
|
||||
|
|
@ -443,8 +407,8 @@ class UserControllerTest extends TestCase
|
|||
$this->actAs($user)
|
||||
->postJson(
|
||||
'/user/profile',
|
||||
['action' => 'delete'],
|
||||
['X-Requested-With' => 'XMLHttpRequest'])
|
||||
['action' => 'delete']
|
||||
)
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'password']),
|
||||
|
|
@ -454,8 +418,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'delete',
|
||||
'password' => '1',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.min.string', ['attribute' => 'password', 'min' => 6]),
|
||||
|
|
@ -465,8 +427,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'delete',
|
||||
'password' => Str::random(33),
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.max.string', ['attribute' => 'password', 'max' => 32]),
|
||||
|
|
@ -476,8 +436,6 @@ class UserControllerTest extends TestCase
|
|||
$this->postJson('/user/profile', [
|
||||
'action' => 'delete',
|
||||
'password' => '7654321',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('user.profile.delete.wrong-password'),
|
||||
|
|
@ -512,9 +470,7 @@ class UserControllerTest extends TestCase
|
|||
|
||||
// Without `tid` field
|
||||
$this->actAs($user)
|
||||
->postJson('/user/profile/avatar', [], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->postJson('/user/profile/avatar')
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.required', ['attribute' => 'tid']),
|
||||
|
|
@ -522,11 +478,7 @@ class UserControllerTest extends TestCase
|
|||
|
||||
// TID is not a integer
|
||||
$this->actAs($user)
|
||||
->postJson('/user/profile/avatar', [
|
||||
'tid' => 'string',
|
||||
], [
|
||||
'X-Requested-With' => 'XMLHttpRequest',
|
||||
])
|
||||
->postJson('/user/profile/avatar', ['tid' => 'string'])
|
||||
->assertJson([
|
||||
'errno' => 1,
|
||||
'msg' => trans('validation.integer', ['attribute' => 'tid']),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user