Skip to content

Commit

Permalink
Updates to user testing
Browse files Browse the repository at this point in the history
  • Loading branch information
danrwalker committed Jan 11, 2017
1 parent d54fedc commit 1518546
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
14 changes: 13 additions & 1 deletion tests/Core/Models/UserModel.Test.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class User extends \PHPUnit_Framework_TestCase{
class UserModel extends \PHPUnit_Framework_TestCase{

public function testCreate(){

Expand Down Expand Up @@ -32,6 +32,18 @@ public function testLoginFail(){
$this -> assertFalse($arrSessionArray['status']);
}

public function testLoginPOST(){

$_POST['email'] = 'travisci@unit-test-twistphp.com';
$_POST['password'] = 'X123Password';

$arrSessionArray = \Twist::User()->authenticate();
$this -> assertTrue($arrSessionArray['status']);

\Twist::User()->logout();
$this -> assertFalse(\Twist::User()->loggedIn());
}

public function testEdit(){

$resUser = \Twist::User()->get(1);
Expand Down
36 changes: 36 additions & 0 deletions tests/Core/Utilities/User.Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

class User extends \PHPUnit_Framework_TestCase{

public function testLogin(){

//Create new super user test user
$resUser = \Twist::User()->create();

$resUser->firstname('Travis');
$resUser->surname('CI');
$resUser->level(0);
$resUser->email('travisci2@unit-test-twistphp.com');
$resUser->password('X123Password');

$this -> assertEquals(2,$resUser->commit());

//Login as the new test user
$arrSessionArray = \Twist::User()->authenticate('travisci2@unit-test-twistphp.com','X123Password');
$this -> assertTrue($arrSessionArray['status']);
}

public function testLoggedIn(){

$this -> assertEquals(2,\Twist::User()->loggedInID());

$this -> assertEquals(0,\Twist::User()->loggedInLevel());

$this -> assertTrue(is_object(\Twist::User()->current()));

$this -> assertEquals(2,\Twist::User()->currentID());

$this -> assertEquals(0,\Twist::User()->currentLevel());
}
}

0 comments on commit 1518546

Please sign in to comment.