-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathSubscriptionTrackingTest.php
More file actions
97 lines (77 loc) · 3 KB
/
Copy pathSubscriptionTrackingTest.php
File metadata and controls
97 lines (77 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* This file tests SubscriptionTracking.
*/
namespace SendGrid\Tests\Unit;
use PHPUnit\Framework\TestCase;
use SendGrid\Mail\SubscriptionTracking;
use SendGrid\Mail\TypeException;
/**
* This class tests SubscriptionTracking.
*
* @package SendGrid\Tests
*/
class SubscriptionTrackingTest extends TestCase
{
public function testConstructor()
{
$subscriptionTracking = new SubscriptionTracking(true, 'text', '<h1>html</h1>', 'sub_tag');
$this->assertInstanceOf(SubscriptionTracking::class, $subscriptionTracking);
$this->assertTrue($subscriptionTracking->getEnable());
$this->assertSame('text', $subscriptionTracking->getText());
$this->assertSame('<h1>html</h1>', $subscriptionTracking->getHtml());
$this->assertSame('sub_tag', $subscriptionTracking->getSubstitutionTag());
}
public function testSetEnable()
{
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setEnable(true);
$this->assertTrue($subscriptionTracking->getEnable());
}
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setEnable('invalid_bool_type');
}
public function testSetText()
{
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setText('text');
$this->assertSame('text', $subscriptionTracking->getText());
}
public function testSetTextOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$text" must be a string/');
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setText(true);
}
public function testSetHtml()
{
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setHtml('<h1>I am html text</h1>');
$this->assertSame('<h1>I am html text</h1>', $subscriptionTracking->getHtml());
}
public function testSetHtmlOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$html" must be a string/');
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setHtml(true);
}
public function testSetSubstitutionTag()
{
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setSubstitutionTag('sub_tag');
$this->assertSame('sub_tag', $subscriptionTracking->getSubstitutionTag());
}
public function testSetSubstitutionTagOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$substitution_tag" must be a string/');
$subscriptionTracking = new SubscriptionTracking();
$subscriptionTracking->setSubstitutionTag(true);
}
}