StandardTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 22
c 3
b 0
f 0
dl 0
loc 54
rs 10
wmc 5

5 Methods

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