|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2018 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Jobs\Catalog\Export\Sitemap; |
|
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() |
|
20
|
|
|
{ |
|
21
|
|
|
\Aimeos\MShop\Factory::setCache( true ); |
|
22
|
|
|
|
|
23
|
|
|
$this->context = \TestHelperJobs::getContext(); |
|
24
|
|
|
$this->aimeos = \TestHelperJobs::getAimeos(); |
|
25
|
|
|
|
|
26
|
|
|
$this->object = new \Aimeos\Controller\Jobs\Catalog\Export\Sitemap\Standard( $this->context, $this->aimeos ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
protected function tearDown() |
|
31
|
|
|
{ |
|
32
|
|
|
\Aimeos\MShop\Factory::setCache( false ); |
|
33
|
|
|
\Aimeos\MShop\Factory::clear(); |
|
34
|
|
|
|
|
35
|
|
|
$this->object = null; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
public function testGetName() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->assertEquals( 'Catalog site map', $this->object->getName() ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
public function testGetDescription() |
|
46
|
|
|
{ |
|
47
|
|
|
$text = 'Creates a catalog site map for search engines'; |
|
48
|
|
|
$this->assertEquals( $text, $this->object->getDescription() ); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
public function testRun() |
|
53
|
|
|
{ |
|
54
|
|
|
$this->context->getConfig()->set( 'controller/jobs/catalog/export/sitemap/max-items', 5 ); |
|
55
|
|
|
|
|
56
|
|
|
$this->object->run(); |
|
57
|
|
|
|
|
58
|
|
|
$ds = DIRECTORY_SEPARATOR; |
|
59
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-catalog-sitemap-1.xml.gz' ); |
|
60
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-catalog-sitemap-2.xml.gz' ); |
|
61
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-catalog-sitemap-index.xml.gz' ); |
|
62
|
|
|
|
|
63
|
|
|
$file1 = gzread( gzopen( 'tmp' . $ds . 'aimeos-catalog-sitemap-1.xml.gz', 'rb' ), 0x1000 ); |
|
|
|
|
|
|
64
|
|
|
$file2 = gzread( gzopen( 'tmp' . $ds . 'aimeos-catalog-sitemap-2.xml.gz', 'rb' ), 0x1000 ); |
|
65
|
|
|
$index = gzread( gzopen( 'tmp' . $ds . 'aimeos-catalog-sitemap-index.xml.gz', 'rb' ), 0x1000 ); |
|
66
|
|
|
|
|
67
|
|
|
unlink( 'tmp' . $ds . 'aimeos-catalog-sitemap-1.xml.gz' ); |
|
68
|
|
|
unlink( 'tmp' . $ds . 'aimeos-catalog-sitemap-2.xml.gz' ); |
|
69
|
|
|
unlink( 'tmp' . $ds . 'aimeos-catalog-sitemap-index.xml.gz' ); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertContains( 'Kaffee', $file2 ); |
|
72
|
|
|
$this->assertContains( 'Tee', $file2 ); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertContains( 'aimeos-catalog-sitemap-1.xml.gz', $index ); |
|
75
|
|
|
$this->assertContains( 'aimeos-catalog-sitemap-2.xml.gz', $index ); |
|
76
|
|
|
} |
|
77
|
|
|
} |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.