forked from lesstif/php-JiraCloud-RESTAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSerializeTest.php
More file actions
53 lines (41 loc) · 1.67 KB
/
Copy pathSerializeTest.php
File metadata and controls
53 lines (41 loc) · 1.67 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
<?php
namespace JiraCloud\Test;
use PHPUnit\Framework\TestCase;
use JiraCloud\Dumper;
use JiraCloud\Issue\Reporter;
class SerializeTest extends TestCase
{
/**
* @see https://github.com/lesstif/php-jira-rest-client/issues/18
*/
public function testDefaultAssignee()
{
$r = new Reporter();
$r->name = '-1';
$r->emailAddress = 'user@example.com';
$r->avatarUrls = '';
$d = $r->jsonSerialize();
// passing a name value of '' then serialized array has 'name' key and empty value.
// $this->assertEquals(true, array_key_exists('name', $d), 'Can\'t found "name" key.');
$this->assertEquals(false, array_key_exists('avatarUrls', $d));
}
public function testSerialize()
{
$r = new Reporter();
$r->name = 'KwangSeob Jeong';
$r->emailAddress = 'user@example.com';
$r->avatarUrls = 'http://my.avatar.com/avatarUrls';
$r->displayName = 'lesstif';
$d = $r->toArray(['name', 'emailAddress'], $excludeMode = true);
Dumper::dump($d);
// serialized array have not 'name' and 'emailAddress' keys.
$this->assertEquals(false, array_key_exists('name', $d), '"name" key is exists!.');
$this->assertEquals(false, array_key_exists('emailAddress', $d));
$d = $r->toArray(['name', 'emailAddress'], $excludeMode = false);
// serialized array must have only 'name' and 'emailAddress' keys.
$this->assertEquals(true, array_key_exists('name', $d), '"name" key is not exists!.');
$this->assertEquals(true, array_key_exists('emailAddress', $d));
$this->assertEquals(2, count($d));
Dumper::dump($d);
}
}