1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://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 PHPTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() : void |
18
|
|
|
{ |
19
|
|
|
$this->object = new \Aimeos\Base\Session\PHP(); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
|
23
|
|
|
protected function tearDown() : void |
24
|
|
|
{ |
25
|
|
|
unset( $this->object ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
public function testApply() |
30
|
|
|
{ |
31
|
|
|
$result = $this->object->apply( ['test' => '123456789', 'test2' => '987654321'] ); |
32
|
|
|
|
33
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
34
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
35
|
|
|
$this->assertEquals( '987654321', $this->object->get( 'test2' ) ); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
public function testDel() |
40
|
|
|
{ |
41
|
|
|
$this->object->set( 'test', '123456789' ); |
42
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
43
|
|
|
|
44
|
|
|
$result = $this->object->del( 'test' ); |
45
|
|
|
|
46
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
47
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function testGet() |
52
|
|
|
{ |
53
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
54
|
|
|
|
55
|
|
|
$this->object->set( 'test', '123456789' ); |
56
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
57
|
|
|
|
58
|
|
|
$this->object->set( 'test', ['123456789'] ); |
59
|
|
|
$this->assertEquals( ['123456789'], $this->object->get( 'test' ) ); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
|
63
|
|
|
public function testPull() |
64
|
|
|
{ |
65
|
|
|
$this->object->set( 'test', '123456789' ); |
66
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
67
|
|
|
|
68
|
|
|
$this->assertEquals( '123456789', $this->object->pull( 'test' ) ); |
69
|
|
|
$this->assertEquals( null, $this->object->pull( 'test' ) ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
public function testRemove() |
74
|
|
|
{ |
75
|
|
|
$this->object->set( 'test', '123456789' ); |
76
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
77
|
|
|
|
78
|
|
|
$result = $this->object->remove( ['test'] ); |
79
|
|
|
|
80
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
81
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
public function testSet() |
86
|
|
|
{ |
87
|
|
|
$this->object->set( 'test', null ); |
88
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
89
|
|
|
|
90
|
|
|
$result = $this->object->set( 'test', '234' ); |
91
|
|
|
|
92
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
93
|
|
|
$this->assertEquals( '234', $this->object->get( 'test' ) ); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|