PHP?????????????PHPUNIT???
???????????? ???????[ 2011/8/16 14:44:10 ] ????????
??????????????????????????????μ??????????????????儷???????ú?????????????????????????????????????????bug????????μ??????Щbug?????????????????????Щbug?????й???????????????????????????
??????????????????Щ??????????????????????????????????????????????????е????????????????????????????????????????????????????????????????????????????????????????????????????????
??????????д??????????????????????????????????????????????????????????????????????????Щ???????????????????????????????????????????????
?????????????????????????????????????????????????????д???????????????????????????????
????1???????д??????????????????????IDE????????д???????????????????????????????д?Щ????????????????????е????????????????????????????????????????????????????????????1?????????????????????????????????????????????н????????????????????????????????????????????
????2?????????????????????????????д??????????????????????μ?????????????????????????????3?????п???????????????????????????????б?д?????????????????????????и?????????????????bug???????
????3???????д???????????????ζ????????????????????????????????????????????????????д?????????????????????????????????????д?????????????????????????????ж??????????????????????????????????????
?????????????phpunit
?????????н????????php?е???????????phpunit?????????????????????????????????????phpunit????????phpunit????????????php?μ?pear??????
????pearchannel-discoverpear??phpunit??de
????pearchannel-discovercomponents??ez??no
????pearchannel-discoverpear??symfony-project??com
????pearinstallphpunit/PHPUnit
??????д????????????????
????????????????д?????????????????????д???????????????????μ?phpunit?????
????1. ???????????????У????????PHPUnit_Framework_TestCase???????????????setUp??????tearDown????????????
????2. ??????????????????????????????????????????????????Test?????????????????RemoteConnect??????????????????RemoteConnectTest??
????3. ??????????????е????е???????????????????????test+??????????????????testDoesLikeWaffles?????????????÷??????????????public??????????????????????????а???private?????????????????phpunit?????á?
????4. ???????????????????????
??????????????????????????????£?
????<??php
????classRemoteConnect
????{
????publicfunctionconnectToServer??$serverName=null??
????{
????if??$serverName==null??{
????thrownewException????That??snotaservername????????
????}
????$fp=fsockopen??$serverName??80????
????return??$fp????true??false??
????}
????publicfunctionreturnSampleObject????
????{
????return$this??
????}
????}
???????????????????????????????????????????????????????д??????????£?
????<??php
????require_once????RemoteConnect.php??????
????classRemoteConnectTestextendsPHPUnit_Framework_TestCase
????{
????publicfunctionsetUp????{}
????publicfunctiontearDown????{}
????publicfunctiontestConnectionIsValid????
????{
????//testtoensurethattheobjectfromanfsockopenisvalid
????$connObj=newRemoteConnect??????
????$serverName=??www.google.com????
????$this->assertTrue??$connObj->connectToServer??$serverName????==false????
????}
????}
??????>
???????????????У?????????PHPUnit_Framework_TestCase???????setUp??tearDown?????У????????д?κδ???SetUp?????????????????????????????Щ??????????????tearDown??????????????????к?????Щ???????????????????????????У???????phpunit?????assertTrue??ж?????????????????棬?????????????RemoteConnect.php?е?connectToServe??????ж?????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11