public function testCreateTestInvalidExpectation()
 {
     $newTest = new Test();
     $newTest->setName("Ping 1234")->setActual("1.2.3.4")->setExpectation("IfThisExpectationExistsIBrokeIt");
     $this->logIn("ROLE_SUPER_ADMIN");
     $this->makeJsonRequest('POST', '/api/tests/group/' . TestGroupFixtures::$groups['group-2']->getId(), ["name" => $newTest->getName(), "actual" => $newTest->getActual(), "expectation" => $newTest->getExpectation()]);
     $this->assertEquals(Response::HTTP_UNPROCESSABLE_ENTITY, $this->client->getResponse()->getStatusCode());
     $this->assertContains($newTest->getExpectation(), $this->getResponseContent(TRUE));
     $this->assertContains("could not be found", $this->getResponseContent(TRUE));
     $this->assertNull($this->em->getRepository("Overwatch\\TestBundle\\Entity\\Test")->findOneBy(["name" => $newTest->getName()]));
 }
 /**
  * Creates a test in the given group
  * 
  * @Route("/group/{id}")
  * @Method({"POST"})
  * @Security("is_granted('edit', group)")
  * @ApiDoc(
  *     resource=true,
  *     parameters={
  *         {"name"="name", "description"="A user-friendly name for the test", "required"=true, "format"="Github Status", "dataType"="string"},
  *         {"name"="actual", "description"="The actual value to test against", "required"=true, "format"="status.github.com", "dataType"="string"},
  *         {"name"="expectation", "description"="The expectation to test with", "required"=true, "format"="toResolveTo", "dataType"="string"},
  *         {"name"="expected", "description"="The expected value to test against", "required"=false, "format"="octostatus-production.github.com", "dataType"="string"},
  *     },
  *     requirements={
  *         {"name"="id", "description"="The ID of the group to create the test under", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919",
  *         "Admin" = "#ffff33"
  *     }
  * )
  */
 public function createTest(Request $request, TestGroup $group)
 {
     $test = new Test();
     $test->setActual($request->request->get('actual'))->setExpectation($request->request->get('expectation'))->setExpected($request->request->get('expected'))->setName($request->request->get('name'))->setGroup($group);
     try {
         $this->expectationManager->get($test->getExpectation());
     } catch (ExpectationNotFoundException $ex) {
         return new JsonResponse("Expectation '" . $test->getExpectation() . "' could not be found", JsonResponse::HTTP_UNPROCESSABLE_ENTITY);
     }
     if ($test->getActual() === NULL) {
         return new JsonResponse("An actual value to test against must be provided.", JsonResponse::HTTP_UNPROCESSABLE_ENTITY);
     }
     $this->_em->persist($test);
     $this->_em->flush();
     return new JsonResponse($test, JsonResponse::HTTP_CREATED);
 }