I am writing a custom Codeception module because I can't find how to achieve the same using the bundled Doctrine2 module. Basically I need to get the MAX value for a column. This is how the code looks like:
namespace Helper;
use Codeception\Module\Doctrine2;
class ExtendedDoctrine2 extends Doctrine2
{
public function grabMaxValueFromRepository($entity, $field): array
{
$this->em->flush();
$data = $this->em->getClassMetadata($entity);
$qb = $this->em->getRepository($entity)->createQueryBuilder('s');
$qb->select('MAX(s.'.$field.')');
$this->debug($qb->getDQL());
return $qb->getQuery()->getSingleScalarResult();
}
}
On my api.suite.yml I define the module as follow:
actor: ApiTester
modules:
enabled:
- Asserts
- Symfony:
app_path: 'src'
environment: 'test'
- Doctrine2:
depends: Symfony
cleanup: true
- \Helper\ExtendedDoctrine2
depends: Symfony
cleanup: true
When I try to run the test I got the following error:
Module \Helper\ExtendedDoctrine2 depends: Symfony cleanup: true could not be found and loaded
What I am missing here? Is there any way to achieve get the MAX value without the need to write a module for this?
Codeception docs are not so good (no docs for how to extends modules) or at least is what seems to me, I read here and some links there leads to dead repositories on Github.
Aucun commentaire:
Enregistrer un commentaire