コード例 #1
0
ファイル: client_test.php プロジェクト: bmdevel/ezc
 public function runTest()
 {
     $this->setup->adjustRequest($this->testData['request']);
     $response = $this->performTestSetRun($this->testData['request']);
     $this->setup->adjustResponse($response, $this->testData['response']);
     $this->assertRunCorrect($this->testData['response'], $response);
 }
コード例 #2
0
 public function adjustResponse(array &$realResponse, array &$expectedResponse)
 {
     parent::adjustResponse($realResponse, $expectedResponse);
     if (isset($realResponse['headers']['Lock-Token']) && !isset($expectedResponse['headers']['Lock-Token'])) {
         throw new RuntimeException('Real response had Lock-Token, expected not!');
     }
     if (!isset($realResponse['headers']['Lock-Token']) && isset($expectedResponse['headers']['Lock-Token'])) {
         throw new RuntimeException('Expected response had Lock-Token, real not!');
     }
     if (isset($realResponse['headers']['Lock-Token'])) {
         $toReplace = $expectedResponse['headers']['Lock-Token'];
         $replaceWith = $realResponse['headers']['Lock-Token'];
         $this->tokenReplacement[$toReplace] = $replaceWith;
         $expectedResponse['headers']['Lock-Token'] = $realResponse['headers']['Lock-Token'];
     }
     foreach ($this->tokenReplacement as $from => $to) {
         $expectedResponse['body'] = preg_replace('(' . preg_quote($from) . ')', $to, $expectedResponse['body']);
     }
     // Unify last access dates
     $realResponse['body'] = preg_replace('([0-9]{4}-[0-9]{2}-[0-9]{2}[0-9T:+]+)', '2008-11-09T22:14:18+00:00', $realResponse['body']);
     $expectedResponse['body'] = preg_replace('([0-9]{4}-[0-9]{2}-[0-9]{2}[0-9T:+]+)', '2008-11-09T22:14:18+00:00', $expectedResponse['body']);
 }