Skip to content

Commit 55c7be9

Browse files
Prepare for PHPUnit 6
1 parent 184be37 commit 55c7be9

9 files changed

+57
-43
lines changed

.travis.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@ sudo: false
22

33
language: php
44

5-
php:
6-
- 5.6
7-
- 7.0
8-
- hhvm
9-
105
matrix:
116
fast_finish: true
127
include:
13-
- php: 5.6
14-
env: deps="low"
158
- php: 7.0
169
env: SYMFONY_DI_VERSION=2.3.*
1710
- php: 7.0
@@ -20,15 +13,18 @@ matrix:
2013
env: SYMFONY_DI_VERSION=2.8.*
2114
- php: 7.0
2215
env: SYMFONY_DI_VERSION=3.2.*
23-
allow_failures:
24-
- php: hhvm
25-
26-
before_script:
27-
- if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then phpenv config-rm xdebug.ini; fi
28-
- if [ "$SYMFONY_DI_VERSION" != "" ]; then composer require --no-update "symfony/dependency-injection:${SYMFONY_DI_VERSION}"; fi
29-
- if [ "$PHPUNIT_VERSION" != "" ]; then composer require --no-update "phpunit/phpunit:${PHPUNIT_VERSION}"; fi
30-
- if [ "$deps" = "low" ]; then composer update --prefer-lowest; fi
31-
- if [ "$deps" = "" ]; then composer install; fi
16+
17+
cache:
18+
directories:
19+
- ~/.composer/cache/files
20+
21+
before_install:
22+
- phpenv config-rm xdebug.ini || true
23+
- composer self-update
24+
25+
install:
26+
- if [ ! -z ${SYMFONY_VERSION+x} ]; then composer require --no-update "symfony/dependency-injection:${SYMFONY_VERSION}"; fi
27+
- composer install --prefer-dist
3228

3329
script: vendor/bin/phpunit
3430

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## v2.0.0
4+
5+
- Only support PHPUnit 6
6+
- Only support Symfony 2.* and 3.* LTS versions
7+
- Require PHP ^7.0
8+
- Drop support for HHVM
9+
310
## v0.7.2
411

512
- Made alias/service id comparison case insensitive. Reported and fixed by Christian Flothmann (@xabbuh).

PhpUnit/AbstractContainerBuilderTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Matthias\SymfonyDependencyInjectionTest\PhpUnit;
44

5+
use PHPUnit\Framework\Constraint\LogicalNot;
56
use PHPUnit\Framework\TestCase;
67
use Symfony\Component\DependencyInjection\ContainerBuilder;
78
use Symfony\Component\DependencyInjection\Definition;
@@ -96,7 +97,7 @@ protected function assertContainerBuilderNotHasService($serviceId)
9697
{
9798
self::assertThat(
9899
$this->container,
99-
new \PHPUnit_Framework_Constraint_Not(new ContainerBuilderHasServiceDefinitionConstraint($serviceId, null, false))
100+
new LogicalNot(new ContainerBuilderHasServiceDefinitionConstraint($serviceId, null, false))
100101
);
101102
}
102103

Tests/PhpUnit/AbstractExtensionTestCaseTest.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
66
use Matthias\SymfonyDependencyInjectionTest\Tests\Fixtures\MatthiasDependencyInjectionTestExtension;
7+
use PHPUnit\Framework\ExpectationFailedException;
78

89
class AbstractExtensionTestCaseTest extends AbstractExtensionTestCase
910
{
@@ -57,7 +58,7 @@ public function if_service_is_undefined_it_fails()
5758
{
5859
$this->load();
5960

60-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
61+
$this->expectException(ExpectationFailedException::class);
6162

6263
$this->assertContainerBuilderHasService('undefined', 'AnyClass');
6364
}
@@ -69,7 +70,7 @@ public function if_synthetic_service_is_undefined_it_fails()
6970
{
7071
$this->load();
7172

72-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
73+
$this->expectException(ExpectationFailedException::class);
7374
$this->expectExceptionMessage('no service');
7475

7576
$this->assertContainerBuilderHasSyntheticService('undefined');
@@ -82,7 +83,7 @@ public function if_service_is_defined_but_not_synthetic_it_fails()
8283
{
8384
$this->load();
8485

85-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
86+
$this->expectException(ExpectationFailedException::class);
8687
$this->expectExceptionMessage('synthetic');
8788

8889
$this->assertContainerBuilderHasSyntheticService('loaded_service_id');
@@ -95,7 +96,7 @@ public function if_service_is_defined_but_has_another_class_it_fails()
9596
{
9697
$this->load();
9798

98-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
99+
$this->expectException(ExpectationFailedException::class);
99100
$this->expectExceptionMessage('stdClass');
100101

101102
$this->assertContainerBuilderHasService('manual_service_id', 'SomeOtherClass');
@@ -108,7 +109,7 @@ public function if_alias_is_not_defined_it_fails()
108109
{
109110
$this->load();
110111

111-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
112+
$this->expectException(ExpectationFailedException::class);
112113

113114
$this->assertContainerBuilderHasAlias('undefined', 'any_service_id');
114115
}
@@ -120,7 +121,7 @@ public function if_alias_exists_but_for_wrong_service_it_fails()
120121
{
121122
$this->load();
122123

123-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
124+
$this->expectException(ExpectationFailedException::class);
124125
$this->expectExceptionMessage('service_id');
125126

126127
$this->assertContainerBuilderHasAlias('manual_alias', 'wrong');
@@ -133,7 +134,7 @@ public function if_parameter_does_not_exist_it_fails()
133134
{
134135
$this->load();
135136

136-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
137+
$this->expectException(ExpectationFailedException::class);
137138
$this->expectExceptionMessage('undefined');
138139

139140
$this->assertContainerBuilderHasParameter('undefined', 'any value');
@@ -146,7 +147,7 @@ public function if_parameter_exists_but_has_wrong_value_it_fails()
146147
{
147148
$this->load();
148149

149-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
150+
$this->expectException(ExpectationFailedException::class);
150151
$this->expectExceptionMessage('parameter value');
151152

152153
$this->assertContainerBuilderHasParameter('manual_parameter', 'wrong');
@@ -159,7 +160,7 @@ public function if_definition_does_not_have_argument_it_fails()
159160
{
160161
$this->load();
161162

162-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
163+
$this->expectException(ExpectationFailedException::class);
163164
$this->expectExceptionMessage('10');
164165

165166
$this->assertContainerBuilderHasServiceDefinitionWithArgument('manual_service_id', 10, 'any value');
@@ -172,7 +173,7 @@ public function if_definition_has_argument_but_with_wrong_value_it_fails()
172173
{
173174
$this->load();
174175

175-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
176+
$this->expectException(ExpectationFailedException::class);
176177

177178
$this->assertContainerBuilderHasServiceDefinitionWithArgument('manual_service_id', 1, 'wrong value');
178179
}
@@ -184,7 +185,7 @@ public function if_definition_is_decorated_and_argument_has_wrong_value_it_fails
184185
{
185186
$this->load();
186187

187-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
188+
$this->expectException(ExpectationFailedException::class);
188189
$this->expectExceptionMessage('second argument');
189190

190191
$this->assertContainerBuilderHasServiceDefinitionWithArgument('child_service_id', 1, 'wrong value');
@@ -197,7 +198,7 @@ public function if_definition_is_decorated_but_by_the_wrong_parent_it_fails()
197198
{
198199
$this->load();
199200

200-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
201+
$this->expectException(ExpectationFailedException::class);
201202
$this->expectExceptionMessage('parent_service_id');
202203

203204
$this->assertContainerBuilderHasServiceDefinitionWithParent('child_service_id', 'wrong_parent_service_id');
@@ -210,7 +211,7 @@ public function if_definition_should_be_decorated_when_it_is_not_it_fails()
210211
{
211212
$this->load();
212213

213-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
214+
$this->expectException(ExpectationFailedException::class);
214215
$this->expectExceptionMessage('parent');
215216

216217
$this->assertContainerBuilderHasServiceDefinitionWithParent('parent_service_id', 'any_other_service_id');
@@ -223,7 +224,7 @@ public function if_definition_should_have_a_method_call_and_it_has_not_it_fails(
223224
{
224225
$this->load();
225226

226-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
227+
$this->expectException(ExpectationFailedException::class);
227228
$this->expectExceptionMessage('wrongMethodName');
228229

229230
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
@@ -240,7 +241,7 @@ public function if_definition_should_have_a_certain_arguments_for_a_method_call_
240241
{
241242
$this->load();
242243

243-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
244+
$this->expectException(ExpectationFailedException::class);
244245
$this->expectExceptionMessage('theRightMethodName');
245246

246247
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
@@ -257,7 +258,7 @@ public function if_service_is_defined_it_fails()
257258
{
258259
$this->load();
259260

260-
$this->expectException(\PHPUnit_Framework_ExpectationFailedException::class);
261+
$this->expectException(ExpectationFailedException::class);
261262

262263
$this->assertContainerBuilderNotHasService('loaded_service_id');
263264
}

Tests/PhpUnit/ContainerBuilderHasAliasConstraintTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ public function it_has_a_string_representation()
6262
*/
6363
public function it_expects_a_string_for_alias_id()
6464
{
65-
$this->setExpectedException('\InvalidArgumentException', 'string');
65+
$this->expectException(\InvalidArgumentException::class);
66+
$this->expectExceptionMessage('string');
67+
6668
new ContainerBuilderHasAliasConstraint(new \stdClass(), 'service_id');
6769
}
6870

@@ -71,7 +73,9 @@ public function it_expects_a_string_for_alias_id()
7173
*/
7274
public function it_expects_a_string_for_service_id()
7375
{
74-
$this->setExpectedException('\InvalidArgumentException', 'string');
76+
$this->expectException(\InvalidArgumentException::class);
77+
$this->expectExceptionMessage('string');
78+
7579
new ContainerBuilderHasAliasConstraint('alias_id', new \stdClass());
7680
}
7781

Tests/PhpUnit/ContainerBuilderHasServiceDefinitionConstraintTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ public function it_has_a_string_representation()
8686
*/
8787
public function it_expects_a_string_for_service_id()
8888
{
89-
$this->setExpectedException('\InvalidArgumentException', 'string');
89+
$this->expectException(\InvalidArgumentException::class);
90+
$this->expectExceptionMessage('string');
91+
9092
new ContainerBuilderHasServiceDefinitionConstraint(new \stdClass(), 'class');
9193
}
9294

@@ -95,7 +97,9 @@ public function it_expects_a_string_for_service_id()
9597
*/
9698
public function it_expects_a_string_for_class()
9799
{
98-
$this->setExpectedException('\InvalidArgumentException', 'string');
100+
$this->expectException(\InvalidArgumentException::class);
101+
$this->expectExceptionMessage('string');
102+
99103
new ContainerBuilderHasServiceDefinitionConstraint('service_id', new \stdClass());
100104
}
101105
}

Tests/PhpUnit/ContainerHasParameterConstraintTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function containerBuilderProvider()
4646

4747
private function createMockContainerWithParameters(array $parameters)
4848
{
49-
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
49+
$container = $this->createMock(ContainerInterface::class);
5050

5151
$container
5252
->expects($this->any())

Tests/PhpUnit/DefinitionHasTagConstraintTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Matthias\SymfonyDependencyInjectionTest\Tests\PhpUnit\DependencyInjection;
44

55
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\DefinitionHasTagConstraint;
6+
use PHPUnit\Framework\ExpectationFailedException;
67
use PHPUnit\Framework\TestCase;
78
use Symfony\Component\DependencyInjection\Definition;
89

@@ -33,7 +34,7 @@ public function evaluateThrowsExceptionOnFailure(Definition $definition, $tag, $
3334
try {
3435
$constraint->evaluate($definition);
3536
$this->fail('DefinitionHasTagConstraint doesn\'t throw expected exception');
36-
} catch (\PHPUnit_Framework_ExpectationFailedException $e) {
37+
} catch (ExpectationFailedException $e) {
3738
$this->assertTrue(true, 'DefinitionHasTagConstraint throws expected exception');
3839
}
3940
}

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
}
1414
],
1515
"require": {
16-
"matthiasnoback/symfony-config-test": "^1.0|^2.0",
16+
"php": "^7.0",
17+
"matthiasnoback/symfony-config-test": "^3.0",
1718
"symfony/dependency-injection": "^2.3|^3.0",
1819
"symfony/config": "^2.3|^3.0",
19-
"symfony/yaml": "^2.7|^3.0",
20-
"sebastian/exporter": "^1.0|^2.0"
20+
"symfony/yaml": "^2.7|^3.0"
2121
},
2222
"require-dev": {
23-
"phpunit/phpunit": "^5.4.3|^6.0"
23+
"phpunit/phpunit": "^6.0"
2424
},
2525
"autoload": {
2626
"psr-4" : { "Matthias\\SymfonyDependencyInjectionTest\\" : "" }

0 commit comments

Comments
 (0)