1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2014 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2025 |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
namespace Aimeos\Controller\Jobs\Order\Cleanup\Unpaid; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
class StandardTest |
14
|
|
|
extends \PHPUnit\Framework\TestCase |
15
|
|
|
{ |
16
|
|
|
private $object; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
protected function setUp() : void |
20
|
|
|
{ |
21
|
|
|
\Aimeos\MShop::cache( true ); |
22
|
|
|
|
23
|
|
|
$context = \TestHelper::context(); |
24
|
|
|
$aimeos = \TestHelper::getAimeos(); |
25
|
|
|
|
26
|
|
|
$this->object = new \Aimeos\Controller\Jobs\Order\Cleanup\Unpaid\Standard( $context, $aimeos ); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
protected function tearDown() : void |
31
|
|
|
{ |
32
|
|
|
\Aimeos\MShop::cache( false ); |
33
|
|
|
unset( $this->object ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
public function testGetName() |
38
|
|
|
{ |
39
|
|
|
$this->assertEquals( 'Removes unpaid orders', $this->object->getName() ); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
public function testGetDescription() |
44
|
|
|
{ |
45
|
|
|
$text = 'Deletes unpaid orders to keep the database clean'; |
46
|
|
|
$this->assertEquals( $text, $this->object->getDescription() ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
public function testRun() |
51
|
|
|
{ |
52
|
|
|
$context = \TestHelper::context(); |
53
|
|
|
$aimeos = \TestHelper::getAimeos(); |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
$orderManagerStub = $this->getMockBuilder( '\\Aimeos\\MShop\\Order\\Manager\\Standard' ) |
57
|
|
|
->onlyMethods( ['iterate', 'delete', 'unblock'] ) |
58
|
|
|
->setConstructorArgs( array( $context ) ) |
59
|
|
|
->getMock(); |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
\Aimeos\MShop::inject( '\\Aimeos\\MShop\\Order\\Manager\\Standard', $orderManagerStub ); |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
$orderItem = $orderManagerStub->create()->setId( 2 ); |
66
|
|
|
|
67
|
|
|
$orderManagerStub->expects( $this->exactly( 2 ) )->method( 'iterate' ) |
68
|
|
|
->willReturn( map( [$orderItem->getId() => $orderItem] ), null ); |
69
|
|
|
|
70
|
|
|
$orderManagerStub->expects( $this->once() )->method( 'delete' ); |
71
|
|
|
|
72
|
|
|
$orderManagerStub->expects( $this->once() )->method( 'unblock' ); |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
$object = new \Aimeos\Controller\Jobs\Order\Cleanup\Unpaid\Standard( $context, $aimeos ); |
76
|
|
|
$object->run(); |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|