1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2020 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Session; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class Laravel5Test extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
private $mock; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
protected function setUp() : void |
19
|
|
|
{ |
20
|
|
|
if( interface_exists( '\\Illuminate\\Session\\Store' ) === false ) { |
21
|
|
|
$this->markTestSkipped( 'Class \\Illuminate\\Session\\Store not found' ); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
$this->mock = $this->getMockBuilder( '\\Illuminate\\Session\\Store' )->getMock(); |
25
|
|
|
$this->object = new \Aimeos\MW\Session\Laravel5( $this->mock ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
protected function tearDown() : void |
30
|
|
|
{ |
31
|
|
|
unset( $this->object ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testDel() |
36
|
|
|
{ |
37
|
|
|
$this->mock->expects( $this->once() )->method( 'forget' ) |
38
|
|
|
->with( $this->equalTo( 'test' ) )->will( $this->returnSelf() ); |
39
|
|
|
|
40
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $this->object->del( 'test' ) ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
|
44
|
|
|
public function testGet() |
45
|
|
|
{ |
46
|
|
|
$this->mock->expects( $this->once() )->method( 'get' ) |
47
|
|
|
->with( $this->equalTo( 'test' ) )->will( $this->returnValue( '123456789' ) ); |
48
|
|
|
|
49
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
|
53
|
|
|
public function testPull() |
54
|
|
|
{ |
55
|
|
|
$this->mock->expects( $this->once() )->method( 'pull' ) |
56
|
|
|
->with( $this->equalTo( 'test' ) )->will( $this->returnValue( '123456789' ) ); |
57
|
|
|
|
58
|
|
|
$this->assertEquals( '123456789', $this->object->pull( 'test' ) ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public function testRemove() |
63
|
|
|
{ |
64
|
|
|
$this->mock->expects( $this->once() )->method( 'forget' ) |
65
|
|
|
->with( $this->equalTo( ['test'] ) )->will( $this->returnSelf() ); |
66
|
|
|
|
67
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $this->object->remove( ['test'] ) ); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
|
71
|
|
|
public function testSet() |
72
|
|
|
{ |
73
|
|
|
$this->mock->expects( $this->once() )->method( 'put' ) |
74
|
|
|
->with( $this->equalTo( 'test' ), $this->equalTo( '123456789' ) ); |
75
|
|
|
|
76
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $this->object->set( 'test', '123456789' ) ); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|