Completed
Pull Request — master (#116)
by Johan
04:00
created

UserLogoutTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Authentication\UI\WEB\Tests\Functional;
4
5
use App\Ship\Parents\Tests\PhpUnit\TestCase;
6
use App\Ship\Parents\Tests\PhpUnit\WebTestCase;
7
use Illuminate\Foundation\Testing\WithoutMiddleware;
8
9
/**
10
 * Class UserLoginTest
11
 *
12
 * @author  Johan Alvarez <[email protected]>
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class UserLogoutTest extends TestCase
16
{
17
    // overrides the default subDomain in the base URL
18
    protected $subDomain = 'admin';
19
    protected $endpoint = '/logout';
20
21
    public function setUp()
22
    {
23
        // we change the API_PREFIX for web routes to make available all the
24
        // right web behavior. Maybe this should be seted up on
25
        // TestCaseTrait->overrideSubDomain() method?
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
        putenv("API_PREFIX=api");
27
28
        parent::setUp();
29
    }
30
31
    public function tearDown()
32
    {
33
        // revert the API_PREFIX variable to null to avoid effects on other test
34
        putenv("API_PREFIX=");
35
        parent::tearDown();
36
    }
37
38
    public function testUserLogout()
39
    {
40
        // go to the page
41
        $this->visit('login')
42
            ->see('Login');
43
44
        // fill the login form
45
        $this->type('[email protected]', 'email')
46
            ->type('admin', 'password')
47
            ->press('login');
48
49
        // login success and redirect to welcome view
50
        $this->seePageIs('/dashboard')
51
            ->see('Hello Admin');
52
53
        // trigger the logout request
54
        $response = $this->post($this->endpoint);
55
56
        $response->assertResponseStatus(302);
57
        $this->assertRedirectedTo('login');
58
        $this->see('login');
59
    }
60
}
61