Passed
Pull Request — master (#1)
by Max
07:34 queued 02:12
created

BasicTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 24
dl 0
loc 43
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testInferNameNameAlreadyExists() 0 20 2
A testInferName() 0 19 2
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
	public function testInferName()
13
	{
14
		$def = new NamelessDef([
15
			'type' => Type::boolean(),
16
			'args' => [
17
				'bookId' => [
18
					'type' => Type::id(),
19
					'errorCodes' => ['bookNotFound'],
20
					'validate' => 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
	public function testInferNameNameAlreadyExists()
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' => 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