Commit c48ca8c2 authored by Bas de Nooijer's avatar Bas de Nooijer

- removed trailing whitespace in __toString() output

- added both the original resource and the urldecoded version to the __toString() output
- added a testcase for __toString()
parent 652e0c1d
...@@ -396,10 +396,11 @@ class Solarium_Client_Request extends Solarium_Configurable ...@@ -396,10 +396,11 @@ class Solarium_Client_Request extends Solarium_Configurable
*/ */
public function __toString() public function __toString()
{ {
$output = __CLASS__ . '::toString ' . " \n" $output = __CLASS__ . '::toString' . "\n"
. 'method: ' . $this->getMethod() . "\n" . 'method: ' . $this->getMethod() . "\n"
. 'header: ' . print_r($this->getHeaders(), 1) //don't add newline when using print_r . 'header: ' . print_r($this->getHeaders(), 1) //don't add newline when using print_r
. 'resource: ' . urldecode($this->getUri()) . "\n" . 'resource: ' . $this->getUri() . "\n"
. 'resource urldecoded: ' . urldecode($this->getUri()) . "\n"
. 'raw data: ' . $this->getRawData() . "\n"; . 'raw data: ' . $this->getRawData() . "\n";
return $output; return $output;
......
...@@ -439,4 +439,37 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase ...@@ -439,4 +439,37 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
); );
} }
public function testToString()
{
$options = array(
'method' => Solarium_Client_Request::METHOD_POST,
'handler' => '/myHandler',
'param' => array(
'param1' => 1,
'param2' => 'test content',
),
'rawdata' => 'post data',
'header' => array(
'myHeader1' => 'X-myHeader1: value1',
'myHeader2' => 'X-myHeader2: value2',
),
);
$this->_request->setOptions($options);
$this->assertEquals(
'Solarium_Client_Request::toString
method: POST
header: Array
(
[0] => X-myHeader1: value1
[1] => X-myHeader2: value2
)
resource: /myHandler?param1=1&param2=test+content
resource urldecoded: /myHandler?param1=1&param2=test content
raw data: post data
',
(string)$this->_request
);
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment