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\Resolver; |
13
|
|
|
|
14
|
|
|
use GraphQL\Type\Definition\ResolveInfo; |
15
|
|
|
use Overblog\GraphQLBundle\Resolver\Resolver; |
16
|
|
|
|
17
|
|
|
class ResolverTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param $fieldName |
21
|
|
|
* @param $source |
22
|
|
|
* @param $expected |
23
|
|
|
* |
24
|
|
|
* @dataProvider resolverProvider |
25
|
|
|
*/ |
26
|
|
|
public function testDefaultResolveFn($fieldName, $source, $expected) |
27
|
|
|
{ |
28
|
|
|
$info = new ResolveInfo(['fieldName' => $fieldName]); |
29
|
|
|
|
30
|
|
|
$this->assertEquals($expected, Resolver::defaultResolveFn($source, [], $info)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function resolverProvider() |
34
|
|
|
{ |
35
|
|
|
$object = new Toto(); |
36
|
|
|
|
37
|
|
|
return [ |
38
|
|
|
['key', ['key' => 'toto'], 'toto'], |
39
|
|
|
['fake', ['coco'], null], |
40
|
|
|
['privatePropertyWithoutGetter', $object, null], |
41
|
|
|
['privatePropertyWithGetter', $object, Toto::PRIVATE_PROPERTY_WITH_GETTER_VALUE], |
42
|
|
|
['private_property_with_getter2', $object, Toto::PRIVATE_PROPERTY_WITH_GETTER2_VALUE], |
43
|
|
|
['not_object_or_array', 'String', null], |
44
|
|
|
['name', $object, $object->name], |
45
|
|
|
]; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
} |
49
|
|
|
|