浏览代码

usa el request correcto

Luciano Andrade 7 年之前
父节点
当前提交
2e727ea82b
共有 2 个文件被更改,包括 7 次插入0 次删除
  1. 5 0
      src/FTTHBundle/Controller/ONURESTController.php
  2. 2 0
      src/FTTHBundle/tests/ONURESTControllerTest.php

+ 5 - 0
src/FTTHBundle/Controller/ONURESTController.php

@@ -147,6 +147,8 @@ class ONURESTController extends RESTController
      */
     public function applyAction(Request $request, ONU $entity, String $workflow, String $transition)
     {
+	$entity->setAdministrativeState("suspend");
+	return $entity;
         try {
 
 	    $wr = $this->container->get("workflow.registry");
@@ -154,6 +156,7 @@ class ONURESTController extends RESTController
 
 	    $newState = $wf->apply($entity, $transition);
 
+
 	    $em = $this->container->get("doctrine.orm.entity_manager");
 	    $validator = $this->container->get('validator');
 	    $errors = $validator->validate($entity);
@@ -161,8 +164,10 @@ class ONURESTController extends RESTController
 		    $errorsString = (string) $errors;
 		    return FOSView::create($errorsString, Codes::HTTP_INTERNAL_SERVER_ERROR);
 	    }else{
+		    $entity->setAdministrativeState("suspend");
 		    $em->persist($entity);
 		    $em->flush();
+		    $em->getConnection()->commit();
 
 		    return $entity;
 	    }

+ 2 - 0
src/FTTHBundle/tests/ONURESTControllerTest.php

@@ -195,10 +195,12 @@ class ONURESTControllerTest extends WebTestCaseBase
 
 	$this->getClient()->request('PATCH',
 		$this->getUriPutDelete(). "apply/". $json["id"] . "/administrative_state/active_to_suspend.json" , array());
+        $response = $this->getClient()->getResponse();
 
 	$json = json_decode($response->getContent(), true);
 	$json = $json[0];
 
+        $this->assertEquals(200, $response->getStatusCode(), "Error en la respuesta http.");
 	$this->assertEquals("suspend", $json["administrativeState"]);
 
         $response = $this->getClient()->getResponse();