• 技术文章 >开发工具 >phpstorm

    phpstrom怎么配置webman单元测试

    藏色散人藏色散人2021-12-31 14:54:14转载1095

    下面由phpstorm教程栏目给大家介绍phpstrom docker phpunit 配置webman单元测试 ,希望对需要的朋友有所帮助!

    1、项目结构

    2、Cli Interpreter 设置

    这里的注意点就是映射目录的配置,是一个坑

    (1)Path mappings 目录配置

    注意:Remote Path 是不需要配置的哦!
    注意:Remote Path 是不需要配置的哦!
    注意:Remote Path 是不需要配置的哦!

    (2)Docker Container 目录配置

    注意:Container Path 是不需要配置的哦!
    注意:Container Path 是不需要配置的哦!
    注意:Container Path 是不需要配置的哦!

    3、设置 Test Framework

    (1)安装 phpunit 组件库

    composer require --dev phpunit/phpunit

    (2)配置单元测试配置文件

    4、配置文件

    (1)phpunit.xml:单元测试配置文件

    <?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>

    (2)tests:存放测试代码目录

    (3)tests/bootstrap.php 脚手架入口

    <?php
    /**
     * @desc bootstrap.php 描述信息
     * @author Tinywan(ShaoBo Wan)
     * @date 2021/11/9 18:00 */use Webman\Bootstrap;use Webman\Config;require_once __DIR__ . '/../vendor/autoload.php';
    
    Config::load(config_path(), ['route', 'container']);if ($timezone = config('app.default_timezone')) {
        date_default_timezone_set($timezone);
    }foreach (config('autoload.files', []) as $file) {    include_once $file;
    }foreach (config('bootstrap', []) as $class_name) {    /** @var Bootstrap $class_name */
        $class_name::start(null);
    }

    (4)build:生成测试报告目录

    5、开始调试.

    以上就是phpstrom怎么配置webman单元测试的详细内容,更多请关注php中文网其它相关文章!

    声明:本文转载于:cnblogs,如有侵犯,请联系admin@php.cn删除
    专题推荐:phpstrom
    上一篇:PhpStorm配置php7.3的环境(图文步骤) 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • 详解关于PHPSTROM的远程调试• 解决phpstrom报错“Cannot start internal HTTP server...”问题• 解决sublime和phpstrom 中文光标跟随问题• 教大家怎么卸载phpstrom插件
    1/1

    PHP中文网