public function testUpgradeLifeCycleAutomaticWithTest()
 {
     $template = new TemplateModel($this->_template->exportData());
     $template->importData(Zend_Json::decode(self::LIFE_CYCLE_AUTOMATIC_WITH_TESTS));
     $lifeCycle = App_MigrationTool_TemplatesTo24_LifeCycleUtils::upgradeLifeCycle($template);
     $this->assertInstanceOf('Application\\Model\\LifeCycleModel', $lifeCycle);
     $status = $lifeCycle->getStatusByOriginStatus(LifeCycleModel::STATUS_ACTIVATION_READY);
     $this->assertInstanceOf('Application\\Model\\LifeCycle\\StatusModel', $status);
     $trasition = $status->getTransitionByDestinationStatus(LifeCycleModel::STATUS_ACTIVE);
     $this->assertInstanceOf('Application\\Model\\LifeCycle\\TransitionModel', $trasition);
     $this->assertTrue($trasition->manual);
     $validator = new LifeCycleAutomaticWithTest();
     $this->assertTrue($validator->isValid($lifeCycle), var_export($validator->getMessages(), 1));
 }
 public function testUpgradeTariffPlanLifeCycle()
 {
     $template = new TemplateModel($this->_template->exportData());
     $template->importData(Zend_Json::decode(self::LIFE_CYCLE_TARIFF));
     $tariff = App_MigrationTool_TemplatesTo24_LifeCycleTariffUtils::upgradeTariffPlanLifeCycle($template);
     $this->assertInstanceOf('Application\\Model\\TariffPlanLifeCycleModel', $tariff);
     $status = $tariff->findStatus(LifeCycleModel::STATUS_ACTIVATION_READY);
     $this->assertInstanceOf('Application\\Model\\TariffPlan\\StatusCostModel', $status);
     $this->assertEquals(0, $status->cost);
     $status = $tariff->findStatus(LifeCycleModel::STATUS_ACTIVATION_PENDANT);
     $this->assertInstanceOf('Application\\Model\\TariffPlan\\StatusCostModel', $status);
     $this->assertEquals(0, $status->cost);
     $validator = new TariffPlanLifeCycleValidate();
     $this->assertTrue($validator->isValid($tariff), var_export($validator->getMessages(), 1));
 }
 /**
  *
  * @param  \Application\Model\TemplateModel           $template
  * @throws App_MigrationTool_TemplatesTo23_Exception
  * @return \Application\Model\LifeCycleModel
  */
 public static function upgradeLifeCycle($template)
 {
     $oldData = $template->exportData();
     $lifeCycle = new LifeCycleModel();
     $lifeCycle->importData($oldData);
     $validatorAuto = new App_MigrationTool_TemplatesTo24_LifeCycleAutomatic();
     $validatorAutoTest = new App_MigrationTool_TemplatesTo24_LifeCycleAutomaticWithTest();
     if (!($validatorAuto->isValid($lifeCycle) || $validatorAutoTest->isValid($lifeCycle))) {
         throw new App_MigrationTool_TemplatesTo24_Exception("LifeCycle template {$template->id} does not need upgrade.");
     }
     $status = $lifeCycle->getStatusByOriginStatus(LifeCycleModel::STATUS_ACTIVATION_READY);
     $transition = $status->getTransitionByDestinationStatus(LifeCycleModel::STATUS_ACTIVE);
     if ($transition->manual) {
         throw new App_MigrationTool_TemplatesTo24_Exception("LifeCycle template {$template->id} already upgraded.");
     }
     $transition->manual = true;
     return $lifeCycle;
 }
 public static function upgradeTariffPlanTemplate($id, $orgId, $tariffPlan)
 {
     $template = new TemplateModel();
     $template->id = $id;
     $template->organizationId = $orgId;
     $template->type = 'tariffPlanService';
     $template->description = $tariffPlan->name;
     $template->importData($tariffPlan->exportData());
     return $template;
 }
 public function tearDown()
 {
     $this->_template->delete();
 }
 /**
  * @expectedException Application\Exceptions\NotFoundException
  */
 public function testDeleteNonExistingTemplate()
 {
     $this->template->setId('NoExistsId');
     $this->templateMapper->delete($this->template->getId());
 }