{"id":322112,"date":"2021-04-26T15:01:19","date_gmt":"2021-04-26T15:01:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=322112"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=322112","title":{"rendered":"\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u043e\u043a\u0430\u043c\u0438 \u0432 PHPUnit 10"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e9f\/28e\/728\/e9f28e728c8eb9f58c391fe56f0c318e.png\" width=\"4001\" height=\"2101\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0439\u0442\u0438 PHPUnit 10 (\u0440\u0435\u043b\u0438\u0437 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 2 \u0430\u043f\u0440\u0435\u043b\u044f 2021 \u0433\u043e\u0434\u0430, \u043d\u043e \u0431\u044b\u043b \u043e\u0442\u043b\u043e\u0436\u0435\u043d). \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/blob\/master\/ChangeLog-10.0.md\">\u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/a>, \u0442\u043e \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>MockBuilder::setMethods()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u043e\u043a\u0430\u043c\u0438. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 8.0, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u043d \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 \u0438 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u043e \u0435\u0433\u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 PHPUnit, issues \u0438 \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b \u043d\u0430 GitHub, \u0442\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0441\u0432\u0435\u0449\u0443 \u044d\u0442\u043e\u0442 \u043d\u044e\u0430\u043d\u0441 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u043b \u043d\u0430 \u043d\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u043d\u044c\u0448\u0435: \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 setMethods, \u043f\u0443\u0442\u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 PHPUnit 10.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438?<\/h3>\n<p>\u0423 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0438\u0448\u0435\u043c, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u044b \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430 \u043a\u043e\u0434\u0430 \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u0438 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u043a\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 &#171;\u043c\u043e\u043a&#187;<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439: \u043c\u043e\u043a, mock-\u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f. \u042f \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043b\u044c\u043a\u043e\u0439 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 mock (\u043c\u043e\u043a).<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0443\u0442\u044c \u043c\u043e\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>PHPUnit \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <a href=\"https:\/\/phpunit.readthedocs.io\/ru\/latest\/test-doubles.html\">\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u043a\u0430\u043c\u0438<\/a>. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u043a\u043e\u0432 (partial mocks), \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u043c\u043e\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435).<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u0433\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u043c\u043e\u043a\u0438.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u043e\u0434 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u043a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb:<\/p>\n<pre><code class=\"php\">abstract class AbstractCommand {     \/**      * @throws \\PhpUnitMockDemo\\CommandException      * @return void      *\/     abstract protected function execute(): void;      public function run(): bool     {         $success = true;         try {             $this-&gt;execute();         } catch (\\Exception $e) {             $success = false;             $this-&gt;logException($e);         }          return $success;     }      protected function logException(\\Exception $e)     {         \/\/ Logging     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 execute \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>run()<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 exception safe \u0438 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>run<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u043e\u043a\u0430\u043c\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <code>PHPUnit\\Framework\\MockObject\\MockBuilder<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 TestCase (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e <code>getMockBuilder<\/code> \u0438 <code>createPartialMock<\/code>):<\/p>\n<pre><code class=\"php\">use PHPUnit\\Framework\\TestCase;  class AbstractCommandTest extends TestCase {     public function testRunOnSuccess()     {         \/\/ Arrange         $command = $this-&gt;getMockBuilder(AbstractCommand::class)             -&gt;setMethods(['execute', 'logException'])             -&gt;getMock();         $command-&gt;expects($this-&gt;once())-&gt;method('execute');         $command-&gt;expects($this-&gt;never())-&gt;method('logException');          \/\/ Act         $result = $command-&gt;run();          \/\/ Assert         $this-&gt;assertTrue($result, \"True result is expected in the success case\");     }      public function testRunOnFailure()     {         \/\/ Arrange         $runException = new CommandException();          \/\/ It's an analogue of $this-&gt;getMockBuilder(...)-&gt;setMethods([...])-&gt;getMock()         $command = $this-&gt;createPartialMock(AbstractCommand::class, ['execute', 'logException']);         $command-&gt;expects($this-&gt;once())             -&gt;method('execute')             -&gt;will($this-&gt;throwException($runException));         $command-&gt;expects($this-&gt;once())             -&gt;method('logException')             -&gt;with($runException);          \/\/ Act         $result = $command-&gt;run();          \/\/ Assert         $this-&gt;assertFalse($result, \"False result is expected in the failure case\");     } } <\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example1\/tests\/AbstractCommandTest.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, <a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/actions\/runs\/761025993\">\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/a><\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>testRunOnSuccess<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>MockBuilder::setMethods()<\/code> \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c (\u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c). \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0437 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>AbstractCommand<\/code> (\u0438 \u0438\u0445 \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c). \u0412 <code>testRunOnFailure<\/code> \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>createPartialMock<\/code> \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u044f\u0432\u043d\u043e.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0441\u0451 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u043c\u043e\u043a\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0432 \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0445 \u0432\u044b\u0437\u043e\u0432 \u0438\u043b\u0438 \u043d\u0435\u0432\u044b\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>expects<\/code>. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432:&nbsp;<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438\u043b\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445);<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u044e\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u0435\u0448\u0430 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u0438 \u0442. \u0434.);<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0430\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0442 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0442\u0435\u0441\u0442\u044b \u0445\u0440\u0443\u043f\u043a\u0438\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u0434\u0430).<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, <code>MockBulder::setMethods()<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u043a\u0430 \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043a\u043e\u0434\u0435 \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e\u00bb \u043c\u0435\u0442\u043e\u0434\u0430 <code>__call<\/code>.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/predis\/predis\/blob\/main\/src\/Client.php\">\\Predis\\Client<\/a>. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>__call<\/code> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u043c\u043e\u043a\u0435 \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u043a\u043e\u0434\u0435 \u043c\u0435\u0442\u043e\u0434, \u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <code>__call<\/code>, \u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">   public function testRedisHandle()     {         if (!class_exists('Redis')) {             $this-&gt;markTestSkipped('The redis ext is required to run this test');         }          $redis = $this-&gt;createPartialMock('Redis', ['rPush']);          \/\/ Redis uses rPush         $redis-&gt;expects($this-&gt;once())             -&gt;method('rPush')             -&gt;with('key', 'test');          $record = $this-&gt;getRecord(Logger::WARNING, 'test', ['data' =&gt; new \\stdClass, 'foo' =&gt; 34]);          $handler = new RedisHandler($redis, 'key');         $handler-&gt;setFormatter(new LineFormatter(\"%message%\"));         $handler-&gt;handle($record);     } <\/code><\/pre>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a href=\"https:\/\/github.com\/Seldaek\/monolog\/blob\/2.2.0\/tests\/Monolog\/Handler\/RedisHandlerTest.php\">\u0442\u0435\u0441\u0442 RedisHandlerTest \u0438\u0437 monolog 2.2.0<\/a><\/p>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 setMethods?<\/h3>\n<p>\u0414\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043c\u043e\u043a\u0430\u0445 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0435\u0437 expectations, \u0442\u043e \u043f\u0440\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c (\u0445\u043e\u0442\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0436\u0435 \u043d\u0435\u0442 \u0438 \u0432 \u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043a \u043c\u043e\u043a\u0443 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430).<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">--- a\/src\/AbstractCommand.php +++ b\/src\/AbstractCommand.php @@ -13,6 +13,7 @@ abstract class AbstractCommand       public function run(): bool      { +        $this-&gt;timerStart();          $success = true;          try {              $this-&gt;execute(); @@ -21,6 +22,7 @@ abstract class AbstractCommand              $this-&gt;logException($e);          }  +        $this-&gt;timerStop();          return $success;      }  @@ -28,4 +30,14 @@ abstract class AbstractCommand      {          \/\/ Logging      } + +    protected function timerStart() +    { +        \/\/ Timer implementation +    } + +    protected function timerStop() +    { +        \/\/ Timer implementation +    }  } <\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example2\/src\/AbstractCommand.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<p>\u0412 \u043a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u043e\u043a \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0447\u0435\u0440\u0435\u0437 <em>expectations<\/em>:<\/p>\n<pre><code class=\"php\">--- a\/tests\/AbstractCommandTest.php +++ b\/tests\/AbstractCommandTest.php @@ -11,7 +11,7 @@ class AbstractCommandTest extends TestCase      {          \/\/ Arrange          $command = $this-&gt;getMockBuilder(AbstractCommand::class) -            -&gt;setMethods(['execute', 'logException']) +            -&gt;setMethods(['execute', 'logException', 'timerStart', 'timerStopt']) \/\/ timerStopt is a typo              -&gt;getMock();          $command-&gt;expects($this-&gt;once())-&gt;method('execute');          $command-&gt;expects($this-&gt;never())-&gt;method('logException');<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example2\/tests\/AbstractCommandTest.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, <a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/actions\/runs\/761045115\">\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/a><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0432 PHPUnit \u0432\u0435\u0440\u0441\u0438\u0439 8.5 \u0438\u043b\u0438 9.5, \u0442\u043e \u043e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"php\">PHPUnit 9.5.0 by Sebastian Bergmann and contributors.  .                                                                   1 \/ 1 (100%)  Time: 00:00.233, Memory: 6.00 MB  OK (1 test, 2 assertions) <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440,&nbsp; \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c expectations \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438 \u043c\u043d\u0435 \u043d\u0435 \u0440\u0430\u0437 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430\u0442\u044b\u043a\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043c\u043e\u043a\u0430\u0445.<\/p>\n<blockquote>\n<p>\u0415\u0449\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>MockBuilder::setMethodsExcept<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u0440\u043e\u043c\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/blockquote>\n<h2>\u041a\u0430\u043a \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0432 PHPUnit 10?<\/h2>\n<p>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00ab\u043c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u043e\u0433\u043e\u00bb \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u0432 2019 \u0433\u043e\u0434\u0443 \u0432 <a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/pull\/3687\">\u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u0435 #3687<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0448\u0451\u043b \u0432 \u0440\u0435\u043b\u0438\u0437 PHPUnit 8.<\/p>\n<p>\u0412 MockBuilder \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 <code>onlyMethods()<\/code> \u0438 <code>addMethods()<\/code> \u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c <code>setMethods()<\/code> \u043d\u0430 \u0447\u0430\u0441\u0442\u0438. <code>onlyMethods()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0430 <code>addMethods()<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 (\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u0442).<\/p>\n<p>\u0412 \u0442\u043e\u043c \u0436\u0435 PHPUnit 8 <code>setMethods<\/code> \u0431\u044b\u043b \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c \u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 <code>TestCase::createPartialMock()<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>createPartialMock<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>getMockBuilder(...)-&gt;setMethods(...)<\/code>, \u0442\u043e \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0451\u0442, \u043d\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043e \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">createPartialMock() called with method(s) timerStopt that do not exist in PhpUnitMockDemo\\AbstractCommand. This will not be allowed  in future versions of PHPUnit.<\/code><\/pre>\n<p>\u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u044d\u0442\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0431\u044b\u043b\u043e \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u043e \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u2014 \u0442\u0430\u043c \u043f\u043e \u043f\u043e-\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u0431\u044b\u043b\u0430 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0431\u043e\u0442\u0430 <code>setMethods()<\/code>, \u0430 \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 \u0431\u044b\u043b\u043e \u0441\u043a\u0440\u044b\u0442\u043e \u0432 \u043d\u0435\u0434\u0440\u0430\u0445 \u043a\u043e\u0434\u0430 \u0438 GitHub.<\/p>\n<p>\u0412 PHPUnit 10 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 <code>setMethods()<\/code> \u0440\u0435\u0448\u0435\u043d\u0430 \u0440\u0430\u0434\u0438\u043a\u0430\u043b\u044c\u043d\u043e: <code>setMethods<\/code> \u0438 <code>setMethodsExcept<\/code> \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u044b. \u042d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e PHPUnit, \u0442\u043e \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438 \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 <code>onlyMethods<\/code> \u0438 <code>addMethods<\/code>.<\/p>\n<h2>\u041a\u0430\u043a \u043c\u0438\u0433\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438 \u0438\u0437 \u0441\u0442\u0430\u0440\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 PHPUnit 10?<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u044f \u0434\u0430\u043c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>\u0421\u0440\u0430\u0437\u0443 \u0441\u043a\u0430\u0436\u0443, \u0447\u0442\u043e \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u043e\u0432\u0435\u0442\u043e\u0432 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0436\u0434\u0430\u0442\u044c \u0432\u044b\u0445\u043e\u0434\u0430 PHPUnit 10 \u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0433\u043e. \u0412\u0441\u0451 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0442\u0441\u044f \u0432 PHPUnit 8 \u0438\u043b\u0438 9.<\/p>\n<h4>\u0412\u0435\u0437\u0434\u0435, \u0433\u0434\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u0432\u044b\u0437\u043e\u0432\u044b MockBuilder::setMethods() \u043d\u0430 onlyMethods()<\/h4>\n<p>\u042d\u0442\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c, \u043d\u043e \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e. \u042f \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0430\u0434\u0435\u043d\u0438\u044f\u043c\u0438. \u0427\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u044b\u0448\u0435 (\u0438 \u0442\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u0438\u0437 \u043c\u043e\u043a\u0430, \u043b\u0438\u0431\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435), \u0430 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u00ab\u043c\u0430\u0433\u0438\u0438\u00bb \u0432 \u043c\u043e\u043a\u0430\u0435\u043c\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 MockBuilder::addMethods() \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u00ab\u043c\u0430\u0433\u0438\u0435\u0439\u00bb<\/h4>\n<p>\u0415\u0441\u043b\u0438 \u043c\u0435\u0442\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u043c\u043e\u043a\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0447\u0435\u0440\u0435\u0437 \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439\u00bb \u043c\u0435\u0442\u043e\u0434 <code>__call<\/code>, \u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 <code>MockBuilder::addMethods()<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0440\u0430\u043d\u044c\u0448\u0435 \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0441 \u00ab\u043c\u0430\u0433\u0438\u0435\u0439\u00bb \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 <code>TestCase::createPartialMock()<\/code> \u0438 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u0442\u043e \u0432 PHPUnit 10 \u044d\u0442\u043e \u0441\u043b\u043e\u043c\u0430\u0435\u0442\u0441\u044f. \u0422\u0435\u043f\u0435\u0440\u044c createPartialMock \u0443\u043c\u0435\u0435\u0442 \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043c\u043e\u043a\u0430\u0435\u043c\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0438 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 <code>createPartialMock<\/code> \u043d\u0430 <code>getMockBuilder()-&gt;addMethods()<\/code>.<\/p>\n<h4>\u0415\u0441\u043b\u0438 \u0432\u044b \u0441\u043e\u0437\u0434\u0430\u0451\u0442\u0435 \u043c\u043e\u043a\u0438 \u0434\u043b\u044f \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0442\u043e \u0438\u0437\u0443\u0447\u0438\u0442\u0435 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u0441\u0438\u044e<\/h4>\n<p>\u0412 \u0442\u0435\u0441\u0442\u0430\u0445, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0445 \u043c\u043e\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u0438\u0437-\u0437\u0430 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0442\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u044d\u0442\u043e, \u0435\u0441\u043b\u0438 \u0432 CI \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 lowest \u0432\u0435\u0440\u0441\u0438\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c\u0438.<\/p>\n<p><strong>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u0440\u0438\u043c\u0435\u0440<\/strong> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <a href=\"https:\/\/github.com\/php-amqplib\/php-amqplib\">PhpAmqpLib<\/a>.<\/p>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043c\u043e\u043a \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>\\PhpAmqpLib\\Channel\\AMQPChannel<\/code>.<\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 2.4 \u0442\u0430\u043c \u0431\u044b\u043b \u043c\u0435\u0442\u043e\u0434 <code>__destruct<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u043b \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 (\u0438 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0433\u043e \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u043c\u043e\u043a\u0430\u0442\u044c).<\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 2.5 \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0431\u044b\u043b \u0443\u0434\u0430\u043b\u0451\u043d \u0438 \u043c\u043e\u043a\u0430\u0442\u044c \u0435\u0433\u043e \u0443\u0436\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 composer.json \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c: <code>\"php-amqplib\/php-amqplib\": \"~2.4\"<\/code>, \u0442\u043e \u043e\u0431\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442\u044c (\u043d\u043e \u043c\u043e\u043a\u0438 \u0434\u043b\u044f \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b \u0440\u0430\u0437\u043d\u044b\u0435) \u0438 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043a\u0430\u043a\u0430\u044f \u0438\u0437 \u043d\u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>\u0420\u0435\u0448\u0430\u0442\u044c \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ul>\n<li>\n<p>\u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>~2.4.0<\/code> \u2014 \u0438 \u0442\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u043d\u0438\u0446\u0430 \u0431\u0443\u0434\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 patch-\u0432\u0435\u0440\u0441\u0438\u044f\u0445);<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0432\u044f\u0437\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0432\u0435\u0440\u0441\u0438\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u043b\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 (\u043d\u043e \u044d\u0442\u043e \u043f\u043b\u043e\u0445\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0443\u0447\u0430\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432\u0441\u0435\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u0434\u0430 \u0438 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436\u0435 \u044d\u0442\u043e \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0445\u0430\u043a);<\/p>\n<\/li>\n<li>\n<p>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0438\u0437 \u0432\u043d\u0435\u0448\u043d\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043f\u043e\u043b\u043d\u044b\u0435 \u043c\u043e\u043a\u0438, \u0430 \u043d\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 (\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e).<\/p>\n<\/li>\n<\/ul>\n<h2>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h2>\n<p>\u0427\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438 \u2014 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PHPUnit \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0451\u0439 \u043c\u043d\u0435 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u043a\u0430\u043a-\u0442\u043e \u044d\u0442\u043e \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448\u0443 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044e \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435.<\/p>\n<h3>\u0421\u043c. \u0442\u0430\u043a\u0436\u0435<\/h3>\n<ul>\n<li>\n<p><a href=\"https:\/\/phpunit.readthedocs.io\/ru\/latest\/test-doubles.html\">\u0420\u0430\u0437\u0434\u0435\u043b \u00ab\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0432\u043e\u0439\u043d\u0438\u043a\u0438\u00bb \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 PHPUnit<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/pull\/3687\">Pull request &#171;Add onlyMethods + addMethods and soft deprecate setMethods&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/issues\/3769\">Pull request &#171;Remove MockBuilder::setMethods() and MockBuilder::setMethodsExcept()&#187;<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/adelf\/acwa_book_ru\/blob\/master\/manuscript\/8-unit-test.md\">\u0413\u043b\u0430\u0432\u0430 \u00abUnit-\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u00bb \u043a\u043d\u0438\u0433\u0438 \u00ab\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439. \u0421 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0430 Laravel\u00bb<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/badoo\/blog\/553782\/\"> https:\/\/habr.com\/ru\/company\/badoo\/blog\/553782\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u043c \u0433\u043e\u0434\u0443 \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u044b\u0439\u0442\u0438 PHPUnit 10 (\u0440\u0435\u043b\u0438\u0437 \u043f\u043b\u0430\u043d\u0438\u0440\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430 2 \u0430\u043f\u0440\u0435\u043b\u044f 2021 \u0433\u043e\u0434\u0430, \u043d\u043e \u0431\u044b\u043b \u043e\u0442\u043b\u043e\u0436\u0435\u043d). \u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/blob\/master\/ChangeLog-10.0.md\">\u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439<\/a>, \u0442\u043e \u0431\u0440\u043e\u0441\u0430\u0435\u0442\u0441\u044f \u0432 \u0433\u043b\u0430\u0437\u0430 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0439 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0442\u0430\u043a\u0438\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 <code>MockBuilder::setMethods()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u043e\u043a\u0430\u043c\u0438. \u042d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 8.0, \u043d\u043e \u0442\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435 \u043e\u043d \u043e\u043f\u0438\u0441\u0430\u043d \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u043b\u0438\u0431\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432 \u0438 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u043e \u0435\u0433\u043e \u043d\u0435\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0415\u0441\u043b\u0438 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 PHPUnit, issues \u0438 \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b \u043d\u0430 GitHub, \u0442\u043e \u0441\u0442\u0430\u043d\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0430\u043a \u0438 \u043a\u0430\u043a\u0438\u0435 \u0435\u0441\u0442\u044c \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u044b.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043e\u0441\u0432\u0435\u0449\u0443 \u044d\u0442\u043e\u0442 \u043d\u044e\u0430\u043d\u0441 \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u043b \u043d\u0430 \u043d\u0435\u0433\u043e \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0440\u0430\u043d\u044c\u0448\u0435: \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043f\u0440\u043e \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438, \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b, \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0438\u0435 \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 setMethods, \u043f\u0443\u0442\u0438 \u0438\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u044f, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0437\u0430\u0442\u0440\u043e\u043d\u0443 \u0432\u043e\u043f\u0440\u043e\u0441 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430 PHPUnit 10.<\/p>\n<h3>\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0435 \u043c\u043e\u043a\u0438?<\/h3>\n<p>\u0423 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u043f\u0438\u0448\u0435\u043c, \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u044e\u043d\u0438\u0442-\u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u044b \u0438\u0437\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u044d\u0442\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u0432\u043c\u0435\u0441\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0441 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e\u0433\u043e \u043a\u0443\u0441\u043e\u0447\u043a\u0430 \u043a\u043e\u0434\u0430 \u0432 \u043e\u0434\u0438\u043d \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u0438 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u043a\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0440\u043e \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 &#171;\u043c\u043e\u043a&#187;<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u0440\u043c\u0438\u043d\u0430 \u0432 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \u044f\u0437\u044b\u043a\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439: \u043c\u043e\u043a, mock-\u043e\u0431\u044a\u0435\u043a\u0442, \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u043d\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0438\u043c\u0438\u0442\u0430\u0446\u0438\u044f. \u042f \u0431\u0443\u0434\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043b\u044c\u043a\u043e\u0439 \u0430\u043d\u0433\u043b\u0438\u0439\u0441\u043a\u043e\u0433\u043e \u0441\u043b\u043e\u0432\u0430 mock (\u043c\u043e\u043a).<\/p>\n<\/div>\n<\/details>\n<p>\u0421\u0443\u0442\u044c \u043c\u043e\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0437\u0430\u043c\u0435\u043d\u0435\u043d\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0414\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>PHPUnit \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 <a href=\"https:\/\/phpunit.readthedocs.io\/ru\/latest\/test-doubles.html\">\u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043c\u043e\u043a\u0430\u043c\u0438<\/a>. \u041e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u0445 \u043c\u043e\u043a\u043e\u0432 (partial mocks), \u043a\u043e\u0433\u0434\u0430 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0422\u0430\u043a\u0438\u0435 \u043c\u043e\u043a\u0438 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u0432\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0441\u0432\u043e\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0443\u0433\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435).<\/p>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0443 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u043e\u0433\u043e, \u0433\u0434\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0442\u0430\u043a\u0438\u0435 \u043c\u043e\u043a\u0438.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u043e\u0434 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0449\u0438\u0439 \u043f\u0430\u0442\u0442\u0435\u0440\u043d \u00ab\u043a\u043e\u043c\u0430\u043d\u0434\u0430\u00bb:<\/p>\n<pre><code class=\"php\">abstract class AbstractCommand {     \/**      * @throws \\PhpUnitMockDemo\\CommandException      * @return void      *\/     abstract protected function execute(): void;      public function run(): bool     {         $success = true;         try {             $this-&gt;execute();         } catch (\\Exception $e) {             $success = false;             $this-&gt;logException($e);         }          return $success;     }      protected function logException(\\Exception $e)     {         \/\/ Logging     } } <\/code><\/pre>\n<p>\u0420\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u0434\u0430\u0451\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 execute \u043a\u043b\u0430\u0441\u0441\u043e\u0432-\u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432, \u0430 \u043c\u0435\u0442\u043e\u0434 <code>run()<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0431\u0449\u0435\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 exception safe \u0438 \u043b\u043e\u0433\u0438\u0440\u0443\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438).<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442 \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <code>run<\/code>, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u044b\u043c\u0438 \u043c\u043e\u043a\u0430\u043c\u0438, \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u043b\u0430\u0441\u0441 <code>PHPUnit\\Framework\\MockObject\\MockBuilder<\/code>, \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 TestCase (\u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u044d\u0442\u043e <code>getMockBuilder<\/code> \u0438 <code>createPartialMock<\/code>):<\/p>\n<pre><code class=\"php\">use PHPUnit\\Framework\\TestCase;  class AbstractCommandTest extends TestCase {     public function testRunOnSuccess()     {         \/\/ Arrange         $command = $this-&gt;getMockBuilder(AbstractCommand::class)             -&gt;setMethods(['execute', 'logException'])             -&gt;getMock();         $command-&gt;expects($this-&gt;once())-&gt;method('execute');         $command-&gt;expects($this-&gt;never())-&gt;method('logException');          \/\/ Act         $result = $command-&gt;run();          \/\/ Assert         $this-&gt;assertTrue($result, \"True result is expected in the success case\");     }      public function testRunOnFailure()     {         \/\/ Arrange         $runException = new CommandException();          \/\/ It's an analogue of $this-&gt;getMockBuilder(...)-&gt;setMethods([...])-&gt;getMock()         $command = $this-&gt;createPartialMock(AbstractCommand::class, ['execute', 'logException']);         $command-&gt;expects($this-&gt;once())             -&gt;method('execute')             -&gt;will($this-&gt;throwException($runException));         $command-&gt;expects($this-&gt;once())             -&gt;method('logException')             -&gt;with($runException);          \/\/ Act         $result = $command-&gt;run();          \/\/ Assert         $this-&gt;assertFalse($result, \"False result is expected in the failure case\");     } } <\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example1\/tests\/AbstractCommandTest.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, <a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/actions\/runs\/761025993\">\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/a><\/p>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>testRunOnSuccess<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>MockBuilder::setMethods()<\/code> \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c (\u0432\u044b\u0437\u043e\u0432\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u043e\u0442\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0438\u043b\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c). \u0412\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442 \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0438\u0437 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 <code>AbstractCommand<\/code> (\u0438 \u0438\u0445 \u043b\u043e\u0433\u0438\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c). \u0412 <code>testRunOnFailure<\/code> \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <code>createPartialMock<\/code> \u043c\u044b \u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u043d\u043e \u044f\u0432\u043d\u043e.<\/p>\n<p>\u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u0441\u0451 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: \u043c\u044b \u0437\u0430\u0434\u0430\u0451\u043c \u043c\u043e\u043a\u0430\u0435\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u0432 \u0442\u0435\u0441\u0442\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0438\u0445 \u0432\u044b\u0437\u043e\u0432 \u0438\u043b\u0438 \u043d\u0435\u0432\u044b\u0437\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 <code>expects<\/code>. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u044b\u0432\u0430\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u043b\u0443\u0447\u0430\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u043e\u0432:&nbsp;<\/p>\n<ul>\n<li>\n<p>\u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0438\u043b\u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445);<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0435\u0448\u043d\u0438\u0435 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u044e\u0442 \u0442\u0435\u0441\u0442\u044b \u0438 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u044e\u0442 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 (\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u0435\u043d\u0438\u0435 \u0438\u0437 \u043a\u0435\u0448\u0430 \u0438\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u043d\u0435\u0433\u043e \u0438 \u0442. \u0434.);<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043e\u0442\u043b\u0430\u0434\u043e\u0447\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0427\u0430\u0441\u0442\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0432\u044b\u0437\u043e\u0432\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0442 (\u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043e\u043d\u0438 \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u044b \u0438 \u0434\u0435\u043b\u0430\u044e\u0442 \u0442\u0435\u0441\u0442\u044b \u0445\u0440\u0443\u043f\u043a\u0438\u043c\u0438 \u043f\u0440\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f\u0445 \u043a\u043e\u0434\u0430).<\/p>\n<p>\u041a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, <code>MockBulder::setMethods()<\/code> \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441 \u043c\u043e\u043a\u0430 \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0435\u0442 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u043c \u043a\u043e\u0434\u0435 \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e\u00bb \u043c\u0435\u0442\u043e\u0434\u0430 <code>__call<\/code>.<\/p>\n<p>\u0412\u043e\u0437\u044c\u043c\u0451\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/predis\/predis\/blob\/main\/src\/Client.php\">\\Predis\\Client<\/a>. \u041e\u043d \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>__call<\/code> \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u043a\u043b\u0438\u0435\u043d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432\u043e \u0432\u043d\u0435\u0448\u043d\u0435\u043c \u043a\u043e\u0434\u0435 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043a\u0430\u043a \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0432 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u043c\u043e\u043a\u0435 \u044d\u0442\u043e\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0432 \u043a\u043e\u0434\u0435 \u043c\u0435\u0442\u043e\u0434, \u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c <code>__call<\/code>, \u0432\u0434\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"php\">   public function testRedisHandle()     {         if (!class_exists('Redis')) {             $this-&gt;markTestSkipped('The redis ext is required to run this test');         }          $redis = $this-&gt;createPartialMock('Redis', ['rPush']);          \/\/ Redis uses rPush         $redis-&gt;expects($this-&gt;once())             -&gt;method('rPush')             -&gt;with('key', 'test');          $record = $this-&gt;getRecord(Logger::WARNING, 'test', ['data' =&gt; new \\stdClass, 'foo' =&gt; 34]);          $handler = new RedisHandler($redis, 'key');         $handler-&gt;setFormatter(new LineFormatter(\"%message%\"));         $handler-&gt;handle($record);     } <\/code><\/pre>\n<p>\u0418\u0441\u0442\u043e\u0447\u043d\u0438\u043a: <a href=\"https:\/\/github.com\/Seldaek\/monolog\/blob\/2.2.0\/tests\/Monolog\/Handler\/RedisHandlerTest.php\">\u0442\u0435\u0441\u0442 RedisHandlerTest \u0438\u0437 monolog 2.2.0<\/a><\/p>\n<h3>\u041a\u0430\u043a\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 setMethods?<\/h3>\n<p>\u0414\u0432\u043e\u0439\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u043c.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043c\u043e\u043a\u0430\u0445 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0431\u0435\u0437 expectations, \u0442\u043e \u043f\u0440\u0438 \u0438\u0445 \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c (\u0445\u043e\u0442\u044f \u043c\u0435\u0442\u043e\u0434\u0430 \u0443\u0436\u0435 \u043d\u0435\u0442 \u0438 \u0432 \u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u043a \u043c\u043e\u043a\u0443 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430).<\/p>\n<p>\u041d\u0435\u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u044f. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043a\u043e\u0434 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0435\u0451 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f:<\/p>\n<pre><code class=\"php\">--- a\/src\/AbstractCommand.php +++ b\/src\/AbstractCommand.php @@ -13,6 +13,7 @@ abstract class AbstractCommand       public function run(): bool      { +        $this-&gt;timerStart();          $success = true;          try {              $this-&gt;execute(); @@ -21,6 +22,7 @@ abstract class AbstractCommand              $this-&gt;logException($e);          }  +        $this-&gt;timerStop();          return $success;      }  @@ -28,4 +30,14 @@ abstract class AbstractCommand      {          \/\/ Logging      } + +    protected function timerStart() +    { +        \/\/ Timer implementation +    } + +    protected function timerStop() +    { +        \/\/ Timer implementation +    }  } <\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example2\/src\/AbstractCommand.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a><\/p>\n<p>\u0412 \u043a\u043e\u0434 \u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043c\u043e\u043a \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u0447\u0435\u0440\u0435\u0437 <em>expectations<\/em>:<\/p>\n<pre><code class=\"php\">--- a\/tests\/AbstractCommandTest.php +++ b\/tests\/AbstractCommandTest.php @@ -11,7 +11,7 @@ class AbstractCommandTest extends TestCase      {          \/\/ Arrange          $command = $this-&gt;getMockBuilder(AbstractCommand::class) -            -&gt;setMethods(['execute', 'logException']) +            -&gt;setMethods(['execute', 'logException', 'timerStart', 'timerStopt']) \/\/ timerStopt is a typo              -&gt;getMock();          $command-&gt;expects($this-&gt;once())-&gt;method('execute');          $command-&gt;expects($this-&gt;never())-&gt;method('logException');<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/blob\/article_example2\/tests\/AbstractCommandTest.php\">\u0418\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434<\/a>, <a href=\"https:\/\/github.com\/pryazhnikov\/phpunit-mock-examples\/actions\/runs\/761045115\">\u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0433\u043e\u043d\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/a><\/p>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0433\u043d\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u0442\u0435\u0441\u0442 \u0432 PHPUnit \u0432\u0435\u0440\u0441\u0438\u0439 8.5 \u0438\u043b\u0438 9.5, \u0442\u043e \u043e\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u043f\u0440\u043e\u0439\u0434\u0451\u0442 \u0431\u0435\u0437 \u043a\u0430\u043a\u0438\u0445-\u0442\u043e \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"php\">PHPUnit 9.5.0 by Sebastian Bergmann and contributors.  .                                                                   1 \/ 1 (100%)  Time: 00:00.233, Memory: 6.00 MB  OK (1 test, 2 assertions) <\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u044d\u0442\u043e \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440,&nbsp; \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c expectations \u0434\u043b\u044f \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432. \u0412 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0432\u0441\u0451 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0438 \u043c\u043d\u0435 \u043d\u0435 \u0440\u0430\u0437 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0430\u0442\u044b\u043a\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u043c\u043e\u043a\u0430\u0445.<\/p>\n<blockquote>\n<p>\u0415\u0449\u0451 \u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 <code>MockBuilder::setMethodsExcept<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430, \u043a\u0440\u043e\u043c\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<\/blockquote>\n<h2>\u041a\u0430\u043a \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0440\u0435\u0448\u0435\u043d\u0430 \u0432 PHPUnit 10?<\/h2>\n<p>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u00ab\u043c\u043e\u043b\u0447\u0430\u043b\u0438\u0432\u043e\u0433\u043e\u00bb \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u044b\u043b\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u043e \u0432 2019 \u0433\u043e\u0434\u0443 \u0432 <a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/pull\/3687\">\u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u0435 #3687<\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043e\u0448\u0451\u043b \u0432 \u0440\u0435\u043b\u0438\u0437 PHPUnit 8.<\/p>\n<p>\u0412 MockBuilder \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u0432\u0430 \u043d\u043e\u0432\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430 \u2014 <code>onlyMethods()<\/code> \u0438 <code>addMethods()<\/code> \u2014 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0435\u043b\u044f\u0442 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c <code>setMethods()<\/code> \u043d\u0430 \u0447\u0430\u0441\u0442\u0438. <code>onlyMethods()<\/code> \u043c\u043e\u0436\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u0430 <code>addMethods()<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 (\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u043d\u0435\u0442).<\/p>\n<p>\u0412 \u0442\u043e\u043c \u0436\u0435 PHPUnit 8 <code>setMethods<\/code> \u0431\u044b\u043b \u043f\u043e\u043c\u0435\u0447\u0435\u043d \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u043c \u0438 \u043f\u043e\u044f\u0432\u0438\u043b\u043e\u0441\u044c \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0435 \u043d\u0435\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 <code>TestCase::createPartialMock()<\/code>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u044b\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0430 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>createPartialMock<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 <code>get<\/code><\/p>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-322112","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=322112"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/322112\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=322112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=322112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=322112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}