-
Notifications
You must be signed in to change notification settings - Fork 610
Expand file tree
/
Copy pathOpenTrackingTest.php
More file actions
60 lines (48 loc) · 1.55 KB
/
Copy pathOpenTrackingTest.php
File metadata and controls
60 lines (48 loc) · 1.55 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
<?php
/**
* This file tests OpenTracking.
*/
namespace SendGrid\Tests\Unit;
use PHPUnit\Framework\TestCase;
use SendGrid\Mail\OpenTracking;
use SendGrid\Mail\TypeException;
/**
* This class tests OpenTracking.
*
* @package SendGrid\Tests
*/
class OpenTrackingTest extends TestCase
{
public function testConstructor()
{
$openTracking = new OpenTracking(true, 'substitution_tag');
$this->assertTrue($openTracking->getEnable());
$this->assertSame('substitution_tag', $openTracking->getSubstitutionTag());
}
public function testSetEnable()
{
$openTracking = new OpenTracking();
$openTracking->setEnable(true);
$this->assertTrue($openTracking->getEnable());
}
public function testSetEnableOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$enable" must be a boolean/');
$openTracking = new OpenTracking();
$openTracking->setEnable('invalid_bool');
}
public function testSetSubstitutionTag()
{
$openTracking = new OpenTracking();
$openTracking->setSubstitutionTag('substitution_tag');
$this->assertSame('substitution_tag', $openTracking->getSubstitutionTag());
}
public function testSetSubstitutionTagOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$substitution_tag" must be a string/');
$openTracking = new OpenTracking();
$openTracking->setSubstitutionTag(123);
}
}