Passed
Push — 1.x ( 485655...f0552c )
by David
02:41
created

anonymous//tests/FieldTest.php$0   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheCodingMachine\Tdbm\GraphQL;
4
5
use PHPUnit\Framework\TestCase;
6
use TheCodingMachine\Tdbm\GraphQL\Registry\AuthorizationServiceInterface;
7
use TheCodingMachine\Tdbm\GraphQL\Registry\EmptyContainer;
8
use TheCodingMachine\Tdbm\GraphQL\Registry\Registry;
9
use Youshido\GraphQL\Type\Scalar\StringType;
10
11
class FieldTest extends TestCase
12
{
13
    public function testIsHidden()
14
    {
15
        $authorizationService = new class implements AuthorizationServiceInterface {
16
            public function isAllowed(string $right): bool
17
            {
18
                return ($right === 'ok');
19
            }
20
        };
21
22
        $registry = new Registry(new EmptyContainer(), $authorizationService);
23
24
        $field = new Field('test', new StringType(), $registry);
25
26
        $this->assertFalse($field->isHidden());
27
        $field->hide();
28
        $this->assertTrue($field->isHidden());
29
        $field->show();
30
        $this->assertFalse($field->isHidden());
31
32
        $field->requiresRight('nope');
33
34
    }
35
}
36