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
7d35e58a
Unverified
Commit
7d35e58a
authored
Jan 16, 2018
by
Markus Kalkbrenner
Committed by
GitHub
Jan 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve re-usability of components for any any query type (#544)
parent
c620d93b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
217 additions
and
129 deletions
+217
-129
library/Component/ComponentAwareQueryInterface.php
library/Component/ComponentAwareQueryInterface.php
+143
-0
library/Component/ComponentAwareQueryTrait.php
library/Component/ComponentAwareQueryTrait.php
+20
-92
library/Component/Debug.php
library/Component/Debug.php
+1
-1
library/Component/MoreLikeThis.php
library/Component/MoreLikeThis.php
+1
-1
library/Component/Spatial.php
library/Component/Spatial.php
+1
-1
library/Component/Spellcheck.php
library/Component/Spellcheck.php
+1
-1
library/Component/Suggester.php
library/Component/Suggester.php
+1
-1
library/QueryType/Select/Query/Query.php
library/QueryType/Select/Query/Query.php
+26
-22
tests/Component/DebugTest.php
tests/Component/DebugTest.php
+2
-3
tests/Component/MoreLikeThisTest.php
tests/Component/MoreLikeThisTest.php
+2
-3
tests/Component/SpellcheckTest.php
tests/Component/SpellcheckTest.php
+2
-2
tests/Component/SuggesterTest.php
tests/Component/SuggesterTest.php
+2
-2
tests/Integration/AbstractTechproductsTest.php
tests/Integration/AbstractTechproductsTest.php
+15
-0
No files found.
library/Component/ComponentAwareQueryInterface.php
0 → 100644
View file @
7d35e58a
<?php
namespace
Solarium\Component
;
/**
* Trait query types supporting components.
*/
interface
ComponentAwareQueryInterface
{
/**
* Query component morelikethis.
*/
const
COMPONENT_MORELIKETHIS
=
'morelikethis'
;
/**
* Query component spellcheck.
*/
const
COMPONENT_SPELLCHECK
=
'spellcheck'
;
/**
* Query component spellcheck.
*/
const
COMPONENT_SUGGESTER
=
'suggest'
;
/**
* Query component debug.
*/
const
COMPONENT_DEBUG
=
'debug'
;
/**
* Query component spatial.
*/
const
COMPONENT_SPATIAL
=
'spatial'
;
/**
* Get all registered component types.
*
* @return array
*/
public
function
getComponentTypes
();
/**
* Register a component type.
*
* @param string $key
* @param string $component
*
* @return self Provides fluent interface
*/
public
function
registerComponentType
(
$key
,
$component
);
/**
* Get all registered components.
*
* @return AbstractComponent[]
*/
public
function
getComponents
();
/**
* Get a component instance by key.
*
* You can optionally supply an autoload class to create a new component
* instance if there is no registered component for the given key yet.
*
* @throws \Solarium\Exception\OutOfBoundsException
*
* @param string $key Use one of the constants
* @param string|boolean $autoload Class to autoload if component needs to be created
* @param array|null $config Configuration to use for autoload
*
* @return object|null
*/
public
function
getComponent
(
$key
,
$autoload
=
false
,
$config
=
null
);
/**
* Set a component instance.
*
* This overwrites any existing component registered with the same key.
*
* @param string $key
* @param AbstractComponent $component
*
* @return self Provides fluent interface
*/
public
function
setComponent
(
$key
,
$component
);
/**
* Remove a component instance.
*
* You can remove a component by passing its key or the component instance.
*
* @param string|AbstractComponent $component
*
* @return self Provides fluent interface
*/
public
function
removeComponent
(
$component
);
/**
* Get a MoreLikeThis component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\MoreLikeThis
*/
public
function
getMoreLikeThis
();
/**
* Get a spellcheck component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spellcheck
*/
public
function
getSpellcheck
();
/**
* Get a suggest component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spellcheck
*/
public
function
getSuggester
();
/**
* Get a Debug component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Debug
*/
public
function
getDebug
();
/**
* Get a Spatial component instance.
*
* This is a convenience method that maps presets to getComponent
*
* @return \Solarium\Component\Spatial
*/
public
function
getSpatial
();
}
library/Component/
AbstractComponentAwareQuery
.php
→
library/Component/
ComponentAwareQueryTrait
.php
View file @
7d35e58a
<?php
<?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.
*
* @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
*
* @link http://www.solarium-project.org/
*/
/**
* @namespace
*/
namespace
Solarium\Component
;
namespace
Solarium\Component
;
use
Solarium\Core\Query\AbstractQuery
;
use
Solarium\Exception\OutOfBoundsException
;
use
Solarium\Exception\OutOfBoundsException
;
/**
/**
*
Base class for all query types supporting components, not intended for direct usage
.
*
Trait query types supporting components
.
*/
*/
abstract
class
AbstractComponentAwareQuery
extends
AbstractQuery
trait
ComponentAwareQueryTrait
{
{
/**
* Query component morelikethis.
*/
const
COMPONENT_MORELIKETHIS
=
'morelikethis'
;
/**
* Query component spellcheck.
*/
const
COMPONENT_SPELLCHECK
=
'spellcheck'
;
/**
* Query component spellcheck.
*/
const
COMPONENT_SUGGESTER
=
'suggest'
;
/**
* Query component debug.
*/
const
COMPONENT_DEBUG
=
'debug'
;
/**
* Query component spatial.
*/
const
COMPONENT_SPATIAL
=
'spatial'
;
/**
/**
* Search components.
* Search components.
*
*
* @var AbstractComponent[]
* @var AbstractComponent[]
*/
*/
protected
$components
=
array
()
;
protected
$components
=
[]
;
/**
/**
* Default select query component types.
* Default select query component types.
*
*
* @var array
* @var array
*/
*/
protected
$componentTypes
=
array
(
protected
$componentTypes
=
[];
self
::
COMPONENT_MORELIKETHIS
=>
'Solarium\Component\MoreLikeThis'
,
self
::
COMPONENT_SPELLCHECK
=>
'Solarium\Component\Spellcheck'
,
self
::
COMPONENT_SUGGESTER
=>
'Solarium\Component\Suggester'
,
self
::
COMPONENT_DEBUG
=>
'Solarium\Component\Debug'
,
self
::
COMPONENT_SPATIAL
=>
'Solarium\Component\Spatial'
,
);
/**
/**
* Get all registered component types.
* Get all registered component types.
...
@@ -146,22 +76,20 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -146,22 +76,20 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
{
{
if
(
isset
(
$this
->
components
[
$key
]))
{
if
(
isset
(
$this
->
components
[
$key
]))
{
return
$this
->
components
[
$key
];
return
$this
->
components
[
$key
];
}
else
{
}
elseif
(
$autoload
===
true
)
{
if
(
$autoload
===
true
)
{
if
(
!
isset
(
$this
->
componentTypes
[
$key
]))
{
if
(
!
isset
(
$this
->
componentTypes
[
$key
]))
{
throw
new
OutOfBoundsException
(
'Cannot autoload unknown component: '
.
$key
);
throw
new
OutOfBoundsException
(
'Cannot autoload unknown component: '
.
$key
);
}
$className
=
$this
->
componentTypes
[
$key
];
$className
=
class_exists
(
$className
)
?
$className
:
$className
.
strrchr
(
$className
,
'\\'
);
$component
=
new
$className
(
$config
);
$this
->
setComponent
(
$key
,
$component
);
return
$component
;
}
}
return
;
$className
=
$this
->
componentTypes
[
$key
];
$className
=
class_exists
(
$className
)
?
$className
:
$className
.
strrchr
(
$className
,
'\\'
);
$component
=
new
$className
(
$config
);
$this
->
setComponent
(
$key
,
$component
);
return
$component
;
}
}
return
null
;
}
}
/**
/**
...
@@ -230,7 +158,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -230,7 +158,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
*/
*/
public
function
getMoreLikeThis
()
public
function
getMoreLikeThis
()
{
{
return
$this
->
getComponent
(
self
::
COMPONENT_MORELIKETHIS
,
true
);
return
$this
->
getComponent
(
ComponentAwareQueryInterface
::
COMPONENT_MORELIKETHIS
,
true
);
}
}
/**
/**
...
@@ -242,7 +170,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -242,7 +170,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
*/
*/
public
function
getSpellcheck
()
public
function
getSpellcheck
()
{
{
return
$this
->
getComponent
(
self
::
COMPONENT_SPELLCHECK
,
true
);
return
$this
->
getComponent
(
ComponentAwareQueryInterface
::
COMPONENT_SPELLCHECK
,
true
);
}
}
/**
/**
...
@@ -254,7 +182,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -254,7 +182,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
*/
*/
public
function
getSuggester
()
public
function
getSuggester
()
{
{
return
$this
->
getComponent
(
self
::
COMPONENT_SUGGESTER
,
true
);
return
$this
->
getComponent
(
ComponentAwareQueryInterface
::
COMPONENT_SUGGESTER
,
true
);
}
}
/**
/**
...
@@ -266,7 +194,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -266,7 +194,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
*/
*/
public
function
getDebug
()
public
function
getDebug
()
{
{
return
$this
->
getComponent
(
self
::
COMPONENT_DEBUG
,
true
);
return
$this
->
getComponent
(
ComponentAwareQueryInterface
::
COMPONENT_DEBUG
,
true
);
}
}
/**
/**
...
@@ -278,7 +206,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
...
@@ -278,7 +206,7 @@ abstract class AbstractComponentAwareQuery extends AbstractQuery
*/
*/
public
function
getSpatial
()
public
function
getSpatial
()
{
{
return
$this
->
getComponent
(
self
::
COMPONENT_SPATIAL
,
true
);
return
$this
->
getComponent
(
ComponentAwareQueryInterface
::
COMPONENT_SPATIAL
,
true
);
}
}
}
}
library/Component/Debug.php
View file @
7d35e58a
...
@@ -57,7 +57,7 @@ class Debug extends AbstractComponent
...
@@ -57,7 +57,7 @@ class Debug extends AbstractComponent
*/
*/
public
function
getType
()
public
function
getType
()
{
{
return
AbstractComponentAwareQuery
::
COMPONENT_DEBUG
;
return
ComponentAwareQueryInterface
::
COMPONENT_DEBUG
;
}
}
/**
/**
...
...
library/Component/MoreLikeThis.php
View file @
7d35e58a
...
@@ -57,7 +57,7 @@ class MoreLikeThis extends AbstractComponent
...
@@ -57,7 +57,7 @@ class MoreLikeThis extends AbstractComponent
*/
*/
public
function
getType
()
public
function
getType
()
{
{
return
AbstractComponentAwareQuery
::
COMPONENT_MORELIKETHIS
;
return
ComponentAwareQueryInterface
::
COMPONENT_MORELIKETHIS
;
}
}
/**
/**
...
...
library/Component/Spatial.php
View file @
7d35e58a
...
@@ -18,7 +18,7 @@ class Spatial extends AbstractComponent
...
@@ -18,7 +18,7 @@ class Spatial extends AbstractComponent
*/
*/
public
function
getType
()
public
function
getType
()
{
{
return
AbstractComponentAwareQuery
::
COMPONENT_SPATIAL
;
return
ComponentAwareQueryInterface
::
COMPONENT_SPATIAL
;
}
}
/**
/**
...
...
library/Component/Spellcheck.php
View file @
7d35e58a
...
@@ -61,7 +61,7 @@ class Spellcheck extends AbstractComponent
...
@@ -61,7 +61,7 @@ class Spellcheck extends AbstractComponent
*/
*/
public
function
getType
()
public
function
getType
()
{
{
return
AbstractComponentAwareQuery
::
COMPONENT_SPELLCHECK
;
return
ComponentAwareQueryInterface
::
COMPONENT_SPELLCHECK
;
}
}
/**
/**
...
...
library/Component/Suggester.php
View file @
7d35e58a
...
@@ -60,7 +60,7 @@ class Suggester extends AbstractComponent
...
@@ -60,7 +60,7 @@ class Suggester extends AbstractComponent
*/
*/
public
function
getType
()
public
function
getType
()
{
{
return
AbstractComponentAwareQuery
::
COMPONENT_SUGGESTER
;
return
ComponentAwareQueryInterface
::
COMPONENT_SUGGESTER
;
}
}
/**
/**
...
...
library/QueryType/Select/Query/Query.php
View file @
7d35e58a
...
@@ -40,8 +40,10 @@
...
@@ -40,8 +40,10 @@
namespace
Solarium\QueryType\Select\Query
;
namespace
Solarium\QueryType\Select\Query
;
use
Solarium\Component\AbstractComponentAwareQuery
;
use
Solarium\Component\ComponentAwareQueryInterface
;
use
Solarium\Component\ComponentAwareQueryTrait
;
use
Solarium\Core\Client\Client
;
use
Solarium\Core\Client\Client
;
use
Solarium\Core\Query\AbstractQuery
;
use
Solarium\QueryType\Select\RequestBuilder\RequestBuilder
;
use
Solarium\QueryType\Select\RequestBuilder\RequestBuilder
;
use
Solarium\QueryType\Select\ResponseParser\ResponseParser
;
use
Solarium\QueryType\Select\ResponseParser\ResponseParser
;
use
Solarium\Exception\InvalidArgumentException
;
use
Solarium\Exception\InvalidArgumentException
;
...
@@ -53,8 +55,10 @@ use Solarium\Exception\InvalidArgumentException;
...
@@ -53,8 +55,10 @@ use Solarium\Exception\InvalidArgumentException;
* lots of options and there are many Solarium subclasses for it.
* lots of options and there are many Solarium subclasses for it.
* See the Solr documentation and the relevant Solarium classes for more info.
* See the Solr documentation and the relevant Solarium classes for more info.
*/
*/
class
Query
extends
Abstract
ComponentAwareQuery
class
Query
extends
Abstract
Query
implements
ComponentAwareQueryInterface
{
{
use
ComponentAwareQueryTrait
;
/**
/**
* Solr sort mode descending.
* Solr sort mode descending.
*/
*/
...
@@ -133,26 +137,6 @@ class Query extends AbstractComponentAwareQuery
...
@@ -133,26 +137,6 @@ class Query extends AbstractComponentAwareQuery
*/
*/
protected
$tags
=
array
();
protected
$tags
=
array
();
/**
* Default select query component types.
*
* @var array
*/
protected
$componentTypes
=
array
(
self
::
COMPONENT_FACETSET
=>
'Solarium\QueryType\Select\Query\Component\FacetSet'
,
self
::
COMPONENT_DISMAX
=>
'Solarium\QueryType\Select\Query\Component\DisMax'
,
self
::
COMPONENT_EDISMAX
=>
'Solarium\QueryType\Select\Query\Component\EdisMax'
,
parent
::
COMPONENT_MORELIKETHIS
=>
'Solarium\Component\MoreLikeThis'
,
self
::
COMPONENT_HIGHLIGHTING
=>
'Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting'
,
self
::
COMPONENT_GROUPING
=>
'Solarium\QueryType\Select\Query\Component\Grouping'
,
parent
::
COMPONENT_SPELLCHECK
=>
'Solarium\Component\Spellcheck'
,
parent
::
COMPONENT_SUGGESTER
=>
'Solarium\Component\Suggester'
,
self
::
COMPONENT_DISTRIBUTEDSEARCH
=>
'Solarium\QueryType\Select\Query\Component\DistributedSearch'
,
self
::
COMPONENT_STATS
=>
'Solarium\QueryType\Select\Query\Component\Stats\Stats'
,
parent
::
COMPONENT_DEBUG
=>
'Solarium\Component\Debug'
,
parent
::
COMPONENT_SPATIAL
=>
'Solarium\Component\Spatial'
,
);
/**
/**
* Fields to fetch.
* Fields to fetch.
*
*
...
@@ -174,6 +158,26 @@ class Query extends AbstractComponentAwareQuery
...
@@ -174,6 +158,26 @@ class Query extends AbstractComponentAwareQuery
*/
*/
protected
$filterQueries
=
array
();
protected
$filterQueries
=
array
();
public
function
__construct
(
$options
=
null
)
{
$this
->
componentTypes
=
[
ComponentAwareQueryInterface
::
COMPONENT_MORELIKETHIS
=>
'Solarium\Component\MoreLikeThis'
,
ComponentAwareQueryInterface
::
COMPONENT_SPELLCHECK
=>
'Solarium\Component\Spellcheck'
,
ComponentAwareQueryInterface
::
COMPONENT_SUGGESTER
=>
'Solarium\Component\Suggester'
,
ComponentAwareQueryInterface
::
COMPONENT_DEBUG
=>
'Solarium\Component\Debug'
,
ComponentAwareQueryInterface
::
COMPONENT_SPATIAL
=>
'Solarium\Component\Spatial'
,
self
::
COMPONENT_FACETSET
=>
'Solarium\QueryType\Select\Query\Component\FacetSet'
,
self
::
COMPONENT_DISMAX
=>
'Solarium\QueryType\Select\Query\Component\DisMax'
,
self
::
COMPONENT_EDISMAX
=>
'Solarium\QueryType\Select\Query\Component\EdisMax'
,
self
::
COMPONENT_HIGHLIGHTING
=>
'Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting'
,
self
::
COMPONENT_GROUPING
=>
'Solarium\QueryType\Select\Query\Component\Grouping'
,
self
::
COMPONENT_DISTRIBUTEDSEARCH
=>
'Solarium\QueryType\Select\Query\Component\DistributedSearch'
,
self
::
COMPONENT_STATS
=>
'Solarium\QueryType\Select\Query\Component\Stats\Stats'
,
];
parent
::
__construct
(
$options
);
}
/**
/**
* Get type for this query.
* Get type for this query.
*
*
...
...
tests/Component/DebugTest.php
View file @
7d35e58a
...
@@ -31,9 +31,8 @@
...
@@ -31,9 +31,8 @@
namespace
Solarium\Tests\Component
;
namespace
Solarium\Tests\Component
;
use
Solarium\Component\
AbstractComponentAwareQuery
;
use
Solarium\Component\
ComponentAwareQueryInterface
;
use
Solarium\Component\Debug
;
use
Solarium\Component\Debug
;
use
Solarium\QueryType\Select\Query\Query
;
class
DebugTest
extends
\PHPUnit_Framework_TestCase
class
DebugTest
extends
\PHPUnit_Framework_TestCase
{
{
...
@@ -61,7 +60,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
...
@@ -61,7 +60,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
public
function
testGetType
()
public
function
testGetType
()
{
{
$this
->
assertEquals
(
$this
->
assertEquals
(
AbstractComponentAwareQuery
::
COMPONENT_DEBUG
,
ComponentAwareQueryInterface
::
COMPONENT_DEBUG
,
$this
->
debug
->
getType
()
$this
->
debug
->
getType
()
);
);
}
}
...
...
tests/Component/MoreLikeThisTest.php
View file @
7d35e58a
...
@@ -31,9 +31,8 @@
...
@@ -31,9 +31,8 @@
namespace
Solarium\Tests\Component
;
namespace
Solarium\Tests\Component
;
use
Solarium\Component\
AbstractComponentAwareQuery
;
use
Solarium\Component\
ComponentAwareQueryInterface
;
use
Solarium\Component\MoreLikeThis
;
use
Solarium\Component\MoreLikeThis
;
use
Solarium\QueryType\Select\Query\Query
;
class
MoreLikeThisTest
extends
\PHPUnit_Framework_TestCase
class
MoreLikeThisTest
extends
\PHPUnit_Framework_TestCase
{
{
...
@@ -77,7 +76,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
...
@@ -77,7 +76,7 @@ class MoreLikeThisTest extends \PHPUnit_Framework_TestCase
public
function
testGetType
()
public
function
testGetType
()
{
{
$this
->
assertEquals
(
AbstractComponentAwareQuery
::
COMPONENT_MORELIKETHIS
,
$this
->
mlt
->
getType
());
$this
->
assertEquals
(
ComponentAwareQueryInterface
::
COMPONENT_MORELIKETHIS
,
$this
->
mlt
->
getType
());
}
}
public
function
testGetResponseParser
()
public
function
testGetResponseParser
()
...
...
tests/Component/SpellcheckTest.php
View file @
7d35e58a
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
namespace
Solarium\Tests\Component
;
namespace
Solarium\Tests\Component
;
use
Solarium\Component\
AbstractComponentAwareQuery
;
use
Solarium\Component\
ComponentAwareQueryInterface
;
use
Solarium\Component\Spellcheck
;
use
Solarium\Component\Spellcheck
;
use
Solarium\QueryType\Select\Query\Query
;
use
Solarium\QueryType\Select\Query\Query
;
...
@@ -50,7 +50,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
...
@@ -50,7 +50,7 @@ class SpellcheckTest extends \PHPUnit_Framework_TestCase
public
function
testGetType
()
public
function
testGetType
()
{
{
$this
->
assertEquals
(
AbstractComponentAwareQuery
::
COMPONENT_SPELLCHECK
,
$this
->
spellCheck
->
getType
());
$this
->
assertEquals
(
ComponentAwareQueryInterface
::
COMPONENT_SPELLCHECK
,
$this
->
spellCheck
->
getType
());
}
}
public
function
testGetResponseParser
()
public
function
testGetResponseParser
()
...
...
tests/Component/SuggesterTest.php
View file @
7d35e58a
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
namespace
Solarium\Tests\Component
;
namespace
Solarium\Tests\Component
;
use
Solarium\Component\
AbstractComponentAwareQuery
;
use
Solarium\Component\
ComponentAwareQueryInterface
;
use
Solarium\Component\Suggester
;
use
Solarium\Component\Suggester
;
use
Solarium\QueryType\Select\Query\Query
;
use
Solarium\QueryType\Select\Query\Query
;
...
@@ -50,7 +50,7 @@ class SuggesterTest extends \PHPUnit_Framework_TestCase
...
@@ -50,7 +50,7 @@ class SuggesterTest extends \PHPUnit_Framework_TestCase
public
function
testGetType
()
public
function
testGetType
()
{
{
$this
->
assertEquals
(
AbstractComponentAwareQuery
::
COMPONENT_SUGGESTER
,
$this
->
suggester
->
getType
());
$this
->
assertEquals
(
ComponentAwareQueryInterface
::
COMPONENT_SUGGESTER
,
$this
->
suggester
->
getType
());
}
}
public
function
testGetResponseParser
()
public
function
testGetResponseParser
()
...
...
tests/Integration/AbstractTechproductsTest.php
View file @
7d35e58a
...
@@ -122,4 +122,19 @@ abstract class AbstractTechproductsTest extends \PHPUnit_Framework_TestCase
...
@@ -122,4 +122,19 @@ abstract class AbstractTechproductsTest extends \PHPUnit_Framework_TestCase
'electronics and stuff2'
'electronics and stuff2'
],
$phrases
);
],
$phrases
);
}
}
public
function
testTerms
()
{
$terms
=
$this
->
client
->
createTerms
();
$terms
->
setFields
(
'name'
);
$result
=
$this
->
client
->
terms
(
$terms
);
$phrases
=
[];
foreach
(
$result
->
getTerms
(
'name'
)
as
$term
=>
$count
)
{
$phrases
[]
=
$term
;
}
$this
->
assertEquals
([
'one'
,
184
,
'1gb'
,
3200
,
400
,
'ddr'
,
'gb'
,
'ipod'
,
'memory'
,
'pc'
,
],
$phrases
);
}
}
}
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