-
Notifications
You must be signed in to change notification settings - Fork 627
/
Copy pathSectionTest.php
61 lines (49 loc) · 1.38 KB
/
SectionTest.php
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
<?php
/**
* This file tests Section.
*/
namespace SendGrid\Tests\Unit;
use PHPUnit\Framework\TestCase;
use SendGrid\Mail\Section;
use SendGrid\Mail\TypeException;
/**
* This class tests Section.
*
* @package SendGrid\Tests
*/
class SectionTest extends TestCase
{
public function testConstructor()
{
$section = new Section('key', 'value');
$this->assertInstanceOf(Section::class, $section);
$this->assertSame('key', $section->getKey());
$this->assertSame('value', $section->getValue());
}
public function testSetKey()
{
$section = new Section();
$section->setKey('key');
$this->assertSame('key', $section->getKey());
}
public function testSetKeyOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$key" must be a string/');
$section = new Section();
$section->setKey(true);
}
public function testSetValue()
{
$section = new Section();
$section->setValue('value');
$this->assertSame('value', $section->getValue());
}
public function testSetValueOnInvalidType()
{
$this->expectException(TypeException::class);
$this->expectExceptionMessageMatches('/"\$value" must be a string/');
$section = new Section();
$section->setValue(true);
}
}