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\Connection\SessionInterface; |
13
|
|
|
use Core23\LastFmBundle\Event\AuthSuccessEvent; |
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Symfony\Component\EventDispatcher\Event; |
16
|
|
|
use Symfony\Component\HttpFoundation\Response; |
17
|
|
|
|
18
|
|
|
class AuthSuccessEventTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
public function testCreation(): void |
21
|
|
|
{ |
22
|
|
|
$session = $this->prophesize(SessionInterface::class); |
23
|
|
|
|
24
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
25
|
|
|
|
26
|
|
|
$this->assertInstanceOf(Event::class, $event); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function testGetUsername(): void |
30
|
|
|
{ |
31
|
|
|
$session = $this->prophesize(SessionInterface::class); |
32
|
|
|
$session->getName()->willReturn('MyUser'); |
33
|
|
|
|
34
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
35
|
|
|
|
36
|
|
|
$this->assertSame('MyUser', $event->getUsername()); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testGetSession(): void |
40
|
|
|
{ |
41
|
|
|
$session = $this->prophesize(SessionInterface::class); |
42
|
|
|
|
43
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
44
|
|
|
|
45
|
|
|
$this->assertSame($session->reveal(), $event->getSession()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testGetResponse(): void |
49
|
|
|
{ |
50
|
|
|
$session = $this->prophesize(SessionInterface::class); |
51
|
|
|
|
52
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
53
|
|
|
|
54
|
|
|
$this->assertNull($event->getResponse()); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testSetResponse(): void |
58
|
|
|
{ |
59
|
|
|
$session = $this->prophesize(SessionInterface::class); |
60
|
|
|
|
61
|
|
|
$reponse = $this->prophesize(Response::class); |
62
|
|
|
|
63
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
64
|
|
|
$event->setResponse($reponse->reveal()); |
65
|
|
|
|
66
|
|
|
$this->assertSame($reponse->reveal(), $event->getResponse()); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|