??????????????????????????????(unit testing)????????????????????
??????????PHP????????????????????????????PHP???????????????????飬xml??????????飬?????????????????飬????????????????????????????????????*nix???????????Web??????????????????????????????????????????????????????????????????????
????????
?????д????????????????Щ?????????Щ????PHP???????????
????????????????????????????
??????????????????????????????????????в???????????????
?????????????????????е?С??????????м???????????????????е??????壬?????????????????????ж?????庬?壬??C?????е????????????Java???????????λ???????п??????????????????????????????????????漲??С?????????顣????????????????????????????е??????????????????????????????????????????????????????в????
?????????????????????????????????????????????????????????α?д??????????????????????????д??????????е?????????????????δ???????????????????????
????--?????
???????
????PHPUnit????????????4.6?????????????????Ч?????磬???з?????????????Pear???а????????????????Phar??????Composer?????????????
????wget https://phar.phpunit.de/phpunit.phar
????? chmod +x phpunit.phar
????? sudo mv phpunit.phar /usr/local/bin/phpunit
????? phpunit --version
????{
????"require-dev": {
????"phpunit/phpunit": "4.6.*"
????}
????}
?????????????????????????phpunit-skelgen??а??????????????????????????????https://phar.phpunit.de/phpunit-skelgen.phar
????wget https://phar.phpunit.de/phpunit-skelgen.phar
????chmod +x phpunit-skelgen.phar
????mv phpunit-skelgen.phar /usr/local/bin/phpunit-skelgen
?????????????
??????????????У?????????????????????и???????????????????????????????????????????????????????????????????????????????????Щ??ν??????????????????????????????????????н??????????????
????????????????????????????????????????????????????????????????????????????????????????????
???????е?????????????С?
??????????????????
???????????????
???????????????????????????????????
???????????????????μ???????????????д????????????????????????б?????????????
???????
????1?????????????????
?????????е????????????????????????????????????????????????????????????????????????????????????????????????????????л??????????????????????????????????????????????????????????????и????
????2?????????????????
??????д?????????????????????????????????д?????test-first?????????????????????????ú??????????????????????е?????
????3??????????д??????????
?????????????????????????????????????????????????????????????????????е?????????????£??????????????
????4???????л?????
?????????????????????????????飬??д???????????????????????в????
???????
?????????????
???????????????????絽??????
??????????(Extreme Programming??????XP)????TDD?????????????????????д???????????п???????????????У????????????????????????????????Ч??о??????
??????????????????д????????????????д????????????????????????д??????????????д?????????????д???????????в????????????????????
??????ν???д??????????????????д????????????з??????????????????????????????????д?????????????????????????????????????????????????????д????????????????????????С??
????????????
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????
????????г?????????????????????д?????????????????????????????????????????е?????????о????????????????????Ч????????phpunit?????????????????????(docblock)????? @test ??????????????????????????????????????????????
????<?php
????class Calculator
????{
????/**
????* @assert (0?? 0) == 0
????* @assert (0?? 1) == 1
????* @assert (1?? 0) == 1
????* @assert (1?? 1) == 2
????* @assert (1?? 2) == 4
????*/
????public function add($a?? $b)
????{
????return $a + $b;
????}
????}
???????????
?????????????????????????????
???????????д???????????????????????????????????????????PHP????????????????????????PHPUnit??DBUnit????????????????DBUnit??????
????????????????У???????????м??????????????????????????????????????ü????????????ó??????????в??????????????????????????ó??????????????????????????????????? Wordpress??TYPO3???? Symfony????? Doctrine ?? Propel????????????????????? PHPUnit ???????????????????????Щ??????????????????????????
??????????????????????????о???????????????????????????? PHPUnit ?????????????????????????????????????
??????????????????????? JOIN ??????????????????????????Щ?????????
???????????л??????? SELECT??INSERT??UPDATE ?? DELETE ???
??????????????????????????????????????????????????????????????ò????????