Пример #1
0
 public function testCopyForOwner()
 {
     $mockOwner2 = $this->getMockUser(2);
     $model = $this->modelObjects[2];
     $childModel = $this->modelObjects[3];
     $entity = new CeModelEntity();
     $assetClass = new AssetClass();
     $subclass = new Subclass();
     $assetClass->setModel($model);
     $assetClass->addSubclasse($subclass);
     $subclass->setAssetClass($assetClass);
     $entity->setSubclass($subclass);
     $childModel->addModelEntity($entity);
     $copiedModel = $this->manager->copyForOwner($model, $mockOwner2);
     $this->assertEquals(5, $copiedModel->getRiskRating());
     $this->assertEquals(2, $copiedModel->getOwner()->getId());
     $this->assertCount(1, $copiedModel->getChildren());
     foreach ($copiedModel->getChildren() as $child) {
         $this->assertEquals(2, $child->getOwner()->getId());
         $this->assertCount(1, $child->getModelEntities());
         foreach ($child->getModelEntities() as $entity) {
             $this->assertNotNull($entity->getSubclass());
             $this->assertNotNull($entity->getSubclass()->getAssetClass());
         }
     }
 }
Пример #2
0
 /**
  * Add asset
  *
  * @param AssetClass $asset
  * @return $this
  */
 public function addAsset(AssetClass $asset)
 {
     $asset->setModel($this->model);
     if ($this->model->getId()) {
         $asset->setModelId($this->model->getId());
     }
     $this->assets[] = $asset;
     return $this;
 }
Пример #3
0
 public function load(ObjectManager $manager)
 {
     $index = 1;
     foreach ($this->assetClasses as $name) {
         $model = $this->getReference('strategy-' . $index);
         $assetClass = new AssetClass();
         $assetClass->setName($name);
         $assetClass->setType(AssetClass::TYPE_STOCKS);
         $assetClass->setModel($model);
         $manager->persist($assetClass);
         $this->addReference('asset-class-' . $index, $assetClass);
         $index++;
     }
     $manager->flush();
 }