/
LogoutServiceTest.php
69 lines (53 loc) · 1.65 KB
/
LogoutServiceTest.php
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Aura\Auth\Service;
use Aura\Auth\Adapter\FakeAdapter;
use Aura\Auth\Session\FakeSession;
use Aura\Auth\Session\FakeSegment;
use Aura\Auth\Session\Timer;
use Aura\Auth\Auth;
use Aura\Auth\Status;
class LogoutServiceTest extends \PHPUnit_Framework_TestCase
{
protected $session;
protected $segment;
protected $adapter;
protected $auth;
protected $login_service;
protected $logout_service;
protected function setUp()
{
$this->segment = new FakeSegment;
$this->session = new FakeSession;
$this->adapter = new FakeAdapter;
$this->auth = new Auth($this->segment);
$this->login_service = new LoginService(
$this->adapter,
$this->session
);
$this->logout_service = new LogoutService(
$this->adapter,
$this->session
);
}
public function testLogout()
{
$this->login_service->forceLogin($this->auth, 'boshag');
$this->assertTrue($this->auth->isValid());
$this->logout_service->logout($this->auth);
$this->assertTrue($this->auth->isAnon());
}
public function testForceLogout()
{
$result = $this->login_service->forceLogin(
$this->auth,
'boshag',
array('foo' => 'bar')
);
$this->assertSame(Status::VALID, $result);
$this->assertTrue($this->auth->isValid());
$result = $this->logout_service->forceLogout($this->auth);
$this->assertSame(Status::ANON, $result);
$this->assertSame(Status::ANON, $this->auth->getStatus());
$this->assertNull($this->auth->getUserName());
}
}