-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from GrupaZero/KMS-179_add_basic_tests
Kms 179 add basic tests
- Loading branch information
Showing
4 changed files
with
126 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php namespace platform; | ||
|
||
use DateTime; | ||
|
||
class AccountCest | ||
{ | ||
|
||
public function _before(FunctionalTester $I) | ||
{ | ||
$I->haveRecord( | ||
'Users', | ||
[ | ||
'firstName' => 'Johny', | ||
'lastName' => 'Doe', | ||
'email' => 'john@doe.com', | ||
'password' => bcrypt('test123'), | ||
'createdAt' => new DateTime(), | ||
'updatedAt' => new DateTime(), | ||
] | ||
); | ||
} | ||
|
||
public function _after(FunctionalTester $I) | ||
{ | ||
} | ||
|
||
// tests | ||
public function canAccessUserAccount(FunctionalTester $I) | ||
{ | ||
$I->wantTo('can access user account'); | ||
$I->login('john@doe.com', 'test123'); | ||
$I->click('Edit Account', '.user-nav'); | ||
$I->canSeeInCurrentUrl('/en/account/edit'); | ||
$I->click('My Account', '.nav'); | ||
$I->canSeeInCurrentUrl('/en/account'); | ||
} | ||
|
||
public function canChangeFirstNameAndLastName(FunctionalTester $I) | ||
{ | ||
$I->wantTo('change user first name & last name'); | ||
$I->login('john@doe.com', 'test123'); | ||
$I->click('Edit Account', '.user-nav'); | ||
$I->canSee('Change password'); | ||
$token = $I->grabValueFrom("input[name='_token']"); | ||
$loggedUser = $I->grabRecord('Users', ['email' => 'john@doe.com']); | ||
$I->sendAjaxRequest('PUT', '/en/api/v1/account/' . $loggedUser->id, ['firstName' => 'xxx', 'lastName' => 'yyy', '_token' => $token]); | ||
$I->seeResponseCodeIs(200); | ||
$I->amOnPage('/en'); | ||
$I->see('xxx yyy'); | ||
} | ||
|
||
public function canChangePassword(FunctionalTester $I) | ||
{ | ||
$I->wantTo('change user password'); | ||
$I->login('john@doe.com', 'test123'); | ||
$I->click('Edit Account', '.user-nav'); | ||
$I->canSee('Change password'); | ||
$token = $I->grabValueFrom("input[name='_token']"); | ||
$loggedUser = $I->grabRecord('Users', ['email' => 'john@doe.com']); | ||
$I->sendAjaxRequest('PUT', '/en/api/v1/account/' . $loggedUser->id, ['password' => 'test124', 'password_confirmation' => 'test124', '_token' => $token]); | ||
$I->seeResponseCodeIs(200); | ||
$I->logout(); | ||
$I->login('john@doe.com', 'test124'); | ||
} | ||
|
||
public function canNotChangePasswordWithoutConfirmation(FunctionalTester $I) | ||
{ | ||
$I->wantTo('change user password'); | ||
$I->login('john@doe.com', 'test123'); | ||
$I->click('Edit Account', '.user-nav'); | ||
$I->canSee('Change password'); | ||
$token = $I->grabValueFrom("input[name='_token']"); | ||
$loggedUser = $I->grabRecord('Users', ['email' => 'john@doe.com']); | ||
$I->sendAjaxRequest('PUT', '/en/api/v1/account/' . $loggedUser->id, ['password' => 'test124', '_token' => $token]); | ||
$I->seeResponseCodeIs(400); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php namespace platform; | ||
|
||
use DateTime; | ||
|
||
class HomePageCest | ||
{ | ||
|
||
public function _before(FunctionalTester $I) | ||
{ | ||
} | ||
|
||
public function _after(FunctionalTester $I) | ||
{ | ||
} | ||
|
||
// tests | ||
public function canViewHomePage(FunctionalTester $I) | ||
{ | ||
$I->wantTo('can view home page'); | ||
$I->amOnPage('/en'); | ||
$I->seeResponseCodeIs(200); | ||
$I->canSee('GZERO CMS!'); | ||
$I->seeLink('Get started today', 'http://localhost/en/register'); | ||
$I->seeLink('Login', 'http://localhost/en/login'); | ||
$I->seeLink('Register', 'http://localhost/en/register'); | ||
} | ||
|
||
} | ||
|