Commit 3f2a7742 authored by Bas de Nooijer's avatar Bas de Nooijer

Merge branch 'develop' into feature/nextgen

Conflicts:
	library/Solarium/Client/ResponseParser/Analysis/Field.php
	library/Solarium/Plugin/ParallelExecution.php
parents 149258eb 72ffa056
language: php
phps:
- 5.4
- 5.3
script: phpunit -c phpunit.xml.dist
# Solarium PHP Solr client library
Solarium is a PHP Solr client that not only facilitates Solr communication but Solarium is a PHP Solr client that not only facilitates Solr communication but
also tries to accurately model Solr concepts. also tries to accurately model Solr concepts.
Please see the project website for a more detailed description. Please see the project website for a more detailed description.
Project website: ## Project website
http://www.solarium-project.org/ http://www.solarium-project.org/
GitHub project: ## License:
http://github.com/basdenooijer/solarium
License:
See the COPYING file or view online See the COPYING file or view online
https://github.com/basdenooijer/solarium/blob/master/COPYING https://github.com/basdenooijer/solarium/blob/master/COPYING
Issue tracker: ## Issue tracker
http://github.com/basdenooijer/solarium/issues http://github.com/basdenooijer/solarium/issues
Contributors: ## Contributors
https://github.com/basdenooijer/solarium/contributors https://github.com/basdenooijer/solarium/contributors
API docs: ## API docs
http://api.solarium-project.org/ http://api.solarium-project.org/
\ No newline at end of file
## Travis Continuous Integration status
* Develop branch [![Develop build status](https://secure.travis-ci.org/basdenooijer/solarium.png?branch=develop)](http://travis-ci.org/basdenooijer/solarium)
* Master branch [![Develop build status](https://secure.travis-ci.org/basdenooijer/solarium.png?branch=master)](http://travis-ci.org/basdenooijer/solarium)
\ No newline at end of file
...@@ -2,18 +2,14 @@ ...@@ -2,18 +2,14 @@
"name": "solarium/solarium", "name": "solarium/solarium",
"type": "library", "type": "library",
"description": "PHP Solr client", "description": "PHP Solr client",
"keywords": ["solr", "search"], "keywords": ["solr", "search", "php"],
"homepage": "http://www.solarium-project.org", "homepage": "http://www.solarium-project.org",
"version": "2.3.0", "version": "3.0.0",
"license": "NewBSD", "license": "NewBSD",
"authors": [ "authors": [
{ {
"name": "Bas de Nooijer", "name": "See GitHub contributors",
"email": "github@raspberry.nl" "homepage": "https://github.com/basdenooijer/solarium/contributors"
},
{
"name": "Gasol Wu",
"email": "gasol.wu@gmail.com"
} }
], ],
"require": { "require": {
......
...@@ -15,7 +15,7 @@ $ping = $client->createPing(); ...@@ -15,7 +15,7 @@ $ping = $client->createPing();
// execute the ping query // execute the ping query
try{ try{
$result = $client->ping($ping); $result = $client->ping($ping);
echo 'Ping query succesful'; echo 'Ping query successful';
echo '<br/><pre>'; echo '<br/><pre>';
var_dump($result->getData()); var_dump($result->getData());
}catch(Solarium\Exception $e){ }catch(Solarium\Exception $e){
......
...@@ -26,7 +26,7 @@ if ($_POST) { ...@@ -26,7 +26,7 @@ if ($_POST) {
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -28,7 +28,7 @@ $update->addCommit(); ...@@ -28,7 +28,7 @@ $update->addCommit();
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -16,7 +16,7 @@ $update->addCommit(); ...@@ -16,7 +16,7 @@ $update->addCommit();
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -16,7 +16,7 @@ $update->addCommit(); ...@@ -16,7 +16,7 @@ $update->addCommit();
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -15,7 +15,7 @@ $update->addOptimize(true, false, 5); ...@@ -15,7 +15,7 @@ $update->addOptimize(true, false, 5);
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -15,7 +15,7 @@ $update->addRollback(); ...@@ -15,7 +15,7 @@ $update->addRollback();
// this executes the query and returns the result // this executes the query and returns the result
$result = $client->update($update); $result = $client->update($update);
echo '<b>Update query executed<b><br/>'; echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>'; echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime(); echo 'Query time: ' . $result->getQueryTime();
......
...@@ -7,17 +7,28 @@ htmlHeader(); ...@@ -7,17 +7,28 @@ htmlHeader();
$client = new Solarium\Client\Client($config); $client = new Solarium\Client\Client($config);
$parallel = $client->getPlugin('parallelexecution'); $parallel = $client->getPlugin('parallelexecution');
// create two queries to execute in an array. Keys are important for fetching the results later! // Add a delay param to better show the effect, as an example Solr install with
$queries = array( // only a dozen documents is too fast for good testing
'instock' => $client->createSelect()->setQuery('inStock:true'), // This param only works with the correct Solr plugin,
'lowprice' => $client->createSelect()->setQuery('price:[1 TO 300]'), // see http://www.raspberry.nl/2012/01/04/solr-delay-component/
); // If you don't have to plugin the example still works, just without the delay.
$customizer = $client->getPlugin('customizerequest');
$customizer->createCustomization(array(
'key' => 'delay',
'type' => 'param',
'name' => 'delay',
'value' => '500',
'persistent' => true
));
// create two queries to execute in an array. Keys are important for fetching the results later!
$queryInstock = $client->createSelect()->setQuery('inStock:true');
$queryLowprice = $client->createSelect()->setQuery('price:[1 TO 300]');
// first execute the queries the normal way and time it // first execute the queries the normal way and time it
$start = microtime(true); $start = microtime(true);
$client->execute($queries['instock']); $client->execute($queryInstock);
$client->execute($queries['lowprice']); $client->execute($queryLowprice);
echo 'Execution time for normal "serial" execution of two queries: ' . round(microtime(true)-$start, 3); echo 'Execution time for normal "serial" execution of two queries: ' . round(microtime(true)-$start, 3);
...@@ -26,13 +37,15 @@ echo '<hr/>'; ...@@ -26,13 +37,15 @@ echo '<hr/>';
// now execute the two queries parallel and time it // now execute the two queries parallel and time it
$start = microtime(true); $start = microtime(true);
$results = $parallel->execute($queries); $parallel->addQuery('instock', $queryInstock);
$parallel->addQuery('lowprice', $queryLowprice);
$results = $parallel->execute();
echo 'Execution time for parallel execution of two queries: ' . round(microtime(true)-$start, 3); echo 'Execution time for parallel execution of two queries: ' . round(microtime(true)-$start, 3);
htmlFooter(); htmlFooter();
// Note: for this example on a default Solr index (with a tiny index) the performance gain is minimal to none. // Note: for this example on a default Solr index (with a tiny index) running on localhost the performance gain is
// With a bigger dataset, more complex queries or multiple solr instances the performance gain is much more. // minimal to none, sometimes even slightly slower!
// For testing you can use a Solr delay component (see https://github.com/basdenooijer/raspberry-solr-plugins) to // In a realworld scenario with network latency, a bigger dataset, more complex queries or multiple solr instances the
// artificially slow Solr down by an exact amount of time. // performance gain is much more.
\ No newline at end of file
...@@ -12,7 +12,7 @@ $query->setFields(array('id')); ...@@ -12,7 +12,7 @@ $query->setFields(array('id'));
// get a plugin instance and apply settings // get a plugin instance and apply settings
$prefetch = $client->getPlugin('prefetchiterator'); $prefetch = $client->getPlugin('prefetchiterator');
$prefetch->setPrefetch(2); //fetch 5 rows per query (for real world use this can be way higher) $prefetch->setPrefetch(2); //fetch 2 rows per query (for real world use this can be way higher)
$prefetch->setQuery($query); $prefetch->setQuery($query);
// display the total number of documents found by solr // display the total number of documents found by solr
......
...@@ -118,14 +118,16 @@ class Field extends \Solarium\Client\ResponseParser\ResponseParser ...@@ -118,14 +118,16 @@ class Field extends \Solarium\Client\ResponseParser\ResponseParser
if (is_string($analysis)) { if (is_string($analysis)) {
$item = new Analysis\Item(array( $item = new Analysis\Item(
'text' => $analysis, array(
'start' => null, 'text' => $analysis,
'end' => null, 'start' => null,
'position' => null, 'end' => null,
'positionHistory' => null, 'position' => null,
'type' => null, 'positionHistory' => null,
)); 'type' => null,
)
);
$classes[] = new Analysis\ResultList($class, array($item)); $classes[] = new Analysis\ResultList($class, array($item));
......
...@@ -54,28 +54,95 @@ use Solarium\Client; ...@@ -54,28 +54,95 @@ use Solarium\Client;
* @subpackage Plugin * @subpackage Plugin
*/ */
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
class ParallelExecution extends AbstractPlugin class ParallelExecution extends AbstractPlugin
{ {
/**
* Default options
*
* @var array
*/
protected $_options = array(
'curlmultiselecttimeout' => 0.1,
);
/**
* Queries (and optionally clients) to execute
*
* @var array
*/
protected $_queries = array();
/**
* Add a query to execute
*
* @param string $key
* @param Solarium_Query $query
* @param null|Solarium_Client $client
* @return Solarium_Plugin_ParallelExecution
*/
public function addQuery($key, $query, $client = null)
{
if($client == null) $client = $this->_client;
$this->_queries[$key] = array(
'query' => $query,
'client' => $client,
);
return $this;
}
/**
* Get queries (and coupled client instances)
*
* @return array
*/
public function getQueries()
{
return $this->_queries;
}
/**
* Clear all queries
*
* @return self Provides fluent interface
*/
public function clearQueries()
{
$this->_queries = array();
return $this;
}
// @codeCoverageIgnoreStart
/** /**
* Execute queries parallel * Execute queries parallel
* *
* Use an array of Solarium_Query objects as input. The keys of the array are important, as they are also used in * Use an array of Solarium_Query objects as input. The keys of the array are important, as they are also used in
* the result array. You can mix all querytypes in the input array. * the result array. You can mix all querytypes in the input array.
* *
* @param array $queries * @param array $queries (deprecated, use addQuery instead)
* @return array * @return array
*/ */
public function execute($queries) public function execute($queries = null)
{ {
$adapter = $this->_client->setAdapter('Solarium\Client\Adapter\Curl')->getAdapter();
// this is for backwards compatibility
if (is_array($queries)) {
foreach ($queries as $key => $query) {
$this->addQuery($key, $query);
}
}
// create handles and add all handles to the multihandle // create handles and add all handles to the multihandle
$multiHandle = curl_multi_init(); $multiHandle = curl_multi_init();
$handles = array(); $handles = array();
foreach ($queries as $key => $query) { foreach ($this->_queries as $key => $data) {
$request = $this->_client->createRequest($query); $request = $this->_client->createRequest($data['query']);
$adapter = $data['client']->setAdapter('Solarium\Client\Adapter\Curl')->getAdapter();
$handle = $adapter->createHandle($request); $handle = $adapter->createHandle($request);
curl_multi_add_handle($multiHandle, $handle); curl_multi_add_handle($multiHandle, $handle);
$handles[$key] = $handle; $handles[$key] = $handle;
...@@ -83,9 +150,20 @@ class ParallelExecution extends AbstractPlugin ...@@ -83,9 +150,20 @@ class ParallelExecution extends AbstractPlugin
// executing multihandle (all requests) // executing multihandle (all requests)
$this->_client->triggerEvent('ParallelExecutionStart'); $this->_client->triggerEvent('ParallelExecutionStart');
do { do {
curl_multi_exec($multiHandle, $running); $mrc = curl_multi_exec($multiHandle, $active);
} while($running > 0); } while ($mrc == CURLM_CALL_MULTI_PERFORM);
$timeout = $this->getOption('curlmultiselecttimeout');
while ($active && $mrc == CURLM_OK) {
if (curl_multi_select($multiHandle, $timeout) != -1) {
do {
$mrc = curl_multi_exec($multiHandle, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
}
}
$this->_client->triggerEvent('ParallelExecutionEnd'); $this->_client->triggerEvent('ParallelExecutionEnd');
// get the results // get the results
...@@ -94,8 +172,9 @@ class ParallelExecution extends AbstractPlugin ...@@ -94,8 +172,9 @@ class ParallelExecution extends AbstractPlugin
try { try {
curl_multi_remove_handle($multiHandle, $handle); curl_multi_remove_handle($multiHandle, $handle);
$response = $adapter->getResponse($handle, curl_multi_getcontent($handle)); $response = $adapter->getResponse($handle, curl_multi_getcontent($handle));
$results[$key] = $this->_client->createResult($queries[$key], $response); $results[$key] = $this->_client->createResult($queries[$key]['query'], $response);
} catch(Client\HttpException $e) { } catch(Client\HttpException $e) {
$results[$key] = $e; $results[$key] = $e;
} }
} }
...@@ -105,5 +184,5 @@ class ParallelExecution extends AbstractPlugin ...@@ -105,5 +184,5 @@ class ParallelExecution extends AbstractPlugin
return $results; return $results;
} }
// @codeCoverageIgnoreEnd
} }
// @codeCoverageIgnoreEnd
\ No newline at end of file
...@@ -75,7 +75,7 @@ class Version ...@@ -75,7 +75,7 @@ class Version
* *
* @var string * @var string
*/ */
const VERSION = '2.3.0'; const VERSION = '3.0.0';
/** /**
......
The buildphar.php will generate a solarium.phar PHAR file that is ready for distribution.
<?php
/**
* Copyright 2012 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 2012 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*/
// Check phar.readonly ini setting
if (ini_get('phar.readonly') == '1') {
exit("Your php.ini has phar.readonly enabled. Phar cannot be created. Please alter your php.ini first.\n");
}
// You can optionally use arguments to enable compression and whitespace/comment stripping.
// Example: "php buildphar.php -s 1 -c 1"
// -c with a value of 1 enables compression, multiple phars will be created
// -s with a value of 1 enables stripping
$options = getopt('s:c:');
$compress = (isset($options['c']) && $options['c'] == '1');
$strip = (isset($options['s']) && $options['s'] == '1');
$start = microtime(true);
// Create a new Solarium phar file
@unlink('solarium.phar');
$phar = new Phar('solarium.phar', 0, 'solarium.phar');
$phar->setStub(file_get_contents("stub.php"));
$phar->setSignatureAlgorithm(Phar::SHA1);
// Add files to the phar
$basePath = realpath(__DIR__."/../library/Solarium");
if ($strip) {
$directoryIterator = new RecursiveIteratorIterator (new RecursiveDirectoryIterator ($basePath), RecursiveIteratorIterator::SELF_FIRST);
foreach ($directoryIterator as $file) {
if ( preg_match ('/\\.php$/i', $file) ) {
$phar->addFromString (substr ($file, strlen ($basePath) + 1), php_strip_whitespace ($file));
}
}
} else {
$phar->buildFromDirectory($basePath, '/\.php$/');
}
// Create compressed versions
if ($compress) {
$phar->compress(Phar::BZ2);
$phar->compress(Phar::GZ);
}
$time = round(microtime(true)-$start,5);
echo "\nDONE ($time seconds)\n\n";
<?php
/**
* Copyright 2012 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 2012 Bas de Nooijer <solarium@raspberry.nl>
* @license http://github.com/basdenooijer/solarium/raw/master/COPYING
* @link http://www.solarium-project.org/
*/
Phar::mapPhar("solarium.phar");
require_once 'phar://solarium.phar/Autoloader.php';
Solarium_Autoloader::register();
if ('cli' === php_sapi_name() && basename(__FILE__) === basename($_SERVER['argv'][0]) && isset($_SERVER['argv'][1])) {
switch ($_SERVER['argv'][1]) {
case 'version':
echo "Solarium version " . Solarium_Version::VERSION ."\n";
break;
default:
echo "Unknown command '" . $_SERVER['argv'][1] . "' (Supported commands: version)\n";
}
exit(0);
}
__HALT_COMPILER();
?>
\ No newline at end of file
<?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.
*/
namespace Solarium\Tests\Plugin;
class ParallelExecutionTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \Solarium\Plugin\ParallelExecution
*/
protected $_plugin;
public function setUp()
{
$this->_plugin = new \Solarium\Plugin\ParallelExecution();
}
public function testAddAndGetQueries()
{
$client1 = new \Solarium\Client\Client();
$client2 = new \Solarium\Client\Client(array(
'adapter' => 'MyAdapter',
'adapteroptions' => array(
'host' => 'myhost',
)
)
);
$this->_plugin->init($client1, array());
$query1 = $client1->createSelect()->setQuery('test1');
$query2 = $client1->createSelect()->setQuery('test2');
$this->_plugin->addQuery(1, $query1);
$this->_plugin->addQuery(2, $query2, $client2);
$this->assertEquals(
array(
1 => array('query' => $query1, 'client' => $client1),
2 => array('query' => $query2, 'client' => $client2),
),
$this->_plugin->getQueries()
);
}
public function testClearQueries()
{
$client = new \Solarium\Client\Client();
$this->_plugin->init($client, array());
$query1 = $client->createSelect()->setQuery('test1');
$query2 = $client->createSelect()->setQuery('test2');
$this->_plugin->addQuery(1, $query1);
$this->_plugin->addQuery(2, $query2);
$this->_plugin->clearQueries();
$this->assertEquals(
array(),
$this->_plugin->getQueries()
);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment