Passed
Push — master ( 781785...834e6a )
by Aimeos
05:51
created

Laravel5Test::testRemove()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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