1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2014-2022 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Base\Session; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class Typo3Test extends \PHPUnit\Framework\TestCase |
14
|
|
|
{ |
15
|
|
|
private $object; |
16
|
|
|
private $mock; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
if( !class_exists( '\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication' ) ) { |
22
|
|
|
$this->markTestSkipped( 'TYPO3 AbstractUserAuthentication not available' ); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->mock = $this->getMockBuilder( '\TYPO3\CMS\Core\Authentication\AbstractUserAuthentication' ) |
26
|
|
|
->setMethods( ['getSessionData', 'setAndSaveSessionData'] ) |
27
|
|
|
->disableOriginalConstructor() |
28
|
|
|
->getMockForAbstractClass(); |
29
|
|
|
|
30
|
|
|
$this->object = new \Aimeos\Base\Session\Typo3( $this->mock ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
protected function tearDown() : void |
35
|
|
|
{ |
36
|
|
|
unset( $this->object, $this->mock ); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
public function testDel() |
41
|
|
|
{ |
42
|
|
|
$this->mock->expects( $this->once() )->method( 'setAndSaveSessionData' ); |
43
|
|
|
|
44
|
|
|
$result = $this->object->del( 'test' ); |
45
|
|
|
|
46
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function testGet() |
51
|
|
|
{ |
52
|
|
|
$this->mock->expects( $this->once() )->method( 'getSessionData' )->will( $this->returnValue( '123456789' ) ); |
53
|
|
|
|
54
|
|
|
$this->assertEquals( '123456789', $this->object->get( 'test' ) ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
public function testPull() |
59
|
|
|
{ |
60
|
|
|
$this->mock->expects( $this->once() )->method( 'setAndSaveSessionData' ); |
61
|
|
|
$this->mock->expects( $this->once() )->method( 'getSessionData' )->will( $this->returnValue( '123456789' ) ); |
62
|
|
|
|
63
|
|
|
$this->assertEquals( '123456789', $this->object->pull( 'test' ) ); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
public function testRemove() |
68
|
|
|
{ |
69
|
|
|
$this->mock->expects( $this->once() )->method( 'setAndSaveSessionData' ); |
70
|
|
|
|
71
|
|
|
$result = $this->object->remove( ['test'] ); |
72
|
|
|
|
73
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
public function testSet() |
78
|
|
|
{ |
79
|
|
|
$this->mock->expects( $this->once() )->method( 'setAndSaveSessionData' ); |
80
|
|
|
|
81
|
|
|
$result = $this->object->set( 'test', '234' ); |
82
|
|
|
|
83
|
|
|
$this->assertInstanceOf( \Aimeos\Base\Session\Iface::class, $result ); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|