1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2020 |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
namespace Aimeos\Client\Html\Email\Payment\Pdf; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
13
|
|
|
{ |
14
|
|
|
private static $orderItem; |
15
|
|
|
private static $orderBaseItem; |
16
|
|
|
private $object; |
17
|
|
|
private $context; |
18
|
|
|
private $emailMock; |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
public static function setUpBeforeClass() : void |
22
|
|
|
{ |
23
|
|
|
$manager = \Aimeos\MShop\Order\Manager\Factory::create( \TestHelperHtml::getContext() ); |
24
|
|
|
$orderBaseManager = $manager->getSubManager( 'base' ); |
25
|
|
|
|
26
|
|
|
$search = $manager->createSearch(); |
27
|
|
|
$search->setConditions( $search->compare( '==', 'order.datepayment', '2008-02-15 12:34:56' ) ); |
28
|
|
|
|
29
|
|
|
if( ( self::$orderItem = $manager->searchItems( $search )->first() ) === null ) { |
30
|
|
|
throw new \RuntimeException( 'No order found' ); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
self::$orderBaseItem = $orderBaseManager->load( self::$orderItem->getBaseId() ); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
protected function setUp() : void |
38
|
|
|
{ |
39
|
|
|
$this->context = \TestHelperHtml::getContext(); |
40
|
|
|
$this->emailMock = $this->getMockBuilder( '\\Aimeos\\MW\\Mail\\Message\\None' )->getMock(); |
41
|
|
|
|
42
|
|
|
$view = \TestHelperHtml::getView( 'unittest', $this->context->getConfig() ); |
43
|
|
|
$view->extOrderItem = self::$orderItem; |
44
|
|
|
$view->extOrderBaseItem = self::$orderBaseItem; |
45
|
|
|
$view->addHelper( 'mail', new \Aimeos\MW\View\Helper\Mail\Standard( $view, $this->emailMock ) ); |
46
|
|
|
|
47
|
|
|
$this->object = new \Aimeos\Client\Html\Email\Payment\Pdf\Standard( $this->context ); |
48
|
|
|
$this->object->setView( $view ); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
protected function tearDown() : void |
53
|
|
|
{ |
54
|
|
|
unset( $this->object ); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
|
58
|
|
|
public function testGetBody() |
59
|
|
|
{ |
60
|
|
|
$this->emailMock->expects( $this->once() )->method( 'addAttachment' ); |
61
|
|
|
|
62
|
|
|
$this->object->setView( $this->object->addData( $this->object->getView() ) ); |
63
|
|
|
$this->object->getBody(); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
|
67
|
|
|
public function testGetSubClientInvalid() |
68
|
|
|
{ |
69
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
70
|
|
|
$this->object->getSubClient( 'invalid', 'invalid' ); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
public function testGetSubClientInvalidName() |
75
|
|
|
{ |
76
|
|
|
$this->expectException( '\\Aimeos\\Client\\Html\\Exception' ); |
77
|
|
|
$this->object->getSubClient( '$$$', '$$$' ); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|