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
d9ae2147
Commit
d9ae2147
authored
Jul 13, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unittests for responsewriter changes
parent
d97b5855
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
1 deletion
+40
-1
tests/Solarium/Tests/Core/Query/QueryTest.php
tests/Solarium/Tests/Core/Query/QueryTest.php
+13
-0
tests/Solarium/Tests/Core/Query/RequestBuilderTest.php
tests/Solarium/Tests/Core/Query/RequestBuilderTest.php
+2
-1
tests/Solarium/Tests/Core/Query/Result/ResultTest.php
tests/Solarium/Tests/Core/Query/Result/ResultTest.php
+25
-0
No files found.
tests/Solarium/Tests/Core/Query/QueryTest.php
View file @
d9ae2147
...
@@ -73,6 +73,19 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -73,6 +73,19 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testGetDefaultResponseWriter
()
{
$query
=
new
TestQuery
;
$this
->
assertEquals
(
'json'
,
$query
->
getResponseWriter
());
}
public
function
testSetAndGetResponseWriter
()
{
$query
=
new
TestQuery
;
$query
->
setResponseWriter
(
'phps'
);
$this
->
assertEquals
(
'phps'
,
$query
->
getResponseWriter
());
}
}
}
class
TestQuery
extends
Query
class
TestQuery
extends
Query
...
...
tests/Solarium/Tests/Core/Query/RequestBuilderTest.php
View file @
d9ae2147
...
@@ -50,10 +50,11 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
...
@@ -50,10 +50,11 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$query
=
new
SelectQuery
;
$query
=
new
SelectQuery
;
$query
->
addParam
(
'p1'
,
'v1'
);
$query
->
addParam
(
'p1'
,
'v1'
);
$query
->
addParam
(
'p2'
,
'v2'
);
$query
->
addParam
(
'p2'
,
'v2'
);
$query
->
setResponseWriter
(
'xyz'
);
$request
=
$this
->
builder
->
build
(
$query
);
$request
=
$this
->
builder
->
build
(
$query
);
$this
->
assertEquals
(
$this
->
assertEquals
(
'select?omitHeader=true&p1=v1&p2=v2&wt=
json
'
,
'select?omitHeader=true&p1=v1&p2=v2&wt=
xyz
'
,
urldecode
(
$request
->
getUri
())
urldecode
(
$request
->
getUri
())
);
);
}
}
...
...
tests/Solarium/Tests/Core/Query/Result/ResultTest.php
View file @
d9ae2147
...
@@ -85,6 +85,31 @@ class ResultTest extends \PHPUnit_Framework_TestCase
...
@@ -85,6 +85,31 @@ class ResultTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
$data
,
$this
->
result
->
getData
());
$this
->
assertEquals
(
$data
,
$this
->
result
->
getData
());
}
}
public
function
testGetDataWithPhps
()
{
$phpsData
=
'a:2:{s:14:"responseHeader";a:3:{s:6:"status";i:0;s:5:"QTime";i:0;s:6:"params";a:6:{s:6:"indent";s:2:"on";s:5:"start";s:1:"0";s:1:"q";s:3:"*:*";s:2:"wt";s:4:"phps";s:7:"version";s:3:"2.2";s:4:"rows";s:1:"0";}}s:8:"response";a:3:{s:8:"numFound";i:57;s:5:"start";i:0;s:4:"docs";a:0:{}}}'
;
$this
->
query
->
setResponseWriter
(
'phps'
);
$resultData
=
array
(
'responseHeader'
=>
array
(
'status'
=>
0
,
'QTime'
=>
0
,
'params'
=>
array
(
'indent'
=>
'on'
,
'start'
=>
0
,
'q'
=>
'*:*'
,
'wt'
=>
'phps'
,
'version'
=>
'2.2'
,
'rows'
=>
0
)),
'response'
=>
array
(
'numFound'
=>
57
,
'start'
=>
0
,
'docs'
=>
array
())
);
$response
=
new
Response
(
$phpsData
,
$this
->
headers
);
$result
=
new
Result
(
$this
->
client
,
$this
->
query
,
$response
);
$this
->
assertEquals
(
$resultData
,
$result
->
getData
());
}
public
function
testGetDataWithUnkownResponseWriter
()
{
$this
->
query
->
setResponseWriter
(
'asdf'
);
$result
=
new
Result
(
$this
->
client
,
$this
->
query
,
$this
->
response
);
$this
->
setExpectedException
(
'Solarium\Exception\RuntimeException'
);
$result
->
getData
();
}
public
function
testGetInvalidData
()
public
function
testGetInvalidData
()
{
{
$data
=
'invalid'
;
$data
=
'invalid'
;
...
...
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