|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Jobs\Product\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() : 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\Sitemap\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 site map', $this->object->getName() ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
public function testGetDescription() |
|
44
|
|
|
{ |
|
45
|
|
|
$text = 'Creates a product site map for search engines'; |
|
46
|
|
|
$this->assertEquals( $text, $this->object->getDescription() ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
public function testRun() |
|
51
|
|
|
{ |
|
52
|
|
|
$this->context->config()->set( 'controller/jobs/product/export/sitemap/max-items', 5 ); |
|
53
|
|
|
$this->context->config()->set( 'resource/fs/baseurl', 'https://www.yourshop.com/' ); |
|
54
|
|
|
|
|
55
|
|
|
$this->object->run(); |
|
56
|
|
|
|
|
57
|
|
|
$ds = DIRECTORY_SEPARATOR; |
|
58
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-1.xml' ); |
|
59
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-2.xml' ); |
|
60
|
|
|
$this->assertFileExists( 'tmp' . $ds . 'aimeos-sitemap-index.xml' ); |
|
61
|
|
|
|
|
62
|
|
|
$file1 = file_get_contents( 'tmp' . $ds . 'aimeos-sitemap-1.xml' ); |
|
|
|
|
|
|
63
|
|
|
$file2 = file_get_contents( 'tmp' . $ds . 'aimeos-sitemap-2.xml' ); |
|
64
|
|
|
$index = file_get_contents( 'tmp' . $ds . 'aimeos-sitemap-index.xml' ); |
|
65
|
|
|
|
|
66
|
|
|
unlink( 'tmp' . $ds . 'aimeos-sitemap-1.xml' ); |
|
67
|
|
|
unlink( 'tmp' . $ds . 'aimeos-sitemap-2.xml' ); |
|
68
|
|
|
unlink( 'tmp' . $ds . 'aimeos-sitemap-index.xml' ); |
|
69
|
|
|
|
|
70
|
|
|
$this->assertStringContainsString( 'cafe_noire_expresso', $file2 ); |
|
71
|
|
|
$this->assertStringContainsString( 'unittest-bundle', $file2 ); |
|
72
|
|
|
|
|
73
|
|
|
$this->assertStringContainsString( 'https://www.yourshop.com/aimeos-sitemap-1.xml', $index ); |
|
74
|
|
|
$this->assertStringContainsString( 'https://www.yourshop.com/aimeos-sitemap-2.xml', $index ); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
public function testRunEmptyBaseurl() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->context->config()->set( 'resource/fs/baseurl', '' ); |
|
81
|
|
|
|
|
82
|
|
|
$this->expectException( '\\Aimeos\\Controller\\Jobs\\Exception' ); |
|
83
|
|
|
$this->object->run(); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|