Completed
Pull Request — master (#204)
by Ryan
11:34
created

FieldConfigTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 21
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright (c) 2015–2018 Alexandr Viniychuk <http://youshido.com>.
4
 * Copyright (c) 2015–2018 Portey Vasil <https://github.com/portey>.
5
 * Copyright (c) 2018 Ryan Parman <https://github.com/skyzyx>.
6
 * Copyright (c) 2018 Ashley Hutson <https://github.com/asheliahut>.
7
 * Copyright (c) 2015–2018 Contributors.
8
 *
9
 * http://opensource.org/licenses/MIT
10
 */
11
12
declare(strict_types=1);
13
/*
14
 * This file is a part of GraphQL project.
15
 *
16
 * @author Alexandr Viniychuk <[email protected]>
17
 * created: 5/12/16 7:08 PM
18
 */
19
20
namespace Youshido\Tests\Library\Config;
21
22
use Youshido\GraphQL\Config\Field\FieldConfig;
23
use Youshido\GraphQL\Type\Scalar\StringType;
24
25
class FieldConfigTest extends \PHPUnit_Framework_TestCase
26
{
27
    public function testInvalidParams(): void
28
    {
29
        $fieldConfig = new FieldConfig([
30
            'name'    => 'FirstName',
31
            'type'    => new StringType(),
32
            'resolve' => static function ($value, $args = [], $type = null) {
33
                return 'John';
34
            },
35
        ]);
36
37
        $this->assertEquals('FirstName', $fieldConfig->getName());
38
        $this->assertEquals(new StringType(), $fieldConfig->getType());
39
40
        $resolveFunction = $fieldConfig->getResolveFunction();
41
        $this->assertEquals('John', $resolveFunction([]));
42
    }
43
}
44