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
eca3407d
Commit
eca3407d
authored
Apr 19, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- small bugfixes
- code style fixes - unittest improvements
parent
cc91f30d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
95 additions
and
5 deletions
+95
-5
library/Solarium/Client/Request/Select.php
library/Solarium/Client/Request/Select.php
+2
-2
library/Solarium/Query/Select.php
library/Solarium/Query/Select.php
+1
-1
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
+1
-1
tests/Solarium/Client/Request/SelectTest.php
tests/Solarium/Client/Request/SelectTest.php
+2
-1
tests/Solarium/Query/Select/Component/FacetSetTest.php
tests/Solarium/Query/Select/Component/FacetSetTest.php
+15
-0
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+6
-0
tests/Solarium/Result/Select/Facet/MultiQueryTest.php
tests/Solarium/Result/Select/Facet/MultiQueryTest.php
+68
-0
No files found.
library/Solarium/Client/Request/Select.php
View file @
eca3407d
...
@@ -115,7 +115,7 @@ class Solarium_Client_Request_Select extends Solarium_Client_Request
...
@@ -115,7 +115,7 @@ class Solarium_Client_Request_Select extends Solarium_Client_Request
case
Solarium_Query_Select_Component_Facet
::
QUERY
:
case
Solarium_Query_Select_Component_Facet
::
QUERY
:
$this
->
addFacetQuery
(
$facet
);
$this
->
addFacetQuery
(
$facet
);
break
;
break
;
case
Solarium_Query_Select_Component_Facet
::
MULTIQUERY
:
case
Solarium_Query_Select_Component_Facet
::
MULTIQUERY
:
$this
->
addFacetMultiQuery
(
$facet
);
$this
->
addFacetMultiQuery
(
$facet
);
break
;
break
;
default
:
default
:
...
@@ -177,7 +177,7 @@ class Solarium_Client_Request_Select extends Solarium_Client_Request
...
@@ -177,7 +177,7 @@ class Solarium_Client_Request_Select extends Solarium_Client_Request
*/
*/
public
function
addFacetMultiQuery
(
$facet
)
public
function
addFacetMultiQuery
(
$facet
)
{
{
foreach
(
$facet
->
getQueries
()
AS
$facetQuery
)
{
foreach
(
$facet
->
getQueries
()
AS
$facetQuery
)
{
$this
->
addFacetQuery
(
$facetQuery
);
$this
->
addFacetQuery
(
$facetQuery
);
}
}
}
}
...
...
library/Solarium/Query/Select.php
View file @
eca3407d
...
@@ -615,7 +615,7 @@ class Solarium_Query_Select extends Solarium_Query
...
@@ -615,7 +615,7 @@ class Solarium_Query_Select extends Solarium_Query
*/
*/
protected
function
_createComponents
(
$configs
)
protected
function
_createComponents
(
$configs
)
{
{
foreach
(
$configs
AS
$type
=>
$config
)
foreach
(
$configs
AS
$type
=>
$config
)
{
{
$this
->
getComponent
(
$type
,
true
,
$config
);
$this
->
getComponent
(
$type
,
true
,
$config
);
}
}
...
...
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
View file @
eca3407d
...
@@ -221,7 +221,7 @@ class Solarium_Query_Select_Component_Facet_MultiQuery extends Solarium_Query_Se
...
@@ -221,7 +221,7 @@ class Solarium_Query_Select_Component_Facet_MultiQuery extends Solarium_Query_Se
* @param array $facetQueries
* @param array $facetQueries
* @return Solarium_Query_Select_Component_Facet_MultiQuery Provides fluent interface
* @return Solarium_Query_Select_Component_Facet_MultiQuery Provides fluent interface
*/
*/
public
function
set
Facet
Queries
(
$facetQueries
)
public
function
setQueries
(
$facetQueries
)
{
{
$this
->
clearQueries
();
$this
->
clearQueries
();
return
$this
->
addQueries
(
$facetQueries
);
return
$this
->
addQueries
(
$facetQueries
);
...
...
tests/Solarium/Client/Request/SelectTest.php
View file @
eca3407d
...
@@ -113,6 +113,7 @@ class Solarium_Client_Request_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -113,6 +113,7 @@ class Solarium_Client_Request_SelectTest extends PHPUnit_Framework_TestCase
{
{
$this
->
_query
->
getFacetSet
()
->
addFacet
(
new
Solarium_Query_Select_Component_Facet_Field
(
array
(
'key'
=>
'f1'
,
'field'
=>
'owner'
)));
$this
->
_query
->
getFacetSet
()
->
addFacet
(
new
Solarium_Query_Select_Component_Facet_Field
(
array
(
'key'
=>
'f1'
,
'field'
=>
'owner'
)));
$this
->
_query
->
getFacetSet
()
->
addFacet
(
new
Solarium_Query_Select_Component_Facet_Query
(
array
(
'key'
=>
'f2'
,
'query'
=>
'category:23'
)));
$this
->
_query
->
getFacetSet
()
->
addFacet
(
new
Solarium_Query_Select_Component_Facet_Query
(
array
(
'key'
=>
'f2'
,
'query'
=>
'category:23'
)));
$this
->
_query
->
getFacetSet
()
->
addFacet
(
new
Solarium_Query_Select_Component_Facet_MultiQuery
(
array
(
'key'
=>
'f3'
,
'query'
=>
array
(
'f4'
=>
array
(
'query'
=>
'category:40'
)))));
$request
=
new
Solarium_Client_Request_Select
(
$this
->
_options
,
$this
->
_query
);
$request
=
new
Solarium_Client_Request_Select
(
$this
->
_options
,
$this
->
_query
);
$this
->
assertEquals
(
$this
->
assertEquals
(
...
@@ -121,7 +122,7 @@ class Solarium_Client_Request_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -121,7 +122,7 @@ class Solarium_Client_Request_SelectTest extends PHPUnit_Framework_TestCase
);
);
$this
->
assertEquals
(
$this
->
assertEquals
(
'http://127.0.0.1:80/solr/select?q=*:*&start=0&rows=10&fl=*,score&wt=json&facet=true&facet.field={!key=f1}owner&facet.query={!key=f2}category:23'
,
'http://127.0.0.1:80/solr/select?q=*:*&start=0&rows=10&fl=*,score&wt=json&facet=true&facet.field={!key=f1}owner&facet.query={!key=f2}category:23
&facet.query={!key=f4}category:40
'
,
urldecode
(
$request
->
getUri
())
urldecode
(
$request
->
getUri
())
);
);
}
}
...
...
tests/Solarium/Query/Select/Component/FacetSetTest.php
View file @
eca3407d
...
@@ -99,6 +99,21 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
...
@@ -99,6 +99,21 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
);
);
}
}
public
function
testAddFacetsWithConfig
()
{
$facets
=
array
(
array
(
'type'
=>
'query'
,
'key'
=>
'f1'
,
'query'
=>
'category:1'
),
'f2'
=>
array
(
'type'
=>
'query'
,
'query'
=>
'category:2'
)
);
$this
->
_facetSet
->
addFacets
(
$facets
);
$this
->
assertEquals
(
2
,
count
(
$this
->
_facetSet
->
getFacets
())
);
}
public
function
testRemoveFacet
()
public
function
testRemoveFacet
()
{
{
$fq1
=
new
Solarium_Query_Select_Component_Facet_Query
;
$fq1
=
new
Solarium_Query_Select_Component_Facet_Query
;
...
...
tests/Solarium/Query/SelectTest.php
View file @
eca3407d
...
@@ -433,6 +433,12 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -433,6 +433,12 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testGetInvalidComponentAutoload
()
{
$this
->
setExpectedException
(
'Solarium_Exception'
);
$this
->
_query
->
getComponent
(
'invalid'
,
true
);
}
public
function
testRemoveComponent
()
public
function
testRemoveComponent
()
{
{
$mlt
=
new
Solarium_Query_Select_Component_MoreLikeThis
;
$mlt
=
new
Solarium_Query_Select_Component_MoreLikeThis
;
...
...
tests/Solarium/Result/Select/Facet/MultiQueryTest.php
0 → 100644
View file @
eca3407d
<?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_Result_Select_Facet_MultiQueryTest
extends
PHPUnit_Framework_TestCase
{
protected
$_values
,
$_facet
;
public
function
setUp
()
{
$this
->
_values
=
array
(
'a'
=>
12
,
'b'
=>
5
,
'c'
=>
3
,
);
$this
->
_facet
=
new
Solarium_Result_Select_Facet_MultiQuery
(
$this
->
_values
);
}
public
function
testGetValues
()
{
$this
->
assertEquals
(
$this
->
_values
,
$this
->
_facet
->
getValues
());
}
public
function
testCount
()
{
$this
->
assertEquals
(
count
(
$this
->
_values
),
count
(
$this
->
_facet
));
}
public
function
testIterator
()
{
$values
=
array
();
foreach
(
$this
->
_facet
AS
$key
=>
$value
)
{
$values
[
$key
]
=
$value
;
}
$this
->
assertEquals
(
$this
->
_values
,
$values
);
}
}
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