Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ jobs:
php:
- '8.1'
- '8.2'
- '8.3'
dependency:
- ''
symfony:
- '5.4.*'
- '6.2.*'
- '6.3.*'
- '6.4.*'
- '7.0.*'
include:
- php: '8.1'
symfony: '5.4.*'
dependency: 'lowest'
exclude:
- php: '8.1'
symfony: '7.0.*'
fail-fast: false
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/SimpleConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class SimpleConfiguration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('simple');
$rootNode = $treeBuilder->getRootNode();
Expand Down
20 changes: 10 additions & 10 deletions Tests/PhpUnit/ContainerHasParameterConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@ class ContainerHasParameterConstraintTest extends TestCase
{
/**
* @test
*
* @dataProvider containerBuilderProvider
*/
public function match(
ContainerInterface $container,
array $containerParameters,
$parameterName,
$parameterValue,
$checkParameterValue,
$expectedToMatch
): void {
$container = $this->createMockContainerWithParameters($containerParameters);
$constraint = new ContainerHasParameterConstraint($parameterName, $parameterValue, $checkParameterValue);

$this->assertSame($expectedToMatch, $constraint->evaluate($container, '', true));
}

public function containerBuilderProvider()
public static function containerBuilderProvider()
{
$emptyContainer = $this->createMockContainerWithParameters([]);

$parameterName = 'parameter_name';
$parameterValue = 'some value';
$wrongParameterValue = 'some other value';

return [
// the container does not have the parameter
[$emptyContainer, $parameterName, $parameterValue, true, false],
[[], $parameterName, $parameterValue, true, false],
// the container has the parameter but the values don't match
[$this->createMockContainerWithParameters([$parameterName => $parameterValue]), $parameterName, $wrongParameterValue, true, false],
[[$parameterName => $parameterValue], $parameterName, $wrongParameterValue, true, false],
// the container has the parameter and the value matches
[$this->createMockContainerWithParameters([$parameterName => $parameterValue]), $parameterName, $parameterValue, true, true],
[[$parameterName => $parameterValue], $parameterName, $parameterValue, true, true],
// the container has the parameter and the value is optional
[$this->createMockContainerWithParameters([$parameterName => $parameterValue]), $parameterName, null, false, true],
[[$parameterName => $parameterValue], $parameterName, null, false, true],
];
}

Expand All @@ -49,14 +49,14 @@ private function createMockContainerWithParameters(array $parameters)
$container = $this->createMock(ContainerInterface::class);

$container
->expects($this->any())
->expects(self::any())
->method('hasParameter')
->willReturnCallback(function ($parameterName) use ($parameters) {
return array_key_exists($parameterName, $parameters);
});

$container
->expects($this->any())
->expects(self::any())
->method('getParameter')
->willReturnCallback(function ($parameterName) use ($parameters) {
return $parameters[$parameterName];
Expand Down
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "matthiasnoback/symfony-dependency-injection-test",
"type": "library",
"description": "Library for testing user classes related to the Symfony Dependency Injection Component",
"keywords": ["symfony2", "dependency injection", "phpunit"],
"homepage": "http://github.com/matthiasnoback/SymfonyDependencyInjectionTest",
"keywords": ["symfony2", "dependency injection", "phpunit", "dev"],
"homepage": "https://github.com/matthiasnoback/SymfonyDependencyInjectionTest",
"license": "MIT",
"authors": [
{
Expand All @@ -15,9 +15,9 @@
"require": {
"php": "^8.1",
"matthiasnoback/symfony-config-test": "^5.0",
"symfony/dependency-injection": "^5.4 || ^6.2",
"symfony/config": "^5.4 || ^6.2",
"symfony/yaml": "^5.4 || ^6.2"
"symfony/dependency-injection": "^5.4 || ^6.2 || ^7.0",
"symfony/config": "^5.4 || ^6.2 || ^7.0",
"symfony/yaml": "^5.4 || ^6.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^10.0"
Expand All @@ -36,5 +36,7 @@
"branch-alias": {
"dev-master": "5.0.x-dev"
}
}
},
"minimum-stability": "dev",
"prefer-stable": true
}