Passed
Push — master ( 5788d1...3b28d2 )
by Aimeos
04:17
created

ChangelogTest::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018-2022
6
 */
7
8
9
namespace Aimeos\MShop\Common\Manager\Decorator;
10
11
12
class ChangelogTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $context;
15
	private $object;
16
	private $logger;
17
	private $mock;
18
19
20
	protected function setUp() : void
21
	{
22
		$this->context = \TestHelper::context();
23
24
		$this->logger = $this->getMockBuilder( '\Aimeos\Base\Logger\Errorlog' )
25
			->setConstructorArgs( [\Aimeos\Base\Logger\Iface::NOTICE] )
26
			->setMethods( ['notice'] )
27
			->getMock();
28
29
		$this->mock = $this->getMockBuilder( '\Aimeos\MShop\Product\Manager\Standard' )
30
			->setConstructorArgs( [$this->context] )
31
			->setMethods( ['delete', 'save'] )
32
			->getMock();
33
34
		$this->context->setLogger( $this->logger );
35
36
		$this->object = new \Aimeos\MShop\Common\Manager\Decorator\Changelog( $this->mock, $this->context );
37
	}
38
39
40
	protected function tearDown() : void
41
	{
42
		unset( $this->object, $this->mock, $this->context );
43
	}
44
45
46
	public function testDelete()
47
	{
48
		$item = $this->mock->find( 'U:TESTP' );
49
50
		$this->mock->expects( $this->once() )->method( 'delete' );
51
		$this->logger->expects( $this->once() )->method( 'notice' );
52
53
		$this->assertEquals( $this->object, $this->object->delete( $item ) );
54
	}
55
56
57
	public function testSave()
58
	{
59
		$this->context->config()->set( 'mshop/common/manager/maxdepth', 0 );
60
61
		$item = $this->mock->find( 'U:TESTP' );
62
63
		$this->mock->expects( $this->once() )->method( 'save' )->will( $this->returnArgument( 0 ) );
64
		$this->logger->expects( $this->once() )->method( 'notice' );
65
66
		$this->assertEquals( $item, $this->object->save( $item ) );
67
	}
68
}
69