PHP单元测试利器 PHPUNIT深入用法(二)第1/2页(2)
日期:2020-10-31 栏目:程序人生 浏览:次

<?php

class Testable

{

public$trueProperty=true;

public$resetMe=true;

public$testArray=array(

'first key'=>1,

'second key'=>2

);

private$testString="I do love me some strings";

publicfunction __construct()

{

}

publicfunction addValues($valueOne,$valueTwo) {

return$valueOne+$valueTwo;

}

publicfunction getTestString()

{

return$this->testString;

}

}

?>
我们编写的单元测试代码初步的框架如下:

<?php

class TestableTest extends PHPUnit_Framework_TestCase

{

private$_testable=null;

publicfunction setUp()

{

$this->_testable =new Testable();

}

publicfunction tearDown()

{

$this->_testable =null;

}

/** test methods will go here */

}

?>