SignupTest.php
1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
namespace FootyRoom\Tests;
class SignupTest extends TestCase
{
use SetsUpFixtures;
public function testGuestCanViewSignupPage()
{
$response = $this->call('GET', '/signup');
$this->assertEquals(200, $response->status());
}
public function testLoggedInUserShouldNotViewSignupPage()
{
$user = factory('FootyRoom\User\User')->make();
$response = $this->actingAs($user)->call('GET', '/signup');
$this->assertEquals(302, $response->status());
$response->assertLocation('http://'.app('FootyRoom\Config')->get('domain'));
}
public function testCheckUsernameExistShowCorrectResponse()
{
$response = $this->call('GET', '/signup/check-username?username=chandu');
$this->assertEquals(200, $response->status());
$this->assertEquals('taken', $response->original);
$response = $this->call('GET', '/signup/check-username?username=asf');
$this->assertEquals(200, $response->status());
$this->assertEquals('available', $response->original);
}
public function testSignupWithInvalidCaptchaShouldShowCorrectMessage()
{
$response = $this->call('POST', '/signup', [
'username' => 'asdf',
'password' => 'asdf',
'email' => 'asdf@gmail.com',
]);
$this->assertEquals(400, $response->status());
$this->assertEquals('You have not passed the CAPTCHA test, please try again.', $response->original['server'][0]);
$response = $this->call('POST', '/signup', [
'username' => 'asdf',
'password' => 'asdf',
'email' => 'asdf@gmail.com',
'gRecaptchaResponse' => '',
]);
$this->assertEquals(400, $response->status());
$this->assertEquals('You have not passed the CAPTCHA test, please try again.', $response->original['server'][0]);
}
}