123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace FTTHBundle\tests;
- use FTTHBundle\Entity\ONU;
- use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
- /**
- * @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');
- }
- public 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, "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, "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();
- }
- }
- }
|