PHP Velho Oeste 2024

uopz_get_mock

(PECL uopz 5, PECL uopz 6, PECL uopz 7)

uopz_get_mockGet the current mock for a class

説明

uopz_get_mock(string $class): mixed

Returns the current mock for class.

パラメータ

class

The name of the mocked class.

戻り値

Either a string containing the name of the mock, or an object, or null if no mock has been set.

例1 uopz_get_mock() example

<?php
class A {
public static function
who() {
echo
"A";
}
}

class
mockA {
public static function
who() {
echo
"mockA";
}
}

uopz_set_mock(A::class, mockA::class);
echo
uopz_get_mock(A::class);
?>

上の例の出力は以下となります。

mockA

参考

  • uopz_set_mock() - 新しいオブジェクトを生成する際に、クラスの代わりにモックを使う
  • uopz_unset_mock() - 以前に設定したモックを削除する
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top