Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/04/2014, 17:53
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 1 mes
Puntos: 292
Respuesta: PHPUnit : PHPUnit_TestCase vs PHPUnit_Framework_TestCase

Voy a dar el tema por solucionado..... me baje phar.phar.bat del sitio oficial y lo instale, ahi tengo esa clase y hasta hay un ejemplo en la documentacion oficial:

Código PHP:
Ver original
  1. <?php
  2. require_once 'PHPUnit.php';
  3.  
  4. class MathTest extends PHPUnit_TestCase {
  5.     var $fValue1;
  6.     var $fValue2;
  7.  
  8.     function MathTest($name) {
  9.       $this->PHPUnit_TestCase($name);
  10.     }
  11.  
  12.     function setUp() {
  13.       $this->fValue1 = 2;
  14.       $this->fValue2 = 3;
  15.     }
  16.  
  17.     function testAdd() {
  18.       $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
  19.     }
  20.    
  21.     function testSub() {
  22.       $this->assertTrue($this->fValue2 - $this->fValue1 == 1);
  23.     }
  24. }
  25.  
  26. $suite = new PHPUnit_TestSuite();
  27. $suite->addTest(new MathTest('testAdd'));
  28. $suite->addTest(new MathTest('testSub'));
  29.  
  30. $result = PHPUnit::run($suite);
  31. print $result->toString();
  32. #print $result->toHTML();

Si te fijas... puedes enviar a consola con ->toString() al browser con ->toHTML()

Lo otro que decia... es que permite registrar con addTest() los metodos a probar ... pero se me hace mas simple con la otra clase:

Código PHP:
Ver original
  1. <?php
  2. require_once 'PHPUnit.php';
  3.  
  4. class MathTest extends PHPUnit_Framework_TestCase {
  5.     var $fValue1;
  6.     var $fValue2;
  7.  
  8.     function MathTest($name) {
  9.       $this->PHPUnit_TestCase($name);
  10.     }
  11.  
  12.     function setUp() {
  13.       $this->fValue1 = 2;
  14.       $this->fValue2 = 3;
  15.     }
  16.  
  17.     function testAdd() {
  18.       $this->assertTrue($this->fValue1 + $this->fValue2 == 5);
  19.     }
  20.    
  21.     function testSub() {
  22.       $this->assertTrue($this->fValue2 - $this->fValue1 == 1);
  23.     }
  24. }
__________________
Salu2!