|
@@ -2,9 +2,8 @@
|
|
|
|
|
|
namespace FTTHBundle\tests;
|
|
|
|
|
|
-use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
-
|
|
|
use FTTHBundle\Entity\ONU;
|
|
|
+use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
|
|
/**
|
|
|
* @package FTTHBundle\tests
|
|
@@ -19,53 +18,52 @@ class WorkflowOnuTest extends KernelTestCase
|
|
|
$this->em = static::$kernel->getContainer()
|
|
|
->get('doctrine')
|
|
|
->getManager();
|
|
|
- $this->wr = static::$kernel->getContainer()
|
|
|
+ $this->wr = static::$kernel->getContainer()
|
|
|
->get('workflow.registry');
|
|
|
|
|
|
}
|
|
|
|
|
|
- function testAdministrative(){
|
|
|
+ public function testAdministrative()
|
|
|
+ {
|
|
|
$onu = new ONU;
|
|
|
- $onu->setPonSerialNumber("cafecafecafe");
|
|
|
- $onu->setClientId(1);
|
|
|
- $onu->setTenancyId(1);
|
|
|
+ $onu->setPonSerialNumber("cafecafecafe");
|
|
|
+ $onu->setClientId(1);
|
|
|
+ $onu->setTenancyId(1);
|
|
|
+
|
|
|
+ try {
|
|
|
+ $this->em->persist($onu);
|
|
|
+ $this->em->flush();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- try{
|
|
|
- $this->em->persist($onu);
|
|
|
- $this->em->flush();
|
|
|
- }catch(\Exception $e){
|
|
|
-
|
|
|
- }
|
|
|
+ $this->assertEquals("active", $onu->getAdministrativeState());
|
|
|
|
|
|
- $this->assertEquals("active", $onu->getAdministrativeState());
|
|
|
-
|
|
|
+ $wf = $this->wr->get($onu, "administrative_state");
|
|
|
|
|
|
- $wf = $this->wr->get($onu, "administrative_state");
|
|
|
-
|
|
|
- $wf->apply($onu, "active_to_suspend");
|
|
|
+ $wf->apply($onu, "suspend");
|
|
|
|
|
|
- $this->assertEquals("suspend", $onu->getAdministrativeState());
|
|
|
+ $this->assertEquals("suspend", $onu->getAdministrativeState());
|
|
|
|
|
|
- $this->em->persist($onu);
|
|
|
- $this->em->flush();
|
|
|
+ $this->em->persist($onu);
|
|
|
+ $this->em->flush();
|
|
|
|
|
|
$newOnu = $this->em->getRepository("FTTHBundle\Entity\ONU")->findOneByPonSerialNumber("cafecafecafe");
|
|
|
|
|
|
- $this->assertEquals("suspend", $newOnu->getAdministrativeState());
|
|
|
+ $this->assertEquals("suspend", $newOnu->getAdministrativeState());
|
|
|
|
|
|
- $wf->apply($newOnu, "suspend_to_active");
|
|
|
+ $wf->apply($newOnu, "active");
|
|
|
|
|
|
- $this->em->persist($newOnu);
|
|
|
- $this->em->flush();
|
|
|
+ $this->em->persist($newOnu);
|
|
|
+ $this->em->flush();
|
|
|
|
|
|
$newOnu = $this->em->getRepository("FTTHBundle\Entity\ONU")->findOneByPonSerialNumber("cafecafecafe");
|
|
|
- $this->assertEquals("active", $newOnu->getAdministrativeState());
|
|
|
+ $this->assertEquals("active", $newOnu->getAdministrativeState());
|
|
|
|
|
|
+ if ($newOnu) {
|
|
|
+ $newOnu = $this->em->remove($newOnu);
|
|
|
+ $this->em->flush();
|
|
|
+ }
|
|
|
|
|
|
- if($newOnu){
|
|
|
- $newOnu = $this->em->remove($newOnu);
|
|
|
- $this->em->flush();
|
|
|
- }
|
|
|
-
|
|
|
}
|
|
|
}
|