Exemplo n.º 1
0
 public function generateCVMP($cvmp, $vm)
 {
     //TODO prettify this
     $newCvmps = [];
     $pm = $cvmp['vmp'][$vm];
     Cvmp::removeVm($cvmp, $vm);
     $pms = $cvmp['pmp'];
     unset($pms[$pm]);
     $pms = array_keys($pms);
     foreach ($pms as $pm) {
         if (RulesFreeOfContext::isAllowed($vm, $pm)) {
             $newCvmp = $cvmp;
             Cvmp::addVm($newCvmp, $vm, $pm);
             if (RulesSensitiveToTheContext::isAllowed($newCvmp)) {
                 $newCvmps[] = $newCvmp;
             }
         }
     }
     return $newCvmps;
 }
Exemplo n.º 2
0
 /**
  * @depends testLastAdded
  * @depends testCvmpBuildCVmpByPlacements
  */
 public function testComparisonCvmp()
 {
     $places = ['v1' => 'p1', 'v2' => 'p1', 'v3' => 'p2', 'v4' => 'p2', 'v5' => 'p3'];
     $cvmp1 = Cvmp::buildCVmpByPlacements($places);
     $cvmp2 = [];
     foreach ($places as $vm => $pm) {
         Cvmp::addVm($cvmp2, $vm, $pm);
     }
     unset($cvmp2[OC_LAST_ADD_VM]);
     unset($cvmp2[OC_LAST_ADD_PM]);
     $this->assertEquals($cvmp1, $cvmp2, "CVMP !match");
 }