StandardTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 22
c 0
b 0
f 0
dl 0
loc 53
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetName() 0 3 1
A setUp() 0 8 1
A testGetDescription() 0 4 1
A tearDown() 0 4 1
A testRun() 0 15 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2014
6
 * @copyright Aimeos (aimeos.org), 2015-2025
7
 */
8
9
10
namespace Aimeos\Controller\Jobs\Product\Bought;
11
12
13
class StandardTest extends \PHPUnit\Framework\TestCase
14
{
15
	private $object;
16
	private $context;
17
	private $aimeos;
18
19
20
	protected function setUp() : void
21
	{
22
		\Aimeos\MShop::cache( true );
23
24
		$this->context = \TestHelper::context();
25
		$this->aimeos = \TestHelper::getAimeos();
26
27
		$this->object = new \Aimeos\Controller\Jobs\Product\Bought\Standard( $this->context, $this->aimeos );
28
	}
29
30
31
	protected function tearDown() : void
32
	{
33
		\Aimeos\MShop::cache( false );
34
		unset( $this->object );
35
	}
36
37
38
	public function testGetName()
39
	{
40
		$this->assertEquals( 'Products bought together', $this->object->getName() );
41
	}
42
43
44
	public function testGetDescription()
45
	{
46
		$text = 'Creates bought together product suggestions';
47
		$this->assertEquals( $text, $this->object->getDescription() );
48
	}
49
50
51
	public function testRun()
52
	{
53
		$stub = $this->getMockBuilder( '\\Aimeos\\MShop\\Product\\Manager\\Standard' )
54
			->setConstructorArgs( [$this->context] )
55
			->onlyMethods( ['save', 'type'] )
56
			->getMock();
57
58
		$stub->method( 'type' )->willReturn( ['product'] );
59
		$stub->expects( $this->atLeastOnce() )->method( 'save' );
60
61
		$stub = new \Aimeos\MShop\Common\Manager\Decorator\Lists( $stub, $this->context );
62
63
		\Aimeos\MShop::inject( '\\Aimeos\\MShop\\Product\\Manager\\Standard', $stub );
64
65
		$this->object->run();
66
	}
67
}
68