public function Status400TimeGateErrorResponseCommonTests($URIG, $statuscode, $outputfile, $debugfile)
 {
     global $sessionCookieString;
     $uagent = "Memento-Mediawiki-Plugin/Test";
     $curlCmd = "curl -v -s -A '{$uagent}' -b '{$sessionCookieString}' -k -i -H 'Accept-Datetime: bad-input' --url '{$URIG}'";
     $response = `{$curlCmd} 2> {$debugfile} | tee "{$outputfile}"`;
     $statusline = extractStatusLineFromResponse($response);
     $entity = extractEntityFromResponse($response);
     $headers = extractHeadersFromResponse($response);
     $this->assertEquals($statuscode, $statusline["code"]);
     $this->assertArrayHasKey('Vary', $headers);
     $varyItems = extractItemsFromVary($headers['Vary']);
     $this->assertContains('Accept-Datetime', $varyItems, "Accept-Datetime not present in Vary header");
     # To catch any PHP errors that the test didn't notice
     $this->assertFalse(strpos($entity, "<b>Fatal error</b>"));
     # To catch any PHP notices that the test didn't notice
     $this->assertFalse(strpos($entity, "<b>Notice</b>"));
     # To catch any PHP notices that the test didn't notice
     $this->assertFalse(strpos($entity, "<b>Warning</b>"));
     # To ensure that the error message actually exists in the output
     $expected = acquireFormattedI18NString('en', 'timegate-400-date');
     $this->assertStringMatchesFormat("%A" . $expected . "%A", $entity);
 }
Beispiel #2
0
 public function Status200StyleTimeGateMementoResponseCommonTests($IDENTIFIER, $ACCEPTDATETIME, $REQUESTED_URI, $URIR, $ORIGINALLATEST, $FIRSTMEMENTO, $LASTMEMENTO, $URIM, $URIG, $URIT, $COMMENT, $outputfile, $debugfile)
 {
     global $sessionCookieString;
     $uagent = "Memento-Mediawiki-Plugin/Test";
     $curlCmd = "curl -v -s -A '{$uagent}' -b '{$sessionCookieString}' -k -i -H 'Accept-Datetime: {$ACCEPTDATETIME}' -H \"X-TestComment: {$COMMENT}\" --url \"{$REQUESTED_URI}\"";
     $response = `{$curlCmd} 2> {$debugfile} | tee "{$outputfile}"`;
     $headers = extractHeadersFromResponse($response);
     $statusline = extractStatuslineFromResponse($response);
     $entity = extractEntityFromResponse($response);
     $this->assertEquals("200", $statusline["code"]);
     $this->assertArrayHasKey('Link', $headers);
     $this->assertArrayHasKey('Memento-Datetime', $headers);
     $this->assertArrayHasKey('Vary', $headers);
     $this->assertArrayHasKey('Content-Location', $headers);
     $this->assertEquals($URIM, $headers['Content-Location']);
     $relations = extractItemsFromLink($headers['Link']);
     $this->assertArrayHasKey('original latest-version timegate', $relations);
     $this->assertEquals($URIR, $relations['original latest-version timegate']['url']);
     $this->assertArrayHasKey('timemap', $relations, "timemap relation not present in Link Header");
     $this->assertEquals($URIT, $relations['timemap']['url']);
     $varyItems = extractItemsFromVary($headers['Vary']);
     $this->assertContains('Accept-Datetime', $varyItems);
     $this->StandardEntityTests($entity, $URIR);
     return $response;
 }