StandardTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2015-2026
7
 */
8
9
10
namespace Aimeos\Controller\Jobs\Index\Rebuild;
11
12
13
class StandardTest extends \PHPUnit\Framework\TestCase
14
{
15
	private $object;
16
17
18
	protected function setUp() : void
19
	{
20
		\Aimeos\MShop::cache( true );
21
22
		$context = \TestHelper::context();
23
		$aimeos = \TestHelper::getAimeos();
24
25
		$this->object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard( $context, $aimeos );
26
	}
27
28
29
	protected function tearDown() : void
30
	{
31
		\Aimeos\MShop::cache( false );
32
		unset( $this->object );
33
	}
34
35
36
	public function testGetName()
37
	{
38
		$this->assertEquals( 'Index rebuild', $this->object->getName() );
39
	}
40
41
42
	public function testGetDescription()
43
	{
44
		$text = 'Rebuilds the index for searching products';
45
		$this->assertEquals( $text, $this->object->getDescription() );
46
	}
47
48
49
	public function testRun()
50
	{
51
		$context = \TestHelper::context();
52
		$aimeos = \TestHelper::getAimeos();
53
54
		$indexManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Index\\Manager\\Standard' )
55
			->onlyMethods( array( 'rebuild', 'cleanup' ) )
56
			->setConstructorArgs( array( $context ) )
57
			->getMock();
58
59
		\Aimeos\MShop::inject( '\\Aimeos\\MShop\\Index\\Manager\\Standard', $indexManagerStub );
60
61
		$indexManagerStub->expects( $this->once() )->method( 'rebuild' )->willReturnSelf();
62
		$indexManagerStub->expects( $this->once() )->method( 'cleanup' )->willReturnSelf();
63
64
		$object = new \Aimeos\Controller\Jobs\Index\Rebuild\Standard( $context, $aimeos );
65
		$object->run();
66
	}
67
}
68