Example #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());
         }
     }
 }
Example #2
0
 private function createRiaPortfolioModel(ObjectManager $manager, User $riaUser)
 {
     /** @var CeModel $strategy */
     $strategy = $this->getReference('strategy-1');
     $modelManager = new CeModelManager($manager, '\\Wealthbot\\AdminBundle\\Entity\\CeModel');
     $riaModel = $modelManager->copyForOwner($strategy, $riaUser);
     $manager->persist($riaModel);
     return $riaModel;
 }