Windows10 + IntelliJ IDEA 2017.3.2 + wamp2e + Yii + PHPunit 搭建测试环境
一、环境
系统: windows10
WampServer: wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe
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 搭建测试环境的更多相关文章
- 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 ...
- Intellij IDEA 2017 详细图文教程之概述
天天编码 , 版权所有丨本文标题:Intellij IDEA 2017 详细图文教程之概述 转载请保留页面地址:http://www.tiantianbianma.com/intellij-idea- ...
- IntelliJ IDEA 2017 注册方法
本文使用破解方式注册. JetbrainsCrack-2.6.2.jar适用于ideaIU-2017.2.之前版本,若下载的版本较新破解文件可能无法使用,破解时一闪而退. 其中JetbrainsCra ...
- intellij idea 2017和Jprofiler 10的集成 报错问题
本来想用Jprofiler来分析一下自己写的Java项目,以提高代码执行效率和自己的编码能力.结果,官网和网上很多帖子都写了点出session->IDE integrations->选择i ...
- IntelliJ IDEA 2017新工具
IntelliJ IDEA 2017 教程之概述 图文详解如何安装 Intellij IDEA 2017 深入剖析 IntelliJ IDEA 2017 的目录结构 图文详解如何配置 IntelliJ ...
- IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目
IntelliJ IDEA 2017.2.6 x64 配置 tomcat 启动 maven 项目 1.确认 IDEA 是否启用了 tomcat 插件 2.添加 tomcat 选择 tomcat 存放路 ...
- IntelliJ IDEA 2017.3.1安装步骤
https://www.jetbrains.com/idea/download/#section=windows 下载旗舰版 1.下载完成后,运行安装: 2.next: 3.选择你要安装的目录,nex ...
- IntelliJ IDEA 2017 永久注册方法
https://blog.csdn.net/weixin_39913200/article/details/80859897 在安装的idea下面的bin目录下面有2个文件 : 一个是idea64.e ...
- Idea for Mac 过期 IntelliJ IDEA 2017 完美注册方法(附idea for Mac破解方法)
Idea 不能使用了: 开始破解: (1)首先下载 jar包: https://download.csdn.net/download/engerla/10573069 放到位置: /Applicati ...
随机推荐
- 命令行添加subl命令
添加了此命令后可以使用subl加文件或路径,就能通过命令行使用sublime text打开相应的文件或目录. 这里我的是MacOS,windows系统换路径就好. 第一步 sudo ln -s /Ap ...
- 关于不执行整个大项目而是执行其中一部分独立文件夹的时候的python运行方法
这是项目的整个目录,如果是点击右键运行ic_kw_ks_func.py的话是会报ic_kw_ks_func.py里面import的那些其他路径下的类和函数找不到.而我们发现有个-m的python命令能 ...
- SpringMVC知识点
一.SpringMVC 1.HelloWorld案例 ①步骤: 加jar包 在web.xml文件中配置DispatcherServlet 加入SpringMVC的配置文件 编写处理请求的处理器,并标识 ...
- delphi ListView 设置固定列宽
object Form1: TForm1 Left = Top = Caption = 'Form1' ClientHeight = ClientWidth = Color = clBtnFace F ...
- javaScript系列 [01]-javaScript函数基础
[01]-javaScript函数基础 1.1 函数的创建和结构 函数的定义:函数是JavaScript的基础模块单元,包含一组语句,用于代码复用.信息隐蔽和组合调用. 函数的创建:在javaScri ...
- Idea checkstyle插件的使用
File->Setting 选择Plugins,查询是否已经安装了checkstyle,如果没有安装,可以点击下面的“Browse repositories...”按钮 查询到checkstyl ...
- [Web 前端] 我不再使用React.setState的3个原因
copy from : https://blog.csdn.net/smk108/article/details/85237838 从几个月前开始,我在新开发的React组件中不再使用setState ...
- go依赖包下载加速方法及github加速
go依赖包下载加速方法及github加速 对于https://github.com/kubernetes/kubernetes整个仓库大小为近900M,下载起来那个伤心: 方法一:使用码云 这是码云上 ...
- Mysql查询特定值是哪些表哪些字段
摘自网上 -- 查询整个数据库中某个特定值所在的表和字段的方法 # flush tables; -- 创建表来存储查询结果 drop table if exists tmp_table; CREATE ...
- xsd文件规则和语法
1.简介 XSD即XML结构定义, XML Schemas Definition.其本身就是用xml描述的, 且遵循xml语法规则.一份XML schema文件描述了XML文档的结构. 基本规则: ...