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