anonymous//tests/FieldTest.php$0   A
last analyzed

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\GraphQL\Controllers\Security\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);
0 ignored issues
show
Deprecated Code introduced by
The class TheCodingMachine\Tdbm\GraphQL\Registry\Registry has been deprecated with message: Use TheCodingMachine\GraphQL\Controllers\Registry instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
24
        $field = new Field('test', new StringType(), $registry);
25
26
        $this->assertTrue($field->isHidden());
27
        $field->show();
28
        $this->assertFalse($field->isHidden());
29
        $field->hide();
30
        $this->assertTrue($field->isHidden());
31
32
        $field->requiresRight('nope');
33
    }
34
}
35