Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
6733aa36
Commit
6733aa36
authored
Feb 24, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed some test issues
parent
692a78ae
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
120 additions
and
4 deletions
+120
-4
library/Solarium/Client/Adapter/Http.php
library/Solarium/Client/Adapter/Http.php
+12
-3
library/Solarium/Client/Adapter/ZendHttp.php
library/Solarium/Client/Adapter/ZendHttp.php
+3
-1
tests/Solarium/Client/Request/PingTest.php
tests/Solarium/Client/Request/PingTest.php
+65
-0
tests/Solarium/Client/Request/UpdateTest.php
tests/Solarium/Client/Request/UpdateTest.php
+16
-0
tests/Solarium/Client/RequestTest.php
tests/Solarium/Client/RequestTest.php
+8
-0
tests/Solarium/Document/ReadOnlyTest.php
tests/Solarium/Document/ReadOnlyTest.php
+16
-0
No files found.
library/Solarium/Client/Adapter/Http.php
View file @
6733aa36
...
@@ -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'
);
}
}
}
}
...
...
library/Solarium/Client/Adapter/ZendHttp.php
View file @
6733aa36
...
@@ -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
;
}
}
}
}
...
...
tests/Solarium/Client/Request/PingTest.php
0 → 100644
View file @
6733aa36
<?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
tests/Solarium/Client/Request/UpdateTest.php
View file @
6733aa36
...
@@ -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
;
...
...
tests/Solarium/Client/RequestTest.php
View file @
6733aa36
...
@@ -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
(
...
...
tests/Solarium/Document/ReadOnlyTest.php
View file @
6733aa36
...
@@ -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
));
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment