Unable to mock function to return an empty array.
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 停滞
- 技術スタック
- php
- 領域
- testing-qa
調査の方向性
tests/php/SubscriptionsTest.php の縮小したテストから始め、報告されている PHP および PHPUnit のバージョンで phpunit --filter test_return_empty_array を実行します。失敗に示されている WP_Mock のテストパス、特に vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php を通じてモックされた呼び出しを追跡します。テストが NULL ではなく空の配列を受け取り、設定された戻り値の型を維持すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
In Distributor, I am attempting to mock a function to return an empty array:
However, the return value is coming back as NULL.
As an alternative approach, I've tried setting the return attribute as a callable function(){ return []; } but the same issue occurs.
To Reproduce
- As a reduced test case, create the test:
public function test_return_empty_array() { $post_id = 1; \WP_Mock::userFunction( '\Distributor\Utils\peters_test_function', [ 'return' => [], ] ); $this->assertSame( [], \Distributor\Utils\peters_test_function( $post_id ) ); } - Run
phpunit --filter test_return_empty_array - PHP Unit will throw a failure:
PHPUnit 8.5.26 #StandWithUkraine F 1 / 1 (100%) Time: 2.11 seconds, Memory: 18.00 MB There was 1 failure: 1) Distributor\SubscriptionsTest::test_return_empty_array Failed asserting that null is identical to Array &0 (). /vagrant/content/plugins/distributor/tests/php/SubscriptionsTest.php:18 /vagrant/content/plugins/distributor/vendor/10up/wp_mock/php/WP_Mock/Tools/TestCase.php:307 phpvfscomposer:///vagrant/content/plugins/distributor/vendor/phpunit/phpunit/phpunit:97
Expected behavior
Returned values retain type.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- PHPUnit 8.5.26
- PHP 7.4.30
- OS: Ubuntu 22.04 LTS
Additional context
- 主要言語
- PHP
- スター
- 714
- フォーク
- 72
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
10up/wp_mock のほかの issue
-
`expectActionAdded( array( Functions::type( class-string ), 'method' ) )` fails when same method name used twice対応中かも @faisalahammad が 126 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
-
PHPCS reporting error on dependent library nikic/php-parser, hamcrest/hamcrest-php対応中かも @faisalahammad が 126 日前に担当しました。 オープンDependencies
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
-
Request: control Strict Mode per test対応中かも @BrianHenryIE が 311 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
-
Pass in Closure for Hooks対応中かも @faisalahammad が 126 日前に担当しました。 オープンEnhancement Question
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
Dependencies PHPUnit
難易度 5/5 1週間以上 初心者へのやさしさ 30/100
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 10 日以内に返信
-
help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
freescout-help-desk/freescout#5837 ·
メンテナーはふだん 1 日以内に返信
-
area: content refactoring
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
nplhse/collaborative-ivena-statistics#1530 ·
メンテナーはふだん 1 日以内に返信
-
sync-en
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
Implement parse_url and accept http URLs for PECL backend対応中かも @patelshivani2283-lab が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
fedora-infra/anitya#2218 ·
メンテナーはふだん 2 日以内に返信