Completed
Push — master ( 2ada66...f3cee7 )
by Aimeos
06:21
created

StandardTest::testRun()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 34
rs 8.8571
cc 1
eloc 20
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
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()
18
	{
19
		$context = \TestHelperJobs::getContext();
20
		$aimeos = \TestHelperJobs::getAimeos();
21
22
		$this->object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
23
	}
24
25
26
	protected function tearDown()
27
	{
28
		$this->object = null;
29
	}
30
31
32
	public function testGetName()
33
	{
34
		$this->assertEquals( 'Rescale images', $this->object->getName() );
35
	}
36
37
38
	public function testGetDescription()
39
	{
40
		$text = 'Rescales images to the new sizes';
41
		$this->assertEquals( $text, $this->object->getDescription() );
42
	}
43
44
45
	public function testRun()
46
	{
47
		$context = \TestHelperJobs::getContext();
48
		$aimeos = \TestHelperJobs::getAimeos();
49
50
51
		$name = 'ControllerJobsMediaScaleStandardRun';
52
		$context->getConfig()->set( 'mshop/media/manager/name', $name );
53
		$context->getConfig()->set( 'controller/common/media/name', $name );
54
55
56
		$managerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Media\\Manager\\Standard' )
57
			->setMethods( array( 'saveItem' ) )
58
			->setConstructorArgs( array( $context ) )
59
			->getMock();
60
61
		\Aimeos\MShop\Media\Manager\Factory::injectManager( '\\Aimeos\\MShop\\Media\\Manager\\' . $name, $managerStub );
62
63
		$managerStub->expects( $this->atLeast( 1 ) )->method( 'saveItem' );
64
65
66
		$cntlStub = $this->getMockBuilder( '\\Aimeos\\Controller\\Common\\Media\\Standard' )
67
			->setMethods( array( 'scale' ) )
68
			->setConstructorArgs( array( $context ) )
69
			->getMock();
70
71
		\Aimeos\Controller\Common\Media\Factory::injectController( '\\Aimeos\\Controller\\Common\\Media\\' . $name, $cntlStub );
72
73
		$cntlStub->expects( $this->atLeast( 1 ) )->method( 'scale' );
74
75
76
		$object = new \Aimeos\Controller\Jobs\Media\Scale\Standard( $context, $aimeos );
77
		$object->run();
78
	}
79
}
80