一、环境

系统: 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. C# Web API Modify Post Data Size Limit

    在Web.config中增加下面两个配置后,重启IIS即可. 1.修改http请求数据大小限制 <system.web>  <httpRuntime maxRequestLength ...

  2. Java 消除过期的对象引用

    内存泄漏的第一个常见来源是存在过期引用. import java.util.Arrays; import java.util.EmptyStackException; public class Sta ...

  3. Java 深复制和浅复制

    浅复制是指复制对象时仅仅复制对象本身(包括对象中的基本变量),而不复制对象包含的引用指向的对象.深复制不仅复制对象本身,而且复制对象包含的引用指向的对象. 复制对象时需要调用Object类的clone ...

  4. 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II 线段树维护dp

    题目 4990: [Usaco2017 Feb]Why Did the Cow Cross the Road II 链接 http://www.lydsy.com/JudgeOnline/proble ...

  5. eclipse 安装合适的pydev插件

    http://www.cnblogs.com/yanduanduan/p/7261500.html

  6. Schaepher 博客目录

    update: 2017-03-16 福州大学2015年秋软件工程实践课 软工课程作业目录 软工实践课程总结 团队博客 软件案例分析优秀链接汇总 Android Android学习笔记: (一):th ...

  7. Spring Boot参数校验

    1. 概述 作为接口服务提供方,非常有必要在项目中加入参数校验,比如字段非空,字段长度限制,邮箱格式验证等等,数据校验常用到概念:JSR303/JSR-349: JSR303是一项标准,只提供规范不提 ...

  8. 分布式环境中,模块数据交互协议分析 (百度brpc)

    1. 背景 之前听到同事说,要为自己的模块考虑写个数据协议.今天有空想了一下.写出来,方便后续使用. 开源代码brpc中可以支持多种协议,nshead.redis.mongo等20多种协议. 2. 什 ...

  9. Centos如何安装163yum源

    如果Centos使用系统自带的yum源,在用yum进行安装的时候,速度会受到限制,所以我们需要替换为国内的yum源,一般会选择163源,速度比较快包也比较全,使用yum进行安装的时候可以大大节省时间 ...

  10. JAVA获取程序(打成jar或classpath)所在目录

    一.简述 JAVA获取程序(打成jar或classpath)所在目录. 二.代码 package dearcloud.utils.context; import dearcloud.utils.Str ...