ConnectionTest::testEdgeDefinition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * This file is a part of GraphQL project.
4
 *
5
 * @author Alexandr Viniychuk <[email protected]>
6
 * created: 10:39 PM 5/18/16
7
 */
8
9
namespace Youshido\Tests\Library\Relay;
10
11
12
use Youshido\GraphQL\Relay\Connection\Connection;
13
use Youshido\GraphQL\Relay\Type\PageInfoType;
14
use Youshido\GraphQL\Type\Scalar\StringType;
15
use Youshido\GraphQL\Type\TypeMap;
16
use Youshido\Tests\DataProvider\TestObjectType;
17
18
class ConnectionTest extends \PHPUnit_Framework_TestCase
19
{
20
21
    public function testConnectionArgs()
22
    {
23
        $this->assertEquals([
24
            'after'  => ['type' => TypeMap::TYPE_STRING],
25
            'first'  => ['type' => TypeMap::TYPE_INT],
26
            'before' => ['type' => TypeMap::TYPE_STRING],
27
            'last'   => ['type' => TypeMap::TYPE_INT],
28
29
        ], Connection::connectionArgs());
30
    }
31
32
    public function testPageInfoType()
33
    {
34
        $type = new PageInfoType();
35
        $this->assertEquals('PageInfo', $type->getName());
36
        $this->assertEquals('Information about pagination in a connection.', $type->getDescription());
37
        $this->assertTrue($type->hasField('hasNextPage'));
38
        $this->assertTrue($type->hasField('hasPreviousPage'));
39
        $this->assertTrue($type->hasField('startCursor'));
40
        $this->assertTrue($type->hasField('endCursor'));
41
    }
42
43 View Code Duplication
    public function testEdgeDefinition()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $edgeType = Connection::edgeDefinition(new StringType(), 'user');
46
        $this->assertEquals('userEdge', $edgeType->getName());
47
        $this->assertTrue($edgeType->hasField('node'));
48
        $this->assertTrue($edgeType->hasField('cursor'));
49
    }
50
51 View Code Duplication
    public function testConnectionDefinition()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $connection = Connection::connectionDefinition(new TestObjectType(), 'user');
54
        $this->assertEquals($connection->getName(), 'userConnection');
55
        $this->assertTrue($connection->hasField('pageInfo'));
56
        $this->assertTrue($connection->hasField('edges'));
57
    }
58
59
}
60