??????????????????????????????μ??????????????????儷???????ú?????????????????????????????????????????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??????ж?????????????????