Hello, I'm updating phpunit from a version 5.1 to 6.5 system, but from the update, the tests that were all working successfully, started to fail.
The error message is:
1) Tests \ Administration \ Controller \ StudentControllerTest :: testModuloController TypeError: Argument 3 passed to SebastianBergmann \ GlobalState \ Snapshot :: __ construct () must be of type boolean, called in /usr/share/php/PHPUnit/Framework/TestCase.php on line 2177
I searched for documentation for the migration but did not find it. Anyone who has gone through this can help me? Or do you know of any documents to perform the migration?
The test code file 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');
}
}