PHPUnit, mocked interfaces, and instanceof

后端 未结 3 1891
悲哀的现实
悲哀的现实 2020-12-15 15:41

Sometimes in my code, I\'ll check to see if a particular object implements an interface:

if ($instance instanceof Interface) {};

However, c

3条回答
  •  借酒劲吻你
    2020-12-15 16:24

    Use PhpUnit function assertInstanceOf.

    Example:

    $this->assertInstanceOf(ResponseInterface::class, $signInResponse);
    

提交回复
热议问题