{"id":27289,"date":"2017-02-03T15:14:46","date_gmt":"2017-02-03T13:14:46","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=27289"},"modified":"2017-02-03T15:14:46","modified_gmt":"2017-02-03T13:14:46","slug":"preparing-for-the-phpunit-6-and-php-7","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/03\/preparing-for-the-phpunit-6-and-php-7\/","title":{"rendered":"Preparing for the PHPUnit 6 and PHP 7"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p><a href=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"27290\" data-permalink=\"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/03\/preparing-for-the-phpunit-6-and-php-7\/travis-phpunit\/\" data-orig-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?fit=969%2C614&amp;ssl=1\" data-orig-size=\"969,614\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"travis-phpunit\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?fit=660%2C418&amp;ssl=1\" class=\"aligncenter size-medium wp-image-27290\" src=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit-500x317.png?resize=500%2C317&#038;ssl=1\" alt=\"\" width=\"500\" height=\"317\" srcset=\"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?resize=500%2C317&amp;ssl=1 500w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?resize=768%2C487&amp;ssl=1 768w, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/02\/travis-phpunit.png?w=969&amp;ssl=1 969w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p>If you woke up today and found that most of your PHP projects&#8217; and libraries&#8217; tests break and fail, I have news for you: \u00a0you are doing something wrong. \u00a0How do I know? \u00a0Because I was doing something wrong too&#8230;<\/p>\n<p>First of all, let me save you all the extra Googling. \u00a0Your tests are failing, because a new major version of PHPUnit has been released &#8211; <a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/blob\/6.0\/ChangeLog-6.0.md\">version 6.0.0<\/a>. \u00a0This version drops support for PHP 5 and, using the opportunity of the major version bump, gets rid of a bunch of stuff that was marked obsolete earlier.<\/p>\n<p>But why does it fail, you ask. \u00a0Well, because PHPUnit is included in pretty much every <em>composer.json<\/em> file out there. \u00a0And the way it&#8217;s included is almost always is this:<\/p>\n<p>&quot;require-dev&quot;: {<br \/>\n  &quot;phpunit\/phpunit&quot;: &quot;*&quot;,<br \/>\n}<\/p>\n<p>PHPUnit being a part of pretty much every <em>composer.json<\/em> file, is probably the reason why people want to be much more relaxed with the used version, than with any other component of the system. \u00a0That&#8217;s usually good. \u00a0Until it breaks, much like today with the release of the PHPUnit 6.<\/p>\n<p>How can you fix the problem? Well,<a href=\"https:\/\/github.com\/sebastianbergmann\/phpunit\/wiki\/Preparing-for-PHPUnit-6\"> the quickest and the easiest solution<\/a> is to update the <em>composer.json<\/em> with <em>&#8220;^5.0&#8221;<\/em> instead of <em>&#8220;*&#8221;<\/em>. \u00a0This will prevent PHPUnit from upgrading until you are ready.<\/p>\n<p>While you are doing it, check the other dependencies and make sure that none of them are using the asterisk either. \u00a0Because, chances are, the exact same problem will happen later with those too.<\/p>\n<p>The only difficult bit about this whole situation is the correlated drop for the PHP 5 support. \u00a0Yes, sure, it has reached its <a href=\"http:\/\/php.net\/supported-versions.php\">end of life<\/a>, but there are still a lot of projects and environments that require it, and will require it for a lonweg time.<\/p>\n<p>As you are the master of your code and dependencies, other people are of their own. \u00a0So you can&#8217;t really control when each of your dependencies will update the requirement for the PHPUnit 6, or any other tool that requires PHP 7.<\/p>\n<p>On the bright side, major releases of PHP don&#8217;t happen that often, so this shouldn&#8217;t be the frequent problem.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>If you woke up today and found that most of your PHP projects&#8217; and libraries&#8217; tests break and fail, I have news for you: \u00a0you are doing something wrong. \u00a0How do I know? \u00a0Because I was doing something wrong too&#8230; First of all, let me save you all the extra Googling. \u00a0Your tests are failing, &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/03\/preparing-for-the-phpunit-6-and-php-7\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Preparing for the PHPUnit 6 and PHP 7<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Preparing for the PHPUnit 6 and PHP 7 #PHP #WebDev #QA #tests #PHPUnit","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62,1334],"tags":[38,3492,3074,1108,1330],"keyring_services":[],"class_list":["post-27289","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","category-web-work","tag-php","tag-phpunit","tag-quality-assurance","tag-testing","tag-web-development"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":34326,"url":"https:\/\/mamchenkov.net\/wordpress\/2019\/02\/15\/tips-to-speed-up-your-phpunit-tests\/","url_meta":{"origin":27289,"position":0},"title":"Tips to Speed up Your PHPunit Tests","author":"Leonid Mamchenkov","date":"February 15, 2019","format":false,"excerpt":"I came across this collection of \"Tips to Speed up Your PHPunit Tests\". Apart from the few usual ones, like disabling XDebug and using groups, I found a couple that linked to handy tools: ParaTest - a PHPUnit extension that runs PHPUnit tests in parallel, significantly minimizing the test run\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/02\/fix-slow.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/02\/fix-slow.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2019\/02\/fix-slow.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":28455,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/03\/26\/atoum-modern-simple-and-intuitive-php-unit-testing-framework\/","url_meta":{"origin":27289,"position":1},"title":"atoum &#8211; modern, simple and intuitive PHP unit testing framework","author":"Leonid Mamchenkov","date":"March 26, 2018","format":false,"excerpt":"With all the hype around the quality assurance and testing tools for PHP, I wonder how did I miss atoum.\u00a0 Atoum is a modern, simple and intuitive unit testing framework for PHP.\u00a0 From a quick look around, it seems to be a lot simpler than PHPUnit and I definitely need\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26688,"url":"https:\/\/mamchenkov.net\/wordpress\/2016\/09\/16\/bitbucket-pipelines-and-docker-for-php-developers\/","url_meta":{"origin":27289,"position":2},"title":"BitBucket Pipelines and Docker for PHP Developers","author":"Leonid Mamchenkov","date":"September 16, 2016","format":false,"excerpt":"I've been meaning to look into Docker for a long while now. \u00a0But, as always, time is the issue. \u00a0In the last couple of days though I've been integrating BitBucket Pipelines into our workflow. \u00a0BitBucket Pipelines is a continuous integration solution, which runs your project tests in a Docker container.\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27809,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/07\/29\/improving-the-output-of-phpunit\/","url_meta":{"origin":27289,"position":3},"title":"Improving the output of PHPUnit","author":"Leonid Mamchenkov","date":"July 29, 2017","format":false,"excerpt":"Via \"Improving the output of PHPUnit\" I've learned about\u00a0PHPUnit Emoji Result Printer. \u00a0Obviously, this sounds like fun, but I'm also sure there is some really smart way of using this. Too bad I couldn't try it on one of our work projects just yet, as this requires PHPUnit 6+, while\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/07\/phpumoji-500x127.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":27454,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/03\/26\/phpqa-all-in-one-analyzer-cli-tool\/","url_meta":{"origin":27289,"position":4},"title":"PHPQA all-in-one Analyzer CLI tool","author":"Leonid Mamchenkov","date":"March 26, 2017","format":false,"excerpt":"PHPQA all-in-one Analyzer CLI tool. \u00a0This project bundles together all the usual PHP quality control tools, and then some. \u00a0It simplifies the installation and configuration of the tools and helps developers to push up the quality control bar on their projects. The tools currently included are: PHP Parallel Lint PHP\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2017\/03\/phplint-500x390.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":18239,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/05\/27\/ua-testing-with-selenium-and-phpunit\/","url_meta":{"origin":27289,"position":5},"title":"UA Testing with Selenium and PHPUnit","author":"Leonid Mamchenkov","date":"May 27, 2013","format":"link","excerpt":"UA Testing with Selenium and PHPUnit","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27289","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=27289"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/27289\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=27289"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=27289"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=27289"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=27289"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}