1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Cycle\ORM\Promise\Tests\Declaration; |
5
|
|
|
|
6
|
|
|
use Cycle\ORM\Promise\Declaration\Declaration; |
7
|
|
|
use PHPUnit\Framework\TestCase; |
8
|
|
|
|
9
|
|
|
class DeclarationTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @dataProvider classNameProvider |
13
|
|
|
* |
14
|
|
|
* @param string $class |
15
|
|
|
* @param $expected |
16
|
|
|
*/ |
17
|
|
|
public function testClassName(string $class, $expected) |
18
|
|
|
{ |
19
|
|
|
$schema = new Declaration('Any', $class); |
20
|
|
|
$this->assertSame($expected, $schema->class->class); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function classNameProvider(): array |
24
|
|
|
{ |
25
|
|
|
return [ |
26
|
|
|
['ExampleProxy', 'ExampleProxy'], |
27
|
|
|
['\ExampleProxy', 'ExampleProxy'], |
28
|
|
|
['Path\To\Proxy\ExampleProxy', 'ExampleProxy'], |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @dataProvider classNamespaceProvider |
34
|
|
|
* |
35
|
|
|
* @param string $extends |
36
|
|
|
* @param string $class |
37
|
|
|
* @param $expected |
38
|
|
|
*/ |
39
|
|
|
public function testClassNamespace(string $extends, string $class, $expected) |
40
|
|
|
{ |
41
|
|
|
$schema = new Declaration($extends, $class); |
42
|
|
|
$this->assertSame($expected, $schema->class->namespace); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function classNamespaceProvider(): array |
46
|
|
|
{ |
47
|
|
|
return [ |
48
|
|
|
['Example', 'ExampleProxy', null], |
49
|
|
|
['Example', '\ExampleProxy', null], |
50
|
|
|
['Path\To\Example', '\ExampleProxy', null], |
51
|
|
|
['Path\To\Example', 'ExampleProxy', 'Path\To'], |
52
|
|
|
['Path\To\Example', 'Path\To\Proxy\ExampleProxy', 'Path\To\Proxy'], |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @dataProvider extendsNameProvider |
58
|
|
|
* |
59
|
|
|
* @param string $extends |
60
|
|
|
* @param $expected |
61
|
|
|
*/ |
62
|
|
|
public function testExtendsName(string $extends, $expected) |
63
|
|
|
{ |
64
|
|
|
$schema = new Declaration($extends, 'Any'); |
65
|
|
|
$this->assertSame($expected, $schema->extends->class); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function extendsNameProvider(): array |
69
|
|
|
{ |
70
|
|
|
return [ |
71
|
|
|
['Example', 'Example'], |
72
|
|
|
['\Example', 'Example'], |
73
|
|
|
['Path\To\Proxy\Example', 'Example'], |
74
|
|
|
]; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @dataProvider extendsNamespaceProvider |
79
|
|
|
* |
80
|
|
|
* @param string $extends |
81
|
|
|
* @param $expected |
82
|
|
|
*/ |
83
|
|
|
public function testExtendsNamespace(string $extends, $expected) |
84
|
|
|
{ |
85
|
|
|
$schema = new Declaration($extends, 'Any'); |
86
|
|
|
$this->assertSame($expected, $schema->extends->namespace); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
public function extendsNamespaceProvider(): array |
90
|
|
|
{ |
91
|
|
|
return [ |
92
|
|
|
['Example', null], |
93
|
|
|
['\Example', null], |
94
|
|
|
['Path\To\Example', 'Path\To'], |
95
|
|
|
]; |
96
|
|
|
} |
97
|
|
|
} |