How to configure webman unit testing in phpstrom

藏色散人
Release: 2021-12-31 14:54:14
forward
2009 people have browsed it

The following tutorial column will introduce you to phpstrom docker phpunit configuration webman unit test from the phpstorm tutorial column. I hope it will be helpful to friends in need!

1. Project structure

##2 , Cli Interpreter settings

The point to note here is the configuration of the mapping directory, which is a pitfall

(1) Path mappings directory configuration

Note: Remote Path is not required Configured! Note: Remote Path does not need to be configured!
Note: Remote Path does not need to be configured!

(2) Docker Container directory configuration

Note : Container Path does not need to be configured! Note: Container Path does not need to be configured!
Note: Container Path does not need to be configured!

3. Set up Test Framework

##(1) Install phpunit component library

composer require --dev phpunit/phpunit
Copy after login

(2) Configure unit test configuration file

##4. Configuration file

(1) phpunit.xml: unit test configuration file

<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
         backupStaticAttributes="false"
         bootstrap="tests/bootstrap.php"
         colors="true"
         convertErrorsToExceptions="true"
         convertNoticesToExceptions="true"
         convertWarningsToExceptions="true"
         processIsolation="false"
         stopOnFailure="false"
         cacheResult="false">
    <testsuites>
        <testsuite name="tests">
            <directory suffix="Test.php">./tests</directory>
        </testsuite>
    </testsuites>
</phpunit>
Copy after login
(2) tests: Directory to store test code

(3)tests/bootstrap.php scaffolding entrance

<?php
/**
 * @desc bootstrap.php 描述信息
 * @author Tinywan(ShaoBo Wan)
 * @date 2021/11/9 18:00 */use Webman\Bootstrap;use Webman\Config;require_once __DIR__ . &#39;/../vendor/autoload.php&#39;;

Config::load(config_path(), [&#39;route&#39;, &#39;container&#39;]);if ($timezone = config(&#39;app.default_timezone&#39;)) {
    date_default_timezone_set($timezone);
}foreach (config(&#39;autoload.files&#39;, []) as $file) {    include_once $file;
}foreach (config(&#39;bootstrap&#39;, []) as $class_name) {    /** @var Bootstrap $class_name */
    $class_name::start(null);
}
Copy after login
(4)build: Generate test report directory

5. Start debugging.

The above is the detailed content of How to configure webman unit testing in phpstrom. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!