You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.4 KiB
89 lines
2.4 KiB
<?php
|
|
|
|
namespace Tests\Feature\Users;
|
|
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* User Profile Feature Test.
|
|
*
|
|
* @author Nafies Luthfi <nafiesL@gmail.com>
|
|
*/
|
|
class UserProfileTest extends TestCase
|
|
{
|
|
/** @test */
|
|
public function a_user_can_visit_their_profile_page()
|
|
{
|
|
$user = $this->userSigningIn();
|
|
$this->visit(route('users.profile.show'));
|
|
$this->seePageIs(route('users.profile.show'));
|
|
}
|
|
|
|
/** @test */
|
|
public function a_user_can_visit_their_profile_edit_page()
|
|
{
|
|
$user = $this->userSigningIn();
|
|
$this->visit(route('users.profile.edit'));
|
|
$this->seePageIs(route('users.profile.edit'));
|
|
}
|
|
|
|
/** @test */
|
|
public function a_user_can_update_their_profile()
|
|
{
|
|
$user = $this->userSigningIn();
|
|
$this->visit(route('users.profile.edit'));
|
|
|
|
$this->submitForm(trans('auth.update_profile'), [
|
|
'name' => 'Nama Saya',
|
|
'email' => 'me@domain.com',
|
|
'lang' => 'en', // en, id, de
|
|
]);
|
|
|
|
$this->see(trans('auth.profile_updated'));
|
|
$this->seePageIs(route('users.profile.show'));
|
|
|
|
$this->seeInDatabase('users', [
|
|
'id' => $user->id,
|
|
'name' => 'Nama Saya',
|
|
'email' => 'me@domain.com',
|
|
'lang' => 'en',
|
|
]);
|
|
}
|
|
|
|
/** @test */
|
|
public function user_get_locale_bases_on_their_lang_profile_value()
|
|
{
|
|
$user = $this->userSigningIn(['lang' => 'en']);
|
|
$this->visit(route('home'));
|
|
|
|
$this->assertEquals('en', app()->getLocale());
|
|
|
|
$user = $this->userSigningIn(['lang' => 'id']);
|
|
$this->visit(route('home'));
|
|
|
|
$this->assertEquals('id', app()->getLocale());
|
|
}
|
|
|
|
/** @test */
|
|
public function user_can_switch_lang_from_sidebar()
|
|
{
|
|
$user = $this->userSigningIn(['lang' => 'id']);
|
|
|
|
$this->visit('/');
|
|
|
|
$this->submitForm('switch_lang_en', ['lang' => 'en']);
|
|
|
|
$this->assertEquals('en', app()->getLocale());
|
|
$this->assertEquals('en', $user->fresh()->lang);
|
|
|
|
$this->submitForm('switch_lang_id', ['lang' => 'id']);
|
|
|
|
$this->assertEquals('id', app()->getLocale());
|
|
$this->assertEquals('id', $user->fresh()->lang);
|
|
|
|
$this->submitForm('switch_lang_id', ['lang' => 'de']);
|
|
|
|
$this->assertEquals('de', app()->getLocale());
|
|
$this->assertEquals('de', $user->fresh()->lang);
|
|
}
|
|
}
|