Share
Embed
Transcript
23 slides
-
IVAN ROSOLEN @ivanrosolen http://about.me/ivanrosolen Co-fundador do PHPSP Equipe de inovação
da ARIZONA Desenvolvedor 10+ anos -
PHPT • Apenas um teste por aquivo .phpt • Testes
executados em processos separados • Diferentes configurações do PHP para cada teste -
• Bugs - bug<id>.phpt • Funções Comportamento básico - <nomedafuncao>_basic.phpt
Erro - <nomedafuncao>_error.phpt Variações - <nomedafuncao>_variation.phpt • Extensões - <nomedaextensao><numero>.phpt Nomenclatura -
--TEST-- Uma linha para descrever o teste --FILE-- código PHP
(isso mesmo PHP!) --EXPECT-- Resultado esperado (acerto ou erro) Seções Obrigatórias -
--TEST-- [--DESCRIPTION--] [--CREDITS--] [--SKIPIF--] [--REQUEST--] [--POST-- | --PUT-- | --POST_RAW--
| --GZIP_POST-- | --DEFLATE_POST-- | --GET--] [--COOKIE--] [--STDIN--] [--INI--] [--ARGS--] [--ENV--] --FILE-- | --FILEEOF-- | --FILE_EXTERNAL-- | --REDIRECTTEST-- [--HEADERS--] [--CGI--] [--XFAIL--] [--EXPECTHEADERS--] --EXPECT-- | --EXPECTF-- | --EXPECTREGEX-- [--CLEAN--] -
--EXPECTF-- %s string %d number %c single char %w whitespace
%i integer %f floats %x hexadecimal %e directory sep. -
Baixar o source da versão do PHP desejada ./configure (com
parâmetros necessários) make Como Fazer make test tar -xvf php-5.4.5.tar.gz -
make test TESTS=diretorio/ Testando make test TESTS=diretorio/*.phpt make test TESTS=diretorio/nome.phpt
Teoricamente .zip do PHP win roda os testes com o php.exe nmake test -
--TEST-- Xuplau Error --FILE-- <?php echo 'Xuplau --EXPECTF-- Parse error:
syntax error, unexpected '%s' (T_ENCAPSED_AND_WHITESPACE) in %s.php on line %d -
--TEST-- Xuplau Error --FILE-- <?php echo 'Xuplau --EXPECTREGEX-- Parse error:
(syntax|parse) error, unexpected .* \(T_ENCAPSED_AND_WHITESPACE\) in .* on line \d -
--TEST-- Apagar TMP Files --FILE-- <?php $tmp = dirname(__FILE__) .
'/foo.tmp'; $fp = fopen($tmp, 'w'); fwrite($fp, 'bar'); fclose($fp); ?> --CLEAN-- <?php $tmp = dirname(__FILE__) . '/foo.tmp'; unlink($tmp) ?> --EXPECT-- -
--TEST-- Skipif teste! --SKIPIF-- <?php if ( substr(PHP_OS, 0, 3
) != 'WIN') die('Teste apenas para Unix'); ?> --FILE-- --EXPECT-- -
--TEST-- Testing imagerectangle() of GD library --CREDITS-- Ivan Rosolen <contato
[at] ivanrosolen [dot] com> #testfest PHPSP on 2009-06-30 --SKIPIF-- <?php if ( ! extension_loaded('gd') ) die( 'skip GD not present; skipping test' ); ?> --FILE-- <?php // Create a image $image = imagecreatetruecolor( 100, 100 ); // Draw a rectangle imagerectangle( $image, 0, 0, 50, 50, imagecolorallocate($image, 255, 255, 255) ); ob_start(); imagepng( $image, null, 9 ); $img = ob_get_contents(); ob_end_clean(); echo md5(base64_encode($img)); ?> --EXPECT-- 282aaecfdd50091821d63093d9bb1bb9 -
--TEST-- Testing wrong param passing imagefilledellipse() of GD library --CREDITS--
Ivan Rosolen <contato [at] ivanrosolen [dot] com> #phpsptestfest PHPSP on 2010-05-29 --SKIPIF-- <?php if (!extension_loaded("gd")) die("skip GD not present"); ?> --FILE-- <?php // Create a image $image = imagecreatetruecolor(400, 300); // choose a color for the ellipse $ellipse = imagecolorallocate($image, 255, 255, 255); // draw the white ellipse imagefilledellipse( 'wrong param', 200, 150, 300, 200, $ellipse); ?> --EXPECTF-- Warning: imagefilledellipse() expects parameter 1 to be resource, %s given in %s on line %d -
• Clonar git https://github.com/php/php-src • Pull Request • Avisar na
lista do QA Quality Assurance list - [email protected] Enviando Testes -
http://gcov.php.net http://qa.php.net/write-test.php Links https://wiki.php.net/qa/testfest-2010/windows-test-environment Para Windows ( não testei muito
ainda ) http://pastebin.com/PPBr05kQ http://pastebin.com/CxFtXUwS http://php.net/mailing-lists.php