1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* (c) Christian Gripp <[email protected]> |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
7
|
|
|
* file that was distributed with this source code. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Core23\LastFmBundle\Tests\Event; |
11
|
|
|
|
12
|
|
|
use Core23\LastFm\Session\SessionInterface; |
13
|
|
|
use Core23\LastFmBundle\Event\AuthSuccessEvent; |
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Symfony\Component\HttpFoundation\Response; |
16
|
|
|
|
17
|
|
|
final class AuthSuccessEventTest extends TestCase |
18
|
|
|
{ |
19
|
|
|
public function testGetUsername(): void |
20
|
|
|
{ |
21
|
|
|
$session = $this->prophesize(SessionInterface::class); |
22
|
|
|
$session->getName()->willReturn('MyUser'); |
23
|
|
|
|
24
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
25
|
|
|
|
26
|
|
|
static::assertSame('MyUser', $event->getUsername()); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGetSession(): void |
30
|
|
|
{ |
31
|
|
|
$session = $this->prophesize(SessionInterface::class); |
32
|
|
|
|
33
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
34
|
|
|
|
35
|
|
|
static::assertSame($session->reveal(), $event->getSession()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testGetResponse(): void |
39
|
|
|
{ |
40
|
|
|
$session = $this->prophesize(SessionInterface::class); |
41
|
|
|
|
42
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
43
|
|
|
|
44
|
|
|
static::assertNull($event->getResponse()); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testSetResponse(): void |
48
|
|
|
{ |
49
|
|
|
$session = $this->prophesize(SessionInterface::class); |
50
|
|
|
|
51
|
|
|
$reponse = $this->prophesize(Response::class); |
52
|
|
|
|
53
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
54
|
|
|
$event->setResponse($reponse->reveal()); |
55
|
|
|
|
56
|
|
|
static::assertSame($reponse->reveal(), $event->getResponse()); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|