Commit 5f61e63a authored by thePanz's avatar thePanz

Merge branch 'develop' into 'master'

parents 75ac5576 243d9ac0
language: php
dist: trusty
php:
- 7.1
- 7.0
- 5.6
- 5.5
......@@ -15,6 +18,10 @@ env:
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.* # Does not work with php below 5.5
cache:
directories:
- $HOME/.composer/cache
before_script:
- bash -c "if [ $TRAVIS_PHP_VERSION != 'hhvm' ] && [ $TRAVIS_PHP_VERSION != '7.0' ] && [ $TRAVIS_PHP_VERSION != 'nightly' ]; then printf '\n\n\n\n' | pecl install pecl_http-1.7.6; fi"
- composer require --prefer-source --dev symfony/event-dispatcher:${SYMFONY_VERSION}
......
......@@ -116,7 +116,7 @@ class Curl extends Configurable implements AdapterInterface
$handler = curl_init();
curl_setopt($handler, CURLOPT_URL, $uri);
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
if (!ini_get('open_basedir')) {
if (!(function_exists('ini_get') && ini_get('open_basedir'))) {
curl_setopt($handler, CURLOPT_FOLLOWLOCATION, true);
}
curl_setopt($handler, CURLOPT_TIMEOUT, $options['timeout']);
......
......@@ -74,6 +74,7 @@ class Guzzle extends Configurable implements AdapterInterface
RequestOptions::HEADERS => $this->getRequestHeaders($request),
RequestOptions::BODY => $this->getRequestBody($request),
RequestOptions::TIMEOUT => $endpoint->getTimeout(),
RequestOptions::CONNECT_TIMEOUT => $endpoint->getTimeout(),
];
// Try endpoint authentication first, fallback to request for backwards compatibility
......
......@@ -41,7 +41,6 @@ namespace Solarium\Core\Client\Adapter;
use Guzzle\Http\Client as GuzzleClient;
use Solarium\Core\Configurable;
use Solarium\Core\Client\Adapter\AdapterInterface;
use Solarium\Core\Client\Request;
use Solarium\Core\Client\Response;
use Solarium\Core\Client\Endpoint;
......@@ -76,7 +75,7 @@ class Guzzle3 extends Configurable implements AdapterInterface
$this->getRequestBody($request),
array(
'timeout' => $endpoint->getTimeout(),
'connecttimeout' => $endpoint->getTimeout(),
'connect_timeout' => $endpoint->getTimeout(),
)
);
......
......@@ -111,13 +111,25 @@ class Http extends Configurable implements AdapterInterface
if ($method == Request::METHOD_POST) {
if ($request->getFileUpload()) {
$boundary = '----------' . md5(time());
$CRLF = "\r\n";
$file = $request->getFileUpload();
$filename = basename($file);
// Add the proper boundary to the Content-Type header
$request->addHeader("Content-Type: multipart/form-data; boundary={$boundary}");
$data = "--{$boundary}" . $CRLF;
$data .= 'Content-Disposition: form-data; name="upload"; filename=' . $filename . $CRLF;
$data .= 'Content-Type: application/octet-stream' . $CRLF . $CRLF;
$data .= file_get_contents($request->getFileUpload()) . $CRLF;
$data .= '--' . $boundary . '--';
$content_length = strlen($data);
$request->addHeader("Content-Length: $content_length\r\n");
stream_context_set_option(
$context,
'http',
'content',
file_get_contents($request->getFileUpload())
$data
);
$request->addHeader('Content-Type: multipart/form-data');
} else {
$data = $request->getRawData();
if (null !== $data) {
......@@ -171,10 +183,10 @@ class Http extends Configurable implements AdapterInterface
// @codeCoverageIgnoreStart
$data = @file_get_contents($uri, false, $context);
$headers = array();
if (isset($http_response_header)) {
$headers = $http_response_header;
} else {
$headers = array();
}
return array($data, $headers);
......
......@@ -157,7 +157,7 @@ class Response
// $statusInfo[1] = the HTTP response code
// $statusInfo[2] = the response message
$statusInfo = explode(' ', $statusHeader, 3);
$this->statusCode = $statusInfo[1];
$this->statusCode = (int) $statusInfo[1];
$this->statusMessage = $statusInfo[2];
}
}
......@@ -460,10 +460,10 @@ class Helper
*/
public function cacheControl($useCache, $cost = null)
{
$cache = 'false';
if ($useCache === true) {
$cache = 'true';
} else {
$cache = 'false';
}
$result = '{!cache='.$cache;
......
......@@ -223,7 +223,7 @@ class BufferedAdd extends AbstractPlugin
$this->client->getEventDispatcher()->dispatch(Events::PRE_FLUSH, $event);
$this->updateQuery->addDocuments($event->getBuffer(), $event->getOverwrite(), $event->getCommitWithin());
$result = $this->client->update($this->updateQuery, $this->getEndpoint());
$result = $this->client->update($this->updateQuery, $this->getEndPoint());
$this->clear();
$event = new PostFlushEvent($result);
......@@ -251,7 +251,7 @@ class BufferedAdd extends AbstractPlugin
$this->updateQuery->addDocuments($this->buffer, $event->getOverwrite());
$this->updateQuery->addCommit($event->getSoftCommit(), $event->getWaitSearcher(), $event->getExpungeDeletes());
$result = $this->client->update($this->updateQuery, $this->getEndpoint());
$result = $this->client->update($this->updateQuery, $this->getEndPoint());
$this->clear();
$event = new PostCommitEvent($result);
......
......@@ -44,7 +44,7 @@ use Solarium\Core\Plugin\AbstractPlugin;
use Solarium\Exception\InvalidArgumentException;
use Solarium\Exception\RuntimeException;
use Solarium\Core\Event\Events;
use Solarium\Core\Event\preExecuteRequest as preExecuteRequestEvent;
use Solarium\Core\Event\PreExecuteRequest as preExecuteRequestEvent;
/**
* CustomizeRequest plugin.
......
......@@ -64,10 +64,10 @@ class Field extends ResponseParserAbstract implements ResponseParserInterface
{
$data = $result->getData();
$items = array();
if (isset($data['analysis'])) {
$items = $this->parseAnalysis($result, $data['analysis']);
} else {
$items = array();
}
return $this->addHeaderInfo($data, array('items' => $items));
......
......@@ -64,8 +64,6 @@ class Types extends ResultList
return $item;
}
}
return;
}
/**
......@@ -80,7 +78,5 @@ class Types extends ResultList
return $item;
}
}
return;
}
}
......@@ -107,7 +107,6 @@ class RequestBuilder extends BaseRequestBuilder
} elseif (is_readable($file)) {
$request->setFileUpload($file);
$request->addParam('resource.name', basename($query->getFile()));
$request->addHeader('Content-Type: multipart/form-data');
} else {
throw new RuntimeException('Extract query file path/url invalid or not available');
}
......
......@@ -88,6 +88,5 @@ class Query extends BaseQuery
*/
public function getResponseParser()
{
return;
}
}
......@@ -92,7 +92,6 @@ class DisMax extends AbstractComponent
*/
public function getResponseParser()
{
return;
}
/**
......
......@@ -97,7 +97,6 @@ class DistributedSearch extends AbstractComponent
*/
public function getResponseParser()
{
return;
}
/**
......
......@@ -191,11 +191,15 @@ class Grouping extends AbstractComponent
* This overwrites any existing fields
*
* @param array $fields
*
* @return self Provides fluent interface
*/
public function setFields($fields)
{
$this->clearFields();
$this->addFields($fields);
return $this;
}
/**
......
......@@ -37,7 +37,6 @@ class Spatial extends AbstractComponent
*/
public function getResponseParser()
{
return;
}
/**
......
......@@ -248,11 +248,15 @@ class Stats extends AbstractComponent
* This overwrites any existing fields
*
* @param array $fields
*
* @return self Provides fluent interface
*/
public function setFields($fields)
{
$this->clearFields();
$this->addFields($fields);
return $this;
}
/**
......
......@@ -40,7 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\Query\Component\Dismax as DismaxComponent;
use Solarium\QueryType\Select\Query\Component\DisMax as DismaxComponent;
use Solarium\Core\Client\Request;
/**
......
......@@ -40,7 +40,7 @@
namespace Solarium\QueryType\Select\RequestBuilder\Component;
use Solarium\QueryType\Select\Query\Component\Edismax as EdismaxComponent;
use Solarium\QueryType\Select\Query\Component\EdisMax as EdismaxComponent;
use Solarium\Core\Client\Request;
/**
......
......@@ -95,16 +95,16 @@ class ResponseParser extends ResponseParserAbstract implements ResponseParserInt
}
}
$numFound = null;
if (isset($data['response']['numFound'])) {
$numFound = $data['response']['numFound'];
} else {
$numFound = null;
}
$maxScore = null;
if (isset($data['response']['maxScore'])) {
$maxScore = $data['response']['maxScore'];
} else {
$maxScore = null;
}
return $this->addHeaderInfo(
......
......@@ -229,10 +229,6 @@ class RequestBuilder extends BaseRequestBuilder
*/
protected function buildFieldXml($name, $boost, $value, $modifier = null, $query = null)
{
if ($value instanceof \DateTime) {
$value = $query->getHelper()->formatDate($value);
}
$xml = '<field name="' . $name . '"';
$xml .= $this->attrib('boost', $boost);
$xml .= $this->attrib('update', $modifier);
......@@ -242,10 +238,13 @@ class RequestBuilder extends BaseRequestBuilder
$value = 'false';
} elseif ($value === true) {
$value = 'true';
} elseif ($value instanceof \DateTime) {
$value = $query->getHelper()->formatDate($value);
} else {
$value = htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
}
$xml .= '>' . htmlspecialchars($value, ENT_NOQUOTES, 'UTF-8');
$xml .= '</field>';
$xml .= '>' . $value . '</field>';
return $xml;
}
......
......@@ -66,7 +66,7 @@ class Loader
if (($fileName = $file->getBasename($this->fileExtension)) == $file->getBasename()) {
continue;
}
$sourceFile = realpath($file->getPathName());
$sourceFile = realpath($file->getPathname());
/** @noinspection PhpIncludeInspection */
require_once $sourceFile;
$includedFiles[] = $sourceFile;
......
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false" bootstrap="tests/bootstrap.php">
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
colors="true"
>
<testsuites>
<testsuite name="Solarium">
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\Core\Client\Adapter;
use Guzzle\Plugin\Mock\MockPlugin;
use Guzzle\Http\Message\Response;
use Guzzle\Http\Client as GuzzleClient;
use Solarium\Core\Client\Adapter\Guzzle3 as GuzzleAdapter;
use Solarium\Core\Client\Request;
use Solarium\Core\Client\Endpoint;
......@@ -89,7 +88,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$response = $this->adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -102,7 +101,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame(
......@@ -136,7 +135,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$response = $this->adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -149,10 +148,10 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('POST', $receivedRequests[0]->getMethod());
$this->assertSame(file_get_contents(__FILE__), (string)$receivedRequests[0]->getBody());
$this->assertStringEqualsFile(__FILE__, (string)$receivedRequests[0]->getBody());
$this->assertSame(
'request value',
(string)$receivedRequests[0]->getHeader('X-PHPUnit')
......@@ -185,7 +184,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$response = $this->adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -198,7 +197,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('POST', $receivedRequests[0]->getMethod());
$this->assertSame($xml, (string)$receivedRequests[0]->getBody());
......@@ -237,7 +236,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$response = $this->adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -250,7 +249,7 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$receivedRequests = $plugin->getReceivedRequests();
$this->assertSame(1, count($receivedRequests));
$this->assertCount(1, $receivedRequests);
$this->assertSame('GET', $receivedRequests[0]->getMethod());
$this->assertSame(
......
......@@ -35,7 +35,6 @@
namespace Solarium\Tests\Core\Client\Adapter;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
......@@ -94,7 +93,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$response = $adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -141,7 +140,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$response = $adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -155,7 +154,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertCount(1, $container);
$this->assertSame('POST', $container[0]['request']->getMethod());
$this->assertSame('request value', $container[0]['request']->getHeaderline('X-PHPUnit'));
$this->assertSame(file_get_contents(__FILE__), (string)$container[0]['request']->getBody());
$this->assertStringEqualsFile(__FILE__, (string)$container[0]['request']->getBody());
}
/**
......@@ -190,7 +189,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$response = $adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......@@ -239,7 +238,7 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$response = $adapter->execute($request, $endpoint);
$this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertSame(
array(
'HTTP/1.1 200 OK',
......
......@@ -184,16 +184,20 @@ class HttpTest extends \PHPUnit_Framework_TestCase
$context = $this->adapter->createContext($request, $endpoint);
// Remove content from comparison, since we can't determine the
// random boundary string.
$stream_context_get_options = stream_context_get_options($context);
unset($stream_context_get_options['http']['content']);
unset($stream_context_get_options['http']['header']);
$this->assertEquals(
array(
'http' => array(
'method' => $method,
'timeout' => $timeout,
'content' => file_get_contents(__FILE__),
'header' => 'Content-Type: multipart/form-data',
)
),
stream_context_get_options($context)
$stream_context_get_options
);
}
......
......@@ -211,7 +211,7 @@ EOF;
$response = $mock->execute($request, $endpoint);
$this->assertEquals($body, $response->getBody());
$this->assertEquals($statusCode, $response->getStatusCode());
$this->assertSame($statusCode, $response->getStatusCode());
$this->assertEquals($statusMessage, $response->getStatusMessage());
}
......
......@@ -551,7 +551,7 @@ class ClientTest extends \PHPUnit_Framework_TestCase
->method('getRequestBuilder')
->will($this->returnValue($observer));
$this->client->registerQueryType('testquerytype', 'Solarium\QueryType\Select\Query\Query', $observer, '');
$this->client->registerQueryType('testquerytype', 'Solarium\QueryType\Select\Query\Query');
$this->client->createRequest($queryStub);
}
......@@ -1293,9 +1293,7 @@ class MyAdapter extends ClientAdapterHttp
{
public function execute($request, $endpoint)
{
$response = new Response('{}', array('HTTP/1.1 200 OK'));
return $response;
return new Response('{}', array('HTTP/1.1 200 OK'));
}
}
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\Core\Event;
use Solarium\Core\Client\Client;
use Solarium\Core\Event\PostCreateResult;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\Core\Event;
use Solarium\Core\Event\PostExecute;
use Solarium\Core\Client\Client;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\Core\Event;
use Solarium\Core\Client\Client;
use Solarium\Core\Event\PreCreateResult;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\Core\Event;
use Solarium\Core\Event\PreExecute;
use Solarium\Core\Client\Client;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -32,7 +32,6 @@
namespace Solarium\Tests\Plugin\BufferedAdd\Event;
use Solarium\Plugin\BufferedAdd\Event\PostCommit;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Client;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -32,7 +32,6 @@
namespace Solarium\Tests\Plugin\BufferedAdd\Event;
use Solarium\Plugin\BufferedAdd\Event\PostFlush;
use Solarium\QueryType\Select\Query\Query;
use Solarium\Core\Client\Client;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
......
......@@ -65,7 +65,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
$key = $randomizer->getRandom($excludes);
$this->assertTrue($key !== 'key3');
$this->assertNotSame($key, 'key3');
}
public function testAllEntriesExcluded()
......
......@@ -85,7 +85,7 @@ class ResultTest extends AbstractResultTest
$result = new FilterResultDummy(1, 12, $this->numFound, $this->maxScore, $this->docs, $this->components, Query::FILTER_MODE_REMOVE);
$docs = $result->getDocuments();
$this->assertEquals(3, count($docs));
$this->assertCount(3, $docs);
$this->assertEquals($docs[0]->title, $this->docs[0]->title);
$this->assertEquals($docs[1]->title, $this->docs[1]->title);
$this->assertEquals($docs[2]->title, $this->docs[2]->title);
......
......@@ -86,7 +86,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->plugin));
$this->assertCount(5, $this->plugin);
}
public function testIteratorAndRewind()
......@@ -200,7 +200,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array());
$this->plugin->setQuery($this->query)->setEndpoint('s2');
$this->assertEquals(5, count($this->plugin));
$this->assertCount(5, $this->plugin);
}
public function testWithSpecificEndpointOption()
......@@ -214,7 +214,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->plugin->initPlugin($mockClient, array('endpoint' => 's3'));
$this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->plugin));
$this->assertCount(5, $this->plugin);
}
}
......
......@@ -134,9 +134,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testContentTypeHeader()
{
$headers = array(
'Content-Type: multipart/form-data'
);
$headers = array();
$request = $this->builder->build($this->query);
$this->assertEquals($headers,
$request->getHeaders());
......
......@@ -467,7 +467,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
$components = $query->getComponents();
$this->assertEquals(1, count($components));
$this->assertCount(1, $components);
$this->assertThat(
array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......
......@@ -31,7 +31,6 @@
namespace Solarium\Tests\QueryType\RealtimeGet;
use Solarium\Core\Client\Request;
use Solarium\QueryType\RealtimeGet\Query;
use Solarium\QueryType\RealtimeGet\RequestBuilder;
......
......@@ -262,7 +262,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
{
$key = 'fq1';
$fq = $this->query->createFilterQuery($key, true);
$fq = $this->query->createFilterQuery($key);
$fq->setQuery('category:1');
$this->assertEquals(
......@@ -470,7 +470,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
);
$components = $query->getComponents();
$this->assertEquals(1, count($components));
$this->assertCount(1, $components);
$this->assertThat(
array_pop($components),
$this->isInstanceOf('Solarium\QueryType\Select\Query\Component\FacetSet')
......@@ -612,7 +612,7 @@ abstract class AbstractQueryTest extends \PHPUnit_Framework_TestCase
$components = $this->query->getComponentTypes();
$components['mykey'] = 'mycomponent';
$this->query->registerComponentType('mykey', 'mycomponent', 'mybuilder', 'myparser');
$this->query->registerComponentType('mykey', 'mycomponent');
$this->assertEquals(
$components,
......
......@@ -138,7 +138,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearShards();
$shards = $this->distributedSearch->getShards();
$this->assertTrue(is_array($shards));
$this->assertEquals(0, count($shards));
$this->assertCount(0, $shards);
}
public function testAddShards()
......@@ -167,7 +167,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$shards = $this->distributedSearch->getShards();
$this->assertEquals(3, count($shards));
$this->assertCount(3, $shards);
$this->assertEquals(
array(
'shard3' => 'localhost:8983/solr/shard3',
......@@ -216,7 +216,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearCollections();
$collections = $this->distributedSearch->getCollections();
$this->assertTrue(is_array($collections));
$this->assertEquals(0, count($collections));
$this->assertCount(0, $collections);
}
public function testAddCollections()
......@@ -245,7 +245,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$collections = $this->distributedSearch->getCollections();
$this->assertEquals(3, count($collections));
$this->assertCount(3, $collections);
$this->assertEquals(
array(
'collection3' => 'localhost:8983/solr/collection3',
......@@ -285,7 +285,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
$this->distributedSearch->clearReplicas();
$replicas = $this->distributedSearch->getReplicas();
$this->assertTrue(is_array($replicas));
$this->assertEquals(0, count($replicas));
$this->assertCount(0, $replicas);
}
public function testAddReplicas()
......@@ -314,7 +314,7 @@ class DistributedSearchTest extends \PHPUnit_Framework_TestCase
)
);
$replicas = $this->distributedSearch->getReplicas();
$this->assertEquals(3, count($replicas));
$this->assertCount(3, $replicas);
$this->assertEquals(
array(
'replica3' => 'localhost:8983/solr/replica3',
......
......@@ -117,8 +117,8 @@ class FieldTest extends \PHPUnit_Framework_TestCase
public function testSetAndGetMinCount()
{
$this->facet->setMincount(100);
$this->assertEquals(100, $this->facet->getMincount());
$this->facet->setMinCount(100);
$this->assertEquals(100, $this->facet->getMinCount());
}
public function testSetAndGetMissing()
......
......@@ -157,7 +157,7 @@ class PivotTest extends \PHPUnit_Framework_TestCase
$this->facet->clearStats();
$this->facet->addStats(array('stat1', 'stat2'));
$this->facet->removeStat('stat1');
$this->assertEquals(array('stat2'), $this->facet->getstats());
$this->assertEquals(array('stat2'), $this->facet->getStats());
}
public function testSetStats()
......
......@@ -69,7 +69,7 @@ class FacetSetTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(2, count($facets));
$this->assertEquals($options['prefix'], $this->facetSet->getPrefix());
$this->assertEquals($options['sort'], $this->facetSet->getSort());
$this->assertEquals($options['mincount'], $this->facetSet->getMincount());
$this->assertEquals($options['mincount'], $this->facetSet->getMinCount());
$this->assertEquals($options['missing'], $this->facetSet->getMissing());
$this->assertEquals($options['extractfromresponse'], $this->facetSet->getExtractFromResponse());
$this->assertEquals($options['contains'], $this->facetSet->getContains());
......@@ -117,8 +117,8 @@ class FacetSetTest extends \PHPUnit_Framework_TestCase
public function testSetAndGetMinCount()
{
$this->facetSet->setMincount(100);
$this->assertEquals(100, $this->facetSet->getMincount());
$this->facetSet->setMinCount(100);
$this->assertEquals(100, $this->facetSet->getMinCount());
}
public function testSetAndGetMissing()
......
......@@ -33,7 +33,6 @@ namespace Solarium\Tests\QueryType\Select\Query\Component\Highlighting;
use Solarium\QueryType\Select\Query\Component\Highlighting\Highlighting;
use Solarium\QueryType\Select\Query\Component\Highlighting\Field;
use Solarium\QueryType\Select\Query\Query;
class FieldTest extends \PHPUnit_Framework_TestCase
{
......@@ -101,7 +100,7 @@ class FieldTest extends \PHPUnit_Framework_TestCase
public function testSetAndGetFragSize()
{
$value = 20;
$this->fld->setFragsize($value);
$this->fld->setFragSize($value);
$this->assertEquals(
$value,
......
......@@ -294,7 +294,7 @@ class HighlightingTest extends \PHPUnit_Framework_TestCase
public function testSetAndGetFragSize()
{
$value = 20;
$this->hlt->setFragsize($value);
$this->hlt->setFragSize($value);
$this->assertEquals(
$value,
......
......@@ -139,7 +139,7 @@ class StatsTest extends \PHPUnit_Framework_TestCase
{
$key = 'f1';
$fld = $this->stats->createField($key, true);
$fld = $this->stats->createField($key);
$this->assertEquals(
$key,
......
......@@ -163,7 +163,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testWithEdismaxComponent()
{
$this->query->getEdisMax();
$this->query->getEDisMax();
$request = $this->builder->build($this->query);
$this->assertEquals(
......
......@@ -124,7 +124,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(1, count($result->getExplain()));
$this->assertCount(1, $result->getExplain());
$doc = $result->getExplain()->getDocument('MA147LL/A');
$this->assertEquals(0.5, $doc->getValue());
$this->assertEquals(true, $doc->getMatch());
......@@ -146,7 +146,7 @@ class DebugTest extends \PHPUnit_Framework_TestCase
)
);
$this->assertEquals(array($expectedDetail), $doc->getDetails());
$this->assertEquals(1, count($result->getExplainOther()));
$this->assertCount(1, $result->getExplainOther());
$doc = $result->getExplainOther()->getDocument('IW-02');
$this->assertEquals(0.6, $doc->getValue());
$this->assertEquals(true, $doc->getMatch());
......@@ -158,10 +158,10 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$timing = $result->getTiming();
$this->assertEquals(36, $timing->getTime());
$this->assertEquals(2, count($timing->getPhases()));
$this->assertCount(2, $timing->getPhases());
$phase = $timing->getPhase('process');
$this->assertEquals(8, $phase->getTime());
$this->assertEquals(2, count($phase->getTimings()));
$this->assertCount(2, $phase->getTimings());
$this->assertEquals(5, $phase->getTiming('org.apache.solr.handler.component.QueryComponent'));
$this->assertEquals(3, $phase->getTiming('org.apache.solr.handler.component.MoreLikeThisComponent'));
}
......@@ -183,8 +183,8 @@ class DebugTest extends \PHPUnit_Framework_TestCase
$this->assertEquals('dummy-qp', $result->getQueryParser());
$this->assertEquals('dummy-oq', $result->getOtherQuery());
$this->assertEquals(0, count($result->getExplain()));
$this->assertEquals(0, count($result->getExplainOther()));
$this->assertCount(0, $result->getExplain());
$this->assertCount(0, $result->getExplainOther());
}
public function testParseNoData()
......
......@@ -76,6 +76,6 @@ class StatsTest extends \PHPUnit_Framework_TestCase
public function testParseNoData()
{
$result = $this->parser->parse(null, null, array());
$this->assertEquals(0, count($result));
$this->assertCount(0, $result);
}
}
......@@ -73,13 +73,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
public function testPropertyEmpty()
{
$this->assertTrue(
empty($this->doc->empty_field)
);
$this->assertFalse(
empty($this->doc->categories)
);
$this->assertEmpty($this->doc->empty_field);
$this->assertNotEmpty($this->doc->categories);
}
public function testSetField()
......@@ -124,13 +119,8 @@ abstract class AbstractDocumentTest extends \PHPUnit_Framework_TestCase
public function testArrayEmpty()
{
$this->assertTrue(
empty($this->doc['empty_field'])
);
$this->assertFalse(
empty($this->doc['categories'])
);
$this->assertEmpty($this->doc['empty_field']);
$this->assertNotEmpty($this->doc['categories']);
}
public function testArraySet()
......
......@@ -33,8 +33,4 @@ namespace Solarium\Tests\QueryType\Select\Result;
class ResultTest extends AbstractResultTest
{
public function setUp()
{
parent::setUp();
}
}
......@@ -85,7 +85,7 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals($expected, $result['results']);
$this->assertEquals(2, count($result['results']));
$this->assertCount(2, $result['results']);
}
public function testParseSolr14Format()
......@@ -139,6 +139,6 @@ class ResponseParserTest extends \PHPUnit_Framework_TestCase
);
$this->assertEquals($expected, $result['results']);
$this->assertEquals(2, count($result['results']));
$this->assertCount(2, $result['results']);
}
}
......@@ -71,7 +71,7 @@ class AddTest extends \PHPUnit_Framework_TestCase
}
try {
$doc = new \StdClass();
$doc = new \stdClass;
$this->command->addDocument($doc);
$this->fail(
......
......@@ -437,11 +437,9 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
public function testBuildRollbackXml()
{
$command = new RollbackCommand;
$this->assertEquals(
'<rollback/>',
$this->builder->buildRollbackXml($command)
$this->builder->buildRollbackXml()
);
}
......
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