Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Expected::exactly should have ability to change callback method per times called

オープン
#30 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
php
領域
testing

調査の方向性

まず Codeception Stub リポジトリ内で Expected::exactly の実装箇所を見つけ、現在コールバックの呼び出しがどのように処理されているかを確認します。issue にある 2 つのコールバックの例を受け入れ条件として使用してください。連続する呼び出しでは異なる応答を受け取る必要があり、コールバックは返却前にアサーションを実行できる必要があります。

索引モデルが issue の本文から書いたものです。

説明

What are you trying to achieve?

Http client send method is called 2 times on a test
I would like to make different response objects for each of them
on one of them I would also like to have asserts

What do you get instead?

RN it is impossible to have different callbacks for consecutive calls

Provide console output if related. Use -vvv mode for more details.

Provide test source code if related

$oauth2Provider->setHttpClient($this->construct(Client::class, [], [
    'send' => Expected::exactly(2,
        function (RequestInterface $request) {
            return new Response(200, [
                'content-type' => 'application/json'
            ], '{"access_token": "access", "expires_in": 3600, "refresh_token": "refresh"}');
        },
        function (RequestInterface $request) {
            //assertions go here

            return new Response(200, [
            ], 'response body goes here');
        }
    ]))
]));
Details
  • Codeception version:
  • PHP Version: 7.4.6
  • Operating System: Ubuntu
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
# paste suite config here

Addittional info
RN I do this

$oauth2Provider->setHttpClient($this->construct(Client::class, [], [
    'send' => Expected::exactly(2, Closure::fromCallable(new MultiCallable([
        function (RequestInterface $request) {
            return new Response(200, [
                'content-type' => 'application/json'
            ], '{"access_token": "access", "expires_in": 3600, "refresh_token": "refresh"}');
        },
        function (RequestInterface $request) {
            //asserts go here

            return new Response(200, [
            ], 'response body goes here');
        }
    ])))
]));
<?php

class MultiCallable
{
    private $methods;

    public function __construct($methods)
    {
        $this->methods = $methods;
    }

    public function __invoke(...$args)
    {
        $method = array_shift($this->methods);

        return call_user_func_array($method, $args);
    }
}
主要言語
PHP
スター
301
フォーク
19
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Codeception/Stub のほかの issue

Codeception/Stub の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。