name = 'Risk Test'; $obj->descriptionRaw = 'Description'; $obj->unit = 1; $obj->department = new NullDepartment(1); $obj->category = new Category(); $obj->process = new Process(); $obj->process->unit = 1; $obj->responsible = new NullAccount(1); $obj->deputy = new NullAccount(1); $causeObj = new Cause(); $causeObj->title = 'Risk Test Cause'; $obj->causes[] = $causeObj; $solutionObj = new Solution(); $solutionObj->title = 'Risk Test Solution'; $obj->solutions[] = $solutionObj; $riskObj = new RiskObject(); $riskObj->title = 'Risk Test Object'; $obj->riskObjects[] = $riskObj; $obj->histScore[] = 2; $media = new Media(); $media->createdBy = new NullAccount(1); $media->description = 'desc'; $media->setPath('some/path'); $media->size = 11; $media->extension = 'png'; $media->name = 'Image'; $obj->files[] = $media; RiskMapper::create()->execute($obj); self::assertGreaterThan(0, $obj->id); $objR = RiskMapper::get() ->with('project') ->with('causes') ->with('solutions') ->with('riskObjects') ->with('files') ->where('id', $obj->id) ->execute(); self::assertGreaterThan(0, $objR->id); self::assertEquals($obj->name, $objR->name); self::assertEquals($obj->descriptionRaw, $objR->descriptionRaw); self::assertEquals($obj->unit, $objR->unit); self::assertEquals($obj->department->id, $objR->department->id); self::assertEquals($obj->category->id, $objR->category->id); self::assertEquals($obj->process->id, $objR->process->id); self::assertEquals($obj->responsible?->id, $objR->responsible?->id); self::assertEquals($obj->deputy?->id, $objR->deputy?->id); self::assertEquals($obj->project?->id, $objR->project?->id); $causes = $objR->causes; self::assertEquals($obj->causes[0]->title, \end($causes)->title); $solutions = $objR->solutions; self::assertEquals($obj->solutions[0]->title, \end($solutions)->title); $riskObjects = $objR->riskObjects; self::assertEquals($obj->riskObjects[0]->title, \end($riskObjects)->title); } }