|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverShop\Tests\Checkout; |
|
4
|
|
|
|
|
5
|
|
|
use SilverShop\Checkout\OrderEmailNotifier; |
|
6
|
|
|
use SilverShop\Extension\ShopConfigExtension; |
|
7
|
|
|
use SilverShop\Model\Order; |
|
8
|
|
|
use SilverStripe\Control\Email\Email; |
|
9
|
|
|
use SilverStripe\Core\Config\Config; |
|
10
|
|
|
use SilverStripe\Dev\SapphireTest; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Test OrderEmailNotifier |
|
14
|
|
|
*/ |
|
15
|
|
|
class OrderEmailNotifierTest extends SapphireTest |
|
16
|
|
|
{ |
|
17
|
|
|
protected static $fixture_file = __DIR__ . '/../Fixtures/shop.yml'; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var Order |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $order; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var OrderEmailNotifier |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $notifier; |
|
28
|
|
|
|
|
29
|
|
|
public function setUp(): void |
|
30
|
|
|
{ |
|
31
|
|
|
parent::setUp(); |
|
32
|
|
|
Config::modify()->set(Email::class, 'admin_email', '[email protected]'); |
|
33
|
|
|
// clear any setting that might have been made via shop-config |
|
34
|
|
|
Config::modify()->remove(ShopConfigExtension::class, 'email_from'); |
|
35
|
|
|
$this->order = $this->objFromFixture(Order::class, 'paid'); |
|
36
|
|
|
$this->notifier = OrderEmailNotifier::create($this->order); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testAdminNotification() |
|
40
|
|
|
{ |
|
41
|
|
|
$this->notifier->sendAdminNotification(); |
|
42
|
|
|
$this->assertEmailSent('[email protected]', '[email protected]'); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testConfirmation() |
|
46
|
|
|
{ |
|
47
|
|
|
$this->notifier->sendConfirmation(); |
|
48
|
|
|
$this->assertEmailSent('[email protected]', '[email protected]'); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testReceipt() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->notifier->sendReceipt(); |
|
54
|
|
|
$this->assertEmailSent('[email protected]', '[email protected]'); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function testStatusUpdate() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->notifier->sendStatusChange('test subject'); |
|
60
|
|
|
$this->assertEmailSent('[email protected]', '[email protected]', 'Silvershop - test subject'); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|