Exemplo n.º 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());
         }
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 4
0
 private function createCategories(User $riaUser)
 {
     $categories = array();
     foreach ($this->categories as $category) {
         $asset = new AssetClass();
         $asset->setName($category['name']);
         $asset->setType($category['type']);
         foreach ($category['subclasses'] as $item) {
             $subclass = new Subclass();
             $subclass->setOwner($riaUser);
             $subclass->setAssetClass($asset);
             $subclass->setName($item['name']);
             $subclass->setExpectedPerformance($item['expected_performance']);
             $subclass->setAccountType($this->getReference('subclass-account-type-' . $item['account_type_index']));
             $subclass->setPriority($item['priority']);
             $subclass->setToleranceBand($item['tolerance_band']);
             $asset->addSubclasse($subclass);
         }
         $categories[] = $asset;
     }
     return $categories;
 }