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
aa98efa4
Commit
aa98efa4
authored
May 17, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- unittest improvements
parent
168e6a09
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
397 additions
and
20 deletions
+397
-20
library/Solarium/Client/Adapter/ZendHttp.php
library/Solarium/Client/Adapter/ZendHttp.php
+12
-10
library/Solarium/Client/Request.php
library/Solarium/Client/Request.php
+0
-2
library/Solarium/Client/RequestBuilder/Select.php
library/Solarium/Client/RequestBuilder/Select.php
+0
-1
library/Solarium/Client/ResponseParser/Select.php
library/Solarium/Client/ResponseParser/Select.php
+0
-4
library/Solarium/Result/QueryType.php
library/Solarium/Result/QueryType.php
+0
-2
tests/Solarium/Client/Adapter/ZendHttpTest.php
tests/Solarium/Client/Adapter/ZendHttpTest.php
+158
-0
tests/Solarium/ClientTest.php
tests/Solarium/ClientTest.php
+108
-0
tests/Solarium/Plugin/AbstractTest.php
tests/Solarium/Plugin/AbstractTest.php
+3
-1
tests/Solarium/Query/Select/Component/FacetSetTest.php
tests/Solarium/Query/Select/Component/FacetSetTest.php
+74
-0
tests/Solarium/Query/SelectTest.php
tests/Solarium/Query/SelectTest.php
+16
-0
tests/Solarium/Query/UpdateTest.php
tests/Solarium/Query/UpdateTest.php
+26
-0
No files found.
library/Solarium/Client/Adapter/ZendHttp.php
View file @
aa98efa4
...
@@ -63,7 +63,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
...
@@ -63,7 +63,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
*
*
* Overrides any existing values.
* Overrides any existing values.
*
*
* If the options array has an '
adapter
options' entry it is forwarded to the
* If the options array has an 'options' entry it is forwarded to the
* Zend_Http_Client. See the Zend_Http_Clientdocs for the many config
* Zend_Http_Client. See the Zend_Http_Clientdocs for the many config
* options available.
* options available.
*
*
...
@@ -81,14 +81,14 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
...
@@ -81,14 +81,14 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
if
(
null
!==
$this
->
_zendHttp
)
{
if
(
null
!==
$this
->
_zendHttp
)
{
// forward timeout setting
// forward timeout setting
$this
->
_zendHttp
->
setConfig
(
$adapterOptions
=
array
(
'timeout'
=>
$this
->
getTimeout
());
array
(
'timeout'
=>
$this
->
getOption
(
'timeout'
))
);
// forward adapter options if available
// forward adapter options if available
if
(
isset
(
$this
->
_options
[
'
adapter
options'
]))
{
if
(
isset
(
$this
->
_options
[
'options'
]))
{
$
this
->
_zendHttp
->
setConfig
(
$this
->
_options
[
'adapter
options'
]);
$
adapterOptions
=
array_merge
(
$adapterOptions
,
$this
->
_options
[
'
options'
]);
}
}
$this
->
_zendHttp
->
setConfig
(
$adapterOptions
);
}
}
return
$this
;
return
$this
;
...
@@ -126,10 +126,12 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
...
@@ -126,10 +126,12 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
{
{
if
(
null
==
$this
->
_zendHttp
)
{
if
(
null
==
$this
->
_zendHttp
)
{
$options
=
array
(
'timeout'
=>
$this
->
getOption
(
'timeout'
));
$options
=
array
(
'timeout'
=>
$this
->
getOption
(
'timeout'
));
if
(
isset
(
$this
->
_options
[
'adapteroptions'
]))
{
// forward zendhttp options
if
(
isset
(
$this
->
_options
[
'options'
]))
{
$options
=
array_merge
(
$options
=
array_merge
(
$options
,
$options
,
$this
->
_options
[
'
adapter
options'
]
$this
->
_options
[
'options'
]
);
);
}
}
...
@@ -150,7 +152,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
...
@@ -150,7 +152,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
$client
=
$this
->
getZendHttp
();
$client
=
$this
->
getZendHttp
();
$client
->
setMethod
(
$request
->
getMethod
());
$client
->
setMethod
(
$request
->
getMethod
());
$client
->
setUri
(
$request
->
getUri
());
$client
->
setUri
(
$
this
->
getBaseUri
()
.
$
request
->
getUri
());
$client
->
setRawData
(
$request
->
getRawData
());
$client
->
setRawData
(
$request
->
getRawData
());
$response
=
$client
->
request
();
$response
=
$client
->
request
();
...
@@ -163,7 +165,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
...
@@ -163,7 +165,7 @@ class Solarium_Client_Adapter_ZendHttp extends Solarium_Client_Adapter
);
);
}
}
if
(
$request
->
getMethod
()
==
Solarium_Client_Request
::
HEAD
)
{
if
(
$request
->
getMethod
()
==
Solarium_Client_Request
::
METHOD_
HEAD
)
{
$data
=
''
;
$data
=
''
;
}
else
{
}
else
{
$data
=
$response
->
getBody
();
$data
=
$response
->
getBody
();
...
...
library/Solarium/Client/Request.php
View file @
aa98efa4
...
@@ -38,8 +38,6 @@
...
@@ -38,8 +38,6 @@
/**
/**
* Class for describing a request
* Class for describing a request
*
*
* @todo support config mode
*
* @package Solarium
* @package Solarium
* @subpackage Client
* @subpackage Client
*/
*/
...
...
library/Solarium/Client/RequestBuilder/Select.php
View file @
aa98efa4
...
@@ -88,7 +88,6 @@ class Solarium_Client_RequestBuilder_Select extends Solarium_Client_RequestBuild
...
@@ -88,7 +88,6 @@ class Solarium_Client_RequestBuilder_Select extends Solarium_Client_RequestBuild
foreach
(
$query
->
getComponents
()
as
$component
)
{
foreach
(
$query
->
getComponents
()
as
$component
)
{
$componentBuilderClass
=
$types
[
$component
->
getType
()][
'requestbuilder'
];
$componentBuilderClass
=
$types
[
$component
->
getType
()][
'requestbuilder'
];
if
(
!
empty
(
$componentBuilderClass
))
{
if
(
!
empty
(
$componentBuilderClass
))
{
// todo add caching?
$componentBuilder
=
new
$componentBuilderClass
;
$componentBuilder
=
new
$componentBuilderClass
;
$request
=
$componentBuilder
->
build
(
$component
,
$request
);
$request
=
$componentBuilder
->
build
(
$component
,
$request
);
}
}
...
...
library/Solarium/Client/ResponseParser/Select.php
View file @
aa98efa4
...
@@ -54,9 +54,6 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
...
@@ -54,9 +54,6 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
{
{
$data
=
$result
->
getData
();
$data
=
$result
->
getData
();
$query
=
$result
->
getQuery
();
$query
=
$result
->
getQuery
();
// reset arrays
$this
->
_components
=
array
();
// create document instances
// create document instances
$documentClass
=
$query
->
getOption
(
'documentclass'
);
$documentClass
=
$query
->
getOption
(
'documentclass'
);
...
@@ -74,7 +71,6 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
...
@@ -74,7 +71,6 @@ class Solarium_Client_ResponseParser_Select extends Solarium_Client_ResponsePars
foreach
(
$query
->
getComponents
()
as
$component
)
{
foreach
(
$query
->
getComponents
()
as
$component
)
{
$componentParserClass
=
$types
[
$component
->
getType
()][
'responseparser'
];
$componentParserClass
=
$types
[
$component
->
getType
()][
'responseparser'
];
if
(
!
empty
(
$componentParserClass
))
{
if
(
!
empty
(
$componentParserClass
))
{
// todo add caching?
$componentParser
=
new
$componentParserClass
;
$componentParser
=
new
$componentParserClass
;
$components
[
$component
->
getType
()]
=
$componentParser
->
parse
(
$query
,
$component
,
$data
);
$components
[
$component
->
getType
()]
=
$componentParser
->
parse
(
$query
,
$component
,
$data
);
}
}
...
...
library/Solarium/Result/QueryType.php
View file @
aa98efa4
...
@@ -38,8 +38,6 @@
...
@@ -38,8 +38,6 @@
/**
/**
* QueryType result
* QueryType result
*
*
* TODO intro
*
* @package Solarium
* @package Solarium
* @subpackage Result
* @subpackage Result
*/
*/
...
...
tests/Solarium/Client/Adapter/ZendHttpTest.php
0 → 100644
View file @
aa98efa4
<?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_Client_Adapter_ZendHttpTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Client_Adapter_ZendHttp
*/
protected
$_adapter
;
public
function
setUp
()
{
if
(
!
class_exists
(
'Zend_Loader_Autoloader'
)
&&
(
include_once
'Zend/Loader/Autoloader.php'
)
!==
'OK'
)
{
$this
->
markTestSkipped
(
'ZF not in include_path, skipping ZendHttp adapter tests'
);
}
Zend_Loader_Autoloader
::
getInstance
();
$this
->
_adapter
=
new
Solarium_Client_Adapter_ZendHttp
();
}
public
function
testForwardingToZendHttpInSetOptions
()
{
$options
=
array
(
'timeout'
=>
10
,
'optionZ'
=>
123
,
'options'
=>
array
(
'optionX'
=>
'Y'
));
$adapterOptions
=
array
(
'timeout'
=>
10
,
'optionX'
=>
'Y'
);
$mock
=
$this
->
getMock
(
'Zend_Http_Client'
);
$mock
->
expects
(
$this
->
once
())
->
method
(
'setConfig'
)
->
with
(
$this
->
equalTo
(
$adapterOptions
));
$this
->
_adapter
->
setZendHttp
(
$mock
);
$this
->
_adapter
->
setOptions
(
$options
);
}
public
function
testSetAndGetZendHttp
()
{
$dummy
=
new
StdClass
();
$this
->
_adapter
->
setZendHttp
(
$dummy
);
$this
->
assertEquals
(
$dummy
,
$this
->
_adapter
->
getZendHttp
()
);
}
public
function
testGetZendHttpAutoload
()
{
$this
->
_adapter
->
setOptions
(
array
(
'myoption'
,
123
));
$zendHttp
=
$this
->
_adapter
->
getZendHttp
();
$this
->
assertThat
(
$zendHttp
,
$this
->
isInstanceOf
(
'Zend_Http_Client'
));
}
public
function
testExecute
()
{
$method
=
Solarium_Client_Request
::
METHOD_GET
;
$rawData
=
'xyz'
;
$responseData
=
'abc'
;
$handler
=
'myhandler'
;
$request
=
new
Solarium_Client_Request
();
$request
->
setMethod
(
$method
);
$request
->
setHandler
(
$handler
);
$request
->
setRawData
(
$rawData
);
$response
=
new
Zend_Http_Response
(
200
,
array
(
'status'
=>
'HTTP 1.1 200 OK'
),
$responseData
);
$mock
=
$this
->
getMock
(
'Zend_Http_Client'
);
$mock
->
expects
(
$this
->
once
())
->
method
(
'setMethod'
)
->
with
(
$this
->
equalTo
(
$method
));
$mock
->
expects
(
$this
->
once
())
->
method
(
'setUri'
)
->
with
(
$this
->
equalTo
(
'http://127.0.0.1:8983/solr/myhandler?'
));
$mock
->
expects
(
$this
->
once
())
->
method
(
'setRawData'
)
->
with
(
$this
->
equalTo
(
$rawData
));
$mock
->
expects
(
$this
->
once
())
->
method
(
'request'
)
->
will
(
$this
->
returnValue
(
$response
));
$this
->
_adapter
->
setZendHttp
(
$mock
);
$adapterResponse
=
$this
->
_adapter
->
execute
(
$request
);
$this
->
assertEquals
(
$responseData
,
$adapterResponse
->
getBody
()
);
}
public
function
testExecuteErrorResponse
()
{
$request
=
new
Solarium_Client_Request
();
$response
=
new
Zend_Http_Response
(
404
,
array
(),
''
);
$mock
=
$this
->
getMock
(
'Zend_Http_Client'
);
$mock
->
expects
(
$this
->
once
())
->
method
(
'request'
)
->
will
(
$this
->
returnValue
(
$response
));
$this
->
_adapter
->
setZendHttp
(
$mock
);
$this
->
setExpectedException
(
'Solarium_Client_HttpException'
);
$this
->
_adapter
->
execute
(
$request
);
}
public
function
testExecuteHeadRequestReturnsNoData
()
{
$request
=
new
Solarium_Client_Request
();
$request
->
setMethod
(
Solarium_Client_Request
::
METHOD_HEAD
);
$response
=
new
Zend_Http_Response
(
200
,
array
(
'status'
=>
'HTTP 1.1 200 OK'
),
'data'
);
$mock
=
$this
->
getMock
(
'Zend_Http_Client'
);
$mock
->
expects
(
$this
->
once
())
->
method
(
'request'
)
->
will
(
$this
->
returnValue
(
$response
));
$this
->
_adapter
->
setZendHttp
(
$mock
);
$response
=
$this
->
_adapter
->
execute
(
$request
);
$this
->
assertEquals
(
''
,
$response
->
getBody
()
);
}
}
\ No newline at end of file
tests/Solarium/ClientTest.php
View file @
aa98efa4
...
@@ -486,6 +486,114 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
...
@@ -486,6 +486,114 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
$observer
->
update
(
$query
);
$observer
->
update
(
$query
);
}
}
public
function
testCreateQuery
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$query
=
$this
->
_client
->
createQuery
(
Solarium_Client
::
QUERYTYPE_SELECT
,
$options
);
// check class mapping
$this
->
assertThat
(
$query
,
$this
->
isInstanceOf
(
'Solarium_Query_Select'
));
// check option forwarding
$queryOptions
=
$query
->
getOptions
();
$this
->
assertEquals
(
$options
[
'optionB'
],
$queryOptions
[
'optionB'
]
);
}
public
function
testCreateQueryWithInvalidQueryType
()
{
$this
->
setExpectedException
(
'Solarium_Exception'
);
$this
->
_client
->
createQuery
(
'invalidtype'
);
}
public
function
testCreateQueryPrePlugin
()
{
$type
=
Solarium_Client
::
QUERYTYPE_SELECT
;
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Plugin_Abstract'
,
array
(),
array
(
$this
->
_client
,
array
()));
$observer
->
expects
(
$this
->
once
())
->
method
(
'preCreateQuery'
)
->
with
(
$this
->
equalTo
(
$type
),
$this
->
equalTo
(
$options
));
$this
->
_client
->
registerPlugin
(
'testplugin'
,
$observer
);
$this
->
_client
->
createQuery
(
$type
,
$options
);
}
public
function
testCreateQueryWithOverridingPlugin
()
{
$type
=
Solarium_Client
::
QUERYTYPE_SELECT
;
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$dummyvalue
=
'test123'
;
$observer
=
$this
->
getMock
(
'Solarium_Plugin_Abstract'
,
array
(),
array
(
$this
->
_client
,
array
()));
$observer
->
expects
(
$this
->
once
())
->
method
(
'preCreateQuery'
)
->
with
(
$this
->
equalTo
(
$type
),
$this
->
equalTo
(
$options
))
->
will
(
$this
->
returnValue
(
$dummyvalue
));
$this
->
_client
->
registerPlugin
(
'testplugin'
,
$observer
);
$query
=
$this
->
_client
->
createQuery
(
$type
,
$options
);
$this
->
assertEquals
(
$dummyvalue
,
$query
);
}
public
function
testCreateQueryPostPlugin
()
{
$type
=
Solarium_Client
::
QUERYTYPE_SELECT
;
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$query
=
$this
->
_client
->
createQuery
(
$type
,
$options
);
$observer
=
$this
->
getMock
(
'Solarium_Plugin_Abstract'
,
array
(),
array
(
$this
->
_client
,
array
()));
$observer
->
expects
(
$this
->
once
())
->
method
(
'postCreateQuery'
)
->
with
(
$this
->
equalTo
(
$type
),
$this
->
equalTo
(
$options
),
$this
->
equalTo
(
$query
));
$this
->
_client
->
registerPlugin
(
'testplugin'
,
$observer
);
$this
->
_client
->
createQuery
(
$type
,
$options
);
}
public
function
testCreateSelect
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Client'
,
array
(
'createQuery'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createQuery'
)
->
with
(
$this
->
equalTo
(
Solarium_Client
::
QUERYTYPE_SELECT
),
$this
->
equalTo
(
$options
));
$observer
->
createSelect
(
$options
);
}
public
function
testCreateUpdate
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Client'
,
array
(
'createQuery'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createQuery'
)
->
with
(
$this
->
equalTo
(
Solarium_Client
::
QUERYTYPE_UPDATE
),
$this
->
equalTo
(
$options
));
$observer
->
createUpdate
(
$options
);
}
public
function
testCreatePing
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Client'
,
array
(
'createQuery'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createQuery'
)
->
with
(
$this
->
equalTo
(
Solarium_Client
::
QUERYTYPE_PING
),
$this
->
equalTo
(
$options
));
$observer
->
createPing
(
$options
);
}
}
}
class
MyAdapter
extends
Solarium_Client_Adapter_Http
{
class
MyAdapter
extends
Solarium_Client_Adapter_Http
{
...
...
tests/Solarium/Plugin/AbstractTest.php
View file @
aa98efa4
...
@@ -55,7 +55,7 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
...
@@ -55,7 +55,7 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
}
}
public
function
testEventHooks
()
public
function
testEventHooks
Empty
()
{
{
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateRequest
(
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateRequest
(
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateRequest
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateRequest
(
null
,
null
));
...
@@ -65,6 +65,8 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
...
@@ -65,6 +65,8 @@ class Solarium_Plugin_AbstractTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postExecute
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postExecute
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateResult
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateResult
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateResult
(
null
,
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateResult
(
null
,
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
preCreateQuery
(
null
,
null
));
$this
->
assertEquals
(
null
,
$this
->
_plugin
->
postCreateQuery
(
null
,
null
,
null
));
}
}
}
}
...
...
tests/Solarium/Query/Select/Component/FacetSetTest.php
View file @
aa98efa4
...
@@ -229,5 +229,79 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
...
@@ -229,5 +229,79 @@ class Solarium_Query_Select_Component_FacetSetTest extends PHPUnit_Framework_Tes
$this
->
_facetSet
->
getFacets
()
$this
->
_facetSet
->
getFacets
()
);
);
}
}
public
function
testCreateFacet
()
{
$type
=
Solarium_Query_Select_Component_FacetSet
::
FACET_FIELD
;
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$facet
=
$this
->
_facetSet
->
createFacet
(
$type
,
$options
);
// check class mapping
$this
->
assertEquals
(
$type
,
$facet
->
getType
()
);
// check option forwarding
$facetOptions
=
$facet
->
getOptions
();
$this
->
assertEquals
(
$options
[
'optionB'
],
$facetOptions
[
'optionB'
]
);
}
public
function
testCreateFacetWithInvalidType
()
{
$this
->
setExpectedException
(
'Solarium_Exception'
);
$this
->
_facetSet
->
createFacet
(
'invalidtype'
);
}
public
function
testCreateFacetField
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Query_Select_Component_FacetSet'
,
array
(
'createFacet'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createFacet'
)
->
with
(
$this
->
equalTo
(
Solarium_Query_Select_Component_FacetSet
::
FACET_FIELD
),
$this
->
equalTo
(
$options
));
$observer
->
createFacetField
(
$options
);
}
public
function
testCreateFacetQuery
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Query_Select_Component_FacetSet'
,
array
(
'createFacet'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createFacet'
)
->
with
(
$this
->
equalTo
(
Solarium_Query_Select_Component_FacetSet
::
FACET_QUERY
),
$this
->
equalTo
(
$options
));
$observer
->
createFacetQuery
(
$options
);
}
public
function
testCreateFacetMultiQuery
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Query_Select_Component_FacetSet'
,
array
(
'createFacet'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createFacet'
)
->
with
(
$this
->
equalTo
(
Solarium_Query_Select_Component_FacetSet
::
FACET_MULTIQUERY
),
$this
->
equalTo
(
$options
));
$observer
->
createFacetMultiQuery
(
$options
);
}
public
function
testCreateFacetRange
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$observer
=
$this
->
getMock
(
'Solarium_Query_Select_Component_FacetSet'
,
array
(
'createFacet'
));
$observer
->
expects
(
$this
->
once
())
->
method
(
'createFacet'
)
->
with
(
$this
->
equalTo
(
Solarium_Query_Select_Component_FacetSet
::
FACET_RANGE
),
$this
->
equalTo
(
$options
));
$observer
->
createFacetRange
(
$options
);
}
}
}
tests/Solarium/Query/SelectTest.php
View file @
aa98efa4
...
@@ -520,4 +520,20 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
...
@@ -520,4 +520,20 @@ class Solarium_Query_SelectTest extends PHPUnit_Framework_TestCase
$this
->
_query
->
getComponentTypes
()
$this
->
_query
->
getComponentTypes
()
);
);
}
}
public
function
testCreateFilterQuery
()
{
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$fq
=
$this
->
_query
->
createFilterQuery
(
$options
);
// check class
$this
->
assertThat
(
$fq
,
$this
->
isInstanceOf
(
'Solarium_Query_Select_FilterQuery'
));
// check option forwarding
$fqOptions
=
$fq
->
getOptions
();
$this
->
assertEquals
(
$options
[
'optionB'
],
$fqOptions
[
'optionB'
]
);
}
}
}
\ No newline at end of file
tests/Solarium/Query/UpdateTest.php
View file @
aa98efa4
...
@@ -365,4 +365,30 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
...
@@ -365,4 +365,30 @@ class Solarium_Query_UpdateTest extends PHPUnit_Framework_TestCase
new
Solarium_Query_Update
(
$config
);
new
Solarium_Query_Update
(
$config
);
}
}
public
function
testCreateCommand
()
{
$type
=
Solarium_Query_Update
::
COMMAND_ROLLBACK
;
$options
=
array
(
'optionA'
=>
1
,
'optionB'
=>
2
);
$command
=
$this
->
_query
->
createCommand
(
$type
,
$options
);
// check command type
$this
->
assertEquals
(
$type
,
$command
->
getType
()
);
// check option forwarding
$commandOptions
=
$command
->
getOptions
();
$this
->
assertEquals
(
$options
[
'optionB'
],
$commandOptions
[
'optionB'
]
);
}
public
function
testCreateCommandWithInvalidQueryType
()
{
$this
->
setExpectedException
(
'Solarium_Exception'
);
$this
->
_query
->
createCommand
(
'invalidtype'
);
}
}
}
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