首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >如何使用Docker和PHPUnit在PHPStrom中配置Webman单元测试

如何使用Docker和PHPUnit在PHPStrom中配置Webman单元测试

作者头像
Tinywan
发布2023-11-16 10:54:36
发布2023-11-16 10:54:36
1K00
代码可运行
举报
文章被收录于专栏:开源技术小栈开源技术小栈
运行总次数:0
代码可运行

目录结构

Cli Interpreter 设置

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

(1)Path mappings 目录配置

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

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

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

(2)Docker Container 目录配置

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

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

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

设置 Test Framework

(1)安装 phpunit 组件库

代码语言:javascript
代码运行次数:0
运行
复制
composer require --dev phpunit/phpunit

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

单元测试配置文件

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

代码语言:javascript
代码运行次数:0
运行
复制
<?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 脚手架入口

代码语言:javascript
代码运行次数:0
运行
复制
<?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:生成测试报告目录

开始调试

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-11-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 开源技术小栈 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 目录结构
  • Cli Interpreter 设置
    • (1)Path mappings 目录配置
    • (2)Docker Container 目录配置
  • 设置 Test Framework
    • (1)安装 phpunit 组件库
    • (2)配置单元测试配置文件
  • 单元测试配置文件
    • (1)单元测试配置文件 phpunit.xml
    • (2)tests:存放测试代码目录
    • (3)tests/bootstrap.php 脚手架入口
    • (4)build:生成测试报告目录
  • 开始调试
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档