Created
March 26, 2013 17:34
-
-
Save hyusetiawan/5247406 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class UserTest extends MyTestCase | |
public function testValidRegistration($user = null) | |
{ | |
if ($user === null) { | |
$user = TestData::$USERS[0]; | |
} | |
$user['password_confirmation'] = $user['password']; | |
$resp = $this->json('POST', '/user', $user); | |
$this->responseIs(Status::CREATED); | |
//check the returned data is accurate | |
$this->assertSpecificKeys(['email', 'username'], $user); | |
//check that the user is automatically logged in | |
$this->assertEquals(Confide::user()->email, $user['email']); | |
} | |
public function testValidLogout() | |
{ | |
$this->json('GET', '/user/logout'); | |
$this->assertNull(Confide::user()); | |
} | |
public function testValidLoginWithEmail($user = null) | |
{ | |
if ($user === null){ | |
$user = TestData::$USERS[0]; | |
} | |
$this->testValidRegistration($user); | |
$this->testValidLogout(); | |
//@NOTE:even though I pass this data, what I get from Request::json is registration data from line 35 | |
$resp = $this->json('POST', '/user/login', ['login' => $user['email'], 'password' => $user['password']]); | |
$this->assertEquals(Confide::user()->email, $user['email']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment