forked from jasny/session-middleware
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlashTraitTest.php
More file actions
52 lines (39 loc) · 1.38 KB
/
Copy pathFlashTraitTest.php
File metadata and controls
52 lines (39 loc) · 1.38 KB
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
<?php
declare(strict_types=1);
namespace Jasny\Session\Tests\Flash;
use Jasny\Session\Flash\FlashBag;
use Jasny\Session\Flash\FlashTrait;
use Jasny\Session\MockSession;
use PHPUnit\Framework\TestCase;
/**
* @covers \Jasny\Session\Flash\FlashTrait
*/
class FlashTraitTest extends TestCase
{
public function testFlashes()
{
$bag = $this->createMock(FlashBag::class);
$session = new MockSession([], $bag);
$sessionBag = $this->createMock(FlashBag::class);
$bag->expects($this->once())->method('withSession')
->with($this->identicalTo($session))
->willReturn($sessionBag);
$this->assertSame($sessionBag, $session->flashes());
$sessionBag->expects($this->once())->method('withSession')
->with($this->identicalTo($session))
->willReturnSelf();
$this->assertSame($sessionBag, $session->flashes());
}
public function testFlash()
{
$bag = $this->createMock(FlashBag::class);
$session = new MockSession([], $bag);
$bag->expects($this->any())->method('withSession')
->with($this->identicalTo($session))
->willReturnSelf();
$bag->expects($this->once())->method('add')
->with('notice', 'Foo bar', 'text/plain+abc')
->willReturnSelf();
$session->flash('notice', 'Foo bar', 'text/plain+abc');
}
}