I'm running into some trouble writing a simple test using codeception.
It's a simple procedure to upload a excel file and check if the data on the excel file is available on the database after uploade. My test code:
public function do_carga_vendedores(BTester $I)
{
$I->amOnPage('/admin/carga/vendedores');
$I->attachFile('templateupload', 'carga_vendedores.xlsx');
$I->click('Enviar');
$I->see('Cadastro feito com sucesso!');
$I->seeInDatabase('usuario', [
'cpf' => '332.895.032-08',
'nome' => 'Test1'
]);
$I->seeInDatabase('usuario', [
'cpf' => '776.676.558-63',
'nome' => 'Test2'
]);
}
}
Generates:
Step I see "Cadastro feito com sucesso!"
Fail Failed asserting that /admin/carga/doRealizarCargaVendedor
When I check the output file it shows:
Fatal error: Call to a member function getType() on a non-object in /var/www/apps/shared/models/BaseModel.php on line 82
Line 82 code:
switch ($message->getType()) {
I've done a var_dump on the $message
variable and the result is:
object(Phalcon\Mvc\Model\Message)[148]
protected '_type' => string 'PresenceOf' (length=10)
protected '_message' => string 'nome is required' (length=16)
protected '_field' => string 'nome' (length=4)
protected '_model' => null
The whole code for BaseModel.php can be found here
But if I upload the file using chrome, the issue isn't reproducible. I don't know if this is as phpbrowser problem or if there is a defect on my code.
OBS: Framework: Phalcon 2.0.5 / Codeception 2.1.1