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

Added assertArrayIsList() #4818

Closed

Conversation

kukulich
Copy link
Contributor

No description provided.

@kukulich
Copy link
Contributor Author

@sebastianbergmann Would you accept this when I add more tests etc?

@sebastianbergmann sebastianbergmann added feature/assertion Issues related to assertions and expectations type/enhancement A new idea that should be implemented labels Nov 11, 2021
@sebastianbergmann
Copy link
Owner

@sebastianbergmann Would you accept this when I add more tests etc?

Yes.

@codecov
Copy link

codecov bot commented Nov 11, 2021

Codecov Report

Merging #4818 (0f147f5) into master (d9655c8) will increase coverage by 0.02%.
The diff coverage is 100.00%.

❗ Current head 0f147f5 differs from pull request most recent head 1e6db30. Consider uploading reports for the commit 1e6db30 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4818      +/-   ##
============================================
+ Coverage     83.57%   83.60%   +0.02%     
- Complexity     5797     5806       +9     
============================================
  Files           548      549       +1     
  Lines         15596    15617      +21     
============================================
+ Hits          13035    13056      +21     
  Misses         2561     2561              
Impacted Files Coverage Δ
src/Framework/Assert.php 91.31% <100.00%> (+0.08%) ⬆️
...c/Framework/Constraint/Traversable/ArrayIsList.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9655c8...1e6db30. Read the comment docs.

@kukulich kukulich force-pushed the assert-array-is-list branch 2 times, most recently from 3cb32f6 to 0f147f5 Compare November 11, 2021 12:15
@kukulich kukulich marked this pull request as ready for review November 11, 2021 12:17
@kukulich
Copy link
Contributor Author

It looks the fail of type checker is not related to this patch.

@sebastianbergmann
Copy link
Owner

It looks the fail of type checker is not related to this patch.

I'll look into this.

if ($other === []) {
return true;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (function_exists('array_is_list')) {
return array_is_list($other);
}

On PHP 8.1, we have a native function for that. I suggest we leverage it if it's available.

sebastianbergmann added a commit that referenced this pull request Dec 18, 2021
Suggested by Alexander M. Turek <me@derrabus.de> in #4818 (review)
@sebastianbergmann
Copy link
Owner

Merged manually. Thanks!

jrfnl added a commit to Yoast/PHPUnit-Polyfills that referenced this pull request Mar 30, 2023
…method

PHPUnit 10.0.0 introduces the new `Assert::assertIsList()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Functional tests for the functionality polyfilled.

Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.

Includes:
* Adding the new polyfill to the existing `TestCases` classes and adding a test for the polyfill availability to the `TestCaseTestTrait`.

Refs:
* sebastianbergmann/phpunit#4818
* sebastianbergmann/phpunit@71f5074
* sebastianbergmann/phpunit@e04a947
* sebastianbergmann/phpunit@2bc1aea

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
jrfnl added a commit to Yoast/PHPUnit-Polyfills that referenced this pull request Mar 30, 2023
…method

PHPUnit 10.0.0 introduces the new `Assert::assertIsList()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Functional tests for the functionality polyfilled.

Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.

Includes:
* Adding the new polyfill to the existing `TestCases` classes and adding a test for the polyfill availability to the `TestCaseTestTrait`.

Refs:
* sebastianbergmann/phpunit#4818
* sebastianbergmann/phpunit@71f5074
* sebastianbergmann/phpunit@e04a947
* sebastianbergmann/phpunit@2bc1aea

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
jrfnl added a commit to Yoast/PHPUnit-Polyfills that referenced this pull request Mar 30, 2023
…method

PHPUnit 10.0.0 introduces the new `Assert::assertIsList()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Functional tests for the functionality polyfilled.

Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.

Includes:
* Adding the new polyfill to the existing `TestCases` classes and adding a test for the polyfill availability to the `TestCaseTestTrait`.

Refs:
* sebastianbergmann/phpunit#4818
* sebastianbergmann/phpunit@71f5074
* sebastianbergmann/phpunit@e04a947
* sebastianbergmann/phpunit@2bc1aea

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
jrfnl added a commit to Yoast/PHPUnit-Polyfills that referenced this pull request Apr 1, 2023
…method

PHPUnit 10.0.0 introduces the new `Assert::assertIsList()` method.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* Functional tests for the functionality polyfilled.

Note: the methods use `static::` to call the PHPUnit native functionality. This allows for existing method overloads in a child class of the PHPUnit native `TestCase` to be respected.

Includes:
* Adding the new polyfill to the existing `TestCases` classes and adding a test for the polyfill availability to the `TestCaseTestTrait`.

Refs:
* sebastianbergmann/phpunit#4818
* sebastianbergmann/phpunit@71f5074
* sebastianbergmann/phpunit@e04a947
* sebastianbergmann/phpunit@2bc1aea

Co-authored-by: Jaroslav Hanslík <kukulich@kukulich.cz>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/assertion Issues related to assertions and expectations type/enhancement A new idea that should be implemented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants