public function __construct(Response $Response, CMSAcceptanceTester $acceptanceTester)
 {
     $this->setResponse($Response);
     $this->setAcceptanceTester($acceptanceTester);
     $this->testCase = $this->acceptanceTester->getTestCase();
     $this->testCase->setHTML($this->response->getRaw());
     $this->test = $this->testCase->getCodeTester();
     $this->entityMeta = clone $this->acceptanceTester->getEntityMeta();
 }
 /**
  * Asserted das Result des Tests auf $code
  *
  * converted das json zu json wenn $type 'json' ist
  * gibt das html als string zurück wenn $type 'html' ist
  *
  * ansonsten die response
  * @return array $json|string $html|Psc\URL\Response
  */
 public function result(CMSRequestDispatcher $dispatcher, $type = 'html', $code = 200)
 {
     $this->lastResponse = $response = $dispatcher->dispatch();
     $this->logf("Dispatched CMS Request:\n%s", $dispatcher->getRequestDebug());
     $this->testCase->setHTML($response->getDecodedRaw());
     // versuche error meldung zu bekommen
     $msg = NULL;
     if ($response->getCode() >= 400 && $response->getHeaderField('X-Psc-Cms-Error') == 'true' && $response->getHeaderField('X-Psc-Cms-Error-Message') != NULL) {
         $msg = "\n" . 'Fehler auf der Seite: ' . $response->getHeaderField('X-Psc-Cms-Error-Message');
     }
     $this->testCase->assertEquals($code, $response->getCode(), 'Failed asserting that Response is a ' . $code . '.' . $msg);
     if ($type !== 'response') {
         $this->testCase->assertContains($dispatcher->getContentType($type), $response->getHeaderField('Content-Type'), 'Failed asserting that response is from right ContentType');
     }
     if ($type == 'json') {
         return $this->testCase->getCodeTester()->json($response->getRaw(), FALSE, TRUE);
     } elseif ($type == 'html') {
         return $response->getDecodedRaw();
     } elseif ($type == 'text') {
         return $response->getRaw();
     } elseif ($type == 'response') {
         return $response;
     }
     return $response;
 }