php - How Do I Test a Very Simple Event Handler Without Coupling to Implementation? -
so have question practice when comes (unit) testing event handlers.
my situation involves domain object should mutated , persisted in handler of set of events. logic simple , goes this:
function handle(domainevent $event) { $entitya = $this->entityarepository->getbyid($event->getentityaid()); $entitybid = $entitya->getentitybid(); $entityb = $this->entitybrepository->getbyid($entitybid); if ($entityb->getstatus() == entitybstatus::some_status) { $entitya->commandmethod($entitybid); } $this->entityarepository->save($entitya); }
the main point important behavior of handler calls command method , persists resultant state. how test without coupling test heavily implementation, or necessary evil?
Comments
Post a Comment