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
c09ef6f2
Commit
c09ef6f2
authored
May 22, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- improved unittests for config mode
- two small bugfixes for bugs found by the new tests
parent
bb14ee6b
Changes
18
Show whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
473 additions
and
152 deletions
+473
-152
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
+2
-0
library/Solarium/Query/Select/Component/Facet/Range.php
library/Solarium/Query/Select/Component/Facet/Range.php
+2
-0
tests/Solarium/Query/PingTest.php
tests/Solarium/Query/PingTest.php
+17
-0
tests/Solarium/Query/Select/Component/DisMaxTest.php
tests/Solarium/Query/Select/Component/DisMaxTest.php
+27
-0
tests/Solarium/Query/Select/Component/Facet/FieldTest.php
tests/Solarium/Query/Select/Component/Facet/FieldTest.php
+30
-0
tests/Solarium/Query/Select/Component/Facet/MultiQueryTest.php
.../Solarium/Query/Select/Component/Facet/MultiQueryTest.php
+32
-0
tests/Solarium/Query/Select/Component/Facet/QueryTest.php
tests/Solarium/Query/Select/Component/Facet/QueryTest.php
+18
-0
tests/Solarium/Query/Select/Component/Facet/RangeTest.php
tests/Solarium/Query/Select/Component/Facet/RangeTest.php
+31
-0
tests/Solarium/Query/Select/Component/FacetSetTest.php
tests/Solarium/Query/Select/Component/FacetSetTest.php
+26
-0
tests/Solarium/Query/Select/Component/FacetTest.php
tests/Solarium/Query/Select/Component/FacetTest.php
+16
-12
tests/Solarium/Query/Select/Component/HighlightingTest.php
tests/Solarium/Query/Select/Component/HighlightingTest.php
+52
-0
tests/Solarium/Query/Select/Component/MoreLikeThisTest.php
tests/Solarium/Query/Select/Component/MoreLikeThisTest.php
+31
-0
tests/Solarium/Query/Select/FilterQueryTest.php
tests/Solarium/Query/Select/FilterQueryTest.php
+18
-17
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+17
-32
tests/Solarium/Query/Update/Command/CommitTest.php
tests/Solarium/Query/Update/Command/CommitTest.php
+26
-0
tests/Solarium/Query/Update/Command/DeleteTest.php
tests/Solarium/Query/Update/Command/DeleteTest.php
+2
-2
tests/Solarium/Query/Update/Command/OptimizeTest.php
tests/Solarium/Query/Update/Command/OptimizeTest.php
+26
-0
tests/Solarium/Query/UpdateTest.php
tests/Solarium/Query/UpdateTest.php
+100
-89
No files found.
library/Solarium/Query/Select/Component/Facet/MultiQuery.php
View file @
c09ef6f2
...
...
@@ -64,6 +64,8 @@ class Solarium_Query_Select_Component_Facet_MultiQuery extends Solarium_Query_Se
*/
protected
function
_init
()
{
parent
::
_init
();
foreach
(
$this
->
_options
AS
$name
=>
$value
)
{
switch
(
$name
)
{
case
'query'
:
...
...
library/Solarium/Query/Select/Component/Facet/Range.php
View file @
c09ef6f2
...
...
@@ -74,6 +74,8 @@ class Solarium_Query_Select_Component_Facet_Range extends Solarium_Query_Select_
*/
protected
function
_init
()
{
parent
::
_init
();
foreach
(
$this
->
_options
AS
$name
=>
$value
)
{
switch
(
$name
)
{
case
'include'
:
...
...
tests/Solarium/Query/PingTest.php
View file @
c09ef6f2
...
...
@@ -44,5 +44,22 @@ class Solarium_Query_PingTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
Solarium_Client
::
QUERYTYPE_PING
,
$this
->
_query
->
getType
());
}
public
function
testConfigMode
()
{
$options
=
array
(
'handler'
=>
'myHandler'
,
'resultclass'
=>
'myResult'
,
);
$this
->
_query
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'handler'
],
$this
->
_query
->
getHandler
()
);
$this
->
assertEquals
(
$options
[
'resultclass'
],
$this
->
_query
->
getResultClass
()
);
}
}
\ No newline at end of file
tests/Solarium/Query/Select/Component/DisMaxTest.php
View file @
c09ef6f2
...
...
@@ -42,6 +42,33 @@ class Solarium_Query_Select_Component_DisMaxTest extends PHPUnit_Framework_TestC
$this
->
_disMax
=
new
Solarium_Query_Select_Component_DisMax
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'queryalternative'
=>
'*:*'
,
'queryfields'
=>
'title^2.0 description'
,
'minimummatch'
=>
'2.0'
,
'phrasefields'
=>
'title^2.0 description^3.5'
,
'phraseslop'
=>
2
,
'queryphraseslop'
=>
4
,
'tie'
=>
2.1
,
'boostquery'
=>
'cat:1^3'
,
'boostfunctions'
=>
'funcA(arg1,arg2)^1.2 funcB(arg3,arg4)^2.2'
,
);
$this
->
_disMax
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'queryalternative'
],
$this
->
_disMax
->
getQueryAlternative
());
$this
->
assertEquals
(
$options
[
'queryfields'
],
$this
->
_disMax
->
getQueryFields
());
$this
->
assertEquals
(
$options
[
'minimummatch'
],
$this
->
_disMax
->
getMinimumMatch
());
$this
->
assertEquals
(
$options
[
'phrasefields'
],
$this
->
_disMax
->
getPhraseFields
());
$this
->
assertEquals
(
$options
[
'phraseslop'
],
$this
->
_disMax
->
getPhraseSlop
());
$this
->
assertEquals
(
$options
[
'queryphraseslop'
],
$this
->
_disMax
->
getQueryPhraseSlop
());
$this
->
assertEquals
(
$options
[
'tie'
],
$this
->
_disMax
->
getTie
());
$this
->
assertEquals
(
$options
[
'boostquery'
],
$this
->
_disMax
->
getBoostQuery
());
$this
->
assertEquals
(
$options
[
'boostfunctions'
],
$this
->
_disMax
->
getBoostFunctions
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/Select/Component/Facet/FieldTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_Facet_FieldTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_Facet_Field
*/
protected
$_facet
;
public
function
setUp
()
...
...
@@ -39,6 +42,33 @@ class Solarium_Query_Select_Component_Facet_FieldTest extends PHPUnit_Framework_
$this
->
_facet
=
new
Solarium_Query_Select_Component_Facet_Field
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'key'
=>
'myKey'
,
'exclude'
=>
array
(
'e1'
,
'e2'
),
'field'
=>
'text'
,
'sort'
=>
'index'
,
'limit'
=>
10
,
'offset'
=>
20
,
'mincount'
=>
5
,
'missing'
=>
true
,
'method'
=>
'enum'
,
);
$this
->
_facet
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'key'
],
$this
->
_facet
->
getKey
());
$this
->
assertEquals
(
$options
[
'exclude'
],
$this
->
_facet
->
getExcludes
());
$this
->
assertEquals
(
$options
[
'field'
],
$this
->
_facet
->
getField
());
$this
->
assertEquals
(
$options
[
'sort'
],
$this
->
_facet
->
getSort
());
$this
->
assertEquals
(
$options
[
'limit'
],
$this
->
_facet
->
getLimit
());
$this
->
assertEquals
(
$options
[
'offset'
],
$this
->
_facet
->
getOffset
());
$this
->
assertEquals
(
$options
[
'mincount'
],
$this
->
_facet
->
getMinCount
());
$this
->
assertEquals
(
$options
[
'missing'
],
$this
->
_facet
->
getMissing
());
$this
->
assertEquals
(
$options
[
'method'
],
$this
->
_facet
->
getMethod
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/Select/Component/Facet/MultiQueryTest.php
View file @
c09ef6f2
...
...
@@ -42,6 +42,38 @@ class Solarium_Query_Select_Component_Facet_MultiQueryTest extends PHPUnit_Frame
$this
->
_facet
=
new
Solarium_Query_Select_Component_Facet_MultiQuery
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'key'
=>
'myKey'
,
'exclude'
=>
array
(
'e1'
,
'e2'
),
'query'
=>
array
(
array
(
'key'
=>
'k1'
,
'query'
=>
'category:1'
,
'exclude'
=>
array
(
'fq1'
,
'fq2'
)
),
'k2'
=>
array
(
'query'
=>
'category:2'
),
)
);
$this
->
_facet
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'key'
],
$this
->
_facet
->
getKey
());
$this
->
assertEquals
(
$options
[
'exclude'
],
$this
->
_facet
->
getExcludes
());
$query1
=
$this
->
_facet
->
getQuery
(
'k1'
);
$this
->
assertEquals
(
'k1'
,
$query1
->
getKey
());
$this
->
assertEquals
(
'category:1'
,
$query1
->
getQuery
());
$this
->
assertEquals
(
array
(
'fq1'
,
'fq2'
,
'e1'
,
'e2'
),
$query1
->
getExcludes
());
$query2
=
$this
->
_facet
->
getQuery
(
'k2'
);
$this
->
assertEquals
(
'k2'
,
$query2
->
getKey
());
$this
->
assertEquals
(
'category:2'
,
$query2
->
getQuery
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/Select/Component/Facet/QueryTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_Facet_QueryTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_Facet_Query
*/
protected
$_facet
;
public
function
setUp
()
...
...
@@ -39,6 +42,21 @@ class Solarium_Query_Select_Component_Facet_QueryTest extends PHPUnit_Framework_
$this
->
_facet
=
new
Solarium_Query_Select_Component_Facet_Query
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'key'
=>
'myKey'
,
'exclude'
=>
array
(
'e1'
,
'e2'
),
'query'
=>
'category:1'
,
);
$this
->
_facet
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'key'
],
$this
->
_facet
->
getKey
());
$this
->
assertEquals
(
$options
[
'exclude'
],
$this
->
_facet
->
getExcludes
());
$this
->
assertEquals
(
$options
[
'query'
],
$this
->
_facet
->
getQuery
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/Select/Component/Facet/RangeTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_Facet_RangeTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_Facet_Range
*/
protected
$_facet
;
public
function
setUp
()
...
...
@@ -39,6 +42,34 @@ class Solarium_Query_Select_Component_Facet_RangeTest extends PHPUnit_Framework_
$this
->
_facet
=
new
Solarium_Query_Select_Component_Facet_Range
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'key'
=>
'myKey'
,
'exclude'
=>
array
(
'e1'
,
'e2'
),
'field'
=>
'content'
,
'start'
=>
1
,
'end'
=>
100
,
'gap'
=>
10
,
'hardend'
=>
true
,
'other'
=>
'all'
,
'include'
=>
'lower'
,
);
$this
->
_facet
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'key'
],
$this
->
_facet
->
getKey
());
$this
->
assertEquals
(
$options
[
'exclude'
],
$this
->
_facet
->
getExcludes
());
$this
->
assertEquals
(
$options
[
'field'
],
$this
->
_facet
->
getField
());
$this
->
assertEquals
(
$options
[
'start'
],
$this
->
_facet
->
getStart
());
$this
->
assertEquals
(
$options
[
'end'
],
$this
->
_facet
->
getEnd
());
$this
->
assertEquals
(
$options
[
'gap'
],
$this
->
_facet
->
getGap
());
$this
->
assertEquals
(
$options
[
'hardend'
],
$this
->
_facet
->
getHardend
());
$this
->
assertEquals
(
$options
[
'other'
],
$this
->
_facet
->
getOther
());
$this
->
assertEquals
(
$options
[
'include'
],
$this
->
_facet
->
getInclude
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/Select/Component/FacetSetTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_FacetSetTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_FacetSet
*/
protected
$_facetSet
;
public
function
setUp
()
...
...
@@ -39,6 +42,29 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
$this
->
_facetSet
=
new
Solarium_Query_Select_Component_FacetSet
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'facet'
=>
array
(
array
(
'type'
=>
'query'
,
'key'
=>
'f1'
,
'query'
=>
'category:1'
),
'f2'
=>
array
(
'type'
=>
'query'
,
'query'
=>
'category:2'
)
),
'prefix'
=>
'pr'
,
'sort'
=>
'index'
,
'mincount'
=>
10
,
'missing'
=>
5
,
);
$this
->
_facetSet
->
setOptions
(
$options
);
$facets
=
$this
->
_facetSet
->
getFacets
();
$this
->
assertEquals
(
2
,
count
(
$facets
));
$this
->
assertEquals
(
$options
[
'prefix'
],
$this
->
_facetSet
->
getPrefix
());
$this
->
assertEquals
(
$options
[
'sort'
],
$this
->
_facetSet
->
getSort
());
$this
->
assertEquals
(
$options
[
'mincount'
],
$this
->
_facetSet
->
getMincount
());
$this
->
assertEquals
(
$options
[
'missing'
],
$this
->
_facetSet
->
getMissing
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
Solarium_Query_Select
::
COMPONENT_FACETSET
,
$this
->
_facetSet
->
getType
());
...
...
tests/Solarium/Query/Select/Component/FacetTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_FacetTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_Facet
*/
protected
$_facet
;
public
function
setUp
()
...
...
@@ -39,6 +42,19 @@ class Solarium_Query_Select_Component_FacetTest extends PHPUnit_Framework_TestCa
$this
->
_facet
=
new
TestFacet
;
}
public
function
testConfigMode
()
{
$this
->
_facet
->
setOptions
(
array
(
'key'
=>
'myKey'
,
'exclude'
=>
array
(
'e1'
,
'e2'
)));
$this
->
assertEquals
(
'myKey'
,
$this
->
_facet
->
getKey
());
$this
->
assertEquals
(
array
(
'e1'
,
'e2'
),
$this
->
_facet
->
getExcludes
());
}
public
function
testConfigModeWithSingleValueExclude
()
{
$this
->
_facet
->
setOptions
(
array
(
'exclude'
=>
'e1'
));
$this
->
assertEquals
(
array
(
'e1'
),
$this
->
_facet
->
getExcludes
());
}
public
function
testSetAndGetKey
()
{
$this
->
_facet
->
setKey
(
'testkey'
);
...
...
@@ -77,18 +93,6 @@ class Solarium_Query_Select_Component_FacetTest extends PHPUnit_Framework_TestCa
$this
->
_facet
->
setExcludes
(
array
(
'e3'
,
'e4'
));
$this
->
assertEquals
(
array
(
'e3'
,
'e4'
),
$this
->
_facet
->
getExcludes
());
}
public
function
testConstructorWithConfig
()
{
$this
->
_facet
=
new
TestFacet
(
array
(
'exclude'
=>
array
(
'e1'
,
'e2'
)));
$this
->
assertEquals
(
array
(
'e1'
,
'e2'
),
$this
->
_facet
->
getExcludes
());
}
public
function
testConstructorWithConfigSingleValueExclude
()
{
$this
->
_facet
=
new
TestFacet
(
array
(
'exclude'
=>
'e1'
));
$this
->
assertEquals
(
array
(
'e1'
),
$this
->
_facet
->
getExcludes
());
}
}
class
TestFacet
extends
Solarium_Query_Select_Component_Facet
{
...
...
tests/Solarium/Query/Select/Component/HighlightingTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_HighlightingTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_Highlighting
*/
protected
$_hlt
;
public
function
setUp
()
...
...
@@ -39,6 +42,55 @@ class Solarium_Query_Select_Component_HighlightingTest extends PHPUnit_Framework
$this
->
_hlt
=
new
Solarium_Query_Select_Component_Highlighting
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'fields'
=>
'fieldA,fieldB'
,
'snippets'
=>
2
,
'fragsize'
=>
20
,
'mergecontiguous'
=>
true
,
'requirefieldmatch'
=>
false
,
'maxanalyzedchars'
=>
40
,
'alternatefield'
=>
'text'
,
'maxalternatefieldlength'
=>
50
,
'formatter'
=>
'myFormatter'
,
'simpleprefix'
=>
'<b>'
,
'simplepostfix'
=>
'</b>'
,
'fragmenter'
=>
'myFragmenter'
,
'fraglistbuilder'
=>
'regex'
,
'fragmentsbuilder'
=>
'myBuilder'
,
'usefastvectorhighlighter'
=>
true
,
'usephrasehighlighter'
=>
false
,
'highlightmultiterm'
=>
true
,
'regexslop'
=>
.
8
,
'regexpattern'
=>
'myPattern'
,
'regexmaxanalyzedchars'
=>
500
,
);
$this
->
_hlt
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'fields'
],
$this
->
_hlt
->
getFields
());
$this
->
assertEquals
(
$options
[
'snippets'
],
$this
->
_hlt
->
getSnippets
());
$this
->
assertEquals
(
$options
[
'fragsize'
],
$this
->
_hlt
->
getFragSize
());
$this
->
assertEquals
(
$options
[
'mergecontiguous'
],
$this
->
_hlt
->
getMergeContiguous
());
$this
->
assertEquals
(
$options
[
'maxanalyzedchars'
],
$this
->
_hlt
->
getMaxAnalyzedChars
());
$this
->
assertEquals
(
$options
[
'alternatefield'
],
$this
->
_hlt
->
getAlternateField
());
$this
->
assertEquals
(
$options
[
'maxalternatefieldlength'
],
$this
->
_hlt
->
getMaxAlternateFieldLength
());
$this
->
assertEquals
(
$options
[
'formatter'
],
$this
->
_hlt
->
getFormatter
());
$this
->
assertEquals
(
$options
[
'simpleprefix'
],
$this
->
_hlt
->
getSimplePrefix
());
$this
->
assertEquals
(
$options
[
'simplepostfix'
],
$this
->
_hlt
->
getSimplePostfix
());
$this
->
assertEquals
(
$options
[
'fragmenter'
],
$this
->
_hlt
->
getFragmenter
());
$this
->
assertEquals
(
$options
[
'fraglistbuilder'
],
$this
->
_hlt
->
getFragListBuilder
());
$this
->
assertEquals
(
$options
[
'fragmentsbuilder'
],
$this
->
_hlt
->
getFragmentsBuilder
());
$this
->
assertEquals
(
$options
[
'usefastvectorhighlighter'
],
$this
->
_hlt
->
getUseFastVectorHighlighter
());
$this
->
assertEquals
(
$options
[
'usephrasehighlighter'
],
$this
->
_hlt
->
getUsePhraseHighlighter
());
$this
->
assertEquals
(
$options
[
'highlightmultiterm'
],
$this
->
_hlt
->
getHighlightMultiTerm
());
$this
->
assertEquals
(
$options
[
'regexslop'
],
$this
->
_hlt
->
getRegexSlop
());
$this
->
assertEquals
(
$options
[
'regexpattern'
],
$this
->
_hlt
->
getRegexPattern
());
$this
->
assertEquals
(
$options
[
'regexmaxanalyzedchars'
],
$this
->
_hlt
->
getRegexMaxAnalyzedChars
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
Solarium_Query_Select
::
COMPONENT_HIGHLIGHTING
,
$this
->
_hlt
->
getType
());
...
...
tests/Solarium/Query/Select/Component/MoreLikeThisTest.php
View file @
c09ef6f2
...
...
@@ -32,6 +32,9 @@
class
Solarium_Query_Select_Component_MoreLikeThisTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Query_Select_Component_MoreLikeThis
*/
protected
$_mlt
;
public
function
setUp
()
...
...
@@ -39,6 +42,34 @@ class Solarium_Query_Select_Component_MoreLikeThisTest extends PHPUnit_Framework
$this
->
_mlt
=
new
Solarium_Query_Select_Component_MoreLikeThis
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'fields'
=>
'fieldA,fieldB'
,
'minimumtermfrequency'
=>
10
,
'minimumdocumentfrequency'
=>
2
,
'minimumwordlength'
=>
3
,
'maximumwordlength'
=>
10
,
'maximumqueryterms'
=>
4
,
'maximumnumberoftokens'
=>
20
,
'boost'
=>
1.5
,
'queryfields'
=>
'fieldC,fieldD'
,
'count'
=>
5
,
);
$this
->
_mlt
->
setOptions
(
$options
);
$this
->
assertEquals
(
$options
[
'fields'
],
$this
->
_mlt
->
getFields
());
$this
->
assertEquals
(
$options
[
'minimumtermfrequency'
],
$this
->
_mlt
->
getMinimumTermFrequency
());
$this
->
assertEquals
(
$options
[
'minimumdocumentfrequency'
],
$this
->
_mlt
->
getMinimumDocumentFrequency
());
$this
->
assertEquals
(
$options
[
'minimumwordlength'
],
$this
->
_mlt
->
getMinimumWordLength
());
$this
->
assertEquals
(
$options
[
'maximumwordlength'
],
$this
->
_mlt
->
getMaximumWordLength
());
$this
->
assertEquals
(
$options
[
'maximumqueryterms'
],
$this
->
_mlt
->
getMaximumQueryTerms
());
$this
->
assertEquals
(
$options
[
'boost'
],
$this
->
_mlt
->
getBoost
());
$this
->
assertEquals
(
$options
[
'queryfields'
],
$this
->
_mlt
->
getQueryFields
());
$this
->
assertEquals
(
$options
[
'count'
],
$this
->
_mlt
->
getCount
());
}
public
function
testGetType
()
{
$this
->
assertEquals
(
Solarium_Query_Select
::
COMPONENT_MORELIKETHIS
,
$this
->
_mlt
->
getType
());
...
...
tests/Solarium/Query/Select/FilterQueryTest.php
View file @
c09ef6f2
...
...
@@ -39,6 +39,24 @@ class Solarium_Query_Select_FilterQueryTest extends PHPUnit_Framework_TestCase
$this
->
_filterQuery
=
new
Solarium_Query_Select_FilterQuery
;
}
public
function
testConfigMode
()
{
$fq
=
new
Solarium_Query_Select_FilterQuery
(
array
(
'tag'
=>
array
(
't1'
,
't2'
),
'key'
=>
'k1'
,
'query'
=>
'id:[10 TO 20]'
));
$this
->
assertEquals
(
array
(
't1'
,
't2'
),
$fq
->
getTags
());
$this
->
assertEquals
(
'k1'
,
$fq
->
getKey
());
$this
->
assertEquals
(
'id:[10 TO 20]'
,
$fq
->
getQuery
());
}
public
function
testConfigModeWithSingleValueTag
()
{
$fq
=
new
Solarium_Query_Select_FilterQuery
(
array
(
'tag'
=>
't1'
,
'key'
=>
'k1'
,
'query'
=>
'id:[10 TO 20]'
));
$this
->
assertEquals
(
array
(
't1'
),
$fq
->
getTags
());
$this
->
assertEquals
(
'k1'
,
$fq
->
getKey
());
$this
->
assertEquals
(
'id:[10 TO 20]'
,
$fq
->
getQuery
());
}
public
function
testSetAndGetKey
()
{
$this
->
_filterQuery
->
setKey
(
'testkey'
);
...
...
@@ -84,21 +102,4 @@ class Solarium_Query_Select_FilterQueryTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
array
(
't3'
,
't4'
),
$this
->
_filterQuery
->
getTags
());
}
public
function
testConstructorWithConfig
()
{
$fq
=
new
Solarium_Query_Select_FilterQuery
(
array
(
'tag'
=>
array
(
't1'
,
't2'
),
'key'
=>
'k1'
,
'query'
=>
'id:[10 TO 20]'
));
$this
->
assertEquals
(
array
(
't1'
,
't2'
),
$fq
->
getTags
());
$this
->
assertEquals
(
'k1'
,
$fq
->
getKey
());
$this
->
assertEquals
(
'id:[10 TO 20]'
,
$fq
->
getQuery
());
}
public
function
testConstructorWithConfigSingleValueTag
()
{
$fq
=
new
Solarium_Query_Select_FilterQuery
(
array
(
'tag'
=>
't1'
,
'key'
=>
'k1'
,
'query'
=>
'id:[10 TO 20]'
));
$this
->
assertEquals
(
array
(
't1'
),
$fq
->
getTags
());
$this
->
assertEquals
(
'k1'
,
$fq
->
getKey
());
$this
->
assertEquals
(
'id:[10 TO 20]'
,
$fq
->
getQuery
());
}
}
tests/Solarium/Query/SelectTest.php
View file @
c09ef6f2
...
...
@@ -345,7 +345,7 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
);
}
public
function
testCon
structorWithConfig
()
public
function
testCon
figMode
()
{
$config
=
array
(
'query'
=>
'text:mykeyword'
,
...
...
@@ -364,40 +364,21 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
'category13'
=>
array
(
'type'
=>
'query'
,
'query'
=>
'category:13'
)
)
),
)
),
'resultclass'
=>
'MyResultClass'
,
'documentclass'
=>
'MyDocumentClass'
,
);
$query
=
new
Solarium_Query_Select
(
$config
);
$this
->
assertEquals
(
$config
[
'query'
],
$query
->
getQuery
()
);
$this
->
assertEquals
(
$config
[
'sort'
],
$query
->
getSorts
()
);
$this
->
assertEquals
(
$config
[
'fields'
],
$query
->
getFields
()
);
$this
->
assertEquals
(
$config
[
'rows'
],
$query
->
getRows
()
);
$this
->
assertEquals
(
$config
[
'start'
],
$query
->
getStart
()
);
$fq
=
$query
->
getFilterQuery
(
'pub'
);
$this
->
assertEquals
(
'published:true'
,
$fq
->
getQuery
()
);
$this
->
assertEquals
(
$config
[
'query'
],
$query
->
getQuery
());
$this
->
assertEquals
(
$config
[
'sort'
],
$query
->
getSorts
());
$this
->
assertEquals
(
$config
[
'fields'
],
$query
->
getFields
());
$this
->
assertEquals
(
$config
[
'rows'
],
$query
->
getRows
());
$this
->
assertEquals
(
$config
[
'start'
],
$query
->
getStart
());
$this
->
assertEquals
(
$config
[
'documentclass'
],
$query
->
getDocumentClass
());
$this
->
assertEquals
(
$config
[
'resultclass'
],
$query
->
getResultClass
());
$this
->
assertEquals
(
'published:true'
,
$query
->
getFilterQuery
(
'pub'
)
->
getQuery
());
$this
->
assertEquals
(
'online:true'
,
$query
->
getFilterQuery
(
'online'
)
->
getQuery
());
$facets
=
$query
->
getFacetSet
()
->
getFacets
();
$this
->
assertEquals
(
...
...
@@ -408,6 +389,10 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
'category:13'
,
$facets
[
'category13'
]
->
getQuery
()
);
$components
=
$query
->
getComponents
();
$this
->
assertEquals
(
1
,
count
(
$components
));
$this
->
assertThat
(
array_pop
(
$components
),
$this
->
isInstanceOf
(
'Solarium_Query_Select_Component_FacetSet'
));
}
public
function
testSetAndGetComponents
()
...
...
tests/Solarium/Query/Update/Command/CommitTest.php
View file @
c09ef6f2
...
...
@@ -46,6 +46,32 @@ class Solarium_Query_Update_Command_CommitTest extends PHPUnit_Framework_TestCas
);
}
public
function
testConfigMode
()
{
$options
=
array
(
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'expungedeletes'
=>
true
,
);
$command
=
new
Solarium_Query_Update_Command_Commit
(
$options
);
$this
->
assertEquals
(
true
,
$command
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$command
->
getWaitSearcher
()
);
$this
->
assertEquals
(
true
,
$command
->
getExpungeDeletes
()
);
}
public
function
testGetAndSetWaitFlush
()
{
$this
->
_command
->
setWaitFlush
(
false
);
...
...
tests/Solarium/Query/Update/Command/DeleteTest.php
View file @
c09ef6f2
...
...
@@ -46,7 +46,7 @@ class Solarium_Query_Update_Command_DeleteTest extends PHPUnit_Framework_TestCas
);
}
public
function
test
OptionsSingleValues
()
public
function
test
ConfigMode
()
{
$options
=
array
(
'id'
=>
1
,
...
...
@@ -66,7 +66,7 @@ class Solarium_Query_Update_Command_DeleteTest extends PHPUnit_Framework_TestCas
);
}
public
function
test
Options
MultiValue
()
public
function
test
ConfigMode
MultiValue
()
{
$options
=
array
(
'id'
=>
array
(
1
,
2
),
...
...
tests/Solarium/Query/Update/Command/OptimizeTest.php
View file @
c09ef6f2
...
...
@@ -38,6 +38,32 @@ class Solarium_Query_Update_Command_OptimizeTest extends PHPUnit_Framework_TestC
$this
->
_command
=
new
Solarium_Query_Update_Command_Optimize
;
}
public
function
testConfigMode
()
{
$options
=
array
(
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'maxsegments'
=>
6
,
);
$command
=
new
Solarium_Query_Update_Command_Optimize
(
$options
);
$this
->
assertEquals
(
true
,
$command
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$command
->
getWaitSearcher
()
);
$this
->
assertEquals
(
6
,
$command
->
getMaxSegments
()
);
}
public
function
testGetType
()
{
$this
->
assertEquals
(
...
...
tests/Solarium/Query/UpdateTest.php
View file @
c09ef6f2
...
...
@@ -44,6 +44,106 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
Solarium_Client
::
QUERYTYPE_UPDATE
,
$this
->
_query
->
getType
());
}
public
function
testConfigMode
()
{
$options
=
array
(
'handler'
=>
'myHandler'
,
'resultclass'
=>
'myResult'
,
'command'
=>
array
(
'key1'
=>
array
(
'type'
=>
'delete'
,
'query'
=>
'population:[* TO 1000]'
,
'id'
=>
array
(
1
,
2
),
),
'key2'
=>
array
(
'type'
=>
'commit'
,
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'expungedeletes'
=>
true
,
),
'key3'
=>
array
(
'type'
=>
'optimize'
,
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'maxsegments'
=>
5
,
),
'key4'
=>
array
(
'type'
=>
'rollback'
,
)
)
);
$this
->
_query
->
setOptions
(
$options
);
$commands
=
$this
->
_query
->
getCommands
();
$this
->
assertEquals
(
$options
[
'handler'
],
$this
->
_query
->
getHandler
()
);
$this
->
assertEquals
(
$options
[
'resultclass'
],
$this
->
_query
->
getResultClass
()
);
$delete
=
$commands
[
'key1'
];
$this
->
assertEquals
(
array
(
1
,
2
),
$delete
->
getIds
()
);
$this
->
assertEquals
(
array
(
'population:[* TO 1000]'
),
$delete
->
getQueries
()
);
$commit
=
$commands
[
'key2'
];
$this
->
assertEquals
(
true
,
$commit
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$commit
->
getWaitSearcher
()
);
$this
->
assertEquals
(
true
,
$commit
->
getExpungeDeletes
()
);
$optimize
=
$commands
[
'key3'
];
$this
->
assertEquals
(
true
,
$optimize
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$optimize
->
getWaitSearcher
()
);
$this
->
assertEquals
(
5
,
$optimize
->
getMaxSegments
()
);
$rollback
=
$commands
[
'key4'
];
$this
->
assertEquals
(
'Solarium_Query_Update_Command_Rollback'
,
get_class
(
$rollback
)
);
}
public
function
testConstructorWithConfigAddCommand
()
{
$config
=
array
(
'command'
=>
array
(
'key1'
=>
array
(
'type'
=>
'add'
,
),
)
);
$this
->
setExpectedException
(
'Solarium_Exception'
);
new
Solarium_Query_Update
(
$config
);
}
public
function
testAddWithoutKey
()
{
$command
=
new
Solarium_Query_Update_Command_Rollback
;
...
...
@@ -276,95 +376,6 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
);
}
public
function
testConstructorWithConfig
()
{
$config
=
array
(
'command'
=>
array
(
'key1'
=>
array
(
'type'
=>
'delete'
,
'query'
=>
'population:[* TO 1000]'
,
'id'
=>
array
(
1
,
2
),
),
'key2'
=>
array
(
'type'
=>
'commit'
,
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'expungedeletes'
=>
true
,
),
'key3'
=>
array
(
'type'
=>
'optimize'
,
'waitflush'
=>
true
,
'waitsearcher'
=>
false
,
'maxsegments'
=>
5
,
),
'key4'
=>
array
(
'type'
=>
'rollback'
,
)
)
);
$query
=
new
Solarium_Query_Update
(
$config
);
$commands
=
$query
->
getCommands
();
$delete
=
$commands
[
'key1'
];
$this
->
assertEquals
(
array
(
1
,
2
),
$delete
->
getIds
()
);
$this
->
assertEquals
(
array
(
'population:[* TO 1000]'
),
$delete
->
getQueries
()
);
$commit
=
$commands
[
'key2'
];
$this
->
assertEquals
(
true
,
$commit
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$commit
->
getWaitSearcher
()
);
$this
->
assertEquals
(
true
,
$commit
->
getExpungeDeletes
()
);
$optimize
=
$commands
[
'key3'
];
$this
->
assertEquals
(
true
,
$optimize
->
getWaitFlush
()
);
$this
->
assertEquals
(
false
,
$optimize
->
getWaitSearcher
()
);
$this
->
assertEquals
(
5
,
$optimize
->
getMaxSegments
()
);
$rollback
=
$commands
[
'key4'
];
$this
->
assertEquals
(
'Solarium_Query_Update_Command_Rollback'
,
get_class
(
$rollback
)
);
}
public
function
testConstructorWithConfigAddCommand
()
{
$config
=
array
(
'command'
=>
array
(
'key1'
=>
array
(
'type'
=>
'add'
,
),
)
);
$this
->
setExpectedException
(
'Solarium_Exception'
);
new
Solarium_Query_Update
(
$config
);
}
public
function
testCreateCommand
()
{
$type
=
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