Laravel Integrated Unit Test Tool phpunit can be used in the root directory of the project, the command is: Phpunti./tests/unit test file name. Using PHPUnit in Phpstorm requires some configuration, specifying composer autoload.php. The following are the specific practices:
1. Select file->setting->languages&framework->php->phpunit;
2, in PHPUnit Liberay select Use Composer autoloader;
3, in the box below to fill in the project directory/vendor/autoload.php;
The configuration is completed after saving.
After the configuration is complete, right-click the file you want to unit test,
For example, the unit test file can be written like this:
<?PHP Uselaravel\lumen\testing\databasetransactions;classExampletestextendstestcase{/** * A Basic Test example. * * @return void*/ Public functiontestexample () {$this->get ('/'); $this-Assertequals ($this->app->version (),$this->response->getcontent ()); } Public functionTestinsert () {$this->get ('/user/getlist '); $data=$this->response->getcontent (); Var_dump($data); $this->asserttrue (Strpos($data, ' {')!==false); }}
Phpstorm laravel Unit Test Configuration