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\Connection\Output; |
13
|
|
|
|
14
|
|
|
use Overblog\GraphQLBundle\Relay\Connection\Output\Connection; |
15
|
|
|
use Overblog\GraphQLBundle\Relay\Connection\Output\Edge; |
16
|
|
|
use Overblog\GraphQLBundle\Relay\Connection\Output\PageInfo; |
17
|
|
|
|
18
|
|
|
abstract class AbstractConnectionBuilderTest extends \PHPUnit_Framework_TestCase |
19
|
|
|
{ |
20
|
|
|
protected $letters = ['A', 'B', 'C', 'D', 'E']; |
21
|
|
|
|
22
|
|
|
protected function getExpectedConnection(array $wantedEdges, $hasPreviousPage, $hasNextPage) |
23
|
|
|
{ |
24
|
|
|
$edges = [ |
25
|
|
|
'A' => new Edge('YXJyYXljb25uZWN0aW9uOjA=', 'A'), |
26
|
|
|
'B' => new Edge('YXJyYXljb25uZWN0aW9uOjE=', 'B'), |
27
|
|
|
'C' => new Edge('YXJyYXljb25uZWN0aW9uOjI=', 'C'), |
28
|
|
|
'D' => new Edge('YXJyYXljb25uZWN0aW9uOjM=', 'D'), |
29
|
|
|
'E' => new Edge('YXJyYXljb25uZWN0aW9uOjQ=', 'E'), |
30
|
|
|
]; |
31
|
|
|
|
32
|
|
|
$expectedEdges = array_values(array_intersect_key($edges, array_flip($wantedEdges))); |
33
|
|
|
|
34
|
|
|
return new Connection( |
35
|
|
|
$expectedEdges, |
36
|
|
|
new PageInfo( |
37
|
|
|
isset($expectedEdges[0]) ? $expectedEdges[0]->cursor : null, |
38
|
|
|
end($expectedEdges) ? end($expectedEdges)->cursor : null, |
39
|
|
|
$hasPreviousPage, |
40
|
|
|
$hasNextPage |
41
|
|
|
) |
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|