|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the OverblogGraphQLBundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Overblog <http://github.com/overblog/> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Overblog\GraphQLBundle\Tests\Relay\Node; |
|
13
|
|
|
|
|
14
|
|
|
use Overblog\GraphQLBundle\Relay\Node\GlobalId; |
|
15
|
|
|
|
|
16
|
|
|
class GlobalIdTest extends \PHPUnit_Framework_TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
public function testToGlobalId() |
|
19
|
|
|
{ |
|
20
|
|
|
$globalId = GlobalId::toGlobalId('User', 15); |
|
21
|
|
|
|
|
22
|
|
|
$this->assertEquals(sprintf('User%s15', GlobalId::SEPARATOR), base64_decode($globalId)); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function testToGlobalIdWithTypeEmpty() |
|
26
|
|
|
{ |
|
27
|
|
|
$globalId = GlobalId::toGlobalId('', 15); |
|
28
|
|
|
|
|
29
|
|
|
$this->assertEquals(sprintf('%s15', GlobalId::SEPARATOR), base64_decode($globalId)); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function testToGlobalIdWithIdEmpty() |
|
33
|
|
|
{ |
|
34
|
|
|
$globalId = GlobalId::toGlobalId('User', null); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertEquals(sprintf('User%s', GlobalId::SEPARATOR), base64_decode($globalId)); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
public function testToGlobalIdWithTypeAndIdEmpty() |
|
40
|
|
|
{ |
|
41
|
|
|
$globalId = GlobalId::toGlobalId(null, null); |
|
42
|
|
|
|
|
43
|
|
|
$this->assertEquals(sprintf('%s', GlobalId::SEPARATOR), base64_decode($globalId)); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function testFromGlobalId() |
|
47
|
|
|
{ |
|
48
|
|
|
$params = GlobalId::fromGlobalId('VXNlcjoxNQ=='); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertEquals(['type' => 'User', 'id' => 15], $params); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testFromGlobalIdWithTypeEmpty() |
|
54
|
|
|
{ |
|
55
|
|
|
$params = GlobalId::fromGlobalId('OjE1='); |
|
56
|
|
|
|
|
57
|
|
|
$this->assertEquals(['type' => null, 'id' => 15], $params); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testFromGlobalIdWithIdEmpty() |
|
61
|
|
|
{ |
|
62
|
|
|
$params = GlobalId::fromGlobalId('VXNlcjo='); |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals(['type' => 'User', 'id' => null], $params); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function testFromGlobalIdWithTypeAndIdEmpty() |
|
68
|
|
|
{ |
|
69
|
|
|
$params = GlobalId::fromGlobalId('Og=='); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertEquals(['type' => null, 'id' => null], $params); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|