1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2020 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Session; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class Symfony2Test extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private $object; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
protected function setUp() : void |
18
|
|
|
{ |
19
|
|
|
if( class_exists( 'Symfony\Component\HttpFoundation\Session\Session' ) === false ) { |
20
|
|
|
$this->markTestSkipped( 'Class Symfony\Component\HttpFoundation\Session\Session not found' ); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
$storage = new \Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage(); |
24
|
|
|
$session = new \Symfony\Component\HttpFoundation\Session\Session( $storage ); |
25
|
|
|
$this->object = new \Aimeos\MW\Session\Symfony2( $session ); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
protected function tearDown() : void |
30
|
|
|
{ |
31
|
|
|
unset( $this->object ); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
public function testDel() |
36
|
|
|
{ |
37
|
|
|
$this->object->set( 'test', '123456789' ); |
38
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
39
|
|
|
|
40
|
|
|
$result = $this->object->del( 'test' ); |
41
|
|
|
|
42
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $result ); |
43
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
public function testGet() |
48
|
|
|
{ |
49
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
50
|
|
|
|
51
|
|
|
$this->object->set( 'test', '123456789' ); |
52
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
53
|
|
|
|
54
|
|
|
$this->object->set( 'test', ['123456789'] ); |
55
|
|
|
$this->assertEquals( ['123456789'], $this->object->get( 'test' ) ); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
|
59
|
|
|
public function testPull() |
60
|
|
|
{ |
61
|
|
|
$this->object->set( 'test', '123456789' ); |
62
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
63
|
|
|
|
64
|
|
|
$this->assertEquals( '123456789', $this->object->pull( 'test' ) ); |
65
|
|
|
$this->assertEquals( null, $this->object->pull( 'test' ) ); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
public function testRemove() |
70
|
|
|
{ |
71
|
|
|
$this->object->set( 'test', '123456789' ); |
72
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
73
|
|
|
|
74
|
|
|
$result = $this->object->remove( ['test'] ); |
75
|
|
|
|
76
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $result ); |
77
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
public function testSet() |
82
|
|
|
{ |
83
|
|
|
$this->object->set( 'test', null ); |
84
|
|
|
$this->assertEquals( null, $this->object->get( 'test' ) ); |
85
|
|
|
|
86
|
|
|
$result = $this->object->set( 'test', '234' ); |
87
|
|
|
|
88
|
|
|
$this->assertInstanceOf( \Aimeos\MW\Session\Iface::class, $result ); |
89
|
|
|
$this->assertEquals( '234', $this->object->get( 'test' ) ); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|