Skip to content

Commit ef2f06a

Browse files
authored
Merge branch 'master' into patch-1
2 parents a50c618 + c6b094c commit ef2f06a

9 files changed

+248
-53
lines changed

.travis.yml

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,55 @@
1-
sudo: false
2-
31
language: php
4-
5-
matrix:
6-
fast_finish: true
7-
include:
8-
- php: 7.0
9-
env: SYMFONY_DI_VERSION=2.3.*
10-
- php: 7.0
11-
env: SYMFONY_DI_VERSION=2.7.*
12-
- php: 7.0
13-
env: SYMFONY_DI_VERSION=2.8.*
14-
- php: 7.0
15-
env: SYMFONY_DI_VERSION=3.2.*
16-
2+
sudo: false
173
cache:
18-
directories:
19-
- ~/.composer/cache/files
4+
directories:
5+
- $HOME/.composer/cache/files
6+
- $HOME/symfony-bridge/.phpunit
7+
env:
8+
global:
9+
- PHPUNIT_FLAGS="-v"
10+
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
11+
matrix:
12+
fast_finish: true
13+
include:
14+
# Minimum supported Symfony version with the latest PHP version
15+
- php: 7.1
16+
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
17+
18+
# Test the latest stable release
19+
- php: 7.0
20+
- php: 7.1
21+
- php: 7.2
22+
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"
23+
24+
# Force some major versions of Symfony
25+
- php: 7.2
26+
env: DEPENDENCIES="dunglas/symfony-lock:^2"
27+
- php: 7.2
28+
env: DEPENDENCIES="dunglas/symfony-lock:^3"
29+
- php: 7.2
30+
env: DEPENDENCIES="dunglas/symfony-lock:^4" STABILITY="beta"
31+
32+
# Latest commit to master
33+
- php: 7.2
34+
env: STABILITY="dev"
35+
36+
allow_failures:
37+
# Dev-master is allowed to fail.
38+
- env: STABILITY="dev"
2039

2140
before_install:
22-
- phpenv config-rm xdebug.ini || true
23-
- composer self-update
41+
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
42+
- if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi;
43+
- if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi;
2444

2545
install:
26-
- if [ ! -z ${SYMFONY_VERSION+x} ]; then composer require --no-update "symfony/dependency-injection:${SYMFONY_VERSION}"; fi
27-
- composer install --prefer-dist
46+
# To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355
47+
- if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi
48+
- composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
2849

29-
script: vendor/bin/phpunit
50+
script:
51+
- composer validate --strict --no-check-lock
52+
- ./vendor/bin/phpunit $PHPUNIT_FLAGS
3053

3154
notifications:
3255
33-
34-
cache:
35-
directories:
36-
- $COMPOSER_CACHE_DIR

CHANGELOG.md

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

3+
## v2.2.0
4+
5+
- Support for Symfony 4
6+
37
## v2.1.0
48

59
- Added support for validating invocation index order of method call (see #69).

PhpUnit/AbstractExtensionTestCase.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,13 @@ protected function setUp()
4545
* Call this method from within your test after you have (optionally) modified the ContainerBuilder for this test
4646
* ($this->container).
4747
*
48-
* If your extension(s) implements \Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface, you may
49-
* set $withPrependInvocation to TRUE to invoke prepend() method prior to load() method of your extension.
50-
*
5148
* @param array $configurationValues
5249
*/
5350
protected function load(array $configurationValues = array())
5451
{
5552
$configs = array($this->getMinimalConfiguration(), $configurationValues);
5653

5754
foreach ($this->container->getExtensions() as $extension) {
58-
5955
if ($extension instanceof PrependExtensionInterface) {
6056
$extension->prepend($this->container);
6157
}

PhpUnit/DefinitionHasArgumentConstraint.php

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

1010
class DefinitionHasArgumentConstraint extends Constraint
1111
{
12+
13+
/**
14+
* @var int|string
15+
*/
1216
private $argumentIndex;
1317
private $expectedValue;
1418
private $checkExpectedValue;
@@ -17,13 +21,36 @@ public function __construct($argumentIndex, $expectedValue, $checkExpectedValue
1721
{
1822
parent::__construct();
1923

20-
$this->argumentIndex = (integer)$argumentIndex;
24+
if (!(is_string($argumentIndex) || (is_int($argumentIndex) && $argumentIndex >= 0))) {
25+
throw new \InvalidArgumentException('Expected either a string or a positive integer for $argumentIndex.');
26+
}
27+
28+
if (is_string($argumentIndex)) {
29+
if ('' === $argumentIndex) {
30+
throw new \InvalidArgumentException('A named argument must begin with a "$".');
31+
}
32+
33+
if ('$' !== $argumentIndex[0]) {
34+
throw new \InvalidArgumentException(
35+
sprintf('Unknown argument "%s". Did you mean "$%s"?', $argumentIndex, $argumentIndex)
36+
);
37+
}
38+
}
39+
40+
$this->argumentIndex = $argumentIndex;
2141
$this->expectedValue = $expectedValue;
2242
$this->checkExpectedValue = $checkExpectedValue;
2343
}
2444

2545
public function toString()
2646
{
47+
if (is_string($this->argumentIndex)) {
48+
return sprintf(
49+
'has an argument named "%s" with the given value',
50+
$this->argumentIndex
51+
);
52+
}
53+
2754
return sprintf(
2855
'has an argument with index %d with the given value',
2956
$this->argumentIndex
@@ -65,13 +92,13 @@ private function evaluateArgumentIndex(Definition $definition, $returnResult)
6592
return false;
6693
}
6794

68-
$this->fail(
69-
$definition,
70-
sprintf(
71-
'The definition has no argument with index %d',
72-
$this->argumentIndex
73-
)
74-
);
95+
if (is_string($this->argumentIndex)) {
96+
$message = sprintf('The definition has no argument named "%s"', $this->argumentIndex);
97+
} else {
98+
$message = sprintf('The definition has no argument with index %d', $this->argumentIndex);
99+
}
100+
101+
$this->fail($definition, $message);
75102
}
76103

77104
return true;
@@ -88,15 +115,23 @@ private function evaluateArgumentValue(Definition $definition, $returnResult)
88115
return false;
89116
}
90117

91-
$this->fail(
92-
$definition,
93-
sprintf(
118+
if (is_string($this->argumentIndex)) {
119+
$message = sprintf(
120+
'The value of argument named "%s" (%s) is not equal to the expected value (%s)',
121+
$this->argumentIndex,
122+
$this->exporter->export($actualValue),
123+
$this->exporter->export($this->expectedValue)
124+
);
125+
} else {
126+
$message = sprintf(
94127
'The value of argument with index %d (%s) is not equal to the expected value (%s)',
95128
$this->argumentIndex,
96129
$this->exporter->export($actualValue),
97130
$this->exporter->export($this->expectedValue)
98-
)
99-
);
131+
);
132+
}
133+
134+
$this->fail($definition, $message);
100135
}
101136

102137
return true;

PhpUnit/DefinitionIsChildOfConstraint.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Matthias\SymfonyDependencyInjectionTest\PhpUnit;
44

55
use PHPUnit\Framework\Constraint\Constraint;
6+
use Symfony\Component\DependencyInjection\ChildDefinition;
67
use Symfony\Component\DependencyInjection\Definition;
78
use Symfony\Component\DependencyInjection\DefinitionDecorator;
89

@@ -19,7 +20,7 @@ public function __construct($expectedParentServiceId)
1920

2021
public function evaluate($other, $description = '', $returnResult = false)
2122
{
22-
if (!($other instanceof Definition)) {
23+
if (!$other instanceof Definition) {
2324
throw new \InvalidArgumentException(
2425
'Expected an instance of Symfony\Component\DependencyInjection\Definition'
2526
);
@@ -46,7 +47,7 @@ public function toString()
4647

4748
private function evaluateDefinitionIsDecorator(Definition $definition, $returnResult)
4849
{
49-
if (!($definition instanceof DefinitionDecorator)) {
50+
if (!$definition instanceof ChildDefinition && !$definition instanceof DefinitionDecorator) {
5051
if ($returnResult) {
5152
return false;
5253
}
@@ -57,7 +58,7 @@ private function evaluateDefinitionIsDecorator(Definition $definition, $returnRe
5758
return true;
5859
}
5960

60-
private function evaluateDefinitionHasExpectedParentService(DefinitionDecorator $definition, $returnResult)
61+
private function evaluateDefinitionHasExpectedParentService($definition, $returnResult)
6162
{
6263
$actualParentService = $this->expectedParentServiceId;
6364

README.md

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

33
By Matthias Noback
44

5-
[![Build Status](https://secure.travis-ci.org/matthiasnoback/SymfonyDependencyInjectionTest.png)](http://travis-ci.org/matthiasnoback/SymfonyDependencyInjectionTest)
5+
[![Build Status](https://secure.travis-ci.org/SymfonyTest/SymfonyDependencyInjectionTest.png)](http://travis-ci.org/SymfonyTest/SymfonyDependencyInjectionTest)
66

77
This library contains several PHPUnit test case classes and many semantic [assertions](#list-of-assertions) which
88
you can use to functionally test your [container extensions](#testing-a-container-extension) (or "bundle extensions")

0 commit comments

Comments
 (0)