• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In
Info updated!

10up / wp_mock
66%
master: 52%

Build:
Build:
LAST BUILD BRANCH: trunk
DEFAULT BRANCH: master
Repo Added 03 Dec 2017 06:54PM UTC
Files 22
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

LAST BUILD ON BRANCH trunk
branch: trunk
CHANGE BRANCH
x
Reset
  • trunk
  • chore/fix-gh-actions
  • chore/update-changelog-v1.1
  • dependabot/composer/composer-65e32c6de6
  • dev
  • feat/add-support-for-types-in-expect-filter-mocks
  • feat/add-with-anything-method-for-on-filter
  • fix/multiple-onfilter-call-issues-related-to-withanyargs-method
  • master

17 Mar 2025 02:27PM UTC coverage: 66.142% (+0.1%) from 66.01%
13901966852

push

github

web-flow
Fix: Multiple `onFilter` call issues related to the `withAnyArgs` method (#259)

# Summary <!-- Required -->

This PR implements a fix for an issue I discovered when using multiple
`onFilter` calls with the `withAnyArgs` method.

<img width="807" alt="Screenshot 2025-03-12 at 18 47 52"
src="https://github.com/user-attachments/assets/3c1bb38a-830a-4a4a-907c-a61b7f0d8e11"
/>

### Closes: #258 

## Details <!-- Optional -->

While writing some unit test cases using the `withAnyArgs` method, I
came across issues for multiple `onFilter` calls introduced into the
tests. At the moment, if a single `onFilter` call is used alongside
`withAnyArgs`, it works correctly, but for multiple cases, it doesn't
correctly pass the tests. The expected behaviour should be that this
works for both single and multiple use cases using the `withAnyArgs`.

This PR fixes this issue correctly.

<img width="587" alt="Screenshot 2025-03-12 at 19 42 19"
src="https://github.com/user-attachments/assets/46cfd651-62a7-455b-9b58-257d38a78b84"
/>

---

Run tests:

```php
vendor/bin/phpunit ./tests/Unit/WP_MockTest.php 
```

## Contributor checklist <!-- Required -->

- [x] I agree to follow this project's [**Code of
Conduct**](https://github.com/10up/.github/blob/trunk/CODE_OF_CONDUCT.md).
- [x] I have updated the documentation accordingly 
- [x] I have added tests to cover changes introduced by this pull
request
- [x] All new and existing tests pass

## Testing <!-- Required -->

```php
public function testMultipleOnFilterPassesWithAnyArgs(): void
{
    WP_Mock::bootstrap();

    /** @phpstan-ignore-next-line */
    WP_Mock::onFilter('testFilter1')
        ->withAnyArgs()
        ->reply('Filtered value 1');

    /** @phpstan-ignore-next-line */
    WP_Mock::onFilter('testFilter2')
        ->withAnyArgs()
        ->reply('Filtered value 2');

    /** @phpstan-ignore-next-line */
    WP_Mock::onFilter('testFilter3')
        ->withAnyArgs()
        ->reply('Filtered value 3');

    $filter... (continued)

0 of 2 new or added lines in 1 file covered. (0.0%)

504 of 762 relevant lines covered (66.14%)

2.68 hits per line

Relevant lines Covered
Build:
Build:
762 RELEVANT LINES 504 COVERED LINES
2.68 HITS PER LINE
Source Files on trunk
  • Tree
  • List 22
  • Changed 1
  • Source Changed 0
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
13901966852 trunk Fix: Multiple `onFilter` call issues related to the `withAnyArgs` method (#259) # Summary <!-- Required --> This PR implements a fix for an issue I discovered when using multiple `onFilter` calls with the `withAnyArgs` method. <img width="807" ... push 17 Mar 2025 02:28PM UTC web-flow github
66.14
13801039158 trunk Add changelog for v1.1.0 (#257) # Summary <!-- Required --> This updates the changelog prior to tagging the `1.1.0` release. ## Contributor checklist <!-- Required --> - [x] I agree to follow this project's [**Code of Conduct**](https://github... push 12 Mar 2025 12:36AM UTC web-flow github
66.01
13787664706 trunk Bump symfony/process from 5.4.28 to 5.4.46 in the composer group (#252) Bumps the composer group with 1 update: [symfony/process](https://github.com/symfony/process). Updates `symfony/process` from 5.4.28 to 5.4.46 <details> <summary>Release not... push 11 Mar 2025 12:10PM UTC web-flow github
66.01
13787625687 trunk Add support for `withAnyArgs` method for `onFilter` calls. (#256) # Summary <!-- Required --> This PR implements a new method called `withAnyArgs` for `onFilter` calls. This method is particularly useful in test cases where we do not care about ... push 11 Mar 2025 12:08PM UTC web-flow github
66.01
13706662543 trunk Fix: GitHub workflows broken due to outdated versions / OS (#255) # Summary <!-- Required --> Updates the versions used for various actions to address: > Error: This request has been automatically failed because it uses a deprecated version of ... push 06 Mar 2025 07:32PM UTC web-flow github
66.45
10296049395 trunk Fix typos (#250) # Summary <!-- Required --> Found misspellings in docs and in function name. ## Contributor checklist <!-- Required --> - [ ] I agree to follow this project's [**Code of Conduct**](https://github.com/10up/.github/blob/t... push 08 Aug 2024 04:41AM UTC web-flow github
66.31
9711864001 trunk Ignore throws in function mocks (#245) # Summary <!-- Required --> I have noticed that in some circumstances the mocks contained in `API/function-mocks.php` could trigger false positives in static analyzers like PhpStan or just the IDE if us... push 28 Jun 2024 11:12AM UTC web-flow github
66.31
7605656466 trunk Remove version from composer and update changelog.md (#242) # Summary <!-- Required --> Removes package version from composer.json. This should make packagist point to the git tags. Also updated the changelog.md to include changes from 1.0.1... push 22 Jan 2024 02:23AM UTC web-flow github
66.44
7524764186 trunk ci: Use GITHUB_OUTPUT envvar instead of set-output command (#240) `save-state` and `set-output` commands used in GitHub Actions are deprecated and [GitHub recommends using environment files](https://github.blog/changelog/2023-07-24-github-actio... push 15 Jan 2024 05:30AM UTC web-flow github
66.44
7514737426 trunk Merge 361822858 into 1bcc9a4ae Pull #240 15 Jan 2024 05:27AM UTC web-flow github
66.31
See All Builds (339)
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc