2021-05-13 21:08:55 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2021-05-14 18:57:35 +03:00
|
|
|
* PHP 7.2
|
2021-05-13 21:08:55 +03:00
|
|
|
*
|
|
|
|
* @category MockInterface
|
|
|
|
* @package Pock
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pock;
|
|
|
|
|
2021-05-21 09:38:15 +03:00
|
|
|
use Pock\Factory\ReplyFactoryInterface;
|
2021-05-13 21:08:55 +03:00
|
|
|
use Pock\Matchers\RequestMatcherInterface;
|
2021-05-20 20:56:45 +03:00
|
|
|
use Psr\Http\Message\RequestInterface;
|
2021-05-13 21:08:55 +03:00
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface MockInterface
|
|
|
|
*
|
|
|
|
* @category MockInterface
|
|
|
|
* @package Pock
|
|
|
|
*/
|
|
|
|
interface MockInterface
|
|
|
|
{
|
|
|
|
/**
|
2021-05-14 18:52:00 +03:00
|
|
|
* Registers a hit to the mock.
|
2021-05-13 21:08:55 +03:00
|
|
|
*
|
|
|
|
* @return \Pock\MockInterface
|
|
|
|
*/
|
2021-05-14 18:52:00 +03:00
|
|
|
public function registerHit(): MockInterface;
|
2021-05-13 21:08:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-05-14 18:52:00 +03:00
|
|
|
* Returns true if mock is still can be used.
|
2021-05-13 21:08:55 +03:00
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2021-05-14 18:52:00 +03:00
|
|
|
public function available(): bool;
|
2021-05-13 21:08:55 +03:00
|
|
|
|
|
|
|
/**
|
2021-05-20 20:56:45 +03:00
|
|
|
* Returns true if underlying matcher has matched provided request.
|
|
|
|
* It also returns false if matcher has matched request but hits condition is not met yet.
|
2021-05-13 21:08:55 +03:00
|
|
|
*
|
2021-05-20 20:56:45 +03:00
|
|
|
* @param \Psr\Http\Message\RequestInterface $request
|
|
|
|
*
|
|
|
|
* @return bool
|
2021-05-13 21:08:55 +03:00
|
|
|
*/
|
2021-05-20 20:56:45 +03:00
|
|
|
public function matches(RequestInterface $request): bool;
|
2021-05-13 21:08:55 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns response which should be used as mock data.
|
|
|
|
*
|
|
|
|
* @return \Psr\Http\Message\ResponseInterface|null
|
|
|
|
*/
|
|
|
|
public function getResponse(): ?ResponseInterface;
|
|
|
|
|
2021-05-21 09:38:15 +03:00
|
|
|
/**
|
|
|
|
* Returns reply factory which should be used to form the mocked response.
|
|
|
|
*
|
|
|
|
* @return \Pock\Factory\ReplyFactoryInterface|null
|
|
|
|
*/
|
|
|
|
public function getReplyFactory(): ?ReplyFactoryInterface;
|
|
|
|
|
2021-05-13 21:08:55 +03:00
|
|
|
/**
|
|
|
|
* Returns the throwable which will be thrown as mock data.
|
|
|
|
*
|
2021-05-20 20:56:45 +03:00
|
|
|
* @param \Psr\Http\Message\RequestInterface $request This request may be set into exception if possible
|
|
|
|
*
|
2021-05-13 21:08:55 +03:00
|
|
|
* @return \Throwable|null
|
|
|
|
*/
|
2021-05-20 20:56:45 +03:00
|
|
|
public function getThrowable(RequestInterface $request): ?Throwable;
|
2021-05-13 21:08:55 +03:00
|
|
|
}
|