{"id":593,"date":"2007-08-20T11:15:14","date_gmt":"2007-08-20T15:15:14","guid":{"rendered":"http:\/\/www.wehuberconsultingllc.com\/wordpress\/?p=593"},"modified":"2007-09-03T14:25:09","modified_gmt":"2007-09-03T18:25:09","slug":"setting-up-phpunit-to-run-the-samples","status":"publish","type":"post","link":"https:\/\/wehuberconsultingllc.com\/wordpress\/2007\/08\/20\/setting-up-phpunit-to-run-the-samples\/","title":{"rendered":"Setting up PHPUnit to run the samples"},"content":{"rendered":"<p>In <a href=\"http:\/\/www.wehuberconsultingllc.com\/wordpress\/?p=592\">my last post<\/a> I thought I had set up PHPUnit correctly. As I worked through the samples I found out that there were a few more problems. <\/p>\n<ol>\n<li>The first problem was finding the Framework folder used in the samples. This folder exists under the test tree. To make things easy I copied the Framework, Extensions, Runner, and Util folders over to my working directory. As I said in previous post my working directory, phpunit, is located under the htdocs folder.  <\/li>\n<li>The ObserverTest sample did not work for me as shown in the documentation. It complained about the Subject object. I got the Observer object to run but I think section of the documentation should be re-written. Mock objects are important.  <\/li>\n<li>The second problem I found was when I was trying to run the BankAccountTest. It threw a BankAccountException and it expected to find the BankAccountException class somewhere. Sebastian has a <a href=\"http:\/\/www.slideshare.net\/sebastian_bergmann\/testing-phpweb-applications-with-phpunit-and-selenium\/\">slide online<\/a> with an updated BankAccount.php that referenced a BankAccountException.php. I looked all around for the file but I could not find it. So I created my own file. It does nothing except create the BankAccountException class by extending Exception. Now the BankAccountTest sample will run.  <\/li>\n<li>Getting the code coverage feature to work was a bit trickier. If you have not enabled xdebug you will get a confusing error message. When you run PHPUnit with the code coverage parameter, &#8220;&#8211;report&#8221;, it will say that there is no report parameter. Huh!? When you run &#8220;phpunit &#8211;help&#8221; you will not see the report parameter. Hmm&#8230; I thought I had fixed this.\n<ol>\n<li>Go back and make sure that you have enabled the extension in the php.ini file. Oops, I had enabled the extensions in the wrong file.  <\/li>\n<li>After&nbsp;enabling the xdebug extension I got an error message when I ran PHPUnit.bat that complained about the version of xdebug.dll and PHP. I am running the latest version of PHP and the xdebug.dll version it is loading looks like it is pretty old. After a couple of iterations I got the configuration correct. You need to enable the xdebug extension as a ZEND extension with the full path to the most recent version of the DLL. The most recent version exists in my ext folder but it had a different name. For my version of XAMPP I added the following line, <strong><code>zend_extension_ts=\"C:\\Program Files\\xampp\\php\\ext\\php_xdebug-2.0.0-5.2.2.dll\". Now I get the pretty code coverage&nbsp;report.<\/code><\/strong><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p><strong><code>So there you have it. I have gone through the examples and gotten all of them except one to work as expected.<\/code><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my last post I thought I had set up PHPUnit correctly. As I worked through the samples I found out that there were a few more problems. The first problem was finding the Framework folder used in the samples. This folder exists under the test tree. To make things easy I copied the Framework, &hellip; <a href=\"https:\/\/wehuberconsultingllc.com\/wordpress\/2007\/08\/20\/setting-up-phpunit-to-run-the-samples\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Setting up PHPUnit to run the samples&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"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_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[2],"tags":[124,32,16],"class_list":["post-593","post","type-post","status-publish","format-standard","hentry","category-css","tag-css","tag-php","tag-webdesign"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4iN3d-9z","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/593","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/comments?post=593"}],"version-history":[{"count":0,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/posts\/593\/revisions"}],"wp:attachment":[{"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/media?parent=593"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/categories?post=593"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wehuberconsultingllc.com\/wordpress\/wp-json\/wp\/v2\/tags?post=593"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}