Updating phpunit v5.1 to v6.5

0

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');
    }
}
    
asked by anonymous 19.03.2018 / 20:43

1 answer

0

I have found that it is a compatibility problem between my version of ZendFramework (2.2. ) and the new version of phpUnit (6.5. ). So I had to keep the previous one.

    
20.03.2018 / 13:33