Commit 6733aa36 authored by Bas de Nooijer's avatar Bas de Nooijer

- fixed some test issues

parent 692a78ae
...@@ -116,9 +116,18 @@ class Solarium_Client_Adapter_Http extends Solarium_Client_Adapter ...@@ -116,9 +116,18 @@ class Solarium_Client_Adapter_Http extends Solarium_Client_Adapter
if ($method == Solarium_Client_Request::POST) { if ($method == Solarium_Client_Request::POST) {
$data = $request->getRawData(); $data = $request->getRawData();
if (null !== $data) { if (null !== $data) {
stream_context_set_option($context, 'http', 'content', $data); stream_context_set_option(
stream_context_set_option($context, 'http', 'header', $context,
'Content-Type: text/xml; charset=UTF-8'); 'http',
'content',
$data
);
stream_context_set_option(
$context,
'http',
'header',
'Content-Type: text/xml; charset=UTF-8'
);
} }
} }
......
...@@ -148,7 +148,9 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter_Http ...@@ -148,7 +148,9 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter_Http
return $this->_jsonDecode($data); return $this->_jsonDecode($data);
break; break;
default: default:
throw new Solarium_Exception('Unknown content-type: ' . $type); throw new Solarium_Exception(
'Unknown Content-Type in ZendHttp adapter: ' . $type
);
break; break;
} }
} }
......
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class Solarium_Client_Request_PingTest extends PHPUnit_Framework_TestCase
{
protected $_query;
protected $_options = array(
'host' => '127.0.0.1',
'port' => 80,
'path' => '/solr',
'core' => null,
);
public function setUp()
{
$this->_query = new Solarium_Query_Ping($this->_options);
}
public function testGetMethod()
{
$this->assertEquals(
Solarium_Client_Request::HEAD,
$this->_getRequest($this->_options)->getMethod()
);
}
public function testGetUri()
{
$this->assertEquals(
'http://127.0.0.1:80/solr/admin/ping?',
$this->_getRequest($this->_options)->getUri()
);
}
}
\ No newline at end of file
...@@ -46,6 +46,22 @@ class Solarium_Client_Request_UpdateTest extends PHPUnit_Framework_TestCase ...@@ -46,6 +46,22 @@ class Solarium_Client_Request_UpdateTest extends PHPUnit_Framework_TestCase
$this->_query = new Solarium_Query_Update; $this->_query = new Solarium_Query_Update;
} }
public function testGetMethod()
{
$this->assertEquals(
Solarium_Client_Request::POST,
$this->_getRequest($this->_options)->getMethod()
);
}
public function testGetUri()
{
$this->assertEquals(
'http://127.0.0.1:80/solr/update?wt=json',
$this->_getRequest($this->_options)->getUri()
);
}
public function testBuildAddXmlNoParamsSingleDocument() public function testBuildAddXmlNoParamsSingleDocument()
{ {
$command = new Solarium_Query_Update_Command_Add; $command = new Solarium_Query_Update_Command_Add;
......
...@@ -49,6 +49,14 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase ...@@ -49,6 +49,14 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
return new $class($options, $query); return new $class($options, $query);
} }
public function testGetMethod()
{
$this->assertEquals(
Solarium_Client_Request::HEAD,
$this->_getRequest($this->_options)->getMethod()
);
}
public function testGetUri() public function testGetUri()
{ {
$this->assertEquals( $this->assertEquals(
......
...@@ -71,5 +71,21 @@ class Solarium_Document_ReadOnlyTest extends PHPUnit_Framework_TestCase ...@@ -71,5 +71,21 @@ class Solarium_Document_ReadOnlyTest extends PHPUnit_Framework_TestCase
$this->setExpectedException('Solarium_Exception'); $this->setExpectedException('Solarium_Exception');
$this->_doc->newField = 'new value'; $this->_doc->newField = 'new value';
} }
public function testIterator()
{
$fields = array();
foreach($this->_doc AS $key => $field)
{
$fields[$key] = $field;
}
$this->assertEquals($this->_fields, $fields);
}
public function testCount()
{
$this->assertEquals(count($this->_fields), count($this->_doc));
}
} }
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