OrderEmailNotifierTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 46
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 8 1
A testConfirmation() 0 4 1
A testReceipt() 0 4 1
A testAdminNotification() 0 4 1
A testStatusUpdate() 0 4 1
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