Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpunit 12 support #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,11 @@ public function processed_configuration_for_array_node_1(): void

## Version Guidance

| Version | Released | PHPUnit | Status |
|---------|--------------| ----------------------|------------|
| 5.x | Jun 2, 2023 | 9.6 and 10.x and 11.x | Latest |
| 4.x | Mar 5, 2018 | 7.x and 8.x and 9.x | Bugfixes |
| 3.x | Nov 30, 2017 | 6.x   | EOL |
| 2.x | Jun 18, 2016 | 4.x and 5.x | EOL |
| 1.x | Oct 12, 2014 | 3.x | EOL |
| Version | Released | PHPUnit | Status |
|---------|--------------|------------------------|----------|
| 6.x | Feb 7, 2025 | 10.5 and 11.x and 12.x | Latest |
| 5.x | Jun 2, 2023 | 9.6 and 10.x and 11.x | Bugfixes |
| 4.x | Mar 5, 2018 | 7.x and 8.x and 9.x | EOL |
| 3.x | Nov 30, 2017 | 6.x | EOL |
| 2.x | Jun 18, 2016 | 4.x and 5.x | EOL |
| 1.x | Oct 12, 2014 | 3.x | EOL |
25 changes: 7 additions & 18 deletions Tests/Partial/PartialNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
use Matthias\SymfonyConfigTest\Partial\Exception\ChildIsNotAnArrayNode;
use Matthias\SymfonyConfigTest\Partial\Exception\UndefinedChildNode;
use Matthias\SymfonyConfigTest\Partial\PartialNode;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\ArrayNode;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\PrototypedArrayNode;

class PartialNodeTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_strips_children_that_are_not_in_the_given_path_with_one_name()
{
$treeBuilder = new TreeBuilder('root');
Expand All @@ -39,9 +38,7 @@ public function it_strips_children_that_are_not_in_the_given_path_with_one_name(
$this->nodeOnlyHasChild($node, 'node_2');
}

/**
* @test
*/
#[Test]
public function it_strips_children_that_are_not_in_the_given_path_with_several_names()
{
$treeBuilder = new TreeBuilder('root');
Expand Down Expand Up @@ -77,9 +74,7 @@ public function it_strips_children_that_are_not_in_the_given_path_with_several_n
$this->nodeOnlyHasChild($node1, 'node_1_b');
}

/**
* @test
*/
#[Test]
public function it_strips_children_when_leaf_node_is_not_an_array()
{
$treeBuilder = new TreeBuilder('root');
Expand All @@ -104,9 +99,7 @@ public function it_strips_children_when_leaf_node_is_not_an_array()
$this->nodeOnlyHasChild($node, 'node_3');
}

/**
* @test
*/
#[Test]
public function it_does_not_crash_on_prototypes()
{
$treeBuilder = new TreeBuilder('root');
Expand Down Expand Up @@ -134,9 +127,7 @@ public function it_does_not_crash_on_prototypes()
$this->nodeOnlyHasChild($prototypeNode, 'node_1');
}

/**
* @test
*/
#[Test]
public function it_fails_when_a_requested_child_node_does_not_exist()
{
$treeBuilder = new TreeBuilder('root');
Expand All @@ -155,9 +146,7 @@ public function it_fails_when_a_requested_child_node_does_not_exist()
PartialNode::excludeEverythingNotInPath($node, ['sub_node', 'non_existing_node']);
}

/**
* @test
*/
#[Test]
public function it_fails_when_a_requested_child_node_is_no_array_node_itself_and_path_not_empty()
{
$treeBuilder = new TreeBuilder('root');
Expand Down
9 changes: 3 additions & 6 deletions Tests/Partial/PartialProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use Matthias\SymfonyConfigTest\Partial\PartialProcessor;
use Matthias\SymfonyConfigTest\Tests\Partial\Fixtures\ConfigurationStub;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;

class PartialProcessorTest extends TestCase
{
/**
* @test
*/
#[Test]
public function it_processes_only_the_values_in_the_breadcrumb_path_for_a_given_node()
{
$treeBuilder = new TreeBuilder('root');
Expand Down Expand Up @@ -56,9 +55,7 @@ public function it_processes_only_the_values_in_the_breadcrumb_path_for_a_given_
);
}

/**
* @test
*/
#[Test]
public function it_processes_only_the_values_in_the_given_breadcrumb_path_for_a_given_configuration_instance()
{
$partialProcessor = new PartialProcessor();
Expand Down
29 changes: 8 additions & 21 deletions Tests/PhpUnit/ConfigurationTestCaseTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\ConfigurationWithRequiredValue;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\ExpectationFailedException;
use PHPUnit\Framework\TestCase;

Expand All @@ -16,9 +17,7 @@ protected function getConfiguration()
return new ConfigurationWithRequiredValue();
}

/**
* @test
*/
#[Test]
public function it_can_assert_that_a_configuration_is_invalid()
{
$this->assertConfigurationIsInvalid(
Expand All @@ -29,9 +28,7 @@ public function it_can_assert_that_a_configuration_is_invalid()
);
}

/**
* @test
*/
#[Test]
public function it_fails_when_a_configuration_is_valid_when_it_should_have_been_invalid()
{
$this->expectException(ExpectationFailedException::class);
Expand All @@ -44,9 +41,7 @@ public function it_fails_when_a_configuration_is_valid_when_it_should_have_been_
);
}

/**
* @test
*/
#[Test]
public function it_can_assert_that_a_configuration_is_valid()
{
$this->assertConfigurationIsValid(
Expand All @@ -56,9 +51,7 @@ public function it_can_assert_that_a_configuration_is_valid()
);
}

/**
* @test
*/
#[Test]
public function it_fails_when_a_configuration_is_invalid_when_it_should_have_been_valid()
{
$this->expectException(ExpectationFailedException::class);
Expand All @@ -72,9 +65,7 @@ public function it_fails_when_a_configuration_is_invalid_when_it_should_have_bee
);
}

/**
* @test
*/
#[Test]
public function it_can_assert_that_a_processed_configuration_matches_the_expected_array_of_values()
{
$value = 'some value';
Expand All @@ -90,9 +81,7 @@ public function it_can_assert_that_a_processed_configuration_matches_the_expecte
);
}

/**
* @test
*/
#[Test]
public function it_fails_when_a_processed_configuration_does_not_match_the_expected_array_of_values()
{
$value = 'some value';
Expand All @@ -110,9 +99,7 @@ public function it_fails_when_a_processed_configuration_does_not_match_the_expec
);
}

/**
* @test
*/
#[Test]
public function it_throws_a_comparison_failed_exception_with_the_values_in_the_right_order()
{
$value = 'some value';
Expand Down
37 changes: 10 additions & 27 deletions Tests/PhpUnit/ConfigurationValuesAreInvalidConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationValuesAreInvalidConstraint;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\AlwaysValidConfiguration;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\ConfigurationWithRequiredValue;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class ConfigurationValuesAreInvalidConstraintTest extends TestCase
{
/**
* @test
*/
#[Test]
public function if_configuration_values_is_no_array_it_fails()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(new AlwaysValidConfiguration());
Expand All @@ -22,9 +21,7 @@ public function if_configuration_values_is_no_array_it_fails()
$constraint->evaluate('not an array');
}

/**
* @test
*/
#[Test]
public function if_configuration_values_is_no_array_of_arrays_it_fails()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(new AlwaysValidConfiguration());
Expand All @@ -35,29 +32,23 @@ public function if_configuration_values_is_no_array_of_arrays_it_fails()
$constraint->evaluate(['not an array']);
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_valid_it_does_not_match()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(new AlwaysValidConfiguration());

$this->assertFalse($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_invalid_it_matches()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(new ConfigurationWithRequiredValue());

$this->assertTrue($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_invalid_it_does_not_match_when_exception_message_is_not_right()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(
Expand All @@ -68,9 +59,7 @@ public function if_configuration_values_are_invalid_it_does_not_match_when_excep
$this->assertFalse($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_invalid_it_matches_when_exception_message_is_right()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(
Expand All @@ -81,9 +70,7 @@ public function if_configuration_values_are_invalid_it_matches_when_exception_me
$this->assertTrue($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_invalid_it_matches_when_exception_message_is_right_according_to_regexp()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(
Expand All @@ -95,9 +82,7 @@ public function if_configuration_values_are_invalid_it_matches_when_exception_me
$this->assertTrue($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function to_string_returns_a_message()
{
$constraint = new ConfigurationValuesAreInvalidConstraint(
Expand All @@ -107,9 +92,7 @@ public function to_string_returns_a_message()
$this->assertSame('is invalid for the given configuration', $constraint->toString());
}

/**
* @test
*/
#[Test]
public function to_string_also_mentions_the_expected_exception_message()
{
$expectedMessage = 'the expected message';
Expand Down
21 changes: 6 additions & 15 deletions Tests/PhpUnit/ConfigurationValuesAreValidConstraintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationValuesAreValidConstraint;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\AlwaysValidConfiguration;
use Matthias\SymfonyConfigTest\Tests\PhpUnit\Fixtures\ConfigurationWithRequiredValue;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;

class ConfigurationValuesAreValidConstraintTest extends TestCase
{
/**
* @test
*/
#[Test]
public function if_configuration_values_is_no_array_it_fails()
{
$constraint = new ConfigurationValuesAreValidConstraint(new AlwaysValidConfiguration());
Expand All @@ -22,9 +21,7 @@ public function if_configuration_values_is_no_array_it_fails()
$constraint->evaluate('not an array');
}

/**
* @test
*/
#[Test]
public function if_configuration_values_is_no_array_of_arrays_it_fails()
{
$constraint = new ConfigurationValuesAreValidConstraint(new AlwaysValidConfiguration());
Expand All @@ -35,29 +32,23 @@ public function if_configuration_values_is_no_array_of_arrays_it_fails()
$constraint->evaluate(['not an array']);
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_valid_it_matches()
{
$constraint = new ConfigurationValuesAreValidConstraint(new AlwaysValidConfiguration());

$this->assertTrue($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function if_configuration_values_are_invalid_it_does_not_match()
{
$constraint = new ConfigurationValuesAreValidConstraint(new ConfigurationWithRequiredValue());

$this->assertFalse($constraint->evaluate([[]], '', true));
}

/**
* @test
*/
#[Test]
public function to_string_returns_a_message()
{
$constraint = new ConfigurationValuesAreValidConstraint(new AlwaysValidConfiguration());
Expand Down
Loading