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
36770638
Commit
36770638
authored
May 22, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixes for bugs detected by new unittests
- improved unittests
parent
bfd4d8d0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
20 deletions
+80
-20
library/Solarium/Client/ResponseParser/Select.php
library/Solarium/Client/ResponseParser/Select.php
+1
-1
library/Solarium/Query/Select.php
library/Solarium/Query/Select.php
+5
-17
tests/Solarium/Client/RequestBuilder/SelectTest.php
tests/Solarium/Client/RequestBuilder/SelectTest.php
+31
-2
tests/Solarium/Client/ResponseParser/SelectTest.php
tests/Solarium/Client/ResponseParser/SelectTest.php
+43
-0
No files found.
library/Solarium/Client/ResponseParser/Select.php
View file @
36770638
...
@@ -78,7 +78,7 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
...
@@ -78,7 +78,7 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
return
array
(
return
array
(
'status'
=>
$data
[
'responseHeader'
][
'status'
],
'status'
=>
$data
[
'responseHeader'
][
'status'
],
'query
t
ime'
=>
$data
[
'responseHeader'
][
'QTime'
],
'query
T
ime'
=>
$data
[
'responseHeader'
][
'QTime'
],
'numfound'
=>
$data
[
'response'
][
'numFound'
],
'numfound'
=>
$data
[
'response'
][
'numFound'
],
'documents'
=>
$documents
,
'documents'
=>
$documents
,
'components'
=>
$components
,
'components'
=>
$components
,
...
...
library/Solarium/Query/Select.php
View file @
36770638
...
@@ -652,26 +652,14 @@ class Solarium_Query_Select extends Solarium_Query
...
@@ -652,26 +652,14 @@ class Solarium_Query_Select extends Solarium_Query
}
else
{
}
else
{
if
(
$autoload
==
true
)
{
if
(
$autoload
==
true
)
{
switch
(
$key
)
{
if
(
!
isset
(
$this
->
_componentTypes
[
$key
]))
{
case
Solarium_Query_Select
::
COMPONENT_MORELIKETHIS
:
throw
new
Solarium_Exception
(
'Cannot autoload unknown component: '
.
$key
);
$className
=
'Solarium_Query_Select_Component_MoreLikeThis'
;
break
;
case
Solarium_Query_Select
::
COMPONENT_FACETSET
:
$className
=
'Solarium_Query_Select_Component_FacetSet'
;
break
;
case
Solarium_Query_Select
::
COMPONENT_DISMAX
:
$className
=
'Solarium_Query_Select_Component_DisMax'
;
break
;
case
Solarium_Query_Select
::
COMPONENT_HIGHLIGHTING
:
$className
=
'Solarium_Query_Select_Component_Highlighting'
;
break
;
default
:
throw
new
Solarium_Exception
(
'Cannot autoload unknown component: '
.
$key
);
}
}
$className
=
$this
->
_componentTypes
[
$key
][
'component'
];
$component
=
new
$className
(
$config
);
$component
=
new
$className
(
$config
);
$this
->
setComponent
(
$key
,
$component
);
$this
->
setComponent
(
$key
,
$component
);
return
$
this
->
_components
[
$key
]
;
return
$
component
;
}
}
return
null
;
return
null
;
}
}
...
...
tests/Solarium/Client/RequestBuilder/SelectTest.php
View file @
36770638
...
@@ -108,9 +108,38 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
...
@@ -108,9 +108,38 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
);
);
}
}
public
function
testWithComponent
s
()
public
function
testWithComponent
NoBuilder
()
{
{
//1 component met en 1 zonder builder registratie
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
_query
->
registerComponentType
(
'testcomponent'
,
'TestDummyComponent'
);
$this
->
_query
->
getComponent
(
'testcomponent'
,
true
);
$requestWithNoBuilderComponent
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
assertEquals
(
$request
,
$requestWithNoBuilderComponent
);
}
public
function
testWithComponent
()
{
$this
->
_query
->
getDisMax
();
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
assertEquals
(
'dismax'
,
$request
->
getParam
(
'defType'
)
);
}
}
}
class
TestDummyComponent
extends
Solarium_Query_Select_Component
{
public
function
getType
()
{
return
'testcomponent'
;
}
}
}
\ No newline at end of file
tests/Solarium/Client/ResponseParser/SelectTest.php
View file @
36770638
...
@@ -34,6 +34,49 @@ class Solarium_Client_ResponseParser_SelectTest extends PHPUnit_Framework_TestCa
...
@@ -34,6 +34,49 @@ class Solarium_Client_ResponseParser_SelectTest extends PHPUnit_Framework_TestCa
public
function
testParse
()
public
function
testParse
()
{
{
$data
=
array
(
'response'
=>
array
(
'docs'
=>
array
(
array
(
'fieldA'
=>
1
,
'fieldB'
=>
'Test'
),
array
(
'fieldA'
=>
2
,
'fieldB'
=>
'Test2'
)
),
'numFound'
=>
503
),
'responseHeader'
=>
array
(
'status'
=>
1
,
'QTime'
=>
13
,
)
);
$query
=
new
Solarium_Query_Select
(
array
(
'documentclass'
=>
'Solarium_Document_ReadWrite'
));
$query
->
getFacetSet
();
$resultStub
=
$this
->
getMock
(
'Solarium_Result_Select'
,
array
(),
array
(),
''
,
false
);
$resultStub
->
expects
(
$this
->
once
())
->
method
(
'getData'
)
->
will
(
$this
->
returnValue
(
$data
));
$resultStub
->
expects
(
$this
->
once
())
->
method
(
'getQuery'
)
->
will
(
$this
->
returnValue
(
$query
));
$parser
=
new
Solarium_Client_ResponseParser_Select
;
$result
=
$parser
->
parse
(
$resultStub
);
$this
->
assertEquals
(
1
,
$result
[
'status'
]);
$this
->
assertEquals
(
13
,
$result
[
'queryTime'
]);
$this
->
assertEquals
(
503
,
$result
[
'numfound'
]);
$docs
=
array
(
new
Solarium_Document_ReadWrite
(
array
(
'fieldA'
=>
1
,
'fieldB'
=>
'Test'
)),
new
Solarium_Document_ReadWrite
(
array
(
'fieldA'
=>
2
,
'fieldB'
=>
'Test2'
))
);
$this
->
assertEquals
(
$docs
,
$result
[
'documents'
]);
$components
=
array
(
Solarium_Query_Select
::
COMPONENT_FACETSET
=>
new
Solarium_Result_Select_FacetSet
(
array
())
);
$this
->
assertEquals
(
$components
,
$result
[
'components'
]);
}
}
...
...
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