win7 wamp 下安装pear phpunit

1,安装pear 用官方的方法 :request http://pear.php.net/go-pear.phar in your browser and save the output to a local file go-pear.phar. You can then run “ php go-pear.phar”in a Windows Command Prompt to start the update process. After changing php.ini , you need to restart your web server. (http://pear.php.net/manual/en/installation.getting.php)php

2 ,安装phpunithtml

先安装下列包 pear channel-discover pear.phpunit.de pear channel-discover components.ez.no pear channel-discover pear.symfony-project.com pear update-channels pear upgrade-all 最后运行 pear install phpunit/PHPUnit或者pear install --alldeps phpunit/PHPUnitweb

3,安装过程种出现这个错误时:No releases available for package "pear.phpunit.de/PHPUnit 用 pear clear-cache清一下缓存就行了。api

4,安装后执行结果:缓存

在此输入图片描述

test1.php的内容:测试

<!-- lang: php -->
<?php
require '../wx.php';
class wxTest extends PHPUnit_Framework_TestCase{
	
	public $o = null;
	
	//初始化时
	function setUp(){
		$this->o = new wechatCallbackapiTest();
	}
	
	//测试后清除此类
	function tearDown(){
		unset($this->o);
	}
	
	function testStr(){
		foreach(array('adsfasdjl...k','jianli','个人简历','sdfs简历dfa') as $value){
			$this->assertTrue($this->o->checkResume($value));
		}
	}
}

wechatCallbackapiTest 此类的checkResume()方法代码:ui

<!-- lang: php -->
function checkResume($content){
	$resum_keywords = array('jl','jianli','简历');
	foreach ($resum_keywords as $key => $value) {
		if(preg_match("/$value/i", $content))
			return true;
	}
	return false;
}

别人的相关博文: http://flyer0126.iteye.com/blog/1441817 http://hi.baidu.com/wuhui/item/17986ed5d9a90893260ae729 http://www.cnblogs.com/zhja/archive/2013/02/28/2937046.html http://blog.csdn.net/jucrazy/article/details/6720935this

phpunit 手册 :http://phpunit.de/manual/3.7/en/index.html.net

相关文章
相关标签/搜索