2018-07-15 05:11:56 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Tests\Browser\Processes\Dashboard;
|
|
|
|
|
|
|
|
use Pterodactyl\Tests\Browser\BrowserTestCase;
|
|
|
|
use Pterodactyl\Tests\Browser\PterodactylBrowser;
|
|
|
|
use Pterodactyl\Tests\Browser\Pages\Dashboard\AccountPage;
|
|
|
|
|
|
|
|
class AccountEmailProcessTest extends BrowserTestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Models\User
|
|
|
|
*/
|
|
|
|
private $user;
|
|
|
|
|
|
|
|
/**
|
2018-07-15 18:44:18 +00:00
|
|
|
* Setup tests.
|
2018-07-15 05:11:56 +00:00
|
|
|
*/
|
2018-07-15 18:44:18 +00:00
|
|
|
protected function setUp()
|
2018-07-15 05:11:56 +00:00
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2018-07-15 18:44:18 +00:00
|
|
|
$this->user = $this->user();
|
2018-07-15 05:11:56 +00:00
|
|
|
}
|
|
|
|
|
2018-07-15 18:44:18 +00:00
|
|
|
/**
|
|
|
|
* Test that an email address can be changed successfully.
|
|
|
|
*/
|
2018-07-15 05:11:56 +00:00
|
|
|
public function testEmailCanBeChanged()
|
|
|
|
{
|
|
|
|
$this->browse(function (PterodactylBrowser $browser) {
|
|
|
|
$browser->loginAs($this->user)
|
|
|
|
->visit(new AccountPage)
|
|
|
|
->assertValue('@email', $this->user->email)
|
|
|
|
->type('@email', 'new.email@example.com')
|
|
|
|
->type('@password', 'Password123')
|
|
|
|
->click('@submit')
|
|
|
|
->waitFor('@@success')
|
|
|
|
->assertSeeIn('@@success', trans('dashboard/account.email.updated'))
|
|
|
|
->assertValue('@email', 'new.email@example.com');
|
|
|
|
|
|
|
|
$this->assertDatabaseHas('users', ['id' => $this->user->id, 'email' => 'new.email@example.com']);
|
|
|
|
});
|
|
|
|
}
|
2018-07-15 18:44:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test that entering the wrong password for an account returns an error.
|
|
|
|
*/
|
|
|
|
public function testInvalidPasswordShowsError()
|
|
|
|
{
|
|
|
|
$this->browse(function (PterodactylBrowser $browser) {
|
|
|
|
$browser->loginAs($this->user)
|
|
|
|
->visit(new AccountPage)
|
|
|
|
->type('@email', 'new.email@example.com')
|
|
|
|
->click('@submit')
|
|
|
|
->assertFocused('@password')
|
|
|
|
->type('@password', 'test1234')
|
|
|
|
->click('@submit')
|
|
|
|
->waitFor('@@error')
|
|
|
|
->assertSeeIn('@@error', trans('validation.internal.invalid_password'))
|
|
|
|
->assertValue('@email', 'new.email@example.com');
|
|
|
|
|
|
|
|
$this->assertDatabaseMissing('users', ['id' => $this->user->id, 'email' => 'new.email@example.com']);
|
|
|
|
});
|
|
|
|
}
|
2018-07-15 05:11:56 +00:00
|
|
|
}
|