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\FacebookBundle\Tests\Event; |
11
|
|
|
|
12
|
|
|
use Core23\FacebookBundle\Event\AuthSuccessEvent; |
13
|
|
|
use Core23\FacebookBundle\Session\SessionInterface; |
14
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
15
|
|
|
use PHPUnit\Framework\TestCase; |
16
|
|
|
use Prophecy\Prophecy\ObjectProphecy; |
17
|
|
|
use Symfony\Component\EventDispatcher\Event; |
18
|
|
|
use Symfony\Component\HttpFoundation\Response; |
19
|
|
|
|
20
|
|
|
class AuthSuccessEventTest extends TestCase |
21
|
|
|
{ |
22
|
|
|
public function testCreation(): void |
23
|
|
|
{ |
24
|
|
|
/** @var ObjectProphecy&SessionInterface $session */ |
|
|
|
|
25
|
|
|
$session = $this->prophesize(SessionInterface::class); |
26
|
|
|
|
27
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
28
|
|
|
|
29
|
|
|
$this->assertInstanceOf(Event::class, $event); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGetUsername(): void |
33
|
|
|
{ |
34
|
|
|
/** @var ObjectProphecy&SessionInterface $session */ |
|
|
|
|
35
|
|
|
$session = $this->prophesize(SessionInterface::class); |
36
|
|
|
$session->getName()->willReturn('MyUser'); |
37
|
|
|
|
38
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
39
|
|
|
|
40
|
|
|
$this->assertSame('MyUser', $event->getUsername()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public function testGetSession(): void |
44
|
|
|
{ |
45
|
|
|
/** @var ObjectProphecy&SessionInterface $session */ |
|
|
|
|
46
|
|
|
$session = $this->prophesize(SessionInterface::class); |
47
|
|
|
|
48
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
49
|
|
|
|
50
|
|
|
$this->assertSame($session->reveal(), $event->getSession()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testGetResponse(): void |
54
|
|
|
{ |
55
|
|
|
/** @var ObjectProphecy&SessionInterface $session */ |
|
|
|
|
56
|
|
|
$session = $this->prophesize(SessionInterface::class); |
57
|
|
|
|
58
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
59
|
|
|
|
60
|
|
|
$this->assertNull($event->getResponse()); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function testSetResponse(): void |
64
|
|
|
{ |
65
|
|
|
/** @var ObjectProphecy&SessionInterface $session */ |
|
|
|
|
66
|
|
|
$session = $this->prophesize(SessionInterface::class); |
67
|
|
|
|
68
|
|
|
/** @var MockObject&Response $session */ |
|
|
|
|
69
|
|
|
$reponse = $this->prophesize(Response::class); |
70
|
|
|
|
71
|
|
|
$event = new AuthSuccessEvent($session->reveal()); |
72
|
|
|
$event->setResponse($reponse->reveal()); |
73
|
|
|
|
74
|
|
|
$this->assertSame($reponse->reveal(), $event->getResponse()); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.