2011-01-27 21 views
3

assertHeaderとassertHeaderContainsがなぜ失敗するのか誰にでも教えてください。それ以外はうまく動作します。assertHeaderが失敗します

私は、有効なデータを返す応答オブジェクトを持っています(下記参照)。私は "assertHeader"と "assertHeaderContains"を除いて、このレスポンスに対していくつかの基本的なコントローラ・ユニット・テストを実行しています。

ここには私のZend_Http_Responseのダンプが本体なしであります。この応答は、(顧客/読み取り)コントローラメソッドによって返されます。

.object(Zend_Http_Response)#182 (5) { 
["version":protected]=> 
string(3) "1.1" 
["code":protected]=> 
int(200) 
["message":protected]=> 
string(2) "OK" 
["headers":protected]=> 
array(8) { 
["Connection"]=> 
string(5) "close" 
["Date"]=> 
string(29) "Thu, 27 Jan 2011 14:30:07 GMT" 
["Server"]=> 
string(17) "Microsoft-IIS/6.0" 
["X-powered-by"]=> 
string(7) "ASP.NET" 
["X-aspnet-version"]=> 
string(9) "2.0.50727" 
["Cache-control"]=> 
string(7) "private" 
["Content-type"]=> 
string(8) "text/xml" 
["Content-length"]=> 
string(4) "2075" 
} 
["body":protected]=> 

は、ここに私のユニットテストです:

public function testCustomerRead(){  
    $this->dispatch('customer/read'); // works 
    $this->assertResponsecode(200); // works 
    $this->assertController('customer'); // works 
    $this->assertAction('read'); // works 

    // FAILS with: Failed asserting response header "Content-type" found** 
    $this->assertHeader('Content-type'); 

    **// FAILS with: Failed asserting response header "Content-type" exists and contains "text/xml"** 
    $this->assertHeaderContains('Content-type', 'text/xml'); 
} 
+0

提供されZend_Http_Responseオブジェクトダンプが(testCustomerReadで行われました)ただの$ this - >発送後(「顧客読み取り/」);? – Marcin

答えて

3

は、「コンテンツタイプ」に試してみて。 そのような何か:

$this->assertHeaderContains('Content-Type', 'text/xml'); 
+0

こんにちは。私もassertHeaderを動かそうとしています。私は 'Content-Type'のスペルを確認して、ブラウザにファイアウォールでapiを開いて、ヘッダーが存在するかどうかを確認しました。まだそれは失敗しています。この質問を投稿した人のように、他のすべての人は合格しています(responseCode、controllerなど) – Martyn

関連する問題