StandardTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 56
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetName() 0 3 1
A testGetDescription() 0 4 1
A setUp() 0 8 1
A testRun() 0 18 1
A tearDown() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2025
6
 */
7
8
9
namespace Aimeos\Controller\Jobs\Product\Export;
10
11
12
class StandardTest extends \PHPUnit\Framework\TestCase
13
{
14
	private $object;
15
	private $context;
16
	private $aimeos;
17
18
19
	protected function setUp() : void
20
	{
21
		\Aimeos\MShop::cache( true );
22
23
		$this->context = \TestHelper::context();
24
		$this->aimeos = \TestHelper::getAimeos();
25
26
		$this->object = new \Aimeos\Controller\Jobs\Product\Export\Standard( $this->context, $this->aimeos );
27
	}
28
29
30
	protected function tearDown() : void
31
	{
32
		\Aimeos\MShop::cache( false );
33
		$this->object = null;
34
	}
35
36
37
	public function testGetName()
38
	{
39
		$this->assertEquals( 'Product export', $this->object->getName() );
40
	}
41
42
43
	public function testGetDescription()
44
	{
45
		$text = 'Exports all available products';
46
		$this->assertEquals( $text, $this->object->getDescription() );
47
	}
48
49
50
	public function testRun()
51
	{
52
		$this->context->config()->set( 'controller/jobs/product/export/filename', 'aimeos-products-%1$d.xml' );
53
54
		$this->object->run();
55
56
		$ds = DIRECTORY_SEPARATOR;
57
		$this->assertFileExists( 'tmp' . $ds . 'aimeos-products-1.xml' );
58
		$this->assertFileExists( 'tmp' . $ds . 'aimeos-products-2.xml' );
59
60
		$file1 = file_get_contents( 'tmp' . $ds . 'aimeos-products-1.xml' );
0 ignored issues
show
Unused Code introduced by
The assignment to $file1 is dead and can be removed.
Loading history...
61
		$file2 = file_get_contents( 'tmp' . $ds . 'aimeos-products-2.xml' );
62
63
		unlink( 'tmp' . $ds . 'aimeos-products-1.xml' );
64
		unlink( 'tmp' . $ds . 'aimeos-products-2.xml' );
65
66
		$this->assertStringContainsString( 'CNE', $file2 );
67
		$this->assertStringContainsString( 'U:BUNDLE', $file2 );
68
	}
69
}
70