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
151b7dc3
Commit
151b7dc3
authored
May 10, 2011
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- unittest improvements
parent
1035216c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
566 additions
and
48 deletions
+566
-48
library/Solarium/Client.php
library/Solarium/Client.php
+3
-3
library/Solarium/Client/Request.php
library/Solarium/Client/Request.php
+2
-2
library/Solarium/Client/RequestBuilder/Select/Component/Highlighting.php
...m/Client/RequestBuilder/Select/Component/Highlighting.php
+1
-1
library/Solarium/Client/RequestBuilder/Select/Component/MoreLikeThis.php
...m/Client/RequestBuilder/Select/Component/MoreLikeThis.php
+1
-1
tests/Solarium/Client/AdapterTest.php
tests/Solarium/Client/AdapterTest.php
+20
-0
tests/Solarium/Client/RequestBuilder/Select/Component/HighlightingTest.php
...ient/RequestBuilder/Select/Component/HighlightingTest.php
+92
-0
tests/Solarium/Client/RequestBuilder/Select/Component/MoreLikeThisTest.php
...ient/RequestBuilder/Select/Component/MoreLikeThisTest.php
+73
-0
tests/Solarium/Client/RequestBuilder/SelectTest.php
tests/Solarium/Client/RequestBuilder/SelectTest.php
+0
-27
tests/Solarium/Client/RequestTest.php
tests/Solarium/Client/RequestTest.php
+307
-1
tests/Solarium/ClientTest.php
tests/Solarium/ClientTest.php
+67
-13
No files found.
library/Solarium/Client.php
View file @
151b7dc3
...
...
@@ -58,9 +58,9 @@ class Solarium_Client extends Solarium_Configurable
/**
* Querytype definitions
*/
const
QUERYTYPE_SELECT
=
'
S
elect'
;
const
QUERYTYPE_UPDATE
=
'
U
pdate'
;
const
QUERYTYPE_PING
=
'
P
ing'
;
const
QUERYTYPE_SELECT
=
'
s
elect'
;
const
QUERYTYPE_UPDATE
=
'
u
pdate'
;
const
QUERYTYPE_PING
=
'
p
ing'
;
/**
* Default options
...
...
library/Solarium/Client/Request.php
View file @
151b7dc3
...
...
@@ -307,8 +307,8 @@ class Solarium_Client_Request extends Solarium_Configurable
*/
public
function
addHeaders
(
$headers
)
{
foreach
(
$headers
as
$
key
=>
$value
)
{
$this
->
addHeader
(
$
key
,
$value
);
foreach
(
$headers
as
$
header
)
{
$this
->
addHeader
(
$
header
);
}
return
$this
;
...
...
library/Solarium/Client/RequestBuilder/Select/Component/Highlighting.php
View file @
151b7dc3
...
...
@@ -54,7 +54,7 @@ class Solarium_Client_RequestBuilder_Select_Component_Highlighting
public
function
build
(
$component
,
$request
)
{
// enable highlighting
$request
->
addParam
(
'hl'
,
'true'
);
$request
->
addParam
(
'hl'
,
true
);
$request
->
addParam
(
'hl.fl'
,
$component
->
getFields
());
$request
->
addParam
(
'hl.snippets'
,
$component
->
getSnippets
());
...
...
library/Solarium/Client/RequestBuilder/Select/Component/MoreLikeThis.php
View file @
151b7dc3
...
...
@@ -54,7 +54,7 @@ class Solarium_Client_RequestBuilder_Select_Component_MoreLikeThis
public
function
build
(
$component
,
$request
)
{
// enable morelikethis
$request
->
addParam
(
'mlt'
,
'true'
);
$request
->
addParam
(
'mlt'
,
true
);
$request
->
addParam
(
'mlt.fl'
,
$component
->
getFields
());
$request
->
addParam
(
'mlt.mintf'
,
$component
->
getMinimumTermFrequency
());
...
...
tests/Solarium/Client/AdapterTest.php
View file @
151b7dc3
...
...
@@ -72,6 +72,26 @@ class Solarium_Client_AdapterTest extends PHPUnit_Framework_TestCase
$this
->
assertEquals
(
'core1'
,
$this
->
_adapter
->
getCore
());
}
public
function
testSetAndGetTimeout
()
{
$this
->
_adapter
->
setTimeout
(
7
);
$this
->
assertEquals
(
7
,
$this
->
_adapter
->
getTimeout
());
}
public
function
testGetBaseUri
()
{
$this
->
_adapter
->
setHost
(
'myserver'
)
->
setPath
(
'/mypath'
)
->
setPort
(
123
);
$this
->
assertEquals
(
'http://myserver:123/mypath/'
,
$this
->
_adapter
->
getBaseUri
());
}
public
function
testGetBaseUriWithCore
()
{
$this
->
_adapter
->
setHost
(
'myserver'
)
->
setPath
(
'/mypath'
)
->
setPort
(
123
)
->
setCore
(
'mycore'
);
$this
->
assertEquals
(
'http://myserver:123/mypath/mycore/'
,
$this
->
_adapter
->
getBaseUri
());
}
}
class
TestAdapter
extends
Solarium_Client_Adapter
...
...
tests/Solarium/Client/RequestBuilder/Select/Component/HighlightingTest.php
0 → 100644
View file @
151b7dc3
<?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_RequestBuilder_Select_Component_HighlightingTest
extends
PHPUnit_Framework_TestCase
{
public
function
testBuild
()
{
$builder
=
new
Solarium_Client_RequestBuilder_Select_Component_Highlighting
;
$request
=
new
Solarium_Client_Request
();
$component
=
new
Solarium_Query_Select_Component_Highlighting
();
$component
->
setFields
(
'fieldA,fieldB'
);
$component
->
setSnippets
(
2
);
$component
->
setFragSize
(
3
);
$component
->
setMergeContiguous
(
true
);
$component
->
setRequireFieldMatch
(
false
);
$component
->
setMaxAnalyzedChars
(
4
);
$component
->
setAlternateField
(
'fieldC'
);
$component
->
setMaxAlternateFieldLength
(
5
);
$component
->
setFormatter
(
'simple'
);
$component
->
setSimplePrefix
(
'<b>'
);
$component
->
setSimplePostfix
(
'</b>'
);
$component
->
setFragmenter
(
'myFragmenter'
);
$component
->
setFragListBuilder
(
'myFragListBuilder'
);
$component
->
setFragmentsBuilder
(
'myFragmentsBuilder'
);
$component
->
setUsePhraseHighlighter
(
true
);
$component
->
setUseFastVectorHighlighter
(
false
);
$component
->
setHighlightMultiTerm
(
true
);
$component
->
setRegexSlop
(
1.3
);
$component
->
setRegexPattern
(
'mypattern'
);
$component
->
setMaxAnalyzedChars
(
100
);
$request
=
$builder
->
build
(
$component
,
$request
);
$this
->
assertEquals
(
array
(
'hl'
=>
true
,
'hl.fl'
=>
'fieldA,fieldB'
,
'hl.snippets'
=>
2
,
'hl.fragsize'
=>
3
,
'hl.mergeContiguous'
=>
true
,
'hl.requireFieldMatch'
=>
false
,
'hl.maxAnalyzedChars'
=>
100
,
'hl.alternateField'
=>
'fieldC'
,
'hl.maxAlternateFieldLength'
=>
5
,
'hl.formatter'
=>
'simple'
,
'hl.simple.pre'
=>
'<b>'
,
'hl.simple.post'
=>
'</b>'
,
'hl.fragmenter'
=>
'myFragmenter'
,
'hl.fragListBuilder'
=>
'myFragListBuilder'
,
'hl.fragmentsBuilder'
=>
'myFragmentsBuilder'
,
'hl.useFastVectorHighlighter'
=>
false
,
'hl.usePhraseHighlighter'
=>
true
,
'hl.highlightMultiTerm'
=>
true
,
'hl.regex.slop'
=>
1.3
,
'hl.regex.pattern'
=>
'mypattern'
,
),
$request
->
getParams
()
);
}
}
tests/Solarium/Client/RequestBuilder/Select/Component/MoreLikeThisTest.php
0 → 100644
View file @
151b7dc3
<?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_RequestBuilder_Select_Component_MoreLikeThisTest
extends
PHPUnit_Framework_TestCase
{
public
function
testBuild
()
{
$builder
=
new
Solarium_Client_RequestBuilder_Select_Component_MoreLikeThis
;
$request
=
new
Solarium_Client_Request
();
$component
=
new
Solarium_Query_Select_Component_MoreLikeThis
();
$component
->
setFields
(
'description,name'
);
$component
->
setMinimumTermFrequency
(
1
);
$component
->
setMinimumDocumentFrequency
(
3
);
$component
->
setMinimumWordLength
(
2
);
$component
->
setMaximumWordLength
(
15
);
$component
->
setMaximumQueryTerms
(
4
);
$component
->
setMaximumNumberOfTokens
(
5
);
$component
->
setBoost
(
true
);
$component
->
setQueryFields
(
'description'
);
$component
->
setCount
(
6
);
$request
=
$builder
->
build
(
$component
,
$request
);
$this
->
assertEquals
(
array
(
'mlt'
=>
true
,
'mlt.fl'
=>
'description,name'
,
'mlt.mintf'
=>
1
,
'mlt.mindf'
=>
3
,
'mlt.minwl'
=>
2
,
'mlt.maxwl'
=>
15
,
'mlt.maxqt'
=>
4
,
'mlt.maxntp'
=>
5
,
'mlt.boost'
=>
true
,
'mlt.qf'
=>
'description'
,
'mlt.count'
=>
6
,
),
$request
->
getParams
()
);
}
}
\ No newline at end of file
tests/Solarium/Client/RequestBuilder/SelectTest.php
View file @
151b7dc3
...
...
@@ -180,33 +180,6 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$request
->
getUri
();
}
public
function
testSelectUrlWithMoreLikeThis
()
{
$mlt
=
$this
->
_query
->
getMoreLikeThis
();
$mlt
->
setFields
(
'description,name'
);
$mlt
->
setMinimumTermFrequency
(
1
);
$mlt
->
setMinimumDocumentFrequency
(
3
);
$mlt
->
setMinimumWordLength
(
2
);
$mlt
->
setMaximumWordLength
(
15
);
$mlt
->
setMaximumQueryTerms
(
4
);
$mlt
->
setMaximumNumberOfTokens
(
5
);
$mlt
->
setBoost
(
true
);
$mlt
->
setQueryFields
(
'description'
);
$mlt
->
setCount
(
6
);
$request
=
$this
->
_builder
->
build
(
$this
->
_query
);
$this
->
assertEquals
(
null
,
$request
->
getRawData
()
);
$this
->
assertEquals
(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json&mlt=true&mlt.fl=description,name&mlt.mintf=1&mlt.mindf=3&mlt.minwl=2&mlt.maxwl=15&mlt.maxqt=4&mlt.maxntp=5&mlt.boost=1&mlt.qf=description&mlt.count=6'
,
urldecode
(
$request
->
getUri
())
);
}
}
...
...
tests/Solarium/Client/RequestTest.php
View file @
151b7dc3
...
...
@@ -32,6 +32,9 @@
class
Solarium_Client_RequestTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Client_Request
*/
protected
$_request
;
public
function
setup
()
...
...
@@ -39,7 +42,7 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
$this
->
_request
=
new
Solarium_Client_Request
;
}
public
function
testGetMethod
()
public
function
testGet
Default
Method
()
{
$this
->
assertEquals
(
Solarium_Client_Request
::
METHOD_GET
,
...
...
@@ -47,6 +50,293 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
);
}
public
function
testSetAndGetMethod
()
{
$this
->
_request
->
setMethod
(
Solarium_Client_Request
::
METHOD_POST
);
$this
->
assertEquals
(
Solarium_Client_Request
::
METHOD_POST
,
$this
->
_request
->
getMethod
()
);
}
public
function
testSetAndGetHandler
()
{
$this
->
_request
->
setHandler
(
'myhandler'
);
$this
->
assertEquals
(
'myhandler'
,
$this
->
_request
->
getHandler
()
);
}
public
function
testSetAndGetParams
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
2
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
assertEquals
(
$params
,
$this
->
_request
->
getParams
()
);
}
public
function
testSetAndGetParam
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
2
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
assertEquals
(
2
,
$this
->
_request
->
getParam
(
'param2'
)
);
}
public
function
testAddParam
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
2
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParam
(
'param3'
,
3
);
$params
[
'param3'
]
=
3
;
$this
->
assertEquals
(
$params
,
$this
->
_request
->
getParams
()
);
}
public
function
testAddParamMultivalue
()
{
$params
=
array
(
'param1'
=>
1
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParam
(
'param2'
,
2
);
$this
->
_request
->
addParam
(
'param2'
,
3
);
$params
[
'param2'
]
=
array
(
2
,
3
);
$this
->
assertEquals
(
$params
,
$this
->
_request
->
getParams
()
);
}
public
function
testAddParamNoValue
()
{
$params
=
array
(
'param1'
=>
1
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParam
(
'param2'
,
2
);
$this
->
_request
->
addParam
(
'param2'
,
''
);
$this
->
_request
->
addParam
(
'param3'
,
''
);
$params
[
'param2'
]
=
2
;
$this
->
assertEquals
(
$params
,
$this
->
_request
->
getParams
()
);
}
public
function
testAddParamOverwrite
()
{
$params
=
array
(
'param1'
=>
1
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParam
(
'param1'
,
2
,
true
);
$this
->
assertEquals
(
array
(
'param1'
=>
2
),
$this
->
_request
->
getParams
()
);
}
public
function
testAddParams
()
{
$params
=
array
(
'param1'
=>
1
,
);
$extraParams
=
array
(
'param1'
=>
2
,
'param2'
=>
3
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParams
(
$extraParams
);
$this
->
assertEquals
(
array
(
'param1'
=>
array
(
1
,
2
),
'param2'
=>
3
,
),
$this
->
_request
->
getParams
()
);
}
public
function
testAddParamsOverwrite
()
{
$params
=
array
(
'param1'
=>
1
,
);
$extraParams
=
array
(
'param1'
=>
2
,
'param2'
=>
3
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
addParams
(
$extraParams
,
true
);
$this
->
assertEquals
(
array
(
'param1'
=>
2
,
'param2'
=>
3
,
),
$this
->
_request
->
getParams
()
);
}
public
function
testRemoveParam
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
2
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
removeParam
(
'param2'
);
$this
->
assertEquals
(
array
(
'param1'
=>
1
),
$this
->
_request
->
getParams
()
);
}
public
function
testClearParams
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
2
,
);
$this
->
_request
->
setParams
(
$params
);
$this
->
_request
->
clearParams
();
$this
->
assertEquals
(
array
(),
$this
->
_request
->
getParams
()
);
}
public
function
testGetAndSetRawData
()
{
$data
=
'1234567890'
;
$this
->
_request
->
setRawData
(
$data
);
$this
->
assertEquals
(
$data
,
$this
->
_request
->
getRawData
()
);
}
public
function
testSetAndGetHeaders
()
{
$headers
=
array
(
'User-Agent: My Agent'
,
'Cache-Control: no-cache'
);
$this
->
_request
->
setHeaders
(
$headers
);
$this
->
assertEquals
(
$headers
,
$this
->
_request
->
getHeaders
()
);
}
public
function
testAddHeader
()
{
$headers
=
array
(
'User-Agent: My Agent'
,
);
$this
->
_request
->
setHeaders
(
$headers
);
$this
->
_request
->
addHeader
(
'Cache-Control: no-cache'
);
$headers
[]
=
'Cache-Control: no-cache'
;
$this
->
assertEquals
(
$headers
,
$this
->
_request
->
getHeaders
()
);
}
public
function
testAddHeaders
()
{
$headers
=
array
(
'User-Agent: My Agent'
,
);
$extraHeaders
=
array
(
'Cache-Control: no-cache'
,
'X-custom: 123'
,
);
$this
->
_request
->
setHeaders
(
$headers
);
$this
->
_request
->
addHeaders
(
$extraHeaders
);
$this
->
assertEquals
(
array_merge
(
$headers
,
$extraHeaders
),
$this
->
_request
->
getHeaders
()
);
}
public
function
testClearHeaders
()
{
$headers
=
array
(
'User-Agent: My Agent'
,
'Cache-Control: no-cache'
);
$this
->
_request
->
setHeaders
(
$headers
);
$this
->
assertEquals
(
$headers
,
$this
->
_request
->
getHeaders
()
);
$this
->
_request
->
clearHeaders
();
$this
->
assertEquals
(
array
(),
$this
->
_request
->
getHeaders
()
);
}
public
function
testGetUri
()
{
$this
->
assertEquals
(
...
...
@@ -55,4 +345,20 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
);
}
public
function
testGetUriWithHandlerAndParams
()
{
$params
=
array
(
'param1'
=>
1
,
'param2'
=>
array
(
2
,
3
),
);
$this
->
_request
->
setHandler
(
'myHandler'
);
$this
->
_request
->
addParams
(
$params
);
$this
->
assertEquals
(
'myHandler?param1=1¶m2=2¶m2=3'
,
$this
->
_request
->
getUri
()
);
}
}
\ No newline at end of file
tests/Solarium/ClientTest.php
View file @
151b7dc3
...
...
@@ -32,43 +32,93 @@
class
Solarium_ClientTest
extends
PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Client
*/
protected
$_client
;
public
function
setUp
()
{
$this
->
_client
=
new
Solarium_Client
();
}
public
function
testGetAdapterWithDefaultAdapter
()
{
$client
=
new
Solarium_Client
();
$defaultAdapter
=
$client
->
getOption
(
'adapter'
);
$adapter
=
$client
->
getAdapter
();
$defaultAdapter
=
$
this
->
_
client
->
getOption
(
'adapter'
);
$adapter
=
$
this
->
_
client
->
getAdapter
();
$this
->
assertThat
(
$adapter
,
$this
->
isInstanceOf
(
$defaultAdapter
));
}
public
function
testGetAdapterWithString
()
{
$adapterClass
=
'MyAdapter'
;
$client
=
new
Solarium_Client
();
$client
->
setAdapter
(
$adapterClass
);
$this
->
assertThat
(
$client
->
getAdapter
(),
$this
->
isInstanceOf
(
$adapterClass
));
$this
->
_client
->
setAdapter
(
$adapterClass
);
$this
->
assertThat
(
$this
->
_client
->
getAdapter
(),
$this
->
isInstanceOf
(
$adapterClass
));
}
public
function
testGetAdapterWithObject
()
{
$adapterClass
=
'MyAdapter'
;
$client
=
new
Solarium_Client
();
$client
->
setAdapter
(
new
$adapterClass
);
$this
->
assertThat
(
$client
->
getAdapter
(),
$this
->
isInstanceOf
(
$adapterClass
));
$this
->
_client
->
setAdapter
(
new
$adapterClass
);
$this
->
assertThat
(
$this
->
_client
->
getAdapter
(),
$this
->
isInstanceOf
(
$adapterClass
));
}
public
function
testRegisterQueryTypeAndGetQueryTypes
()
{
$queryTypes
=
$this
->
_client
->
getQueryTypes
();
$this
->
_client
->
registerQueryType
(
'myquerytype'
,
'mybuilder'
,
'myparser'
);
$queryTypes
[
'myquerytype'
]
=
array
(
'requestbuilder'
=>
'mybuilder'
,
'responseparser'
=>
'myparser'
,
);
$this
->
assertEquals
(
$queryTypes
,
$this
->
_client
->
getQueryTypes
()
);
}
public
function
testRegisterAndGetPlugin
()
{
$options
=
array
(
'option1'
=>
1
);
$this
->
_client
->
registerPlugin
(
'testplugin'
,
'MyClientPlugin'
,
$options
);
$plugin
=
$this
->
_client
->
getPlugin
(
'testplugin'
);
$this
->
assertThat
(
$plugin
,
$this
->
isInstanceOf
(
'MyClientPlugin'
)
);
$this
->
assertEquals
(
$options
,
$plugin
->
getOptions
()
);
}
public
function
testRemoveAndGetPlugins
()
{
$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
(
'testplugin'
);
$plugins
=
$this
->
_client
->
getPlugins
();
$this
->
assertEquals
(
array
(),
$plugins
);
}
public
function
testCreateRequest
()
...
...
@@ -81,12 +131,12 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
}
public
function
testCreateRequest
WithOverriding
Plugin
()
public
function
testCreateRequestPlugin
()
{
}
public
function
testCreateRequest
Post
Plugin
()
public
function
testCreateRequest
WithOverriding
Plugin
()
{
}
...
...
@@ -101,12 +151,12 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
}
public
function
testCreateResult
WithOverriding
Plugin
()
public
function
testCreateResultPlugin
()
{
}
public
function
testCreateResult
Post
Plugin
()
public
function
testCreateResult
WithOverriding
Plugin
()
{
}
...
...
@@ -150,4 +200,8 @@ class myConfig{
{
return
$this
->
_options
;
}
}
class
MyClientPlugin
extends
Solarium_Plugin_Abstract
{
}
\ No newline at end of file
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