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
ad59cf26
Commit
ad59cf26
authored
Aug 12, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/remove-by-object' into develop
parents
3ea5b8b8
7cfb5d74
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
195 additions
and
29 deletions
+195
-29
library/Solarium/Client.php
library/Solarium/Client.php
+17
-5
library/Solarium/Query/Select.php
library/Solarium/Query/Select.php
+27
-9
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
+11
-5
library/Solarium/Query/Select/Component/FacetSet.php
library/Solarium/Query/Select/Component/FacetSet.php
+11
-5
library/Solarium/Query/Update.php
library/Solarium/Query/Update.php
+18
-5
tests/Solarium/ClientTest.php
tests/Solarium/ClientTest.php
+22
-0
tests/Solarium/Query/Select/Component/Facet/MultiQueryTest.php
.../Solarium/Query/Select/Component/Facet/MultiQueryTest.php
+19
-0
tests/Solarium/Query/Select/Component/FacetSetTest.php
tests/Solarium/Query/Select/Component/FacetSetTest.php
+18
-0
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+36
-0
tests/Solarium/Query/UpdateTest.php
tests/Solarium/Query/UpdateTest.php
+16
-0
No files found.
library/Solarium/Client.php
View file @
ad59cf26
...
@@ -358,14 +358,26 @@ class Solarium_Client extends Solarium_Configurable
...
@@ -358,14 +358,26 @@ class Solarium_Client extends Solarium_Configurable
/**
/**
* Remove a plugin instance
* Remove a plugin instance
*
*
* @param string $key
* You can remove a plugin by passing the plugin key, or the plugin instance
*
* @param string|Solarium_Plugin_Abstract $plugin
* @return Solarium_Client Provides fluent interface
* @return Solarium_Client Provides fluent interface
*/
*/
public
function
removePlugin
(
$
key
)
public
function
removePlugin
(
$
plugin
)
{
{
if
(
isset
(
$this
->
_plugins
[
$key
]))
{
if
(
is_object
(
$plugin
))
{
unset
(
$this
->
_plugins
[
$key
]);
foreach
(
$this
->
_plugins
as
$key
=>
$instance
)
{
if
(
$instance
===
$plugin
)
{
unset
(
$this
->
_plugins
[
$key
]);
break
;
}
}
}
else
{
if
(
isset
(
$this
->
_plugins
[
$plugin
]))
{
unset
(
$this
->
_plugins
[
$plugin
]);
}
}
}
return
$this
;
return
$this
;
}
}
...
...
library/Solarium/Query/Select.php
View file @
ad59cf26
...
@@ -581,15 +581,21 @@ class Solarium_Query_Select extends Solarium_Query
...
@@ -581,15 +581,21 @@ class Solarium_Query_Select extends Solarium_Query
}
}
/**
/**
* Remove a single filterquery
by key
* Remove a single filterquery
*
*
* @param string $key
* You can remove a filterquery by passing it's key, or by passing the filterquery instance
*
* @param string|Solarium_Query_Select_FilterQuery $filterQuery
* @return Solarium_Query_Select Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
*/
public
function
removeFilterQuery
(
$
ke
y
)
public
function
removeFilterQuery
(
$
filterQuer
y
)
{
{
if
(
isset
(
$this
->
_filterQueries
[
$key
]))
{
if
(
is_object
(
$filterQuery
))
{
unset
(
$this
->
_filterQueries
[
$key
]);
$filterQuery
=
$filterQuery
->
getKey
();
}
if
(
isset
(
$this
->
_filterQueries
[
$filterQuery
]))
{
unset
(
$this
->
_filterQueries
[
$filterQuery
]);
}
}
return
$this
;
return
$this
;
...
@@ -708,13 +714,25 @@ class Solarium_Query_Select extends Solarium_Query
...
@@ -708,13 +714,25 @@ class Solarium_Query_Select extends Solarium_Query
/**
/**
* Remove a component instance
* Remove a component instance
*
*
* @param string $key
* You can remove a component by passing it's key or the component instance
*
* @param string|Solarium_Query_Select_Component $component
* @return Solarium_Query_Select Provides fluent interface
* @return Solarium_Query_Select Provides fluent interface
*/
*/
public
function
removeComponent
(
$
key
)
public
function
removeComponent
(
$
component
)
{
{
if
(
isset
(
$this
->
_components
[
$key
]))
{
if
(
is_object
(
$component
))
{
unset
(
$this
->
_components
[
$key
]);
foreach
(
$this
->
_components
as
$key
=>
$instance
)
{
if
(
$instance
===
$component
)
{
unset
(
$this
->
_components
[
$key
]);
break
;
}
}
}
else
{
if
(
isset
(
$this
->
_components
[
$component
]))
{
unset
(
$this
->
_components
[
$component
]);
}
}
}
return
$this
;
return
$this
;
}
}
...
...
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
View file @
ad59cf26
...
@@ -191,15 +191,21 @@ class Solarium_Query_Select_Component_Facet_MultiQuery extends Solarium_Query_Se
...
@@ -191,15 +191,21 @@ class Solarium_Query_Select_Component_Facet_MultiQuery extends Solarium_Query_Se
}
}
/**
/**
* Remove a single facetquery
by key
* Remove a single facetquery
*
*
* @param string $key
* You can remove a facetquery by passing it's key or the facetquery instance
*
* @param string|Solarium_Query_Select_Component_Facet_Query $query
* @return Solarium_Query_Select_Component_Facet_MultiQuery Provides fluent interface
* @return Solarium_Query_Select_Component_Facet_MultiQuery Provides fluent interface
*/
*/
public
function
removeQuery
(
$
ke
y
)
public
function
removeQuery
(
$
quer
y
)
{
{
if
(
isset
(
$this
->
_facetQueries
[
$key
]))
{
if
(
is_object
(
$query
))
{
unset
(
$this
->
_facetQueries
[
$key
]);
$query
=
$query
->
getKey
();
}
if
(
isset
(
$this
->
_facetQueries
[
$query
]))
{
unset
(
$this
->
_facetQueries
[
$query
]);
}
}
return
$this
;
return
$this
;
...
...
library/Solarium/Query/Select/Component/FacetSet.php
View file @
ad59cf26
...
@@ -322,15 +322,21 @@ class Solarium_Query_Select_Component_FacetSet extends Solarium_Query_Select_Com
...
@@ -322,15 +322,21 @@ class Solarium_Query_Select_Component_FacetSet extends Solarium_Query_Select_Com
}
}
/**
/**
* Remove a single facet
by key
* Remove a single facet
*
*
* @param string $key
* You can remove a facet by passing it's key or the facet instance
*
* @param string|Solarium_Query_Select_Component_Facet $facet
* @return Solarium_Query Provides fluent interface
* @return Solarium_Query Provides fluent interface
*/
*/
public
function
removeFacet
(
$
key
)
public
function
removeFacet
(
$
facet
)
{
{
if
(
isset
(
$this
->
_facets
[
$key
]))
{
if
(
is_object
(
$facet
))
{
unset
(
$this
->
_facets
[
$key
]);
$facet
=
$facet
->
getKey
();
}
if
(
isset
(
$this
->
_facets
[
$facet
]))
{
unset
(
$this
->
_facets
[
$facet
]);
}
}
return
$this
;
return
$this
;
...
...
library/Solarium/Query/Update.php
View file @
ad59cf26
...
@@ -197,16 +197,29 @@ class Solarium_Query_Update extends Solarium_Query
...
@@ -197,16 +197,29 @@ class Solarium_Query_Update extends Solarium_Query
}
}
/**
/**
* Remove a command
by key
* Remove a command
*
*
* @param string $key
* You can remove a command by passing it's key or by passing the command instance
*
* @param string|Solarium_Query_Update_Command $command
* @return Solarium_Query_Update Provides fluent interface
* @return Solarium_Query_Update Provides fluent interface
*/
*/
public
function
remove
(
$
key
)
public
function
remove
(
$
command
)
{
{
if
(
isset
(
$this
->
_commands
[
$key
]))
{
if
(
is_object
(
$command
))
{
unset
(
$this
->
_commands
[
$key
]);
foreach
(
$this
->
_commands
as
$key
=>
$instance
)
{
if
(
$instance
===
$command
)
{
unset
(
$this
->
_commands
[
$key
]);
break
;
}
}
}
else
{
if
(
isset
(
$this
->
_commands
[
$command
]))
{
unset
(
$this
->
_commands
[
$command
]);
}
}
}
return
$this
;
return
$this
;
}
}
...
...
tests/Solarium/ClientTest.php
View file @
ad59cf26
...
@@ -231,6 +231,28 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
...
@@ -231,6 +231,28 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testRemovePluginAndGetPluginsWithObjectInput
()
{
$options
=
array
(
'option1'
=>
1
);
$this
->
_client
->
registerPlugin
(
'testplugin'
,
'MyClientPlugin'
,
$options
);
$plugin
=
$this
->
_client
->
getPlugin
(
'testplugin'
);
$plugins
=
$this
->
_client
->
getPlugins
();
$this
->
assertEquals
(
array
(
'testplugin'
=>
$plugin
),
$plugins
);
$this
->
_client
->
removePlugin
(
$plugin
);
$plugins
=
$this
->
_client
->
getPlugins
();
$this
->
assertEquals
(
array
(),
$plugins
);
}
public
function
testCreateRequest
()
public
function
testCreateRequest
()
{
{
$queryStub
=
$this
->
getMock
(
'Solarium_Query_Select'
);
$queryStub
=
$this
->
getMock
(
'Solarium_Query_Select'
);
...
...
tests/Solarium/Query/Select/Component/Facet/MultiQueryTest.php
View file @
ad59cf26
...
@@ -260,6 +260,25 @@ class Solarium_Query_Select_Component_Facet_MultiQueryTest extends PHPUnit_Frame
...
@@ -260,6 +260,25 @@ class Solarium_Query_Select_Component_Facet_MultiQueryTest extends PHPUnit_Frame
);
);
}
}
public
function
testRemoveQueryWithObjectInput
()
{
$facetQuery
=
new
Solarium_Query_Select_Component_Facet_Query
;
$facetQuery
->
setKey
(
'k1'
);
$facetQuery
->
setQuery
(
'category:1'
);
$this
->
_facet
->
addQuery
(
$facetQuery
);
$this
->
assertEquals
(
array
(
'k1'
=>
$facetQuery
),
$this
->
_facet
->
getQueries
()
);
$this
->
_facet
->
removeQuery
(
$facetQuery
);
$this
->
assertEquals
(
array
(),
$this
->
_facet
->
getQueries
()
);
}
public
function
testRemoveInvalidQuery
()
public
function
testRemoveInvalidQuery
()
{
{
$facetQuery
=
new
Solarium_Query_Select_Component_Facet_Query
;
$facetQuery
=
new
Solarium_Query_Select_Component_Facet_Query
;
...
...
tests/Solarium/Query/Select/Component/FacetSetTest.php
View file @
ad59cf26
...
@@ -192,6 +192,24 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
...
@@ -192,6 +192,24 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
);
);
}
}
public
function
testRemoveFacetWithObjectInput
()
{
$fq1
=
new
Solarium_Query_Select_Component_Facet_Query
;
$fq1
->
setKey
(
'f1'
)
->
setQuery
(
'category:1'
);
$fq2
=
new
Solarium_Query_Select_Component_Facet_Query
;
$fq2
->
setKey
(
'f2'
)
->
setQuery
(
'category:2'
);
$facets
=
array
(
'f1'
=>
$fq1
,
'f2'
=>
$fq2
);
$this
->
_facetSet
->
addFacets
(
$facets
);
$this
->
_facetSet
->
removeFacet
(
$fq1
);
$this
->
assertEquals
(
array
(
'f2'
=>
$fq2
),
$this
->
_facetSet
->
getFacets
()
);
}
public
function
testRemoveInvalidFacet
()
public
function
testRemoveInvalidFacet
()
{
{
$fq1
=
new
Solarium_Query_Select_Component_Facet_Query
;
$fq1
=
new
Solarium_Query_Select_Component_Facet_Query
;
...
...
tests/Solarium/Query/SelectTest.php
View file @
ad59cf26
...
@@ -287,6 +287,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -287,6 +287,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testRemoveFilterQueryWithObjectInput
()
{
$fq1
=
new
Solarium_Query_Select_FilterQuery
;
$fq1
->
setKey
(
'fq1'
)
->
setQuery
(
'category:1'
);
$fq2
=
new
Solarium_Query_Select_FilterQuery
;
$fq2
->
setKey
(
'fq2'
)
->
setQuery
(
'category:2'
);
$filterQueries
=
array
(
$fq1
,
$fq2
);
$this
->
_query
->
addFilterQueries
(
$filterQueries
);
$this
->
_query
->
removeFilterQuery
(
$fq1
);
$this
->
assertEquals
(
array
(
'fq2'
=>
$fq2
),
$this
->
_query
->
getFilterQueries
()
);
}
public
function
testRemoveInvalidFilterQuery
()
public
function
testRemoveInvalidFilterQuery
()
{
{
$fq1
=
new
Solarium_Query_Select_FilterQuery
;
$fq1
=
new
Solarium_Query_Select_FilterQuery
;
...
@@ -455,6 +473,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -455,6 +473,24 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testRemoveComponentWithObjectInput
()
{
$mlt
=
new
Solarium_Query_Select_Component_MoreLikeThis
;
$this
->
_query
->
setComponent
(
'mlt'
,
$mlt
);
$this
->
assertEquals
(
array
(
'mlt'
=>
$mlt
),
$this
->
_query
->
getComponents
()
);
$this
->
_query
->
removeComponent
(
$mlt
);
$this
->
assertEquals
(
array
(),
$this
->
_query
->
getComponents
()
);
}
public
function
testGetMoreLikeThis
()
public
function
testGetMoreLikeThis
()
{
{
$mlt
=
$this
->
_query
->
getMoreLikeThis
();
$mlt
=
$this
->
_query
->
getMoreLikeThis
();
...
...
tests/Solarium/Query/UpdateTest.php
View file @
ad59cf26
...
@@ -185,6 +185,22 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
...
@@ -185,6 +185,22 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
);
);
}
}
public
function
testRemoveWithObjectInput
()
{
$rollback
=
new
Solarium_Query_Update_Command_Rollback
;
$this
->
_query
->
add
(
'rb'
,
$rollback
);
$commit
=
new
Solarium_Query_Update_Command_Commit
;
$this
->
_query
->
add
(
'cm'
,
$commit
);
$this
->
_query
->
remove
(
$rollback
);
$this
->
assertEquals
(
array
(
'cm'
=>
$commit
),
$this
->
_query
->
getCommands
()
);
}
public
function
testRemoveInvalidKey
()
public
function
testRemoveInvalidKey
()
{
{
$rollback
=
new
Solarium_Query_Update_Command_Rollback
;
$rollback
=
new
Solarium_Query_Update_Command_Rollback
;
...
...
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