{"id":306,"date":"2026-01-27T07:46:24","date_gmt":"2026-01-27T06:46:24","guid":{"rendered":"https:\/\/helloblog.io\/hu\/wordpress-bovitmeny-es-tema-teszteles-phpunit-wp-cli-scaffold\/"},"modified":"2026-01-27T08:04:11","modified_gmt":"2026-01-27T07:04:11","slug":"wordpress-bovitmeny-es-tema-teszteles-phpunit-wp-cli-scaffold","status":"publish","type":"post","link":"https:\/\/helloblog.io\/hu\/wordpress-bovitmeny-es-tema-teszteles-phpunit-wp-cli-scaffold\/","title":{"rendered":"WordPress b\u0151v\u00edtm\u00e9ny- \u00e9s t\u00e9ma-tesztel\u00e9s PHPUnit-tel: gyakorlati \u00fatmutat\u00f3 WP-CLI scaffolddal"},"content":{"rendered":"\n<p>A WordPress-fejleszt\u00e9s egyik legjobb befektet\u00e9se az automatiz\u00e1lt tesztel\u00e9s. Nem az\u00e9rt, mert minden bug elt\u0171nik t\u0151le, hanem mert sokkal kor\u00e1bban veszed \u00e9szre a hib\u00e1kat, \u00e9s nem a felhaszn\u00e1l\u00f3id fognak szembes\u00fclni vel\u00fck \u00e9lesben. A WordPress \u00f6kosziszt\u00e9m\u00e1ban a biztons\u00e1gi probl\u00e9m\u00e1k jelent\u0151s r\u00e9sze b\u0151v\u00edtm\u00e9nyekhez k\u00f6thet\u0151; egy stabil tesztk\u00e9szlet rengeteget seg\u00edt abban, hogy kisebb es\u00e9llyel cs\u00fasszon be regresszi\u00f3 vagy v\u00e1ratlan mell\u00e9khat\u00e1s.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Mi\u00e9rt \u00e9rdemes komolyan venni a tesztel\u00e9st?<\/h2>\n\n\n\n<p>Az automatiz\u00e1lt tesztek (k\u00fcl\u00f6n\u00f6sen a PHPUnit-alap\u00fa tesztek) t\u00f6bb szinten is megt\u00e9r\u00fclnek:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li>Hib\u00e1k korai felismer\u00e9se: nem a release napj\u00e1n der\u00fcl ki, hogy egy edge case sz\u00e9tveri a k\u00f3dot.<\/li>\n\n\n<li>Regresszi\u00f3k megel\u0151z\u00e9se: ha egyszer m\u00e1r kijav\u00edtott\u00e1l egy bugot, legyen r\u00f3la teszt, hogy ne j\u00f6jj\u00f6n vissza.<\/li>\n\n\n<li>Jobb k\u00f3dmin\u0151s\u00e9g: a tesztelhet\u0151 k\u00f3d jellemz\u0151en tiszt\u00e1bb, jobban tagolt.<\/li>\n\n\n<li>Magabiztosabb refaktor\u00e1l\u00e1s: ha a tesztk\u00e9szlet z\u00f6ld, sokkal kev\u00e9sb\u00e9 f\u00e9lsz beleny\u00falni a k\u00f3dba.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">El\u0151felt\u00e9telek: mire lesz sz\u00fcks\u00e9ged?<\/h2>\n\n\n\n<p>A WordPress PHPUnit tesztk\u00f6rnyezethez p\u00e1r alap \u00f6sszetev\u0151 kell. Ezeket \u00e9rdemes el\u0151re \u00f6sszerakni, mert a scaffold parancsok ugyan gener\u00e1lnak f\u00e1jlokat, de a futtat\u00e1shoz a k\u00f6rnyezetednek is k\u00e9szen kell \u00e1llnia.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><strong>PHP 8.0+<\/strong> (a PHPUnit 10 megk\u00f6veteli)<\/li>\n\n\n<li><strong>Composer<\/strong> (f\u00fcgg\u0151s\u00e9gkezel\u00e9shez)<\/li>\n\n\n<li><strong>WP-CLI<\/strong> (WordPress parancssori eszk\u00f6z)<\/li>\n\n\n<li><strong>MySQL\/MariaDB<\/strong> (k\u00fcl\u00f6n teszt adatb\u00e1zishoz)<\/li>\n\n\n<li><strong>Subversion (svn)<\/strong> (a WordPress teszt f\u00e1jlok let\u00f6lt\u00e9s\u00e9hez)<\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">WP-CLI telep\u00edt\u00e9se (gyors m\u00f3dszer)<\/h3>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>curl -O https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar\nchmod +x wp-cli.phar\nsudo mv wp-cli.phar \/usr\/local\/bin\/wp\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">curl<\/span><span style=\"color:#79B8FF\"> -O<\/span><span style=\"color:#9ECBFF\"> https:\/\/raw.githubusercontent.com\/wp-cli\/builds\/gh-pages\/phar\/wp-cli.phar<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">chmod<\/span><span style=\"color:#9ECBFF\"> +x<\/span><span style=\"color:#9ECBFF\"> wp-cli.phar<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">sudo<\/span><span style=\"color:#9ECBFF\"> mv<\/span><span style=\"color:#9ECBFF\"> wp-cli.phar<\/span><span style=\"color:#9ECBFF\"> \/usr\/local\/bin\/wp<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">PHPUnit felv\u00e9tele Composer-rel (aj\u00e1nlott)<\/h3>\n\n\n\n<p>A PHPUnit-et \u00e9rdemes projekt-szinten, dev f\u00fcgg\u0151s\u00e9gk\u00e9nt felvenni. WordPress projektekben gyakori a kompatibilit\u00e1si r\u00e9teg haszn\u00e1lata is, erre val\u00f3 a <code>yoast\/phpunit-polyfills<\/code> csomag (k\u00fcl\u00f6nb\u00f6z\u0151 PHPUnit\/PHP verzi\u00f3k k\u00f6zti elt\u00e9r\u00e9sek \u00e1thidal\u00e1s\u00e1ra).<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>{\n  &quot;require-dev&quot;: {\n    &quot;phpunit\/phpunit&quot;: &quot;^10.0&quot;,\n    &quot;yoast\/phpunit-polyfills&quot;: &quot;^2.0&quot;\n  }\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#E1E4E8\">{<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">  \"require-dev\"<\/span><span style=\"color:#E1E4E8\">: {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    \"phpunit\/phpunit\"<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">\"^10.0\"<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    \"yoast\/phpunit-polyfills\"<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">\"^2.0\"<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">  }<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">B\u0151v\u00edtm\u00e9ny tesztek gener\u00e1l\u00e1sa WP-CLI scaffolddal<\/h2>\n\n\n\n<p>A WP-CLI <code>scaffold<\/code> parancsai pont arra j\u00f3k, hogy ne k\u00e9zzel kelljen \u00f6sszeraknod a WordPress tesztk\u00f6rnyezet tipikus f\u00e1jljait. B\u0151v\u00edtm\u00e9nyhez a kiindul\u00f3pont a <code>wp scaffold plugin-tests<\/code>.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>wp scaffold plugin-tests my-plugin\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> plugin-tests<\/span><span style=\"color:#9ECBFF\"> my-plugin<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Milyen f\u00e1jlokat kapsz a gener\u00e1l\u00e1s ut\u00e1n?<\/h3>\n\n\n\n<p>A parancs l\u00e9trehozza a PHPUnit futtat\u00e1s\u00e1hoz \u00e9s a WordPress tesztk\u00f6rnyezet bootstrappel\u00e9s\u00e9hez sz\u00fcks\u00e9ges alapokat. Tipikusan ezek jelennek meg a projektedben:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><code>phpunit.xml.dist<\/code> \u2013 a PHPUnit konfigur\u00e1ci\u00f3ja (suite-ok, bootstrap, be\u00e1ll\u00edt\u00e1sok).<\/li>\n\n\n<li><code>bin\/install-wp-tests.sh<\/code> \u2013 telep\u00edt\u0151 script a WordPress tesztk\u00f6rnyezethez.<\/li>\n\n\n<li><code>tests\/bootstrap.php<\/code> \u2013 a tesztek inicializ\u00e1l\u00e1sa, WordPress bet\u00f6lt\u00e9se a teszt fut\u00e1s\u00e1hoz.<\/li>\n\n\n<li><code>tests\/test-sample.php<\/code> \u2013 egy minta teszt, amivel gyorsan ellen\u0151rizheted, hogy m\u0171k\u00f6dik-e a setup.<\/li>\n\n\n<li><code>.phpcs.xml.dist<\/code> \u2013 PHP CodeSniffer szab\u00e1lyok (k\u00f3dszabv\u00e1ny ellen\u0151rz\u00e9shez).<\/li>\n\n\n<li><code>.circleci\/config.yml<\/code> \u2013 CI konfigur\u00e1ci\u00f3 (alap\u00e9rtelmez\u00e9sben CircleCI-hez).<\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">CI provider kiv\u00e1laszt\u00e1sa a scaffoldn\u00e1l<\/h3>\n\n\n\n<p>Ha nem CircleCI-t haszn\u00e1lsz, a scaffold k\u00e9pes m\u00e1s CI szolg\u00e1ltat\u00f3khoz is konfigur\u00e1ci\u00f3t gener\u00e1lni. A <code>--ci<\/code> kapcsol\u00f3val tudod megadni, milyen pipeline form\u00e1tumot szeretn\u00e9l.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># GitHub Actions\nwp scaffold plugin-tests my-plugin --ci=github\n\n# GitLab CI\nwp scaffold plugin-tests my-plugin --ci=gitlab\n\n# CircleCI (alap\u00e9rtelmezett)\nwp scaffold plugin-tests my-plugin --ci=circle\n\n# Bitbucket Pipelines\nwp scaffold plugin-tests my-plugin --ci=bitbucket\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\"># GitHub Actions<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> plugin-tests<\/span><span style=\"color:#9ECBFF\"> my-plugin<\/span><span style=\"color:#79B8FF\"> --ci=github<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># GitLab CI<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> plugin-tests<\/span><span style=\"color:#9ECBFF\"> my-plugin<\/span><span style=\"color:#79B8FF\"> --ci=gitlab<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># CircleCI (alap\u00e9rtelmezett)<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> plugin-tests<\/span><span style=\"color:#9ECBFF\"> my-plugin<\/span><span style=\"color:#79B8FF\"> --ci=circle<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># Bitbucket Pipelines<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> plugin-tests<\/span><span style=\"color:#9ECBFF\"> my-plugin<\/span><span style=\"color:#79B8FF\"> --ci=bitbucket<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Tesztk\u00f6rnyezet felh\u00faz\u00e1sa az install-wp-tests.sh script seg\u00edts\u00e9g\u00e9vel<\/h2>\n\n\n\n<p>A scaffold \u00e1ltal gener\u00e1lt <code>bin\/install-wp-tests.sh<\/code> a kulcs: ez rakja \u00f6ssze a WordPress-hez sz\u00fcks\u00e9ges teszt infrastrukt\u00far\u00e1t. A szok\u00e1sos munkafolyamat az, hogy bel\u00e9psz a b\u0151v\u00edtm\u00e9ny k\u00f6nyvt\u00e1r\u00e1ba, majd lefuttatod a scriptet a megfelel\u0151 param\u00e9terekkel.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>cd wp-content\/plugins\/my-plugin\nbash bin\/install-wp-tests.sh wordpress_test root password localhost latest\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#79B8FF\">cd<\/span><span style=\"color:#9ECBFF\"> wp-content\/plugins\/my-plugin<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">bash<\/span><span style=\"color:#9ECBFF\"> bin\/install-wp-tests.sh<\/span><span style=\"color:#9ECBFF\"> wordpress_test<\/span><span style=\"color:#9ECBFF\"> root<\/span><span style=\"color:#9ECBFF\"> password<\/span><span style=\"color:#9ECBFF\"> localhost<\/span><span style=\"color:#9ECBFF\"> latest<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Mit jelentenek a param\u00e9terek?<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n\n<li><code>wordpress_test<\/code> \u2013 a teszt adatb\u00e1zis neve (<strong>minden adat t\u00f6rl\u0151dni fog ebben az adatb\u00e1zisban<\/strong>).<\/li>\n\n\n<li><code>root<\/code> \u2013 MySQL felhaszn\u00e1l\u00f3.<\/li>\n\n\n<li><code>password<\/code> \u2013 a MySQL felhaszn\u00e1l\u00f3 jelszava.<\/li>\n\n\n<li><code>localhost<\/code> \u2013 az adatb\u00e1zis szerver c\u00edme.<\/li>\n\n\n<li><code>latest<\/code> \u2013 a WordPress verzi\u00f3ja (adhatsz konkr\u00e9tat is, p\u00e9ld\u00e1ul: <code>6.9<\/code>).<\/li>\n\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Mit csin\u00e1l a script a h\u00e1tt\u00e9rben?<\/h3>\n\n\n\n<p>A script l\u00e9nyeg\u00e9ben h\u00e1rom nagy l\u00e9p\u00e9st automatiz\u00e1l:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>L\u00e9trehozza (vagy \u00fajrah\u00fazza) a teszt adatb\u00e1zist.<\/li>\n\n\n<li>Let\u00f6lti a WordPress-t a <code>\/tmp<\/code> mapp\u00e1ba.<\/li>\n\n\n<li>Telep\u00edti a WordPress teszt eszk\u00f6z\u00f6ket (a PHPUnit-alap\u00fa WordPress teszt suite-hoz sz\u00fcks\u00e9ges f\u00e1jlokat).<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">T\u00e9ma (theme) tesztek scaffoldol\u00e1sa<\/h2>\n\n\n\n<p>T\u00e9m\u00e1kn\u00e1l ugyanez a logika, csak a scaffold parancs neve m\u00e1s: <code>wp scaffold theme-tests<\/code>. A CI konfigur\u00e1ci\u00f3t itt is k\u00e9rheted p\u00e9ld\u00e1ul GitHub Actions-hoz.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>wp scaffold theme-tests my-theme --ci=github\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">wp<\/span><span style=\"color:#9ECBFF\"> scaffold<\/span><span style=\"color:#9ECBFF\"> theme-tests<\/span><span style=\"color:#9ECBFF\"> my-theme<\/span><span style=\"color:#79B8FF\"> --ci=github<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>A k\u00fcl\u00f6nbs\u00e9g a bootstrappel\u00e9sn\u00e9l lesz fontos: a <code>tests\/bootstrap.php<\/code> t\u00e9m\u00e1n\u00e1l jellemz\u0151en gondoskodik arr\u00f3l, hogy a t\u00e9ma akt\u00edv legyen a tesztek fut\u00e1sa k\u00f6zben.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Tesztek futtat\u00e1sa: a leggyakoribb parancsok<\/h2>\n\n\n\n<p>Ha egyszer megvan a k\u00f6rnyezet (adatb\u00e1zis + WP teszt suite + f\u00fcgg\u0151s\u00e9gek), a futtat\u00e1s egyszer\u0171: a projekt k\u00f6nyvt\u00e1r\u00e1b\u00f3l elind\u00edtod a PHPUnit-et.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>cd wp-content\/plugins\/my-plugin\nphpunit\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#79B8FF\">cd<\/span><span style=\"color:#9ECBFF\"> wp-content\/plugins\/my-plugin<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Ha minden rendben, valami ilyesmit l\u00e1tsz:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>OK (1 test, 1 assertion)\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#B392F0\">OK<\/span><span style=\"color:#E1E4E8\"> (1 <\/span><span style=\"color:#9ECBFF\">test,<\/span><span style=\"color:#79B8FF\"> 1<\/span><span style=\"color:#9ECBFF\"> assertion<\/span><span style=\"color:#E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Konkr\u00e9t tesztek c\u00e9lzott futtat\u00e1sa<\/h3>\n\n\n\n<p>Nagyobb projektekn\u00e9l sok id\u0151t sp\u00f3rolsz, ha nem mindig a teljes suite fut. A PHPUnit erre t\u00f6bb opci\u00f3t is ad:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Egy teszt oszt\u00e1ly\nphpunit --filter TestClassName\n\n# Egy teszt met\u00f3dus\nphpunit --filter test_method_name\n\n# Csoport alapj\u00e1n\nphpunit --group slow\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\"># Egy teszt oszt\u00e1ly<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><span style=\"color:#79B8FF\"> --filter<\/span><span style=\"color:#9ECBFF\"> TestClassName<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># Egy teszt met\u00f3dus<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><span style=\"color:#79B8FF\"> --filter<\/span><span style=\"color:#9ECBFF\"> test_method_name<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># Csoport alapj\u00e1n<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><span style=\"color:#79B8FF\"> --group<\/span><span style=\"color:#9ECBFF\"> slow<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Tesztek \u00edr\u00e1sa WordPress-hez: stabil alapok<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Egy alap teszt oszt\u00e1ly fel\u00e9p\u00edt\u00e9se<\/h3>\n\n\n\n<p>WordPress-ben a klasszikus PHPUnit tesztek gyakran <code>WP_UnitTestCase<\/code>-b\u0151l sz\u00e1rmaznak. A <code>set_up()<\/code> \u00e9s <code>tear_down()<\/code> met\u00f3dusokkal tudod rendbe tenni a k\u00f6rnyezetet tesztenk\u00e9nt.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>&lt;?php\n\nclass Test_My_Plugin extends WP_UnitTestCase {\n\n    public function set_up() {\n        parent::set_up();\n        \/\/ Teszt el\u0151k\u00e9sz\u00edt\u00e9s\n    }\n\n    public function tear_down() {\n        \/\/ Takar\u00edt\u00e1s\n        parent::tear_down();\n    }\n\n    public function test_plugin_is_active() {\n        $this-&gt;assertTrue( is_plugin_active( 'my-plugin\/my-plugin.php' ) );\n    }\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#F97583\">&#x3C;?<\/span><span style=\"color:#79B8FF\">php<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">class<\/span><span style=\"color:#B392F0\"> Test_My_Plugin<\/span><span style=\"color:#F97583\"> extends<\/span><span style=\"color:#B392F0\"> WP_UnitTestCase<\/span><span style=\"color:#E1E4E8\"> {<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> set_up<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        parent::<\/span><span style=\"color:#B392F0\">set_up<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">        \/\/ Teszt el\u0151k\u00e9sz\u00edt\u00e9s<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> tear_down<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">        \/\/ Takar\u00edt\u00e1s<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        parent::<\/span><span style=\"color:#B392F0\">tear_down<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_plugin_is_active<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">        $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertTrue<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#B392F0\">is_plugin_active<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'my-plugin\/my-plugin.php'<\/span><span style=\"color:#E1E4E8\"> ) );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">AAA minta: Arrange, Act, Assert<\/h3>\n\n\n\n<p>A j\u00f3l olvashat\u00f3 tesztek egyik bev\u00e1lt receptje az AAA (Arrange, Act, Assert): el\u0151k\u00e9sz\u00edtesz mindent, v\u00e9grehajtod a m\u0171veletet, majd ellen\u0151rz\u00f6d az eredm\u00e9nyt. Ett\u0151l a teszt nem csak m\u0171k\u00f6dik, de k\u00e9s\u0151bb is gyorsan \u00e9rthet\u0151 marad.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>public function test_coupon_applied_to_order() {\n    \/\/ Arrange - el\u0151k\u00e9sz\u00edt\u00e9s\n    $order = $this-&gt;factory-&gt;order-&gt;create();\n    $coupon = $this-&gt;create_coupon( 'SAVE10', 10 );\n\n    \/\/ Act - v\u00e9grehajt\u00e1s\n    $result = apply_coupon_to_order( $order, $coupon );\n\n    \/\/ Assert - ellen\u0151rz\u00e9s\n    $this-&gt;assertTrue( $result );\n    $this-&gt;assertEquals( 10, get_order_discount( $order ) );\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_coupon_applied_to_order<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Arrange - el\u0151k\u00e9sz\u00edt\u00e9s<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $order <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">order<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $coupon <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create_coupon<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'SAVE10'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">10<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Act - v\u00e9grehajt\u00e1s<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $result <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#B392F0\"> apply_coupon_to_order<\/span><span style=\"color:#E1E4E8\">( $order, $coupon );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Assert - ellen\u0151rz\u00e9s<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertTrue<\/span><span style=\"color:#E1E4E8\">( $result );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertEquals<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">10<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#B392F0\">get_order_discount<\/span><span style=\"color:#E1E4E8\">( $order ) );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Besz\u00e9des tesztnevek: konvenci\u00f3, ami t\u00e9nyleg seg\u00edt<\/h3>\n\n\n\n<p>A tesztnevek legyenek \u00f6nle\u00edr\u00f3k. Ha egy CI fut\u00e1s elhasal, a teszt neve lesz az els\u0151, amit megn\u00e9zel &#8211; \u00e9s sokszor m\u00e1r abb\u00f3l tudni akarod, mi romlott el.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ J\u00f3\npublic function test_user_can_subscribe_to_newsletter() {}\npublic function test_invalid_email_returns_error() {}\npublic function test_duplicate_subscription_is_prevented() {}\n\n\/\/ Rossz\npublic function test_1() {}\npublic function test_subscription() {}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/\/ J\u00f3<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_user_can_subscribe_to_newsletter<\/span><span style=\"color:#E1E4E8\">() {}<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_invalid_email_returns_error<\/span><span style=\"color:#E1E4E8\">() {}<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_duplicate_subscription_is_prevented<\/span><span style=\"color:#E1E4E8\">() {}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ Rossz<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_1<\/span><span style=\"color:#E1E4E8\">() {}<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_subscription<\/span><span style=\"color:#E1E4E8\">() {}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">WordPress Test Factory: gyors adatk\u00e9sz\u00edt\u00e9s tesztekhez<\/h2>\n\n\n\n<p>A WordPress teszt keretrendszer egyik leger\u0151sebb r\u00e9sze a be\u00e9p\u00edtett factory rendszer: nagyon gyorsan tudsz felhaszn\u00e1l\u00f3t, bejegyz\u00e9st, taxon\u00f3mi\u00e1t stb. gener\u00e1lni tesztadatnak. \u00cdgy nem k\u00e9zzel kell SQL-t vagy hossz\u00fa setupot \u00edrnod.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ Post l\u00e9trehoz\u00e1sa\n$post_id = $this-&gt;factory-&gt;post-&gt;create([\n    'post_title' =&gt; 'Test Post',\n    'post_status' =&gt; 'publish'\n]);\n\n\/\/ User l\u00e9trehoz\u00e1sa\n$user_id = $this-&gt;factory-&gt;user-&gt;create([\n    'role' =&gt; 'administrator'\n]);\n\n\/\/ T\u00f6bb elem l\u00e9trehoz\u00e1sa\n$post_ids = $this-&gt;factory-&gt;post-&gt;create_many( 5 );\n\n\/\/ Term l\u00e9trehoz\u00e1sa\n$term_id = $this-&gt;factory-&gt;term-&gt;create([\n    'taxonomy' =&gt; 'category',\n    'name' =&gt; 'Test Category'\n]);\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/\/ Post l\u00e9trehoz\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">$post_id <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">post<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">([<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'post_title'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'Test Post'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'post_status'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'publish'<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">]);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ User l\u00e9trehoz\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">$user_id <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">user<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">([<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'role'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'administrator'<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">]);<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ T\u00f6bb elem l\u00e9trehoz\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">$post_ids <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">post<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create_many<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">5<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ Term l\u00e9trehoz\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">$term_id <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">term<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">([<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'taxonomy'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'category'<\/span><span style=\"color:#E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">    'name'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'Test Category'<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">]);<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">K\u00fcls\u0151 HTTP h\u00edv\u00e1sok tesztel\u00e9se: mockol\u00e1s a pre_http_request filterrel<\/h2>\n\n\n\n<p>Ha a k\u00f3dod k\u00fcls\u0151 API-t h\u00edv, tesztben nem szerencs\u00e9s val\u00f3s h\u00e1l\u00f3zati k\u00e9r\u00e9st futtatni: lass\u00fa, t\u00f6r\u00e9keny, \u00e9s f\u00fcgg a k\u00fcls\u0151 szolg\u00e1ltat\u00f3t\u00f3l. WordPress-ben erre k\u00e9zenfekv\u0151 a <code>pre_http_request<\/code> filter (hook), amivel a HTTP r\u00e9teg el\u00e9 tudsz v\u00e1gni \u00e9s visszaadhatsz egy \u201emintha\u201d v\u00e1laszt.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>public function test_api_call_returns_expected_data() {\n    \/\/ Mock be\u00e1ll\u00edt\u00e1sa\n    add_filter( 'pre_http_request', function( $preempt, $args, $url ) {\n        if ( strpos( $url, 'api.example.com' ) !== false ) {\n            return [\n                'response' =&gt; [ 'code' =&gt; 200 ],\n                'body' =&gt; json_encode( [ 'status' =&gt; 'success' ] )\n            ];\n        }\n        return $preempt;\n    }, 10, 3 );\n\n    \/\/ Teszt v\u00e9grehajt\u00e1sa\n    $result = my_plugin_fetch_data();\n\n    $this-&gt;assertEquals( 'success', $result['status'] );\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_api_call_returns_expected_data<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Mock be\u00e1ll\u00edt\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    add_filter<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'pre_http_request'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#F97583\">function<\/span><span style=\"color:#E1E4E8\">( $preempt, $args, $url ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        if<\/span><span style=\"color:#E1E4E8\"> ( <\/span><span style=\"color:#79B8FF\">strpos<\/span><span style=\"color:#E1E4E8\">( $url, <\/span><span style=\"color:#9ECBFF\">'api.example.com'<\/span><span style=\"color:#E1E4E8\"> ) <\/span><span style=\"color:#F97583\">!==<\/span><span style=\"color:#79B8FF\"> false<\/span><span style=\"color:#E1E4E8\"> ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">            return<\/span><span style=\"color:#E1E4E8\"> [<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                'response'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> [ <\/span><span style=\"color:#9ECBFF\">'code'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#79B8FF\"> 200<\/span><span style=\"color:#E1E4E8\"> ],<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">                'body'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#79B8FF\"> json_encode<\/span><span style=\"color:#E1E4E8\">( [ <\/span><span style=\"color:#9ECBFF\">'status'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#9ECBFF\"> 'success'<\/span><span style=\"color:#E1E4E8\"> ] )<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">            ];<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">        }<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">        return<\/span><span style=\"color:#E1E4E8\"> $preempt;<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    }, <\/span><span style=\"color:#79B8FF\">10<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">3<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Teszt v\u00e9grehajt\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $result <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#B392F0\"> my_plugin_fetch_data<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertEquals<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'success'<\/span><span style=\"color:#E1E4E8\">, $result[<\/span><span style=\"color:#9ECBFF\">'status'<\/span><span style=\"color:#E1E4E8\">] );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Best practice-ek, amik hossz\u00fa t\u00e1von megmentenek<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1) Ne implement\u00e1ci\u00f3t tesztelj, hanem viselked\u00e9st<\/h3>\n\n\n\n<p>Gyakori csapda, hogy egy bels\u0151 megval\u00f3s\u00edt\u00e1si r\u00e9szletre \u00edrsz tesztet (p\u00e9ld\u00e1ul transients, bels\u0151 cache kulcsok, konkr\u00e9t t\u00e1rol\u00e1si strat\u00e9gia). Ezek refaktor\u00e1l\u00e1skor v\u00e1ltozhatnak \u00fagy, hogy k\u00f6zben a funkci\u00f3 viselked\u00e9se helyes marad &#8211; te m\u00e9gis elhasal\u00f3 teszteket kapsz.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ Rossz - transient implement\u00e1ci\u00f3s r\u00e9szlet\npublic function test_data_is_cached() {\n    fetch_data();\n    $this-&gt;assertNotFalse( get_transient( 'my_cache_key' ) );\n}\n\n\/\/ J\u00f3 - viselked\u00e9s tesztel\u00e9se\npublic function test_second_call_uses_cache() {\n    $start = microtime( true );\n    fetch_data();\n    fetch_data(); \/\/ M\u00e1sodik h\u00edv\u00e1s gyorsabb kell legyen\n    $duration = microtime( true ) - $start;\n\n    $this-&gt;assertLessThan( 0.1, $duration );\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/\/ Rossz - transient implement\u00e1ci\u00f3s r\u00e9szlet<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_data_is_cached<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    fetch_data<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertNotFalse<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#B392F0\">get_transient<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#9ECBFF\">'my_cache_key'<\/span><span style=\"color:#E1E4E8\"> ) );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ J\u00f3 - viselked\u00e9s tesztel\u00e9se<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_second_call_uses_cache<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $start <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> microtime<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">true<\/span><span style=\"color:#E1E4E8\"> );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    fetch_data<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">    fetch_data<\/span><span style=\"color:#E1E4E8\">(); <\/span><span style=\"color:#6A737D\">\/\/ M\u00e1sodik h\u00edv\u00e1s gyorsabb kell legyen<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $duration <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> microtime<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">true<\/span><span style=\"color:#E1E4E8\"> ) <\/span><span style=\"color:#F97583\">-<\/span><span style=\"color:#E1E4E8\"> $start;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertLessThan<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#79B8FF\">0.1<\/span><span style=\"color:#E1E4E8\">, $duration );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">2) Tartsd izol\u00e1ltan a teszteket<\/h3>\n\n\n\n<p>A WordPress Test Library alapb\u00f3l seg\u00edt abban, hogy minden teszt ut\u00e1n vissza\u00e1lljon az adatb\u00e1zis \u00e1llapota. Ezt k\u00f6nny\u0171 elrontani, ha tesztek k\u00f6z\u00f6tt megosztott \u00e1llapotra \u00e9p\u00edtesz (p\u00e9ld\u00e1ul statikus property-ben t\u00e1rolt ID-kra). Az ilyen tesztek sorrendf\u00fcgg\u0151k lesznek, \u00e9s CI-ben j\u00f6nnek el\u0151 a legideges\u00edt\u0151bb, nehezen reproduk\u00e1lhat\u00f3 hib\u00e1k.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/\/ Rossz\nprivate static $shared_post_id;\n\npublic function test_one() {\n    self::$shared_post_id = $this-&gt;factory-&gt;post-&gt;create();\n}\n\npublic function test_two() {\n    \/\/ Ez a teszt f\u00fcgg test_one-t\u00f3l\n    $post = get_post( self::$shared_post_id );\n}\n\n\/\/ J\u00f3\npublic function test_one() {\n    $post_id = $this-&gt;factory-&gt;post-&gt;create();\n    \/\/ Minden teszt \u00f6n\u00e1ll\u00f3\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/\/ Rossz<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">private<\/span><span style=\"color:#F97583\"> static<\/span><span style=\"color:#E1E4E8\"> $shared_post_id;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_one<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    self::<\/span><span style=\"color:#E1E4E8\">$shared_post_id <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">post<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_two<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Ez a teszt f\u00fcgg test_one-t\u00f3l<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $post <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#B392F0\"> get_post<\/span><span style=\"color:#E1E4E8\">( <\/span><span style=\"color:#F97583\">self::<\/span><span style=\"color:#E1E4E8\">$shared_post_id );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/\/ J\u00f3<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_one<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    $post_id <\/span><span style=\"color:#F97583\">=<\/span><span style=\"color:#79B8FF\"> $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">factory<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#E1E4E8\">post<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">create<\/span><span style=\"color:#E1E4E8\">();<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Minden teszt \u00f6n\u00e1ll\u00f3<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">3) Data provider-ek: t\u00f6bb eset, kevesebb duplik\u00e1ci\u00f3<\/h3>\n\n\n\n<p>Ha ugyanazt a logik\u00e1t t\u00f6bb input-output kombin\u00e1ci\u00f3val akarod lefedni (klasszikus p\u00e9lda: valid\u00e1ci\u00f3), akkor a PHPUnit data provider-ei sokkal tiszt\u00e1bb\u00e1 teszik a k\u00f3dot.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/**\n * @dataProvider email_validation_provider\n *\/\npublic function test_email_validation( $email, $expected ) {\n    $this-&gt;assertEquals( $expected, is_valid_email( $email ) );\n}\n\npublic function email_validation_provider() {\n    return [\n        'valid email' =&gt; [ 'test@example.com', true ],\n        'missing @' =&gt; [ 'testexample.com', false ],\n        'missing domain' =&gt; [ 'test@', false ],\n        'empty string' =&gt; [ '', false ],\n    ];\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/**<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * @dataProvider email_validation_provider<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_email_validation<\/span><span style=\"color:#E1E4E8\">( $email, $expected ) {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">    $this<\/span><span style=\"color:#F97583\">-><\/span><span style=\"color:#B392F0\">assertEquals<\/span><span style=\"color:#E1E4E8\">( $expected, <\/span><span style=\"color:#B392F0\">is_valid_email<\/span><span style=\"color:#E1E4E8\">( $email ) );<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> email_validation_provider<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">    return<\/span><span style=\"color:#E1E4E8\"> [<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'valid email'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> [ <\/span><span style=\"color:#9ECBFF\">'test@example.com'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">true<\/span><span style=\"color:#E1E4E8\"> ],<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'missing @'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> [ <\/span><span style=\"color:#9ECBFF\">'testexample.com'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">false<\/span><span style=\"color:#E1E4E8\"> ],<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'missing domain'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> [ <\/span><span style=\"color:#9ECBFF\">'test@'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">false<\/span><span style=\"color:#E1E4E8\"> ],<\/span><\/span>\n<span class=\"line\"><span style=\"color:#9ECBFF\">        'empty string'<\/span><span style=\"color:#F97583\"> =><\/span><span style=\"color:#E1E4E8\"> [ <\/span><span style=\"color:#9ECBFF\">''<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#79B8FF\">false<\/span><span style=\"color:#E1E4E8\"> ],<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">    ];<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">4) Teszt csoportok: gyors \u00e9s lass\u00fa fut\u00e1sok sz\u00e9tv\u00e1laszt\u00e1sa<\/h3>\n\n\n\n<p>Nem minden teszt egyforma: lesznek vill\u00e1mgyors unit tesztek \u00e9s lassabb integr\u00e1ci\u00f3s tesztek. A PHPUnit group annot\u00e1ci\u00f3ival ezt j\u00f3l tudod kezelni.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>\/**\n * @group slow\n * @group integration\n *\/\npublic function test_slow_operation() {\n    \/\/ Lass\u00fa teszt\n}\n\n\/**\n * @group fast\n * @group unit\n *\/\npublic function test_fast_calculation() {\n    \/\/ Gyors teszt\n}\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\">\/**<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * @group slow<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * @group integration<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_slow_operation<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Lass\u00fa teszt<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">\/**<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * @group fast<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> * @group unit<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"> *\/<\/span><\/span>\n<span class=\"line\"><span style=\"color:#F97583\">public<\/span><span style=\"color:#F97583\"> function<\/span><span style=\"color:#B392F0\"> test_fast_calculation<\/span><span style=\"color:#E1E4E8\">() {<\/span><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\">    \/\/ Gyors teszt<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">}<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>Futtat\u00e1si p\u00e9ld\u00e1k:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly># Csak gyors tesztek\nphpunit --group fast\n\n# Lass\u00fa tesztek kihagy\u00e1sa\nphpunit --exclude-group slow\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#6A737D\"># Csak gyors tesztek<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><span style=\"color:#79B8FF\"> --group<\/span><span style=\"color:#9ECBFF\"> fast<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#6A737D\"># Lass\u00fa tesztek kihagy\u00e1sa<\/span><\/span>\n<span class=\"line\"><span style=\"color:#B392F0\">phpunit<\/span><span style=\"color:#79B8FF\"> --exclude-group<\/span><span style=\"color:#9ECBFF\"> slow<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Minta GitHub Actions workflow PHPUnit-hez (MySQL service-szel)<\/h2>\n\n\n\n<p>Ha GitHub Actions-t haszn\u00e1lsz, \u00e9rdemes a teszteket t\u00f6bb PHP- \u00e9s WordPress-verzi\u00f3val is lefuttatni. Az al\u00e1bbi p\u00e9lda MySQL 8.0 service-t ind\u00edt, majd matrixban v\u00e9gigpr\u00f3b\u00e1lja a megadott verzi\u00f3kat.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><pre class=\"code-block-pro-copy-button-pre\" aria-hidden=\"true\"><textarea class=\"code-block-pro-copy-button-textarea\" tabindex=\"-1\" aria-hidden=\"true\" readonly>name: PHPUnit Tests\n\non:\n  push:\n    branches: [ main ]\n  pull_request:\n    branches: [ main ]\n\njobs:\n  test:\n    runs-on: ubuntu-latest\n\n    services:\n      mysql:\n        image: mysql:8.0\n        env:\n          MYSQL_ROOT_PASSWORD: root\n          MYSQL_DATABASE: wordpress_test\n        ports:\n          - 3306:3306\n        options: --health-cmd=&quot;mysqladmin ping&quot; --health-interval=10s --health-timeout=5s --health-retries=3\n\n    strategy:\n      matrix:\n        php-version: ['8.1', '8.2', '8.3']\n        wordpress-version: ['6.8', '6.9', 'latest']\n\n    steps:\n      - uses: actions\/checkout@v4\n\n      - name: Setup PHP\n        uses: shivammathur\/setup-php@v2\n        with:\n          php-version: ${{ matrix.php-version }}\n          extensions: mysqli, intl, zip, gd\n          coverage: xdebug\n\n      - name: Install Composer dependencies\n        run: composer install --no-progress --prefer-dist\n\n      - name: Install WordPress test suite\n        run: bash bin\/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wordpress-version }}\n\n      - name: Run PHPUnit\n        run: vendor\/bin\/phpunit --coverage-text\n\n<\/textarea><\/pre><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color:#24292e;color:#e1e4e8\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color:#85E89D\">name<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">PHPUnit Tests<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#79B8FF\">on<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">  push<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    branches<\/span><span style=\"color:#E1E4E8\">: [ <\/span><span style=\"color:#9ECBFF\">main<\/span><span style=\"color:#E1E4E8\"> ]<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">  pull_request<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    branches<\/span><span style=\"color:#E1E4E8\">: [ <\/span><span style=\"color:#9ECBFF\">main<\/span><span style=\"color:#E1E4E8\"> ]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">jobs<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">  test<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    runs-on<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">ubuntu-latest<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    services<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">      mysql<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        image<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">mysql:8.0<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        env<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">          MYSQL_ROOT_PASSWORD<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">root<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">          MYSQL_DATABASE<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">wordpress_test<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        ports<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">          - <\/span><span style=\"color:#9ECBFF\">3306:3306<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        options<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">--health-cmd=\"mysqladmin ping\" --health-interval=10s --health-timeout=5s --health-retries=3<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    strategy<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">      matrix<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        php-version<\/span><span style=\"color:#E1E4E8\">: [<\/span><span style=\"color:#9ECBFF\">'8.1'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'8.2'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'8.3'<\/span><span style=\"color:#E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        wordpress-version<\/span><span style=\"color:#E1E4E8\">: [<\/span><span style=\"color:#9ECBFF\">'6.8'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'6.9'<\/span><span style=\"color:#E1E4E8\">, <\/span><span style=\"color:#9ECBFF\">'latest'<\/span><span style=\"color:#E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">    steps<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      - <\/span><span style=\"color:#85E89D\">uses<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">actions\/checkout@v4<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      - <\/span><span style=\"color:#85E89D\">name<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">Setup PHP<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        uses<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">shivammathur\/setup-php@v2<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        with<\/span><span style=\"color:#E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">          php-version<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">${{ matrix.php-version }}<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">          extensions<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">mysqli, intl, zip, gd<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">          coverage<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">xdebug<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      - <\/span><span style=\"color:#85E89D\">name<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">Install Composer dependencies<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        run<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">composer install --no-progress --prefer-dist<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      - <\/span><span style=\"color:#85E89D\">name<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">Install WordPress test suite<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        run<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">bash bin\/install-wp-tests.sh wordpress_test root root 127.0.0.1 ${{ matrix.wordpress-version }}<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color:#E1E4E8\">      - <\/span><span style=\"color:#85E89D\">name<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">Run PHPUnit<\/span><\/span>\n<span class=\"line\"><span style=\"color:#85E89D\">        run<\/span><span style=\"color:#E1E4E8\">: <\/span><span style=\"color:#9ECBFF\">vendor\/bin\/phpunit --coverage-text<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u00d6sszefoglal\u00e1s: a teljes folyamat r\u00f6viden<\/h2>\n\n\n\n<p>Ha WordPress b\u0151v\u00edtm\u00e9nyt vagy t\u00e9m\u00e1t fejlesztesz, a WP-CLI scaffold parancsokkal meglep\u0151en gyorsan eljutsz egy m\u0171k\u00f6d\u0151 PHPUnit setupig:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n\n<li>Scaffoldold a teszteket: <code>wp scaffold plugin-tests<\/code> vagy <code>wp scaffold theme-tests<\/code>.<\/li>\n\n\n<li>H\u00fazd fel a tesztk\u00f6rnyezetet: <code>bash bin\/install-wp-tests.sh ...<\/code> (k\u00fcl\u00f6n teszt adatb\u00e1zissal!).<\/li>\n\n\n<li>Futtasd a teszteket: <code>phpunit<\/code> (vagy CI-ben <code>vendor\/bin\/phpunit<\/code>).<\/li>\n\n<\/ol>\n\n\n\n<p>A stabil tesztk\u00e9szlet ism\u00e9rvei: izol\u00e1lt tesztek, besz\u00e9des elnevez\u00e9sek, AAA szerkezet, \u00e9s a viselked\u00e9s tesztel\u00e9se implement\u00e1ci\u00f3s r\u00e9szletek helyett. Ha ezt a n\u00e9h\u00e1ny alapelvet k\u00f6veted, a tesztjeid nem akad\u00e1lyozni fognak, hanem gyors\u00edtani a fejleszt\u00e9st.<\/p>\n\n\n<div class=\"references-section\">\n                <h2>Hivatkoz\u00e1sok \/ Forr\u00e1sok<\/h2>\n                <ul class=\"references-list\"><li><a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/scaffold\/\" target=\"_blank\" rel=\"noopener noreferrer\">WP-CLI Scaffold dokument\u00e1ci\u00f3<\/a><\/li><li><a href=\"https:\/\/make.wordpress.org\/core\/handbook\/testing\/automated-testing\/phpunit\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPress PHPUnit Handbook<\/a><\/li><li><a href=\"https:\/\/phpunit.de\/documentation.html\" target=\"_blank\" rel=\"noopener noreferrer\">PHPUnit dokument\u00e1ci\u00f3<\/a><\/li><\/ul>\n            <\/div>","protected":false},"excerpt":{"rendered":"<p>Ha WordPress-ben fejlesztesz b\u0151v\u00edtm\u00e9nyt vagy t\u00e9m\u00e1t, a tesztel\u00e9s nem extra, hanem alap. Megmutatom, hogyan rakod \u00f6ssze gyorsan a PHPUnit-alap\u00fa tesztk\u00f6rnyezetet WP-CLI scaffold parancsokkal, \u00e9s hogyan \u00edrsz \u00e9rtelmes, stabil teszteket.<\/p>\n","protected":false},"author":75,"featured_media":308,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[138,137,30],"class_list":["post-306","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress","tag-ci","tag-phpunit","tag-plugin-fejlesztes"],"_links":{"self":[{"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/posts\/306","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/comments?post=306"}],"version-history":[{"count":1,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/posts\/306\/revisions"}],"predecessor-version":[{"id":307,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/posts\/306\/revisions\/307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/media\/308"}],"wp:attachment":[{"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/media?parent=306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/categories?post=306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/helloblog.io\/hu\/wp-json\/wp\/v2\/tags?post=306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}