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
326d0a65
Commit
326d0a65
authored
May 09, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- unittest improvements and style fixes
parent
c040d36a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
111 additions
and
12 deletions
+111
-12
library/Solarium/Client/HttpException.php
library/Solarium/Client/HttpException.php
+1
-1
tests/Solarium/Client/HttpExceptionTest.php
tests/Solarium/Client/HttpExceptionTest.php
+65
-0
tests/Solarium/Client/ResponseTest.php
tests/Solarium/Client/ResponseTest.php
+8
-0
tests/Solarium/Plugin/AbstractTest.php
tests/Solarium/Plugin/AbstractTest.php
+25
-9
tests/Solarium/ResultTest.php
tests/Solarium/ResultTest.php
+12
-2
No files found.
library/Solarium/Client/HttpException.php
View file @
326d0a65
...
@@ -78,7 +78,7 @@ class Solarium_Client_HttpException extends Solarium_Exception
...
@@ -78,7 +78,7 @@ class Solarium_Client_HttpException extends Solarium_Exception
{
{
$this
->
_statusMessage
=
$statusMessage
;
$this
->
_statusMessage
=
$statusMessage
;
$message
=
'Solr HTTP error
,
'
.
$statusMessage
;
$message
=
'Solr HTTP error
:
'
.
$statusMessage
;
if
(
null
!==
$code
)
{
if
(
null
!==
$code
)
{
$message
.=
' ('
.
$code
.
')'
;
$message
.=
' ('
.
$code
.
')'
;
}
}
...
...
tests/Solarium/Client/HttpExceptionTest.php
0 → 100644
View file @
326d0a65
<?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_HttpExceptionTest
extends
PHPUnit_Framework_TestCase
{
public
function
testConstructor
()
{
$exception
=
new
Solarium_Client_HttpException
(
'message text'
,
123
);
$this
->
assertEquals
(
'Solr HTTP error: message text (123)'
,
$exception
->
getMessage
()
);
}
public
function
testGetMessage
()
{
$exception
=
new
Solarium_Client_HttpException
(
'message text'
,
123
);
$this
->
assertEquals
(
'message text'
,
$exception
->
getStatusMessage
()
);
}
public
function
testConstructorNoCode
()
{
$exception
=
new
Solarium_Client_HttpException
(
'message text'
);
$this
->
assertEquals
(
'Solr HTTP error: message text'
,
$exception
->
getMessage
()
);
}
}
\ No newline at end of file
tests/Solarium/Client/ResponseTest.php
View file @
326d0a65
...
@@ -66,4 +66,12 @@ class Solarium_Client_ResponseTest extends PHPUnit_Framework_TestCase
...
@@ -66,4 +66,12 @@ class Solarium_Client_ResponseTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$this
->
_data
,
$this
->
_response
->
getBody
());
$this
->
assertEquals
(
$this
->
_data
,
$this
->
_response
->
getBody
());
}
}
public
function
testMissingHeader
()
{
$headers
=
array
();
$this
->
setExpectedException
(
'Solarium_Exception'
);
new
Solarium_Client_Response
(
$this
->
_data
,
$headers
);
}
}
}
\ No newline at end of file
tests/Solarium/Plugin/AbstractTest.php
View file @
326d0a65
...
@@ -31,25 +31,41 @@
...
@@ -31,25 +31,41 @@
class
Solarium_Plugin_AbstractTest
extends
PHPUnit_Framework_TestCase
class
Solarium_Plugin_AbstractTest
extends
PHPUnit_Framework_TestCase
{
{
protected
$_plugin
,
$_client
,
$_options
;
public
function
testConstructor
()
public
function
setUp
()
{
{
$client
=
'dummy'
;
$this
->
_client
=
'dummy'
;
$options
=
array
(
'option1'
=>
1
);
$this
->
_options
=
array
(
'option1'
=>
1
);
$plugin
=
new
MyPlugin
(
$client
,
$options
);
$this
->
_plugin
=
new
MyPlugin
(
$this
->
_client
,
$this
->
_options
);
}
$this
->
assertEquals
(
public
function
testConstructor
()
$client
,
{
$plugin
->
getClient
()
$this
->
assertEquals
(
$this
->
_client
,
$this
->
_plugin
->
getClient
()
);
);
$this
->
assertEquals
(
$this
->
assertEquals
(
$options
,
$
this
->
_
options
,
$plugin
->
getOptions
()
$
this
->
_
plugin
->
getOptions
()
);
);
}
}
public
function
testEventHooks
()
{
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateRequest
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateRequest
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preExecuteRequest
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postExcuteRequest
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preExecute
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postExecute
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateResult
());
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateResult
());
}
}
}
class
MyPlugin
extends
Solarium_Plugin_Abstract
{
class
MyPlugin
extends
Solarium_Plugin_Abstract
{
...
...
tests/Solarium/ResultTest.php
View file @
326d0a65
...
@@ -38,9 +38,9 @@ class Solarium_ResultTest extends PHPUnit_Framework_TestCase
...
@@ -38,9 +38,9 @@ class Solarium_ResultTest extends PHPUnit_Framework_TestCase
{
{
$this
->
_client
=
new
Solarium_Client
();
$this
->
_client
=
new
Solarium_Client
();
$this
->
_query
=
new
Solarium_Query_Select
();
$this
->
_query
=
new
Solarium_Query_Select
();
$headers
=
array
(
'HTTP/1.0 304 Not Modified'
);
$
this
->
_
headers
=
array
(
'HTTP/1.0 304 Not Modified'
);
$data
=
'{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"xyz"}},"response":{"numFound":0,"start":0,"docs":[]}}'
;
$data
=
'{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"xyz"}},"response":{"numFound":0,"start":0,"docs":[]}}'
;
$this
->
_response
=
new
Solarium_Client_Response
(
$data
,
$headers
);
$this
->
_response
=
new
Solarium_Client_Response
(
$data
,
$
this
->
_
headers
);
$this
->
_result
=
new
Solarium_Result
(
$this
->
_client
,
$this
->
_query
,
$this
->
_response
);
$this
->
_result
=
new
Solarium_Result
(
$this
->
_client
,
$this
->
_query
,
$this
->
_response
);
}
}
...
@@ -73,5 +73,15 @@ class Solarium_ResultTest extends PHPUnit_Framework_TestCase
...
@@ -73,5 +73,15 @@ class Solarium_ResultTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$data
,
$this
->
_result
->
getData
());
$this
->
assertEquals
(
$data
,
$this
->
_result
->
getData
());
}
}
public
function
testGetInvalidData
()
{
$data
=
'invalid'
;
$this
->
_response
=
new
Solarium_Client_Response
(
$data
,
$this
->
_headers
);
$this
->
_result
=
new
Solarium_Result
(
$this
->
_client
,
$this
->
_query
,
$this
->
_response
);
$this
->
setExpectedException
(
'Solarium_Exception'
);
$this
->
_result
->
getData
();
}
}
}
\ No newline at end of file
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