forked from laminas/laminas-zendframework-bridge
/
ReplacementsTest.php
128 lines (123 loc) · 5.24 KB
/
ReplacementsTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace LaminasTest\ZendFrameworkBridge;
use Laminas\ZendFrameworkBridge\Replacements;
use PHPUnit\Framework\TestCase;
use function file_get_contents;
class ReplacementsTest extends TestCase
{
/**
* @return iterable
*/
public function edgeCases()
{
yield 'Example class' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/TestClass.php'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/TestClass.php.out'),
];
yield 'Apigility module' => ['ZF\Apigility', 'Laminas\ApiTools'];
yield 'Apigility documentation module' => ['ZF\Apigility\Documentation', 'Laminas\ApiTools\Documentation'];
yield 'Apigility modules.config.php' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/edge-case-apigility-modules.php'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/edge-case-apigility-modules.php.out'),
];
yield 'Auryn' => [
'Northwoods\Container\Zend\Config',
'Northwoods\Container\Zend\Config',
];
yield 'BjyAuthorize' => [
'zend-developer-tools/toolbar/bjy-authorize-role',
'zend-developer-tools/toolbar/bjy-authorize-role',
];
yield 'Expressive ZendRouter' => [
'Zend\Expressive\Router\ZendRouter',
'Mezzio\Router\LaminasRouter',
];
yield 'Expressive ZendView Renderer' => [
'Zend\Expressive\ZendView\ZendViewRenderer',
'Mezzio\LaminasView\LaminasViewRenderer',
];
yield 'Expressive ACL Authorizations' => [
'Zend\Expressive\Authorization\Acl\ZendAcl',
'Mezzio\Authorization\Acl\LaminasAcl',
];
yield 'Expressive RBAC Authorizations' => [
'Zend\Expressive\Authorization\Rbac\ZendRbac',
'Mezzio\Authorization\Rbac\LaminasRbac',
];
yield 'Cache Zend Server abstract adapter' => [
'Zend\Cache\Storage\Adapter\AbstractZendServer',
'Laminas\Cache\Storage\Adapter\AbstractZendServer',
];
yield 'Cache Zend Server Disk adapter' => [
'Zend\Cache\Storage\Adapter\ZendServerDisk',
'Laminas\Cache\Storage\Adapter\ZendServerDisk',
];
yield 'Cache Zend Server Shm adapter' => [
'Zend\Cache\Storage\Adapter\ZendServerShm',
'Laminas\Cache\Storage\Adapter\ZendServerShm',
];
yield 'Log Zend Monitor writer' => [
'Zend\Log\Writer\ZendMonitor',
'Laminas\Log\Writer\ZendMonitor',
];
yield 'Generated class name containing ZendCode in namespace' => [
'Some\Module\ZendCode\GeneratedClass',
'Some\Module\ZendCode\GeneratedClass'
];
yield 'Laminas Rbac class definition' => [
'class ZendRbac',
'class LaminasRbac'
];
yield 'Importing Zend\Expressive\ZendView namespace' => [
'use Zend\Expressive\ZendView',
'use Mezzio\LaminasView'
];
yield 'Importing zend-http client as ZendHttp' => [
'use Zend\Http as ZendHttp',
'use Laminas\Http as LaminasHttp'
];
yield 'ZendHttpClientDecorator definition' => [
'class ZendHttpClientDecorator implements HeaderAwareClientInterface',
'class LaminasHttpClientDecorator implements HeaderAwareClientInterface'
];
yield 'Vendor ZendAcl extension' => [
'\'some-alias\' => Some\Vendor\Acl\ZendAcl::class,',
'\'some-alias\' => Some\Vendor\Acl\ZendAcl::class,'
];
yield 'phpstan-baseline.neon' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/phpstan-baseline.neon'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/phpstan-baseline.neon.out'),
];
yield 'api-tools config' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/module.config.php'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/module.config.php.out'),
];
yield 'api-skeletons composer' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/api-skeletons-composer.json'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/api-skeletons-composer.json.out'),
];
yield 'api-skeletons OAuth2 Client' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/ZFOAuth2Client.php'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/ZFOAuth2Client.php.out'),
];
yield 'api-skeletons zf-oauth2-doctrine config' => [
file_get_contents(__DIR__ . '/TestAsset/Replacements/zf-oauth2-config.php'),
file_get_contents(__DIR__ . '/TestAsset/Replacements/zf-oauth2-config.php.out'),
];
yield '3rd party CustomZendFormBinder' => [
'CustomZendFormBinder\Controller\Plugin\BinderPlugin',
'CustomZendFormBinder\Controller\Plugin\BinderPlugin',
];
}
/**
* @dataProvider edgeCases
*
* @param string $string
* @param string $expected
*/
public function testEdgeCases($string, $expected)
{
$replacements = new Replacements();
$this->assertSame($expected, $replacements->replace($string));
}
}