Error "Fatal error: Class 'PHPUnit_Framework_TestCase' not found"

1

Good night, I just installed phpunit by a .phar file and adding the path in windows but when I run the tests it returns me the following error:

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\wamp64\www\QuebraLinha\test\CasoTeste.php on line 6

The test class I'm using is this:

<?php

require_once("../TextWrapExerciseInterface.class.php"); //Classe Interface fornecida pela Galoa
require_once("../QuebraLinha.class.php"); //Classe criada para implementar a classe Interface

class QuebraLinhaTest extends PHPUnit_Framework_TestCase {

  function test01(){  //Confirma se o retorno é um array
    $q = new QuebraLinha();
    $returnTest = array();
    $this->assertInternalType('array', $q->textWrap("Isso é um teste", 5));
  }

}

?>

I'm not using any autoloader in the project. Thanks in advance.

    
asked by anonymous 02.09.2017 / 05:53

1 answer

2

The "mock" namespace PHPUnit_Framework_TestCase is "only" for version 5.7 of PHPunit

In phpunit version 6.3 the correct namespace is PHPUnit\Framework\TestCase (which now uses true namespaces instead of simulated ones).

Then your code should look like this:

<?php

require_once("../TextWrapExerciseInterface.class.php"); //Classe Interface fornecida pela Galoa
require_once("../QuebraLinha.class.php"); //Classe criada para implementar a classe Interface

class QuebraLinhaTest extends PHPUnit\Framework\TestCase
{
    public function test01()
    {
        $q = new QuebraLinha();
        $returnTest = array();
        $this->assertInternalType('array', $q->textWrap("Isso é um teste", 5));
    }
}
    
02.09.2017 / 06:30