Completed
Push — master ( dbf644...4759cd )
by David
01:48 queued 01:46
created

NamingStrategyTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 12
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetInputTypeName() 0 9 1
A testGetFieldNameFromMethodName() 0 9 1
1
<?php
2
3
namespace TheCodingMachine\GraphQL\Controllers;
4
5
use PHPUnit\Framework\TestCase;
6
use TheCodingMachine\GraphQL\Controllers\Annotations\Factory;
7
8
class NamingStrategyTest extends TestCase
9
{
10
11
    public function testGetInputTypeName(): void
12
    {
13
        $namingStrategy = new NamingStrategy();
14
15
        $factory = new Factory();
16
        $this->assertSame('FooClassInput', $namingStrategy->getInputTypeName('Bar\\FooClass', $factory));
17
18
        $factory = new Factory(['name'=>'MyInputType']);
19
        $this->assertSame('MyInputType', $namingStrategy->getInputTypeName('Bar\\FooClass', $factory));
20
    }
21
22
    public function testGetFieldNameFromMethodName(): void
23
    {
24
        $namingStrategy = new NamingStrategy();
25
26
        $this->assertSame('name', $namingStrategy->getFieldNameFromMethodName('getName'));
27
        $this->assertSame('get', $namingStrategy->getFieldNameFromMethodName('get'));
28
        $this->assertSame('name', $namingStrategy->getFieldNameFromMethodName('isName'));
29
        $this->assertSame('is', $namingStrategy->getFieldNameFromMethodName('is'));
30
        $this->assertSame('foo', $namingStrategy->getFieldNameFromMethodName('foo'));
31
    }
32
}
33