0
Hello, I am upgrading phpunit from a 5.1 to 6.5 system, but from the upgrade, the tests that were all working successfully started to fail.
The error message is:
1) Tests Administration Controller Alunocontrollertest::testModuloController Typeerror: Argument 3 passed to Sebastianbergmann Globalstate Snapshot::__Construct() must be of the type Boolean, null Given, called in /usr/share/php/Phpunit/Framework/Testcase.php on line 2177
I searched for documentation for the migration but couldn’t find it. Can someone who has been through it help me? Or know of any document to perform the migration?
The code file of the test in question is:
<?php
namespace Tests\Administracao\Controller;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;
use PHPUnit\Framework\TestCase;
use Domain\Model\Instituicao\Instituicao;
use Domain\Model\Usuario\Administrador;
use Domain\Model\Usuario\Email;
use Domain\Model\Usuario\Senha;
/**
* Classe com métodos comuns para todos os controllers da api
*/
abstract class AbstractControllerTest extends TestCase
{
private $instituicao;
public function setUp()
{
$this->setApplicationConfig(include './config/application.config.php');
parent::setUp();
$serviceManager = $this->getApplicationServiceLocator();
$this->instituicao = $serviceManager->get('InstituicaoRepository')->getByUrl('uov');
}
public function auth()
{
// simula o repositório para não fazer modificações no banco
$session = $this->getMock('Session', array('offsetGet', 'offsetUnset'));
$usuario = $this->novoUsuario();
$session->expects($this->any())
->method('offsetGet')
->willReturn($usuario);
$serviceManager = $this->getApplicationServiceLocator();
$serviceManager->setAllowOverride(true);
$serviceManager->setService('Session', $session);
}
/**
* Cria um novo usuário
*/
private function novoUsuario()
{
$email = new Email('[email protected]');
$senha = new Senha('123456');
$usuario = new Administrador('Teste', $email, $senha, $this->instituicao);
return $usuario;
}
}
And also:
<?php
namespace Tests\Administracao\Controller;
use Doctrine\ORM\Tools\Pagination\Paginator;
/**
* Testa os métodos do controller do Aluno
*/
class AlunoControllerTest extends AbstractControllerTest
{
public function testModuloController()
{
$this->dispatch('/uov/alunos');
$this->assertModuleName('Administracao');
$this->assertControllerName('Administracao\Controller\AlunoController');
$this->assertControllerClass('AlunoController');
$this->assertMatchedRouteName('instituicao/alunos');
}
}