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

Asked

Viewed 1,786 times

3

Good evening, 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 am not using any autoloader in the project. Since I thank you

1 answer

6


The namespace "simulated" 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 real namespaces and no longer simulated).

So 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));
    }
}
  • 1

    It worked really well thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.