/**
  * Makes sure all entities in this registry are ready to work.
  * It means that all properties of these entities are filled.
  *
  * @param TemplateManager $templateManager
  */
 protected function ensureReadyToWork(TemplateManager $templateManager)
 {
     while ($this->isDirty) {
         $this->isDirty = false;
         foreach ($this->entities as $className => &$entities) {
             foreach ($entities as $entityKey => &$val) {
                 if ($val['isDirty']) {
                     $repository = $templateManager->getEntityRepository($className);
                     $repository->fillEntityData($entityKey, $val['entity']);
                     $val['isDirty'] = false;
                 }
             }
         }
     }
 }
 public function testInitialization()
 {
     $repository = new TestTemplateEntityRepository();
     $this->templateManager->addEntityRepository($repository);
     $this->assertSame($this->templateManager, $this->templateManager->getEntityRepository($repository->getEntityClass())->getTemplateManager());
 }