Completed
Push — master ( 0b7ef3...f36d8f )
by Alexandr
03:51
created

ScalarExtendTypeTest::testType()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 32
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
/*
3
* This file is a part of GraphQL project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 8/14/16 12:16 PM
7
*/
8
9
namespace Youshido\Tests\Library\Type;
10
11
12
use Youshido\GraphQL\Execution\Processor;
13
use Youshido\GraphQL\Schema\Schema;
14
use Youshido\GraphQL\Type\Object\ObjectType;
15
use Youshido\GraphQL\Type\Scalar\StringType;
16
use Youshido\Tests\DataProvider\TestTimeType;
17
18
class ScalarExtendTypeTest extends \PHPUnit_Framework_TestCase
19
{
20
21
    public function testType()
22
    {
23
        $reportType = new ObjectType([
24
            'name'   => 'Report',
25
            'fields' => [
26
                'time'  => new TestTimeType(),
27
                'title' => new StringType(),
28
            ]
29
        ]);
30
        $processor  = new Processor(new Schema([
31
                'query' => new ObjectType([
32
                    'name'   => 'RootQueryType',
33
                    'fields' => [
34
                        'latestReport' => [
35
                            'type'    => $reportType,
36
                            'resolve' => function () {
37
                                return [
38
                                    'title' => 'Accident #1',
39
                                    'time'  => '13:30:12',
40
                                ];
41
                            }
42
                        ],
43
                    ]
44
                ])
45
            ])
46
        );
47
48
        $processor->processPayload('{ latestReport { title, time} }');
49
        $this->assertEquals(['data' => ['latestReport' => ['title' => 'Accident #1', 'time' => '13:30:12']]], $processor->getResponseData());
50
51
52
    }
53
54
}