This repository was archived by the owner on Feb 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +23
-15
lines changed Expand file tree Collapse file tree 3 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -1240,11 +1240,12 @@ instance of your plugin manager and override `getV2InvalidPluginException()`
1240
1240
to return the classname of the exception your ` validatePlugin() ` method throws:
1241
1241
1242
1242
``` php
1243
+ use MyNamespace\ObserverInterface;
1243
1244
use MyNamespace\ObserverPluginManager;
1244
1245
use MyNamespace\Exception\RuntimeException;
1245
1246
use PHPUnit_Framework_TestCase as TestCase;
1246
1247
use Zend\ServiceManager\ServiceManager;
1247
- use ZendTest \ServiceManager\TestAsset\V2v3PluginManager ;
1248
+ use Zend \ServiceManager\Test\CommonPluginManagerTrait ;
1248
1249
1249
1250
class MigrationTest extends TestCase
1250
1251
{
@@ -1259,6 +1260,11 @@ class MigrationTest extends TestCase
1259
1260
{
1260
1261
return RuntimeException::class;
1261
1262
}
1263
+
1264
+ protected function getInstanceOf()
1265
+ {
1266
+ return ObserverInterface::class;
1267
+ }
1262
1268
}
1263
1269
```
1264
1270
@@ -1269,17 +1275,6 @@ This will check that:
1269
1275
- That requesting an invalid plugin throws the right exception
1270
1276
- That all your aliases resolve
1271
1277
1272
- Note that you will need to include ServiceManager's test directory in the ` autoload-dev ` section of your ` compoer.json `
1273
- for this test to work:
1274
-
1275
- ```
1276
- "autoload-dev": {
1277
- "psr-4": {
1278
- "MyNamespaceTest\ObserverPluginManager\\": "test/",
1279
- "ZendTest\\ServiceManager\\": "vendor/zendframework/zend-servicemanager/test/"
1280
- }
1281
- }
1282
- ```
1283
1278
1284
1279
### Post migration
1285
1280
Original file line number Diff line number Diff line change 7
7
* @license http://framework.zend.com/license/new-bsd New BSD License
8
8
*/
9
9
10
- namespace ZendTest \ServiceManager ;
10
+ namespace Zend \ServiceManager \ Test ;
11
11
12
12
use ReflectionClass ;
13
13
use ReflectionProperty ;
22
22
*/
23
23
trait CommonPluginManagerTrait
24
24
{
25
- public function testInstanceOfIsSet ()
25
+ public function testInstanceOfMatches ()
26
26
{
27
27
$ manager = $ this ->getPluginManager ();
28
28
$ reflection = new ReflectionProperty ($ manager , 'instanceOf ' );
29
29
$ reflection ->setAccessible (true );
30
- $ this ->assertNotNull ( $ reflection ->getValue ($ manager ), 'instanceOf property not set ' );
30
+ $ this ->assertEquals ( $ this -> getInstanceOf (), $ reflection ->getValue ($ manager ), 'instanceOf does not match ' );
31
31
}
32
32
33
33
public function testShareByDefaultAndSharedByDefault ()
@@ -107,4 +107,10 @@ abstract protected function getPluginManager();
107
107
* @return mixed
108
108
*/
109
109
abstract protected function getV2InvalidPluginException ();
110
+
111
+ /**
112
+ * Returns the value the instanceOf property has been set to
113
+ * @return string
114
+ */
115
+ abstract protected function getInstanceOf ();
110
116
}
Original file line number Diff line number Diff line change 11
11
12
12
use PHPUnit_Framework_TestCase as TestCase ;
13
13
use Zend \ServiceManager \ServiceManager ;
14
+ use Zend \ServiceManager \Test \CommonPluginManagerTrait ;
15
+ use ZendTest \ServiceManager \TestAsset \InvokableObject ;
14
16
use ZendTest \ServiceManager \TestAsset \V2v3PluginManager ;
15
17
16
18
/**
@@ -29,4 +31,9 @@ protected function getV2InvalidPluginException()
29
31
{
30
32
return \RuntimeException::class;
31
33
}
34
+
35
+ protected function getInstanceOf ()
36
+ {
37
+ return InvokableObject::class;
38
+ }
32
39
}
You can’t perform that action at this time.
0 commit comments