PHPUnit Zero-based (1): From its installation configuration.

Source: Internet
Author: User
It's a new year, before a 2016 to write what the opening is a better beginning? And then always tangled in phpunit and design patterns. The final decision is to start with PHPUnit as a new year.
PHPUnit for me is also a new knowledge, before using Laravel, just simple to understand a bit, and did not really practice, before always wanted, so dick things, I am ready to spend a one months to study. Results...... Installation took me half a day, the rest is not a thing.

I would like to add that my environment is as follows:
XAMPP (php5.6) + win7

Install a pit, please be careful

Why did it take me half a day to install? Alas, it is all tears, do not learn, find some outdated documents, simply can't get through. Finally, the official document found the answer you want. The official website has made it very clear, here I still say again, why? The number of words Bai! Hey, of course I would not be so shameless, mainly because XAMPP it installed the PHPUnit ( very old version, so need to reinstall), I would like to focus on how to cover its own phpunit.

Here is lazy, directly to the content of the official website.
Here are the highlights:
Official website says configure environment variables here, we must be careful, for example, I will xampp installed in the D:\XAMPP, in the environment variable configuration xampp PHP location. So if I configure the newly downloaded phpunit in this directory, when using PHPUnit, the XAMPP comes with it. So be sure to remember to configure your new downloaded phpunit before xampp.
To do this, open command (WIN+R) and enter: Phpunit–version. If you see the following effect indicates that you have completed the installation:

Test's Test

Now it's time to try our phpunit. I'm going to put the code directly here, and the next one is about why.
Here for the sake of simplicity, I put the class that needs to be tested, the test case is written in a file inside. You must not do this in the course of use.


   
    /** * @author: helei * @createTime: 2016-01-15 09:45 * @description: */classTryClass{publicfunctiongetValue()    {return1;    }}classTryTestextendsPHPUnit_Framework_TestCase{publicfunctiontestValue()    {$try = new TryClass();        $this->assertEquals(1, $try->getValue());    }}

Then go to the directory where the files are located and run PHPUnit:

This figure shows the correct situation, you can try to change the value of the other values to try.
Oh, here also need to say, phpunit_framework_testcase this class problem, after installing the PHPUnit, do not have this class, need to install PHPUnit libary by composer. The contents of the Composer.json file are as follows:

{  "require"     { },  "require-dev{ "phpunit/phpunit": "5.1"}}

Today about PHPUnit even completed, perhaps not exhaustive, but the multi-action, should not be any problem.
Originally wanted to come in New Year's Day, but because the end of the year just changed work, and just to the new company met to send a major version, overtime finally completed the development task yesterday. Today take this opportunity to write the opening of the 2016, and then casually talk about their own 2016 study plan, write here to remind yourself not to forget.

2016 Study Plan

For my following study plan, I will use a blog-driven approach, that is, to learn a skill, the completion of the corresponding skills of the blog content, one to deepen the learning level, and then share with everyone, sunline ... Forget it, do not come, in short, is learning I wrote it. Please correct the incorrect address.

    • Plan One: PHPUnit study, the plan has begun, for February to complete all the content of the blog (in fact, the study has been completed).
    • Plan two: have been looking at design patterns, but limited to the theory, this time to combine the practice, their own understanding, the design pattern to write once. All the code ends up on GitHub, and of course there's code for every blog post.
    • Plan three: Need to take a look at the implementation of the Laravel process, has been a kind of application, this time to go into the framework, look at its framework code implementation.
    • Plan four: Well, learn a new language, GO. Because of the use of seven of cattle service, it really feels great, and he is all in the go language to achieve, so plan to learn for themselves, is also a kind of supplement.

The words have been released, if 2016 did not finish, hit the face. I'm going to let myself face it? Who knows! Ha ha haha

'). addclass (' pre-numbering '). Hide (); $ (this). addclass (' has-numbering '). Parent (). append ($numbering); for (i = 1; i <= lines; i++) {$numbering. Append ($ ('
  • '). Text (i)); }; $numbering. FadeIn (1700); }); });

    The above describes the PHPUnit from scratch (1): From its installation configuration, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.