一、环境

系统: 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. Java 泛型 介绍

    为什么需要泛型? public class GenericTest { public static void main(String[] args) { List list = new ArrayLi ...

  2. jquery .stop()的用法

    jquery的.stop()的用法: 目的:为了 了解stop()的用法,举个例子,直观的方式看看. 实物:一个id="animater"的div包含了一段文字.(以下用anima ...

  3. 【组合&取补集】数三角形 @CQOI2014/BZOJ3505/upcexam3843

    http://exam.upc.edu.cn/problem.php?id=3843&csrf=8oK86t2oHSgi3Q4SX3qOJGeENe6pfXri 时间限制: 1 Sec 内存限 ...

  4. django之ORM补充

    本篇导航: QuerySet 中介模型 查询优化 extra 一.QuerySet 1.可切片 使用Python 的切片语法来限制查询集记录的数目 .它等同于SQL 的LIMIT 和OFFSET 子句 ...

  5. Android的Databinding-单向绑定

    两种方式实现观察绑定. 一.POJO类实现android.databinding.Observable,在属性set方法中调用notifyPropertyChanged(BR.lastName); 其 ...

  6. Android CollapsingToolbarLayout使用介绍

    我非常喜欢Material Design里折叠工具栏的效果,bilibili Android客户端视频详情页就是采用的这种设计.这篇文章的第二部分我们就通过简单的模仿bilibili视频详情页的实现来 ...

  7. Spring @Configuration 和 @Component 区别

    Spring @Configuration 和 @Component 区别 一句话概括就是 @Configuration 中所有带 @Bean 注解的方法都会被动态代理,因此调用该方法返回的都是同一个 ...

  8. php读取ini配置文件属性

    ini的内容格式如下,请根据自己的INI,格式修改下段程序. autostart = false font_size = font_color = red =================== fu ...

  9. 使用 Python 将 HTML 转成 PDF

    背景 很多人应该经常遇到在网上看到好的学习教程和资料但却没有电子档的,心里顿时痒痒, 下述指导一下大家,如何将网站上的各类教程转换成 PDF 电子书. 关键核心 主要使用的是wkhtmltopdf的P ...

  10. ubuntu intel网卡驱动安装(华硕B250F GAMING主板 )

    jikexianfeng@jikexianfeng:~$ sudo sudo lspci -knn :]: Intel Corporation Device [:591f] (rev ) Subsys ...