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

Commit 654983e

Browse files
committed
Reverted changes to custom assertions
- Added a class_alias directive to ensure that the non-namespaced version of `ExpectationFailedException` can still be used as the namespaced variant within tests.
1 parent b4c51f9 commit 654983e

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
"autoload-dev": {
2929
"psr-4": {
3030
"ZendTest\\ComponentInstaller\\": "test/"
31-
}
31+
},
32+
"files": [
33+
"test/_autoload.php"
34+
]
3235
},
3336
"scripts": {
3437
"check": [

test/ConfigDiscoveryTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
use org\bovigo\vfs\vfsStream;
1111
use org\bovigo\vfs\vfsStreamDirectory;
12+
use PHPUnit\Framework\ExpectationFailedException;
1213
use PHPUnit\Framework\TestCase;
1314
use Zend\ComponentInstaller\Collection;
1415
use Zend\ComponentInstaller\ConfigDiscovery;
@@ -95,22 +96,22 @@ public function createModulesConfig()
9596
public function assertOptionsContainsNoopInjector(Collection $options)
9697
{
9798
if ($options->isEmpty()) {
98-
$this->fail('Options array is empty; no NoopInjector found!');
99+
throw new ExpectationFailedException('Options array is empty; no NoopInjector found!');
99100
}
100101

101102
$options = $options->toArray();
102103
$injector = array_shift($options)->getInjector();
103104

104105
if (! $injector instanceof NoopInjector) {
105-
$this->fail('Options array does not contain a NoopInjector!');
106+
throw new ExpectationFailedException('Options array does not contain a NoopInjector!');
106107
}
107108
}
108109

109110
public function assertOptionsContainsInjector($injectorType, Collection $options)
110111
{
111112
foreach ($options as $option) {
112113
if (! $option instanceof ConfigOption) {
113-
$this->fail(sprintf(
114+
throw new ExpectationFailedException(sprintf(
114115
'Invalid option returned: %s',
115116
is_object($option) ? get_class($option) : gettype($option)
116117
));
@@ -121,7 +122,7 @@ public function assertOptionsContainsInjector($injectorType, Collection $options
121122
}
122123
}
123124

124-
$this->fail(sprintf(
125+
throw new ExpectationFailedException(sprintf(
125126
'Injector of type %s was not found in the options',
126127
$injectorType
127128
));
@@ -133,7 +134,7 @@ public function assertOptionsContainsInjectorInChain($injectorType, Collection $
133134

134135
foreach ($chain->getCollection() as $injector) {
135136
if (! $injector instanceof InjectorInterface) {
136-
$this->fail(sprintf(
137+
throw new ExpectationFailedException(sprintf(
137138
'Invalid Injector returned: %s',
138139
is_object($injector) ? get_class($injector) : gettype($injector)
139140
));
@@ -144,7 +145,7 @@ public function assertOptionsContainsInjectorInChain($injectorType, Collection $
144145
}
145146
}
146147

147-
$this->fail(sprintf(
148+
throw new ExpectationFailedException(sprintf(
148149
'Injector of type %s was not found in the options',
149150
$injectorType
150151
));

test/_autoload.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/**
3+
* @see https://github.com/zendframework/zend-component-installer for the canonical source repository
4+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
5+
* @license https://github.com/zendframework/zend-component-installer/blob/master/LICENSE.md New BSD License
6+
*/
7+
8+
use PHPUnit\Framework\ExpectationFailedException;
9+
10+
class_alias('PHPUnit_Framework_ExpectationFailedException', ExpectationFailedException::class);

0 commit comments

Comments
 (0)