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
9e9885fb
Commit
9e9885fb
authored
Jul 09, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for issue #82
parent
bcaa7493
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
63 additions
and
6 deletions
+63
-6
library/Solarium/QueryType/Select/Query/Component/Component.php
...y/Solarium/QueryType/Select/Query/Component/Component.php
+27
-0
library/Solarium/QueryType/Select/Query/Component/Spellcheck.php
.../Solarium/QueryType/Select/Query/Component/Spellcheck.php
+8
-5
library/Solarium/QueryType/Select/Query/Query.php
library/Solarium/QueryType/Select/Query/Query.php
+2
-1
tests/Solarium/Tests/QueryType/Select/Query/Component/ComponentTest.php
.../Tests/QueryType/Select/Query/Component/ComponentTest.php
+8
-0
tests/Solarium/Tests/QueryType/Select/Query/Component/SpellcheckTest.php
...Tests/QueryType/Select/Query/Component/SpellcheckTest.php
+7
-0
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
+11
-0
No files found.
library/Solarium/QueryType/Select/Query/Component/Component.php
View file @
9e9885fb
...
...
@@ -38,6 +38,7 @@
*/
namespace
Solarium\QueryType\Select\Query\Component
;
use
Solarium\Core\Configurable
;
use
Solarium\Core\Query\Query
;
/**
* Query component base class
...
...
@@ -45,6 +46,11 @@ use Solarium\Core\Configurable;
abstract
class
Component
extends
Configurable
{
/**
* @var Query
*/
protected
$queryInstance
;
/**
* Get component type
*
...
...
@@ -66,4 +72,25 @@ abstract class Component extends Configurable
*/
abstract
public
function
getResponseParser
();
/**
* Set parent query instance
*
* @return self Provides fluent interface
*/
public
function
setQueryInstance
(
Query
$instance
)
{
$this
->
queryInstance
=
$instance
;
return
$this
;
}
/**
* Get parent query instance
*
* @return Query
*/
public
function
getQueryInstance
()
{
return
$this
->
queryInstance
;
}
}
library/Solarium/QueryType/Select/Query/Component/Spellcheck.php
View file @
9e9885fb
...
...
@@ -79,16 +79,19 @@ class Spellcheck extends Component
}
/**
* Set query option
*
* Query to spellcheck
* Set spellcheck query option
*
* @param string $query
* @param array $bind Bind values for placeholders in the query string
* @return self Provides fluent interface
*/
public
function
setQuery
(
$query
)
public
function
setQuery
(
$query
,
$bind
=
null
)
{
return
$this
->
setOption
(
'query'
,
$query
);
if
(
!
is_null
(
$bind
))
{
$query
=
$this
->
getQueryInstance
()
->
getHelper
()
->
assemble
(
$query
,
$bind
);
}
return
$this
->
setOption
(
'query'
,
trim
(
$query
));
}
/**
...
...
library/Solarium/QueryType/Select/Query/Query.php
View file @
9e9885fb
...
...
@@ -817,11 +817,12 @@ class Query extends BaseQuery
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param object|null $
value
* @param object|null $
component
* @return self Provides fluent interface
*/
public
function
setComponent
(
$key
,
$value
)
{
$value
->
setQueryInstance
(
$this
);
$this
->
components
[
$key
]
=
$value
;
return
$this
;
...
...
tests/Solarium/Tests/QueryType/Select/Query/Component/ComponentTest.php
View file @
9e9885fb
...
...
@@ -42,6 +42,14 @@ class ComponentTest extends \PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'testtype'
,
$component
->
getType
());
}
public
function
testSetAndGetQueryInstance
()
{
$query
=
new
Query
;
$component
=
new
TestComponent
();
$component
->
setQueryInstance
(
$query
);
$this
->
assertEquals
(
$query
,
$component
->
getQueryInstance
());
}
}
class
TestComponent
extends
Component
...
...
tests/Solarium/Tests/QueryType/Select/Query/Component/SpellcheckTest.php
View file @
9e9885fb
...
...
@@ -44,6 +44,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
public
function
setUp
()
{
$this
->
spellCheck
=
new
Spellcheck
;
$this
->
spellCheck
->
setQueryInstance
(
new
Query
);
}
public
function
testGetType
()
...
...
@@ -72,6 +73,12 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
);
}
public
function
testSetAndGetQueryWithBind
()
{
$this
->
spellCheck
->
setQuery
(
'id:%1%'
,
array
(
678
));
$this
->
assertEquals
(
'id:678'
,
$this
->
spellCheck
->
getQuery
());
}
public
function
testSetAndGetBuild
()
{
$value
=
true
;
...
...
tests/Solarium/Tests/QueryType/Select/Query/QueryTest.php
View file @
9e9885fb
...
...
@@ -494,6 +494,17 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
}
public
function
testSetAndGetComponentQueryInstance
()
{
$mlt
=
new
MoreLikeThis
;
$this
->
query
->
setComponent
(
'mlt'
,
$mlt
);
$this
->
assertEquals
(
$this
->
query
,
$this
->
query
->
getComponent
(
'mlt'
)
->
getQueryInstance
()
);
}
public
function
testGetInvalidComponent
()
{
$this
->
assertEquals
(
...
...
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