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

Controller_Test_Case - ensure PHPUnit invariance #2065

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lucatume
Copy link
Contributor

@lucatume lucatume commented Apr 2, 2024

This is a follow-up to the #2062 and the Event Tickets #2977 one.

This fixes an issue where, depending on the PHPUnit version (TEC uses any version between 6 and 10 depending on the project, Codeception and wp-browser version), the set-up and tear-down methods of the Controller_Test_Case would not run in consistent order. With this change the code is reasonably isoalated.

There are no existing or new tests in Common proper for this change, since it would require a meta PHPunit setup, but I've created test PRs on ET and TEC pulling this Common branch to make sure all works fine:

@lucatume lucatume self-assigned this Apr 2, 2024
*
* @var array<string,array{0: string, 1: callable, 2: int}>
*/
protected array $controller_added_filters = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.WhiteSpace.ScopeIndent.IncorrectExact
Line indented incorrectly; expected 0 tabs, found 1

/**
* Unregisters the original controller and sets up the test case.
*
* @since TBD
*
* @return void
*/
<<<<<<< Updated upstream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.PHP.Syntax.PHPSyntax
PHP syntax error: syntax error, unexpected '<<' (T_SL), expecting function (T_FUNCTION) or const (T_CONST)

protected function setUp() {
parent::setUp();

=======
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.VersionControl.GitMergeConflict.DelimiterFound
Merge conflict boundary found; type: delimiter

protected function setUp() {
parent::setUp();

=======
protected function set_up_controller_test_case(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.WhiteSpace.ScopeIndent.IncorrectExact
Line indented incorrectly; expected 0 tabs, found 1

protected function setUp() {
parent::setUp();

=======
protected function set_up_controller_test_case(): void {
>>>>>>> Stashed changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.VersionControl.GitMergeConflict.CloserFound
Merge conflict boundary found; type: closer

@@ -255,7 +284,11 @@
0,
$added_filters,
'The controller should have removed all its filters and actions: '
<<<<<<< Updated upstream
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.WhiteSpace.ScopeIndent.Incorrect
Line indented incorrectly; expected at least 2 tabs, found 0

. PHP_EOL . json_encode( $added_filters, JSON_PRETTY_PRINT )
=======
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.VersionControl.GitMergeConflict.DelimiterFound
Merge conflict boundary found; type: delimiter

. PHP_EOL . json_encode( $added_filters, JSON_PRETTY_PRINT )
=======
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.WhiteSpace.ScopeIndent.Incorrect
Line indented incorrectly; expected at least 2 tabs, found 0

. PHP_EOL . json_encode( $added_filters, JSON_PRETTY_PRINT )
=======
. PHP_EOL . wp_json_encode( $this->controller_added_filters, JSON_PRETTY_PRINT )
>>>>>>> Stashed changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.VersionControl.GitMergeConflict.CloserFound
Merge conflict boundary found; type: closer

. PHP_EOL . json_encode( $added_filters, JSON_PRETTY_PRINT )
=======
. PHP_EOL . wp_json_encode( $this->controller_added_filters, JSON_PRETTY_PRINT )
>>>>>>> Stashed changes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Generic.WhiteSpace.ScopeIndent.Incorrect
Line indented incorrectly; expected at least 2 tabs, found 0

@lucatume lucatume force-pushed the test/controller-test-case-invariance branch from ce282ea to d395ff2 Compare April 2, 2024 10:10
callable $callback,
int $priority = 10,
int $args = 1
) use ( $controller_class, &$added_filters ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine
Multi-line use declarations must define one parameter per line

string $tag,
callable $callback,
int $priority = 10
) use ( $controller_class, &$added_filters ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
Squiz.Functions.MultiLineFunctionDeclaration.UseOneParamPerLine
Multi-line use declarations must define one parameter per line

@lucatume lucatume added the hold Status: on hold–do not proceed with other status items. label Apr 2, 2024
@Camwyn Camwyn changed the base branch from release/B24.dipper to master April 10, 2024 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hold Status: on hold–do not proceed with other status items.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants