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