Failed Conditions
Pull Request — master (#1)
by Max
03:22
created

BasicTest::testInferNameNameAlreadyExists()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
dl 21
loc 21
rs 9.584
c 0
b 0
f 0
cc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQL\Tests\Type\ValidatedFieldDefinition;
6
7
use GraphQL\Type\Definition\Type;
8
use PHPUnit\Framework\TestCase;
9
10
final class BasicTest extends TestCase
11
{
12 View Code Duplication
    public function testInferName()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
13
    {
14
        $def = new NamelessDef([
15
            'type' => Type::boolean(),
16
            'args' => [
17
                'bookId' => [
18
                    'type' => Type::id(),
19
                    'errorCodes' => ['bookNotFound'],
20
                    'validate' => static function ($bookId) {
21
                        return $bookId ? 0 : 1;
22
                    },
23
                ],
24
            ],
25
            'resolve' => static function ($value) : bool {
26
                return !!$value;
27
            },
28
        ]);
29
30
        static::assertEquals('namelessDef', $def->name);
31
    }
32
33 View Code Duplication
    public function testInferNameNameAlreadyExists()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $def = new NamelessDef([
36
            'name' => 'FooDef',
37
            'type' => Type::boolean(),
38
            'args' => [
39
                'bookId' => [
40
                    'type' => Type::id(),
41
                    'errorCodes' => ['bookNotFound'],
42
                    'validate' => static function ($bookId) {
43
                        return $bookId ? 0 : 1;
44
                    },
45
                ],
46
            ],
47
            'resolve' => static function ($value) : bool {
48
                return !!$value;
49
            },
50
        ]);
51
52
        static::assertEquals('FooDef', $def->name);
53
    }
54
}
55