FieldTest.php$0 ➔ isAllowed()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
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