一、环境

系统: windows10

WampServer:  wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe

IDE:  IntelliJ IDEA 2017.3.2

PHP: 7.1.15

Intellij IDEA 如何支持php请参考,IntellIJ IDEA 配置 Vue 支持

二、PHPunit配置

1.下载PHPunit.phar:

Linux:

➜ wget -O phpunit https://phar.phpunit.de/phpunit-7.phar

➜ chmod +x phpunit

➜ ./phpunit --version

Window:

下载phpunit-7.phar到你所在的php.exe目录下, 并新建外包覆批处理脚本 phpunit.cmd 文件,内容如下:

@ECHO OFF
php %~dp0phpunit-.phar %*

对于 Cygwin 或 MingW32 (例如 TortoiseGit) shell 环境, 取而代之的是,把文件保存为 phpunit (没有 .phar 扩展名),然后用 chmod 775 phpunit 将其设为可执行。参考:安装 PHPUnit

设置环境变量:

执行: phpunit --version

PS: https://phpunit.de/getting-started/phpunit-7.html

三、新建测试项目

1.以Yii 项目为例,在protected目录下创建一个测试目录tests。在tests目录下创建bootstrap.php文件。

<?php
define('YII_ENV', 'test');
defined('YII_DEBUG') or define('YII_DEBUG', true);
require_once(__DIR__ . '/../../../yiisoft/yii2/Yii.php');
$config = require '../config/web.php';
(new Application($config));

bootstrap文件是用来加载测试用例的运行时用的,各个项目有各个项目的加载配置,按具体项目而定。

2.编写测试用例

<?php

use PHPUnit\Framework\TestCase;

class MyTest extends TestCase{

    public function testEmpty(){
$stack = []; $this->assertEmpty($stack); return $stack;
}
}

在测试用例中需要注意的是命名空间还是需要指定的。参考:编写 PHPUnit 测试

三、配置PHPunit

1. 勾选 Default bootstrap file ,并选择你上文新建的 bootstrap.php 文件。

2. 在你所在的 MyTest.php 文件 testEmpty 方法体中, 点击右键选择执行 。

如果你想手动执行:

D:\IdeaProjects>phpunit --bootstrap D:\IdeaProjects\test\protected\tests\bootstrap.php MyTest D:\IdeaProjects\test\protected\tests\examples\MyTest.php
PHPUnit 7.1. by Sebastian Bergmann and contributors. . / (%) Time: ms, Memory: .00MB OK ( test, assertion)

PS:

http://www.yii-china.com/post/detail/460.html

http://tangl163.iteye.com/blog/2288538

https://phpunit.readthedocs.io/zh_CN/latest/installation.html

https://phpunit.readthedocs.io/zh_CN/latest/index.html

https://phpunit.de/getting-started/phpunit-7.html

Windows10 + IntelliJ IDEA 2017.3.2 + wamp2e + Yii + PHPunit 搭建测试环境的更多相关文章

  1. Windows10 + IntelliJ IDEA 2017.3.2 + wamp2e + xdebug 调试 配置

    一.环境 系统: windows10 WampServer:  wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe IDE:  Intel ...

  2. Intellij IDEA 2017 详细图文教程之概述

    天天编码 , 版权所有丨本文标题:Intellij IDEA 2017 详细图文教程之概述 转载请保留页面地址:http://www.tiantianbianma.com/intellij-idea- ...

  3. IntelliJ IDEA 2017 注册方法

    本文使用破解方式注册. JetbrainsCrack-2.6.2.jar适用于ideaIU-2017.2.之前版本,若下载的版本较新破解文件可能无法使用,破解时一闪而退. 其中JetbrainsCra ...

  4. intellij idea 2017和Jprofiler 10的集成 报错问题

    本来想用Jprofiler来分析一下自己写的Java项目,以提高代码执行效率和自己的编码能力.结果,官网和网上很多帖子都写了点出session->IDE integrations->选择i ...

  5. IntelliJ IDEA 2017新工具

    IntelliJ IDEA 2017 教程之概述 图文详解如何安装 Intellij IDEA 2017 深入剖析 IntelliJ IDEA 2017 的目录结构 图文详解如何配置 IntelliJ ...

  6. IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目

    IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目 1.确认 IDEA 是否启用了 tomcat 插件 2.添加 tomcat 选择 tomcat 存放路 ...

  7. IntelliJ IDEA 2017.3.1安装步骤

    https://www.jetbrains.com/idea/download/#section=windows 下载旗舰版 1.下载完成后,运行安装: 2.next: 3.选择你要安装的目录,nex ...

  8. IntelliJ IDEA 2017 永久注册方法

    https://blog.csdn.net/weixin_39913200/article/details/80859897 在安装的idea下面的bin目录下面有2个文件 : 一个是idea64.e ...

  9. Idea for Mac 过期 IntelliJ IDEA 2017 完美注册方法(附idea for Mac破解方法)

    Idea 不能使用了: 开始破解: (1)首先下载 jar包: https://download.csdn.net/download/engerla/10573069 放到位置: /Applicati ...

随机推荐

  1. linux查看服务安装目录

    linux查看服务安装目录server dir 假如我们想查看 Redis 的安装目录 如果用命令 which redis 或者 whereis redis 都找不到安装目录, 可使用以下办法: ps ...

  2. Python基础-列表推导式、匿名函数、os/sys/time/datetime/pymysql/xlwt/hashlib模块

    列表推导式 [表达式 for 变量 in range(n) if 条件]  等效于 for 变量 in in range(n): if 条件: 表达式 优点:书写方便,缺点:不易读 注意:用的是方括号 ...

  3. poj3069 Saruman's Army(贪心)

    https://vjudge.net/problem/POJ-3069 弄清楚一点,第一个stone的位置,考虑左右两边都要覆盖R,所以一般情况下不会在左边第一个(除非前两个相距>R). 一开始 ...

  4. html的文字样式、下行线、删除线、上标、下标等实现方式

    先看效果如下: 代码如下: <del>del标签删除线</del><br/> <strike>strike标签删除线</strike>< ...

  5. Java知识回顾 (9) 同步、异步IO

    一.基本概念 同步和异步: 同步和异步是针对应用程序和内核的交互而言的. 同步指的是用户进程触发IO 操作并等待或者轮询的去查看IO 操作是否就绪: 而异步是指用户进程触发IO 操作以后便开始做自己的 ...

  6. VS2013中Python学习笔记[基础入门]

    前言 在上一节中简单的介绍了在VS2013中如何进行开发Hello World,在VS2013中进行搭建了环境http://www.cnblogs.com/aehyok/p/3986168.html. ...

  7. Unity中调用DLL库

    DLL -- Dynamic Link Library(动态链接库文件),这里以Window平台为例. Unity支持的两种语言生成的DLL库(C++.C#),这里以C#为例,C++网上可以搜索很详细 ...

  8. mount: wrong fs type, bad option, bad superblock

    mount: wrong fs type, bad option, bad superblock on 125.64.41.244:/data/img,       missing codepage ...

  9. Python - 列联表的独立性检验(卡方检验)

    Python - 列联表的独立性检验(卡方检验) 想对两个或两个以上因子彼此之间是否相互独立做检验时,就要用到卡方检验,原以为在Python中实现会像R的chisq.test一样简便,但scipy的s ...

  10. 3D打印开源软件Cura分析(1) 【转】

    http://www.sohu.com/a/236241465_100000368 Cura是Ultimaker公司开发的3D打印开源软件,在所有的3D打印开源软件中应属上乘之作,很有研究的价值.国内 ...