1<?php 2/** 3 * holds a copy of all produced outputs of a TestRequest 4 */ 5class TestResponse { 6 /** 7 * @var string 8 */ 9 private $content; 10 11 /** 12 * @var array 13 */ 14 private $headers; 15 16 /** 17 * @var phpQueryObject 18 */ 19 private $pq = null; 20 21 /** 22 * @param $content string 23 * @param $headers array 24 */ 25 function __construct($content, $headers) { 26 $this->content = $content; 27 $this->headers = $headers; 28 } 29 30 /** 31 * @return string 32 */ 33 public function getContent() { 34 return $this->content; 35 } 36 37 /** 38 * @return array 39 */ 40 public function getHeaders() { 41 return $this->headers; 42 } 43 44 /** 45 * Query the response for a JQuery compatible CSS selector 46 * 47 * @link https://code.google.com/p/phpquery/wiki/Selectors 48 * @param $selector string 49 * @return phpQueryObject 50 */ 51 public function queryHTML($selector){ 52 if(is_null($this->pq)) $this->pq = phpQuery::newDocument($this->content); 53 return $this->pq->find($selector); 54 } 55} 56