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