Skip to content
This repository was archived by the owner on Feb 6, 2020. It is now read-only.

Commit 5637228

Browse files
committed
Merge branch 'hotfix/179'
Close #179
2 parents 2758533 + 89e2426 commit 5637228

17 files changed

+57
-53
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"require-dev": {
2222
"ocramius/proxy-manager": "^1.0 || ^2.0",
2323
"phpbench/phpbench": "^0.10.0",
24-
"phpunit/phpunit": "^4.6 || ^5.2.10",
24+
"phpunit/phpunit": "^5.7 || ^6.0.6",
2525
"mikey179/vfsStream": "^1.6",
2626
"zendframework/zend-coding-standard": "~1.0.0"
2727
},

src/Test/CommonPluginManagerTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public function testShareByDefaultAndSharedByDefault()
5353

5454
public function testRegisteringInvalidElementRaisesException()
5555
{
56-
$this->setExpectedException($this->getServiceNotFoundException());
56+
$this->expectException($this->getServiceNotFoundException());
5757
$this->getPluginManager()->setService('test', $this);
5858
}
5959

6060
public function testLoadingInvalidElementRaisesException()
6161
{
6262
$manager = $this->getPluginManager();
6363
$manager->setInvokableClass('test', get_class($this));
64-
$this->setExpectedException($this->getServiceNotFoundException());
64+
$this->expectException($this->getServiceNotFoundException());
6565
$manager->get('test');
6666
}
6767

test/AbstractFactory/ConfigAbstractFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
namespace ZendTest\ServiceManager\AbstractFactory;
99

1010
use ArrayObject;
11+
use PHPUnit\Framework\TestCase;
1112
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory;
1213
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
1314
use Zend\ServiceManager\ServiceManager;
@@ -16,7 +17,7 @@
1617
use ZendTest\ServiceManager\TestAsset\SecondComplexDependencyObject;
1718
use ZendTest\ServiceManager\TestAsset\SimpleDependencyObject;
1819

19-
class ConfigAbstractFactoryTest extends \PHPUnit_Framework_TestCase
20+
class ConfigAbstractFactoryTest extends TestCase
2021
{
2122

2223
public function testCanCreateReturnsTrueIfDependencyNotArrays()

test/AbstractFactory/ReflectionBasedAbstractFactoryTest.php

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace ZendTest\ServiceManager\AbstractFactory;
99

1010
use Interop\Container\ContainerInterface;
11-
use PHPUnit_Framework_TestCase as TestCase;
11+
use PHPUnit\Framework\TestCase;
1212
use Zend\ServiceManager\AbstractFactory\ReflectionBasedAbstractFactory;
1313
use Zend\ServiceManager\Exception\ServiceNotFoundException;
1414

@@ -54,27 +54,23 @@ public function testFactoryRaisesExceptionWhenUnableToResolveATypeHintedService(
5454
$this->container->has(TestAsset\SampleInterface::class)->willReturn(false);
5555
$this->container->has('config')->willReturn(false);
5656
$factory = new ReflectionBasedAbstractFactory();
57-
$this->setExpectedException(
58-
ServiceNotFoundException::class,
59-
sprintf(
60-
'Unable to create service "%s"; unable to resolve parameter "sample" using type hint "%s"',
61-
TestAsset\ClassWithTypeHintedConstructorParameter::class,
62-
TestAsset\SampleInterface::class
63-
)
64-
);
57+
$this->expectException(ServiceNotFoundException::class);
58+
$this->expectExceptionMessage(sprintf(
59+
'Unable to create service "%s"; unable to resolve parameter "sample" using type hint "%s"',
60+
TestAsset\ClassWithTypeHintedConstructorParameter::class,
61+
TestAsset\SampleInterface::class
62+
));
6563
$factory($this->container->reveal(), TestAsset\ClassWithTypeHintedConstructorParameter::class);
6664
}
6765

6866
public function testFactoryRaisesExceptionForScalarParameters()
6967
{
7068
$factory = new ReflectionBasedAbstractFactory();
71-
$this->setExpectedException(
72-
ServiceNotFoundException::class,
73-
sprintf(
74-
'Unable to create service "%s"; unable to resolve parameter "foo" to a class, interface, or array type',
75-
TestAsset\ClassWithScalarParameters::class
76-
)
77-
);
69+
$this->expectException(ServiceNotFoundException::class);
70+
$this->expectExceptionMessage(sprintf(
71+
'Unable to create service "%s"; unable to resolve parameter "foo" to a class, interface, or array type',
72+
TestAsset\ClassWithScalarParameters::class
73+
));
7874
$instance = $factory($this->container->reveal(), TestAsset\ClassWithScalarParameters::class);
7975
}
8076

test/AbstractPluginManagerTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace ZendTest\ServiceManager;
99

1010
use Interop\Container\ContainerInterface;
11-
use PHPUnit_Framework_TestCase as TestCase;
11+
use PHPUnit\Framework\TestCase;
1212
use stdClass;
1313
use Zend\ServiceManager\ConfigInterface;
1414
use Zend\ServiceManager\Exception\InvalidArgumentException;
@@ -77,7 +77,7 @@ public function testValidateInstance()
7777
$pluginManager->get(InvokableObject::class);
7878

7979
// Assert it throws an exception for anything else
80-
$this->setExpectedException(InvalidServiceException::class);
80+
$this->expectException(InvalidServiceException::class);
8181
$pluginManager->get(stdClass::class);
8282
}
8383

@@ -181,7 +181,8 @@ function ($container, $name, $callback) {
181181
public function testGetRaisesExceptionWhenNoFactoryIsResolved()
182182
{
183183
$pluginManager = $this->createContainer();
184-
$this->setExpectedException(ServiceNotFoundException::class, get_class($pluginManager));
184+
$this->expectException(ServiceNotFoundException::class);
185+
$this->expectExceptionMessage(get_class($pluginManager));
185186
$pluginManager->get('Some\Unknown\Service');
186187
}
187188

@@ -259,7 +260,7 @@ public function invalidConstructorArguments()
259260
*/
260261
public function testPassingNonContainerNonConfigNonNullFirstConstructorArgumentRaisesException($arg)
261262
{
262-
$this->setExpectedException(InvalidArgumentException::class);
263+
$this->expectException(InvalidArgumentException::class);
263264
new TestAsset\LenientPluginManager($arg);
264265
}
265266

@@ -308,7 +309,8 @@ public function testSupportsRetrievingAutoInvokableServicesByDefault()
308309
public function testPluginManagersMayOptOutOfSupportingAutoInvokableServices()
309310
{
310311
$pluginManager = new TestAsset\NonAutoInvokablePluginManager(new ServiceManager());
311-
$this->setExpectedException(ServiceNotFoundException::class, TestAsset\NonAutoInvokablePluginManager::class);
312+
$this->expectException(ServiceNotFoundException::class);
313+
$this->expectExceptionMessage(TestAsset\NonAutoInvokablePluginManager::class);
312314
$pluginManager->get(TestAsset\InvokableObject::class);
313315
}
314316

@@ -342,14 +344,14 @@ public function testValidateWillFallBackToValidatePluginWhenDefinedAndEmitDeprec
342344
public function testSetServiceShouldRaiseExceptionForInvalidPlugin()
343345
{
344346
$pluginManager = new TestAsset\SimplePluginManager(new ServiceManager());
345-
$this->setExpectedException(InvalidServiceException::class);
347+
$this->expectException(InvalidServiceException::class);
346348
$pluginManager->setService(stdClass::class, new stdClass());
347349
}
348350

349351
public function testPassingServiceInstanceViaConfigureShouldRaiseExceptionForInvalidPlugin()
350352
{
351353
$pluginManager = new TestAsset\SimplePluginManager(new ServiceManager());
352-
$this->setExpectedException(InvalidServiceException::class);
354+
$this->expectException(InvalidServiceException::class);
353355
$pluginManager->configure(['services' => [
354356
stdClass::class => new stdClass(),
355357
]]);

test/CommonServiceLocatorBehaviorsTrait.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function testCanCreateServiceWithAbstractFactory()
136136
]
137137
]);
138138

139-
$serviceManager->get(DateTime::class);
139+
$this->assertInstanceOf(DateTime::class, $serviceManager->get(DateTime::class));
140140
}
141141

142142
public function testAllowsMultipleInstancesOfTheSameAbstractFactory()
@@ -258,7 +258,7 @@ public function testThrowExceptionIfServiceCannotBeCreated()
258258
]
259259
]);
260260

261-
$this->setExpectedException(ServiceNotCreatedException::class);
261+
$this->expectException(ServiceNotCreatedException::class);
262262

263263
$serviceManager->get(stdClass::class);
264264
}
@@ -271,7 +271,7 @@ public function testThrowExceptionWithStringAsCodeIfServiceCannotBeCreated()
271271
]
272272
]);
273273

274-
$this->setExpectedException(ServiceNotCreatedException::class);
274+
$this->expectException(ServiceNotCreatedException::class);
275275

276276
$serviceManager->get(stdClass::class);
277277
}
@@ -512,7 +512,8 @@ public function testPassingInvalidAbstractFactoryTypeViaConfigurationRaisesExcep
512512
$factory,
513513
$contains = 'invalid abstract factory'
514514
) {
515-
$this->setExpectedException(InvalidArgumentException::class, $contains);
515+
$this->expectException(InvalidArgumentException::class);
516+
$this->expectExceptionMessage($contains);
516517
$serviceManager = $this->createContainer([
517518
'abstract_factories' => [
518519
$factory,
@@ -552,7 +553,8 @@ public function testPassingInvalidInitializerTypeViaConfigurationRaisesException
552553
$initializer,
553554
$contains = 'invalid initializer'
554555
) {
555-
$this->setExpectedException(InvalidArgumentException::class, $contains);
556+
$this->expectException(InvalidArgumentException::class);
557+
$this->expectExceptionMessage($contains);
556558
$serviceManager = $this->createContainer([
557559
'initializers' => [
558560
$initializer,
@@ -566,7 +568,8 @@ public function testPassingInvalidInitializerTypeViaConfigurationRaisesException
566568
public function testGetRaisesExceptionWhenNoFactoryIsResolved()
567569
{
568570
$serviceManager = $this->createContainer();
569-
$this->setExpectedException(ContainerException::class, 'Unable to resolve');
571+
$this->expectException(ContainerException::class);
572+
$this->expectExceptionMessage('Unable to resolve');
570573
$serviceManager->get('Some\Unknown\Service');
571574
}
572575

@@ -600,7 +603,8 @@ public function testInvalidDelegatorShouldRaiseExceptionDuringCreation(
600603
],
601604
]);
602605

603-
$this->setExpectedException(ServiceNotCreatedException::class, $contains);
606+
$this->expectException(ServiceNotCreatedException::class);
607+
$this->expectExceptionMessage($contains);
604608
$serviceManager->get(stdClass::class);
605609
}
606610

@@ -799,7 +803,7 @@ public function testConfiguringInstanceRaisesExceptionIfAllowOverrideIsFalse($me
799803
{
800804
$container = $this->createContainer(['services' => ['foo' => $this]]);
801805
$container->setAllowOverride(false);
802-
$this->setExpectedException(ContainerModificationsNotAllowedException::class);
806+
$this->expectException(ContainerModificationsNotAllowedException::class);
803807
call_user_func_array([$container, $method], $args);
804808
}
805809

@@ -841,7 +845,7 @@ public function testCanRetrieveParentContainerViaGetServiceLocatorWithDeprecatio
841845
*/
842846
public function testCrashesOnCyclicAliases()
843847
{
844-
$this->setExpectedException(CyclicAliasException::class);
848+
$this->expectException(CyclicAliasException::class);
845849

846850
$this->createContainer([
847851
'aliases' => [

test/ConfigTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ZendTest\ServiceManager;
99

10-
use PHPUnit_Framework_TestCase as TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Zend\ServiceManager\Config;
1212
use Zend\ServiceManager\ServiceManager;
1313

test/ExamplePluginManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ZendTest\ServiceManager;
99

10-
use PHPUnit_Framework_TestCase as TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Zend\ServiceManager\ServiceManager;
1212
use Zend\ServiceManager\Test\CommonPluginManagerTrait;
1313
use ZendTest\ServiceManager\TestAsset\InvokableObject;

test/Exception/CyclicAliasExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace ZendTest\ServiceManager\Exception;
99

10-
use PHPUnit_Framework_TestCase as TestCase;
10+
use PHPUnit\Framework\TestCase;
1111
use Zend\ServiceManager\Exception\CyclicAliasException;
1212

1313
/**

test/Factory/InvokableFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace ZendTest\ServiceManager\Factory;
99

1010
use Interop\Container\ContainerInterface;
11-
use PHPUnit_Framework_TestCase as TestCase;
11+
use PHPUnit\Framework\TestCase;
1212
use Zend\ServiceManager\Factory\InvokableFactory;
1313
use ZendTest\ServiceManager\TestAsset\InvokableObject;
1414

0 commit comments

Comments
 (0)