|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is a part of GraphQL project. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Alexandr Viniychuk <[email protected]> |
|
6
|
|
|
* created: 5/12/16 4:17 PM |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Youshido\Tests\Library\Config; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
use Youshido\GraphQL\Config\Object\ObjectTypeConfig; |
|
13
|
|
|
use Youshido\GraphQL\Validator\ConfigValidator\ConfigValidator; |
|
14
|
|
|
use Youshido\Tests\DataProvider\TestInterfaceType; |
|
15
|
|
|
|
|
16
|
|
|
class ObjectTypeConfigTest extends \PHPUnit_Framework_TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
public function testCreation() |
|
20
|
|
|
{ |
|
21
|
|
|
$config = new ObjectTypeConfig(['name' => 'Test'], null, false); |
|
22
|
|
|
$this->assertEquals($config->getName(), 'Test', 'Normal creation'); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @expectedException Youshido\GraphQL\Exception\ConfigurationException |
|
27
|
|
|
*/ |
|
28
|
|
|
public function testInvalidConfigNoFields() |
|
29
|
|
|
{ |
|
30
|
|
|
ConfigValidator::getInstance()->assertValidConfig( |
|
31
|
|
|
new ObjectTypeConfig(['name' => 'Test'], null, true) |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @expectedException Youshido\GraphQL\Exception\ConfigurationException |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testInvalidConfigInvalidInterface() |
|
39
|
|
|
{ |
|
40
|
|
|
ConfigValidator::getInstance()->assertValidConfig( |
|
41
|
|
|
new ObjectTypeConfig(['name' => 'Test', 'interfaces' => ['Invalid interface']], null, false) |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testInterfaces() |
|
46
|
|
|
{ |
|
47
|
|
|
$testInterfaceType = new TestInterfaceType(); |
|
48
|
|
|
$config = new ObjectTypeConfig(['name' => 'Test', 'interfaces' => [$testInterfaceType]], null, false); |
|
49
|
|
|
$this->assertEquals($config->getInterfaces(), [$testInterfaceType]); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
} |
|
54
|
|
|
|