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
fd6fe00b
Commit
fd6fe00b
authored
Sep 22, 2011
by
Gasol Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added shards support unittests
parent
a896fb53
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
3 deletions
+95
-3
tests/Solarium/Client/RequestBuilder/SelectTest.php
tests/Solarium/Client/RequestBuilder/SelectTest.php
+24
-1
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+71
-2
No files found.
tests/Solarium/Client/RequestBuilder/SelectTest.php
View file @
fd6fe00b
...
@@ -89,6 +89,29 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
...
@@ -89,6 +89,29 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
);
);
}
}
public
function
testSelectUrlWithShard
()
{
$this
->
_query
->
addShard
(
'shard1'
,
'localhost:8983/solr/shard1'
);
$this
->
_query
->
addShards
(
array
(
'shard2'
=>
'localhost:8983/solr/shard2'
,
'shard3'
=>
'localhost:8983/solr/shard3'
));
$this
->
_query
->
setShardRequestHandler
(
'dummy'
);
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
assertEquals
(
null
,
$request
->
getRawData
()
);
$this
->
assertEquals
(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json'
.
'&shards=localhost:8983/solr/shard1,localhost:8983/solr/shard2,localhost:8983/solr/shard3'
.
'&shards.qt=dummy'
,
urldecode
(
$request
->
getUri
())
);
}
public
function
testSelectUrlWithSortAndFilters
()
public
function
testSelectUrlWithSortAndFilters
()
{
{
$this
->
_query
->
addSort
(
'id'
,
Solarium_Query_Select
::
SORT_ASC
);
$this
->
_query
->
addSort
(
'id'
,
Solarium_Query_Select
::
SORT_ASC
);
...
...
tests/Solarium/Query/SelectTest.php
View file @
fd6fe00b
...
@@ -210,6 +210,75 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -210,6 +210,75 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testAddShard
()
{
$this
->
_query
->
addShard
(
'shard1'
,
'localhost:8983/solr/shard1'
);
$shards
=
$this
->
_query
->
getShards
();
$this
->
assertEquals
(
'localhost:8983/solr/shard1'
,
$shards
[
'shard1'
]
);
}
public
function
testRemoveShard
()
{
$this
->
_query
->
addShard
(
'shard1'
,
'localhost:8983/solr/shard1'
);
$this
->
_query
->
removeShard
(
'shard1'
);
$shards
=
$this
->
_query
->
getShards
();
$this
->
assertFalse
(
isset
(
$shards
[
'shard1'
]));
}
public
function
testClearShards
()
{
$this
->
_query
->
addShards
(
array
(
'shard1'
=>
'localhost:8983/solr/shard1'
,
'shard2'
=>
'localhost:8983/solr/shard2'
,
));
$this
->
_query
->
clearShards
();
$shards
=
$this
->
_query
->
getShards
();
$this
->
assertTrue
(
is_array
(
$shards
));
$this
->
assertEquals
(
0
,
count
(
$shards
));
}
public
function
testAddShards
()
{
$shards
=
array
(
'shard1'
=>
'localhost:8983/solr/shard1'
,
'shard2'
=>
'localhost:8983/solr/shard2'
,
);
$this
->
_query
->
addShards
(
$shards
);
$this
->
assertEquals
(
$shards
,
$this
->
_query
->
getShards
());
}
public
function
testSetShards
()
{
$this
->
_query
->
addShards
(
array
(
'shard1'
=>
'localhost:8983/solr/shard1'
,
'shard2'
=>
'localhost:8983/solr/shard2'
,
));
$this
->
_query
->
setShards
(
array
(
'shard3'
=>
'localhost:8983/solr/shard3'
,
'shard4'
=>
'localhost:8983/solr/shard4'
,
'shard5'
=>
'localhost:8983/solr/shard5'
,
));
$shards
=
$this
->
_query
->
getShards
();
$this
->
assertEquals
(
3
,
count
(
$shards
));
$this
->
assertEquals
(
array
(
'shard3'
=>
'localhost:8983/solr/shard3'
,
'shard4'
=>
'localhost:8983/solr/shard4'
,
'shard5'
=>
'localhost:8983/solr/shard5'
,
),
$shards
);
}
public
function
testSetShardRequestHandler
()
{
$this
->
_query
->
setShardRequestHandler
(
'dummy'
);
$this
->
assertEquals
(
'dummy'
,
$this
->
_query
->
getShardRequestHandler
()
);
}
public
function
testAddAndGetFilterQuery
()
public
function
testAddAndGetFilterQuery
()
{
{
$fq
=
new
Solarium_Query_Select_FilterQuery
;
$fq
=
new
Solarium_Query_Select_FilterQuery
;
...
...
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