Commit bdab7bb7 authored by Bas de Nooijer's avatar Bas de Nooijer

Updated unittests for the reorganized library files. Also added use statements...

Updated unittests for the reorganized library files. Also added use statements for namespaces and added a few tests.
parent 8afa3f4e
...@@ -30,71 +30,73 @@ ...@@ -30,71 +30,73 @@
*/ */
namespace Solarium\Tests; namespace Solarium\Tests;
use Solarium\Client;
class VersionTest extends \PHPUnit_Framework_TestCase
class ClientTest extends \PHPUnit_Framework_TestCase
{ {
public function testVersion() public function testVersion()
{ {
$version = \Solarium\Version::VERSION; $version = Client::VERSION;
$this->assertNotNull($version); $this->assertNotNull($version);
} }
public function testCheckExact() public function testCheckExact()
{ {
$this->assertTrue( $this->assertTrue(
\Solarium\Version::checkExact(\Solarium\Version::VERSION) Client::checkExact(Client::VERSION)
); );
} }
public function testCheckExactPartial() public function testCheckExactPartial()
{ {
$this->assertTrue( $this->assertTrue(
\Solarium\Version::checkExact(substr(\Solarium\Version::VERSION,0,1)) Client::checkExact(substr(Client::VERSION,0,1))
); );
} }
public function testCheckExactLower() public function testCheckExactLower()
{ {
$this->assertFalse( $this->assertFalse(
\Solarium\Version::checkExact('0.1') Client::checkExact('0.1')
); );
} }
public function testCheckExactHigher() public function testCheckExactHigher()
{ {
$this->assertFalse( $this->assertFalse(
\Solarium\Version::checkExact('99.0') Client::checkExact('99.0')
); );
} }
public function testCheckMinimal() public function testCheckMinimal()
{ {
$this->assertTrue( $this->assertTrue(
\Solarium\Version::checkMinimal(\Solarium\Version::VERSION) Client::checkMinimal(Client::VERSION)
); );
} }
public function testCheckMinimalPartial() public function testCheckMinimalPartial()
{ {
$version = substr(\Solarium\Version::VERSION,0,1); $version = substr(Client::VERSION,0,1);
$this->assertTrue( $this->assertTrue(
\Solarium\Version::checkMinimal($version) Client::checkMinimal($version)
); );
} }
public function testCheckMinimalLower() public function testCheckMinimalLower()
{ {
$this->assertTrue( $this->assertTrue(
\Solarium\Version::checkMinimal('0.1.0') Client::checkMinimal('0.1.0')
); );
} }
public function testCheckMinimalHigher() public function testCheckMinimalHigher()
{ {
$this->assertFalse( $this->assertFalse(
\Solarium\Version::checkMinimal('99.0') Client::checkMinimal('99.0')
); );
} }
......
...@@ -29,18 +29,22 @@ ...@@ -29,18 +29,22 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client\Adapter; namespace Solarium\Tests\Core\Client\Adapter;
use Solarium\Core\Client\Adapter\Adapter;
use Solarium\Core\Client\Request;
use Solarium\Core\Exception;
use Solarium\Core\Client\HttpException;
class AdapterTest extends \PHPUnit_Framework_TestCase class AdapterTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var TestAdapter * @var TestAdapter
*/ */
protected $_adapter; protected $adapter;
public function setUp() public function setUp()
{ {
$this->_adapter = new TestAdapter(); $this->adapter = new TestAdapter();
} }
public function testConfigMode() public function testConfigMode()
...@@ -52,66 +56,66 @@ class AdapterTest extends \PHPUnit_Framework_TestCase ...@@ -52,66 +56,66 @@ class AdapterTest extends \PHPUnit_Framework_TestCase
'core' => 'mycore', 'core' => 'mycore',
'timeout' => 3, 'timeout' => 3,
); );
$this->_adapter->setOptions($options); $this->adapter->setOptions($options);
$options['path'] = '/mysolr'; //expected trimming of trailing slash $options['path'] = '/mysolr'; //expected trimming of trailing slash
$this->assertEquals($options, $this->_adapter->getOptions()); $this->assertEquals($options, $this->adapter->getOptions());
} }
public function testSetAndGetHost() public function testSetAndGetHost()
{ {
$this->_adapter->setHost('myhost'); $this->adapter->setHost('myhost');
$this->assertEquals('myhost', $this->_adapter->getHost()); $this->assertEquals('myhost', $this->adapter->getHost());
} }
public function testSetAndGetPort() public function testSetAndGetPort()
{ {
$this->_adapter->setPort(8080); $this->adapter->setPort(8080);
$this->assertEquals(8080, $this->_adapter->getPort()); $this->assertEquals(8080, $this->adapter->getPort());
} }
public function testSetAndGetPath() public function testSetAndGetPath()
{ {
$this->_adapter->setPath('/mysolr'); $this->adapter->setPath('/mysolr');
$this->assertEquals('/mysolr', $this->_adapter->getPath()); $this->assertEquals('/mysolr', $this->adapter->getPath());
} }
public function testSetAndGetPathWithTrailingSlash() public function testSetAndGetPathWithTrailingSlash()
{ {
$this->_adapter->setPath('/mysolr/'); $this->adapter->setPath('/mysolr/');
$this->assertEquals('/mysolr', $this->_adapter->getPath()); $this->assertEquals('/mysolr', $this->adapter->getPath());
} }
public function testSetAndGetCore() public function testSetAndGetCore()
{ {
$this->_adapter->setCore('core1'); $this->adapter->setCore('core1');
$this->assertEquals('core1', $this->_adapter->getCore()); $this->assertEquals('core1', $this->adapter->getCore());
} }
public function testSetAndGetTimeout() public function testSetAndGetTimeout()
{ {
$this->_adapter->setTimeout(7); $this->adapter->setTimeout(7);
$this->assertEquals(7, $this->_adapter->getTimeout()); $this->assertEquals(7, $this->adapter->getTimeout());
} }
public function testGetBaseUri() public function testGetBaseUri()
{ {
$this->_adapter->setHost('myserver')->setPath('/mypath')->setPort(123); $this->adapter->setHost('myserver')->setPath('/mypath')->setPort(123);
$this->assertEquals('http://myserver:123/mypath/', $this->_adapter->getBaseUri()); $this->assertEquals('http://myserver:123/mypath/', $this->adapter->getBaseUri());
} }
public function testGetBaseUriWithCore() public function testGetBaseUriWithCore()
{ {
$this->_adapter->setHost('myserver')->setPath('/mypath')->setPort(123)->setCore('mycore'); $this->adapter->setHost('myserver')->setPath('/mypath')->setPort(123)->setCore('mycore');
$this->assertEquals('http://myserver:123/mypath/mycore/', $this->_adapter->getBaseUri()); $this->assertEquals('http://myserver:123/mypath/mycore/', $this->adapter->getBaseUri());
} }
} }
class TestAdapter extends \Solarium\Client\Adapter\Adapter class TestAdapter extends Adapter
{ {
public function execute($request) public function execute($request)
......
...@@ -29,14 +29,18 @@ ...@@ -29,14 +29,18 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client\Adapter; namespace Solarium\Tests\Core\Client\Adapter;
use Solarium\Core\Client\Adapter\Curl as CurlAdapter;
use Solarium\Core\Client\Request;
use Solarium\Core\Exception;
use Solarium\Core\Client\HttpException;
class CurlTest extends \PHPUnit_Framework_TestCase class CurlTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Client\Adapter\Curl * @var CurlAdapter
*/ */
protected $_adapter; protected $adapter;
public function setUp() public function setUp()
{ {
...@@ -44,7 +48,7 @@ class CurlTest extends \PHPUnit_Framework_TestCase ...@@ -44,7 +48,7 @@ class CurlTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Curl not available, skipping Curl adapter tests'); $this->markTestSkipped('Curl not available, skipping Curl adapter tests');
} }
$this->_adapter = new \Solarium\Client\Adapter\Curl(); $this->adapter = new CurlAdapter();
} }
public function testCheck() public function testCheck()
...@@ -53,13 +57,13 @@ class CurlTest extends \PHPUnit_Framework_TestCase ...@@ -53,13 +57,13 @@ class CurlTest extends \PHPUnit_Framework_TestCase
$headers = array('X-dummy: data'); $headers = array('X-dummy: data');
// this should be ok, no exception // this should be ok, no exception
$this->_adapter->check($data, $headers); $this->adapter->check($data, $headers);
$data = ''; $data = '';
$headers = array(); $headers = array();
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
$this->_adapter->check($data, $headers); $this->adapter->check($data, $headers);
} }
public function testExecute() public function testExecute()
...@@ -68,11 +72,11 @@ class CurlTest extends \PHPUnit_Framework_TestCase ...@@ -68,11 +72,11 @@ class CurlTest extends \PHPUnit_Framework_TestCase
$body = 'data'; $body = 'data';
$data = array($body, $headers); $data = array($body, $headers);
$request = new \Solarium\Client\Request(); $request = new Request();
$mock = $this->getMock('Solarium\Client\Adapter\Curl', array('_getData')); $mock = $this->getMock('Solarium\Core\Client\Adapter\Curl', array('getData'));
$mock->expects($this->once()) $mock->expects($this->once())
->method('_getData') ->method('getData')
->with($request) ->with($request)
->will($this->returnValue($data)); ->will($this->returnValue($data));
......
...@@ -29,30 +29,34 @@ ...@@ -29,30 +29,34 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client\Adapter; namespace Solarium\Tests\Core\Client\Adapter;
use Solarium\Core\Client\Adapter\Http as HttpAdapter;
use Solarium\Core\Client\Request;
use Solarium\Core\Exception;
use Solarium\Core\Client\HttpException;
class HttpTest extends \PHPUnit_Framework_TestCase class HttpTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Client\Adapter\Http * @var HttpAdapter
*/ */
protected $_adapter; protected $adapter;
public function setUp() public function setUp()
{ {
$this->_adapter = new \Solarium\Client\Adapter\Http(); $this->adapter = new HttpAdapter();
} }
public function testExecute() public function testExecute()
{ {
$data = 'test123'; $data = 'test123';
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod(\Solarium\Client\Request::METHOD_GET); $request->setMethod(Request::METHOD_GET);
$mock = $this->getMock('Solarium\Client\Adapter\Http', array('_getData','check')); $mock = $this->getMock('Solarium\Core\Client\Adapter\Http', array('getData','check'));
$mock->expects($this->once()) $mock->expects($this->once())
->method('_getData') ->method('getData')
->with($this->equalTo('http://127.0.0.1:8983/solr/?'), $this->isType('resource')) ->with($this->equalTo('http://127.0.0.1:8983/solr/?'), $this->isType('resource'))
->will($this->returnValue(array($data, array('HTTP 1.1 200 OK')))); ->will($this->returnValue(array($data, array('HTTP 1.1 200 OK'))));
...@@ -63,31 +67,31 @@ class HttpTest extends \PHPUnit_Framework_TestCase ...@@ -63,31 +67,31 @@ class HttpTest extends \PHPUnit_Framework_TestCase
{ {
$data = 'test123'; $data = 'test123';
$request = new \Solarium\Client\Request(); $request = new Request();
$mock = $this->getMock('Solarium\Client\Adapter\Http', array('_getData','check')); $mock = $this->getMock('Solarium\Core\Client\Adapter\Http', array('getData','check'));
$mock->expects($this->once()) $mock->expects($this->once())
->method('_getData') ->method('getData')
->with($this->equalTo('http://127.0.0.1:8983/solr/?'), $this->isType('resource')) ->with($this->equalTo('http://127.0.0.1:8983/solr/?'), $this->isType('resource'))
->will($this->returnValue(array($data, array('HTTP 1.1 200 OK')))); ->will($this->returnValue(array($data, array('HTTP 1.1 200 OK'))));
$mock->expects($this->once()) $mock->expects($this->once())
->method('check') ->method('check')
->will($this->throwException(new \Solarium\Client\HttpException("HTTP request failed"))); ->will($this->throwException(new HttpException("HTTP request failed")));
$this->setExpectedException('Solarium\Client\HttpException'); $this->setExpectedException('Solarium\Core\Client\HttpException');
$mock->execute($request); $mock->execute($request);
} }
public function testCheckError() public function testCheckError()
{ {
$this->setExpectedException('Solarium\Client\HttpException'); $this->setExpectedException('Solarium\Core\Client\HttpException');
$this->_adapter->check(false, array()); $this->adapter->check(false, array());
} }
public function testCheckOk() public function testCheckOk()
{ {
$value = $this->_adapter->check('dummydata',array('HTTP 1.1 200 OK')); $value = $this->adapter->check('dummydata',array('HTTP 1.1 200 OK'));
$this->assertEquals( $this->assertEquals(
null, null,
...@@ -98,13 +102,13 @@ class HttpTest extends \PHPUnit_Framework_TestCase ...@@ -98,13 +102,13 @@ class HttpTest extends \PHPUnit_Framework_TestCase
public function testCreateContextGetRequest() public function testCreateContextGetRequest()
{ {
$timeout = 13; $timeout = 13;
$method = \Solarium\Client\Request::METHOD_HEAD; $method = Request::METHOD_HEAD;
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod($method); $request->setMethod($method);
$this->_adapter->setTimeout($timeout); $this->adapter->setTimeout($timeout);
$context = $this->_adapter->createContext($request); $context = $this->adapter->createContext($request);
$this->assertEquals( $this->assertEquals(
array('http' => array('method' => $method, 'timeout' => $timeout)), array('http' => array('method' => $method, 'timeout' => $timeout)),
...@@ -115,17 +119,17 @@ class HttpTest extends \PHPUnit_Framework_TestCase ...@@ -115,17 +119,17 @@ class HttpTest extends \PHPUnit_Framework_TestCase
public function testCreateContextWithHeaders() public function testCreateContextWithHeaders()
{ {
$timeout = 13; $timeout = 13;
$method = \Solarium\Client\Request::METHOD_HEAD; $method = Request::METHOD_HEAD;
$header1 = 'Content-Type: text/xml; charset=UTF-8'; $header1 = 'Content-Type: text/xml; charset=UTF-8';
$header2 = 'X-MyHeader: dummyvalue'; $header2 = 'X-MyHeader: dummyvalue';
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod($method); $request->setMethod($method);
$request->addHeader($header1); $request->addHeader($header1);
$request->addHeader($header2); $request->addHeader($header2);
$this->_adapter->setTimeout($timeout); $this->adapter->setTimeout($timeout);
$context = $this->_adapter->createContext($request); $context = $this->adapter->createContext($request);
$this->assertEquals( $this->assertEquals(
array('http' => array('method' => $method, 'timeout' => $timeout, 'header' => $header1."\r\n".$header2)), array('http' => array('method' => $method, 'timeout' => $timeout, 'header' => $header1."\r\n".$header2)),
...@@ -136,15 +140,15 @@ class HttpTest extends \PHPUnit_Framework_TestCase ...@@ -136,15 +140,15 @@ class HttpTest extends \PHPUnit_Framework_TestCase
public function testCreateContextPostRequest() public function testCreateContextPostRequest()
{ {
$timeout = 13; $timeout = 13;
$method = \Solarium\Client\Request::METHOD_POST; $method = Request::METHOD_POST;
$data = 'test123'; $data = 'test123';
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod($method); $request->setMethod($method);
$request->setRawData($data); $request->setRawData($data);
$this->_adapter->setTimeout($timeout); $this->adapter->setTimeout($timeout);
$context = $this->_adapter->createContext($request); $context = $this->adapter->createContext($request);
$this->assertEquals( $this->assertEquals(
array('http' => array('method' => $method, 'timeout' => $timeout, 'content' => $data, 'header' => 'Content-Type: text/xml; charset=UTF-8')), array('http' => array('method' => $method, 'timeout' => $timeout, 'content' => $data, 'header' => 'Content-Type: text/xml; charset=UTF-8')),
......
...@@ -29,14 +29,18 @@ ...@@ -29,14 +29,18 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client\Adapter; namespace Solarium\Tests\Core\Client\Adapter;
use Solarium\Core\Client\Adapter\PeclHttp as PeclHttpAdapter;
use Solarium\Core\Client\Request;
use Solarium\Core\Exception;
use Solarium\Core\Client\HttpException;
class PeclHttpTest extends \PHPUnit_Framework_TestCase class PeclHttpTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Client\Adapter\PeclHttp * @var PeclHttpAdapter
*/ */
protected $_adapter; protected $adapter;
public function setUp() public function setUp()
{ {
...@@ -44,7 +48,7 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -44,7 +48,7 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
$this->markTestSkipped('Pecl_http not available, skipping PeclHttp adapter tests'); $this->markTestSkipped('Pecl_http not available, skipping PeclHttp adapter tests');
} }
$this->_adapter = new \Solarium\Client\Adapter\PeclHttp(array('timeout' => 10)); $this->adapter = new PeclHttpAdapter(array('timeout' => 10));
} }
/** /**
...@@ -53,9 +57,9 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -53,9 +57,9 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
public function testToHttpRequestWithMethod($request, $method, $support) public function testToHttpRequestWithMethod($request, $method, $support)
{ {
try { try {
$httpRequest = $this->_adapter->toHttpRequest($request); $httpRequest = $this->adapter->toHttpRequest($request);
$this->assertEquals($httpRequest->getMethod(), $method); $this->assertEquals($httpRequest->getMethod(), $method);
} catch (\Solarium\Exception $e) { } catch (Exception $e) {
if ($support) { if ($support) {
$this->fail("Unsupport method: {$request->getMethod()}"); $this->fail("Unsupport method: {$request->getMethod()}");
} }
...@@ -67,15 +71,15 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -67,15 +71,15 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
// prevents undefined constants errors // prevents undefined constants errors
if (function_exists('http_get')) { if (function_exists('http_get')) {
$methods = array( $methods = array(
\Solarium\Client\Request::METHOD_GET => array( Request::METHOD_GET => array(
'method' => HTTP_METH_GET, 'method' => HTTP_METH_GET,
'support' => true 'support' => true
), ),
\Solarium\Client\Request::METHOD_POST => array( Request::METHOD_POST => array(
'method' => HTTP_METH_POST, 'method' => HTTP_METH_POST,
'support' => true 'support' => true
), ),
\Solarium\Client\Request::METHOD_HEAD => array( Request::METHOD_HEAD => array(
'method' => HTTP_METH_HEAD, 'method' => HTTP_METH_HEAD,
'support' => true 'support' => true
), ),
...@@ -89,8 +93,9 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -89,8 +93,9 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
), ),
); );
$data = array();
foreach ($methods as $method => $options) { foreach ($methods as $method => $options) {
$request = new \Solarium\Client\Request; $request = new Request;
$request->setMethod($method); $request->setMethod($method);
$data[] = array_merge(array($request), $options); $data[] = array_merge(array($request), $options);
} }
...@@ -101,14 +106,14 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -101,14 +106,14 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
public function testToHttpRequestWithHeaders() public function testToHttpRequestWithHeaders()
{ {
$request = new \Solarium\Client\Request(array( $request = new Request(array(
'header' => array( 'header' => array(
'Content-Type: application/json', 'Content-Type: application/json',
'User-Agent: Foo' 'User-Agent: Foo'
) )
)); ));
$httpRequest = $this->_adapter->toHttpRequest($request); $httpRequest = $this->adapter->toHttpRequest($request);
$this->assertEquals(array( $this->assertEquals(array(
'timeout' => 10, 'timeout' => 10,
'headers' => array( 'headers' => array(
...@@ -120,10 +125,10 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase ...@@ -120,10 +125,10 @@ class PeclHttpTest extends \PHPUnit_Framework_TestCase
public function testToHttpRequestWithDefaultContentType() public function testToHttpRequestWithDefaultContentType()
{ {
$request = new \Solarium\Client\Request; $request = new Request;
$request->setMethod(\Solarium\Client\Request::METHOD_POST); $request->setMethod(Request::METHOD_POST);
$httpRequest = $this->_adapter->toHttpRequest($request); $httpRequest = $this->adapter->toHttpRequest($request);
$this->assertEquals(array( $this->assertEquals(array(
'timeout' => 10, 'timeout' => 10,
'headers' => array( 'headers' => array(
...@@ -143,13 +148,13 @@ X-Foo: test ...@@ -143,13 +148,13 @@ X-Foo: test
$body $body
EOF; EOF;
$request = new \Solarium\Client\Request(); $request = new Request();
$mockHttpRequest = $this->getMock('HttpRequest'); $mockHttpRequest = $this->getMock('HttpRequest');
$mockHttpRequest->expects($this->once()) $mockHttpRequest->expects($this->once())
->method('send') ->method('send')
->will($this->returnValue(\HttpMessage::factory($data))); ->will($this->returnValue(\HttpMessage::factory($data)));
$mock = $this->getMock('Solarium\Client\Adapter\PeclHttp', array('toHttpRequest')); $mock = $this->getMock('Solarium\Core\Client\Adapter\PeclHttp', array('toHttpRequest'));
$mock->expects($this->once()) $mock->expects($this->once())
->method('toHttpRequest') ->method('toHttpRequest')
->with($request) ->with($request)
...@@ -162,13 +167,13 @@ EOF; ...@@ -162,13 +167,13 @@ EOF;
} }
/** /**
* @expectedException Solarium\Client\HttpException * @expectedException Solarium\Core\Client\HttpException
*/ */
public function testExecuteWithException() public function testExecuteWithException()
{ {
$this->_adapter->setPort(-1); // this forces an error $this->adapter->setPort(-1); // this forces an error
$request = new \Solarium\Client\Request(); $request = new Request();
$this->_adapter->execute($request); $this->adapter->execute($request);
} }
} }
...@@ -29,14 +29,16 @@ ...@@ -29,14 +29,16 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client\Adapter; namespace Solarium\Tests\Core\Client\Adapter;
use Solarium\Core\Client\Adapter\ZendHttp as ZendHttpAdapter;
use Solarium\Core\Client\Request;
class ZendHttpTest extends \PHPUnit_Framework_TestCase class ZendHttpTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Client\Adapter\ZendHttp * @var ZendHttpAdapter
*/ */
protected $_adapter; protected $adapter;
public function setUp() public function setUp()
{ {
...@@ -46,7 +48,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -46,7 +48,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
\Zend_Loader_Autoloader::getInstance(); \Zend_Loader_Autoloader::getInstance();
$this->_adapter = new \Solarium\Client\Adapter\ZendHttp(); $this->adapter = new ZendHttpAdapter();
} }
public function testForwardingToZendHttpInSetOptions() public function testForwardingToZendHttpInSetOptions()
...@@ -59,34 +61,34 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -59,34 +61,34 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
->method('setConfig') ->method('setConfig')
->with($this->equalTo($adapterOptions)); ->with($this->equalTo($adapterOptions));
$this->_adapter->setZendHttp($mock); $this->adapter->setZendHttp($mock);
$this->_adapter->setOptions($options); $this->adapter->setOptions($options);
} }
public function testSetAndGetZendHttp() public function testSetAndGetZendHttp()
{ {
$dummy = new \stdClass(); $dummy = new \stdClass();
$this->_adapter->setZendHttp($dummy); $this->adapter->setZendHttp($dummy);
$this->assertEquals( $this->assertEquals(
$dummy, $dummy,
$this->_adapter->getZendHttp() $this->adapter->getZendHttp()
); );
} }
public function testGetZendHttpAutoload() public function testGetZendHttpAutoload()
{ {
$options = array('timeout' => 10, 'optionZ' => 123, 'options' => array('adapter' => 'Zend_Http_Client_Adapter_Curl')); $options = array('timeout' => 10, 'optionZ' => 123, 'options' => array('adapter' => 'Zend_Http_Client_Adapter_Curl'));
$this->_adapter->setOptions($options); $this->adapter->setOptions($options);
$zendHttp = $this->_adapter->getZendHttp(); $zendHttp = $this->adapter->getZendHttp();
$this->assertThat($zendHttp, $this->isInstanceOf('Zend_Http_Client')); $this->assertThat($zendHttp, $this->isInstanceOf('Zend_Http_Client'));
} }
public function testExecute() public function testExecute()
{ {
$method = \Solarium\Client\Request::METHOD_GET; $method = Request::METHOD_GET;
$rawData = 'xyz'; $rawData = 'xyz';
$responseData = 'abc'; $responseData = 'abc';
$handler = 'myhandler'; $handler = 'myhandler';
...@@ -94,7 +96,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -94,7 +96,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
'Content-Type: application/x-www-form-urlencoded' 'Content-Type: application/x-www-form-urlencoded'
); );
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod($method); $request->setMethod($method);
$request->setHandler($handler); $request->setHandler($handler);
$request->setHeaders($headers); $request->setHeaders($headers);
...@@ -119,8 +121,8 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -119,8 +121,8 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
->method('request') ->method('request')
->will($this->returnValue($response)); ->will($this->returnValue($response));
$this->_adapter->setZendHttp($mock); $this->adapter->setZendHttp($mock);
$adapterResponse = $this->_adapter->execute($request); $adapterResponse = $this->adapter->execute($request);
$this->assertEquals( $this->assertEquals(
$responseData, $responseData,
...@@ -130,7 +132,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -130,7 +132,7 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
public function testExecuteErrorResponse() public function testExecuteErrorResponse()
{ {
$request = new \Solarium\Client\Request(); $request = new Request();
$response = new \Zend_Http_Response(404, array(), ''); $response = new \Zend_Http_Response(404, array(), '');
$mock = $this->getMock('Zend_Http_Client'); $mock = $this->getMock('Zend_Http_Client');
...@@ -138,17 +140,17 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -138,17 +140,17 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
->method('request') ->method('request')
->will($this->returnValue($response)); ->will($this->returnValue($response));
$this->_adapter->setZendHttp($mock); $this->adapter->setZendHttp($mock);
$this->setExpectedException('Solarium\Client\HttpException'); $this->setExpectedException('Solarium\Core\Client\HttpException');
$this->_adapter->execute($request); $this->adapter->execute($request);
} }
public function testExecuteHeadRequestReturnsNoData() public function testExecuteHeadRequestReturnsNoData()
{ {
$request = new \Solarium\Client\Request(); $request = new Request();
$request->setMethod(\Solarium\Client\Request::METHOD_HEAD); $request->setMethod(Request::METHOD_HEAD);
$response = new \Zend_Http_Response(200, array('status' => 'HTTP 1.1 200 OK'), 'data'); $response = new \Zend_Http_Response(200, array('status' => 'HTTP 1.1 200 OK'), 'data');
$mock = $this->getMock('Zend_Http_Client'); $mock = $this->getMock('Zend_Http_Client');
...@@ -156,8 +158,8 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase ...@@ -156,8 +158,8 @@ class ZendHttpTest extends \PHPUnit_Framework_TestCase
->method('request') ->method('request')
->will($this->returnValue($response)); ->will($this->returnValue($response));
$this->_adapter->setZendHttp($mock); $this->adapter->setZendHttp($mock);
$response = $this->_adapter->execute($request); $response = $this->adapter->execute($request);
$this->assertEquals( $this->assertEquals(
'', '',
......
...@@ -29,14 +29,15 @@ ...@@ -29,14 +29,15 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client; namespace Solarium\Tests\Core\Client;
use Solarium\Core\Client\HttpException;
class HttpExceptionTest extends \PHPUnit_Framework_TestCase class HttpExceptionTest extends \PHPUnit_Framework_TestCase
{ {
public function testConstructor() public function testConstructor()
{ {
$exception = new \Solarium\Client\HttpException('message text', 123); $exception = new HttpException('message text', 123);
$this->assertEquals( $this->assertEquals(
'Solr HTTP error: message text (123)', 'Solr HTTP error: message text (123)',
...@@ -46,7 +47,7 @@ class HttpExceptionTest extends \PHPUnit_Framework_TestCase ...@@ -46,7 +47,7 @@ class HttpExceptionTest extends \PHPUnit_Framework_TestCase
public function testGetMessage() public function testGetMessage()
{ {
$exception = new \Solarium\Client\HttpException('message text', 123); $exception = new HttpException('message text', 123);
$this->assertEquals( $this->assertEquals(
'message text', 'message text',
...@@ -56,7 +57,7 @@ class HttpExceptionTest extends \PHPUnit_Framework_TestCase ...@@ -56,7 +57,7 @@ class HttpExceptionTest extends \PHPUnit_Framework_TestCase
public function testConstructorNoCode() public function testConstructorNoCode()
{ {
$exception = new \Solarium\Client\HttpException('message text'); $exception = new HttpException('message text');
$this->assertEquals( $this->assertEquals(
'Solr HTTP error: message text', 'Solr HTTP error: message text',
......
...@@ -29,51 +29,52 @@ ...@@ -29,51 +29,52 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client; namespace Solarium\Tests\Core\Client;
use Solarium\Core\Client\Response;
class ResponseTest extends \PHPUnit_Framework_TestCase class ResponseTest extends \PHPUnit_Framework_TestCase
{ {
protected $_headers, $_data; protected $headers, $data;
/** /**
* @var Solarium\Client\Response * @var Response
*/ */
protected $_response; protected $response;
public function setUp() public function setUp()
{ {
$this->_headers = array('HTTP/1.0 304 Not Modified'); $this->headers = array('HTTP/1.0 304 Not Modified');
$this->_data = '{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"mdsfgdsfgdf"}},"response":{"numFound":0,"start":0,"docs":[]}}'; $this->data = '{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"mdsfgdsfgdf"}},"response":{"numFound":0,"start":0,"docs":[]}}';
$this->_response = new \Solarium\Client\Response($this->_data, $this->_headers); $this->response = new Response($this->data, $this->headers);
} }
public function testGetStatusCode() public function testGetStatusCode()
{ {
$this->assertEquals(304, $this->_response->getStatusCode()); $this->assertEquals(304, $this->response->getStatusCode());
} }
public function testGetStatusMessage() public function testGetStatusMessage()
{ {
$this->assertEquals('Not Modified', $this->_response->getStatusMessage()); $this->assertEquals('Not Modified', $this->response->getStatusMessage());
} }
public function testGetHeaders() public function testGetHeaders()
{ {
$this->assertEquals($this->_headers, $this->_response->getHeaders()); $this->assertEquals($this->headers, $this->response->getHeaders());
} }
public function testGetBody() public function testGetBody()
{ {
$this->assertEquals($this->_data, $this->_response->getBody()); $this->assertEquals($this->data, $this->response->getBody());
} }
public function testMissingHeader() public function testMissingHeader()
{ {
$headers = array(); $headers = array();
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
new \Solarium\Client\Response($this->_data, $headers); new Response($this->data, $headers);
} }
} }
\ No newline at end of file
...@@ -29,7 +29,10 @@ ...@@ -29,7 +29,10 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests; namespace Solarium\Tests\Core;
use Solarium\Core\Client\Client;
use Solarium\Core\Exception;
use Solarium\Core\Configurable;
class ConfigurableTest extends \PHPUnit_Framework_TestCase class ConfigurableTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -76,11 +79,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ...@@ -76,11 +79,11 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedOptions, $configTest->getOptions()); $this->assertEquals($expectedOptions, $configTest->getOptions());
} }
public function testConstructorWithInvalidConfig() public function testConstructorWithInvalidConfig()
{ {
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
new \Solarium\Client\Client('invalid'); new Client('invalid');
} }
public function testGetOption() public function testGetOption()
...@@ -97,7 +100,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ...@@ -97,7 +100,7 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
public function testInitialisation() public function testInitialisation()
{ {
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
new ConfigTestInit; new ConfigTestInit;
} }
...@@ -124,10 +127,10 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase ...@@ -124,10 +127,10 @@ class ConfigurableTest extends \PHPUnit_Framework_TestCase
} }
} }
class ConfigTest extends \Solarium\Configurable class ConfigTest extends Configurable
{ {
protected $_options = array( protected $options = array(
'option1' => 1, 'option1' => 1,
'option2' => 'value 2', 'option2' => 'value 2',
); );
...@@ -137,9 +140,9 @@ class ConfigTest extends \Solarium\Configurable ...@@ -137,9 +140,9 @@ class ConfigTest extends \Solarium\Configurable
class ConfigTestInit extends ConfigTest class ConfigTestInit extends ConfigTest
{ {
protected function _init() protected function init()
{ {
throw new \Solarium\Exception('test init'); throw new Exception('test init');
} }
} }
......
...@@ -29,55 +29,62 @@ ...@@ -29,55 +29,62 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Plugin; namespace Solarium\Tests\Core;
use Solarium\Core\Plugin;
class AbstractTest extends \PHPUnit_Framework_TestCase class PluginTest extends \PHPUnit_Framework_TestCase
{ {
protected $_plugin, $_client, $_options; /**
* @var Plugin
*/
protected $plugin;
protected $client;
protected $options;
public function setUp() public function setUp()
{ {
$this->_client = 'dummy'; $this->client = 'dummy';
$this->_options = array('option1' => 1); $this->options = array('option1' => 1);
$this->_plugin = new MyPlugin(); $this->plugin = new MyPlugin();
$this->_plugin->init($this->_client, $this->_options); $this->plugin->initPlugin($this->client, $this->options);
} }
public function testConstructor() public function testConstructor()
{ {
$this->assertEquals( $this->assertEquals(
$this->_client, $this->client,
$this->_plugin->getClient() $this->plugin->getClient()
); );
$this->assertEquals( $this->assertEquals(
$this->_options, $this->options,
$this->_plugin->getOptions() $this->plugin->getOptions()
); );
} }
public function testEventHooksEmpty() public function testEventHooksEmpty()
{ {
$this->assertEquals(null, $this->_plugin->preCreateRequest(null)); $this->assertEquals(null, $this->plugin->preCreateRequest(null));
$this->assertEquals(null, $this->_plugin->postCreateRequest(null,null)); $this->assertEquals(null, $this->plugin->postCreateRequest(null,null));
$this->assertEquals(null, $this->_plugin->preExecuteRequest(null)); $this->assertEquals(null, $this->plugin->preExecuteRequest(null));
$this->assertEquals(null, $this->_plugin->postExecuteRequest(null,null)); $this->assertEquals(null, $this->plugin->postExecuteRequest(null,null));
$this->assertEquals(null, $this->_plugin->preExecute(null)); $this->assertEquals(null, $this->plugin->preExecute(null));
$this->assertEquals(null, $this->_plugin->postExecute(null,null)); $this->assertEquals(null, $this->plugin->postExecute(null,null));
$this->assertEquals(null, $this->_plugin->preCreateResult(null,null)); $this->assertEquals(null, $this->plugin->preCreateResult(null,null));
$this->assertEquals(null, $this->_plugin->postCreateResult(null,null,null)); $this->assertEquals(null, $this->plugin->postCreateResult(null,null,null));
$this->assertEquals(null, $this->_plugin->preCreateQuery(null,null)); $this->assertEquals(null, $this->plugin->preCreateQuery(null,null));
$this->assertEquals(null, $this->_plugin->postCreateQuery(null,null,null)); $this->assertEquals(null, $this->plugin->postCreateQuery(null,null,null));
} }
} }
class MyPlugin extends \Solarium\Plugin\AbstractPlugin{ class MyPlugin extends Plugin{
public function getClient() public function getClient()
{ {
return $this->_client; return $this->client;
} }
} }
\ No newline at end of file
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Query; namespace Solarium\Tests\Core\Query;
use Solarium\Core\Query\Query;
class QueryTest extends \PHPUnit_Framework_TestCase class QueryTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -54,7 +55,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -54,7 +55,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
$helper = $query->getHelper(); $helper = $query->getHelper();
$this->assertEquals( $this->assertEquals(
'Solarium\Query\Helper', 'Solarium\Core\Query\Helper',
get_class($helper) get_class($helper)
); );
} }
...@@ -74,7 +75,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase ...@@ -74,7 +75,7 @@ class QueryTest extends \PHPUnit_Framework_TestCase
} }
class TestQuery extends \Solarium\Query\Query class TestQuery extends Query
{ {
public function getType() public function getType()
......
...@@ -29,26 +29,28 @@ ...@@ -29,26 +29,28 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Client; namespace Solarium\Tests\Core\Query;
use Solarium\Core\Query\RequestBuilder;
use Solarium\Query\Select\Query\Query as SelectQuery;
class RequestBuilderTest extends \PHPUnit_Framework_TestCase class RequestBuilderTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var TestRequestBuilder * @var TestRequestBuilder
*/ */
protected $_builder; protected $builder;
public function setup() public function setup()
{ {
$this->_builder = new TestRequestBuilder; $this->builder = new TestRequestBuilder;
} }
public function testBuild() public function testBuild()
{ {
$query = new \Solarium\QueryType\Select\Query\Query; $query = new SelectQuery;
$query->addParam('p1','v1'); $query->addParam('p1','v1');
$query->addParam('p2','v2'); $query->addParam('p2','v2');
$request = $this->_builder->build($query); $request = $this->builder->build($query);
$this->assertEquals( $this->assertEquals(
'select?p1=v1&p2=v2&wt=json', 'select?p1=v1&p2=v2&wt=json',
...@@ -62,7 +64,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -62,7 +64,7 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals( $this->assertEquals(
'{!tag=mytag ex=exclude1,exclude2}myValue', '{!tag=mytag ex=exclude1,exclude2}myValue',
$this->_builder->renderLocalParams('myValue', $myParams) $this->builder->renderLocalParams('myValue', $myParams)
); );
} }
...@@ -70,12 +72,52 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -70,12 +72,52 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
{ {
$this->assertEquals( $this->assertEquals(
'myValue', 'myValue',
$this->_builder->renderLocalParams('myValue') $this->builder->renderLocalParams('myValue')
);
}
public function testBoolAttribWithNull()
{
$this->assertEquals(
'',
$this->builder->boolAttrib('myattrib', null)
);
}
public function testBoolAttribWithString()
{
$this->assertEquals(
' myattrib="true"',
$this->builder->boolAttrib('myattrib', 'true')
);
}
public function testBoolAttribWithBool()
{
$this->assertEquals(
' myattrib="false"',
$this->builder->boolAttrib('myattrib', false)
);
}
public function testAttribWithNull()
{
$this->assertEquals(
'',
$this->builder->attrib('myattrib', null)
);
}
public function testAttribWithString()
{
$this->assertEquals(
' myattrib="myvalue"',
$this->builder->attrib('myattrib', 'myvalue')
); );
} }
} }
class TestRequestBuilder extends \Solarium\Client\RequestBuilder{ class TestRequestBuilder extends RequestBuilder{
} }
\ No newline at end of file
...@@ -29,60 +29,66 @@ ...@@ -29,60 +29,66 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Result; namespace Solarium\Tests\Core\Query\Result;
use Solarium\Core\Client\Client;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\QueryType as QueryTypeResult;
use Solarium\Query\Select\Query\Query as SelectQuery;
use Solarium\Query\Update\Query\Query as UpdateQuery;
class QueryTypeTest extends \PHPUnit_Framework_TestCase class QueryTypeTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var QueryTypeDummy * @var QueryTypeDummy
*/ */
protected $_result; protected $result;
public function setUp() public function setUp()
{ {
$client = new \Solarium\Client\Client; $client = new Client;
$query = new \Solarium\QueryType\Update\Query\Query; $query = new UpdateQuery;
$response = new \Solarium\Client\Response('{"responseHeader":{"status":1,"QTime":12}}',array('HTTP 1.1 200 OK')); $response = new Response('{"responseHeader":{"status":1,"QTime":12}}',array('HTTP 1.1 200 OK'));
$this->_result = new QueryTypeDummy($client, $query, $response); $this->result = new QueryTypeDummy($client, $query, $response);
} }
public function testParseResponse() public function testParseResponse()
{ {
$client = new \Solarium\Client\Client; $client = new Client;
$query = new QueryDummyTest; $query = new QueryDummyTest;
$response = new \Solarium\Client\Response('{"responseHeader":{"status":1,"QTime":12}}',array('HTTP 1.1 200 OK')); $response = new Response('{"responseHeader":{"status":1,"QTime":12}}',array('HTTP 1.1 200 OK'));
$result = new QueryTypeDummy($client, $query, $response); $result = new QueryTypeDummy($client, $query, $response);
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
$result->parse(); $result->parse();
} }
public function testParseResponseInvalidQuerytype() public function testParseResponseInvalidQuerytype()
{ {
$this->_result->parse(); $this->result->parse();
} }
public function testParseLazyLoading() public function testParseLazyLoading()
{ {
$this->assertEquals(0,$this->_result->parseCount); $this->assertEquals(0,$this->result->parseCount);
$this->_result->parse(); $this->result->parse();
$this->assertEquals(1,$this->_result->parseCount); $this->assertEquals(1,$this->result->parseCount);
$this->_result->parse(); $this->result->parse();
$this->assertEquals(1,$this->_result->parseCount); $this->assertEquals(1,$this->result->parseCount);
} }
public function testMapData() public function testMapData()
{ {
$this->_result->mapData(array('dummyvar' => 'dummyvalue')); $this->result->mapData(array('dummyvar' => 'dummyvalue'));
$this->assertEquals('dummyvalue',$this->_result->getVar('dummyvar')); $this->assertEquals('dummyvalue',$this->result->getVar('dummyvar'));
} }
} }
class QueryDummyTest extends \Solarium\QueryType\Select\Query\Query class QueryDummyTest extends SelectQuery
{ {
public function getType() public function getType()
{ {
...@@ -90,30 +96,25 @@ class QueryDummyTest extends \Solarium\QueryType\Select\Query\Query ...@@ -90,30 +96,25 @@ class QueryDummyTest extends \Solarium\QueryType\Select\Query\Query
} }
} }
class QueryTypeDummy extends \Solarium\Result\QueryType class QueryTypeDummy extends QueryTypeResult
{ {
public $parseCount = 0; public $parseCount = 0;
public function parse() public function parse()
{ {
$this->_parseResponse(); $this->parseResponse();
}
public function _mapData($data)
{
$this->parseCount++;
parent::_mapData($data);
} }
public function mapData($data) public function mapData($data)
{ {
$this->_mapData($data); $this->parseCount++;
parent::mapData($data);
} }
public function getVar($name) public function getVar($name)
{ {
return $this->{'_'.$name}; return $this->$name;
} }
} }
\ No newline at end of file
...@@ -29,41 +29,50 @@ ...@@ -29,41 +29,50 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\Result; namespace Solarium\Tests\Core\Query\Result;
use Solarium\Core\Client\Client;
use Solarium\Core\Client\Response;
use Solarium\Core\Query\Result\Result;
use Solarium\Query\Select\Query\Query as SelectQuery;
class ResultTest extends \PHPUnit_Framework_TestCase class ResultTest extends \PHPUnit_Framework_TestCase
{ {
protected $_client, $_query, $_response, $_result; /**
* @var Result
*/
protected $result;
protected $client, $query, $response, $headers;
public function setUp() public function setUp()
{ {
$this->_client = new \Solarium\Client\Client(); $this->client = new Client();
$this->_query = new \Solarium\QueryType\Select\Query\Query(); $this->query = new SelectQuery();
$this->_headers = array('HTTP/1.0 304 Not Modified'); $this->headers = array('HTTP/1.0 304 Not Modified');
$data = '{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"xyz"}},"response":{"numFound":0,"start":0,"docs":[]}}'; $data = '{"responseHeader":{"status":0,"QTime":1,"params":{"wt":"json","q":"xyz"}},"response":{"numFound":0,"start":0,"docs":[]}}';
$this->_response = new \Solarium\Client\Response($data, $this->_headers); $this->response = new Response($data, $this->headers);
$this->_result = new \Solarium\Result\Result($this->_client, $this->_query, $this->_response); $this->result = new Result($this->client, $this->query, $this->response);
} }
public function testResultWithErrorResponse() public function testResultWithErrorResponse()
{ {
$headers = array('HTTP/1.0 404 Not Found'); $headers = array('HTTP/1.0 404 Not Found');
$response = new \Solarium\Client\Response('', $headers); $response = new Response('', $headers);
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
new \Solarium\Result\Result($this->_client, $this->_query, $response); new Result($this->client, $this->query, $response);
} }
public function testGetResponse() public function testGetResponse()
{ {
$this->assertEquals($this->_response, $this->_result->getResponse()); $this->assertEquals($this->response, $this->result->getResponse());
} }
public function testGetQuery() public function testGetQuery()
{ {
$this->assertEquals($this->_query, $this->_result->getQuery()); $this->assertEquals($this->query, $this->result->getQuery());
} }
public function testGetData() public function testGetData()
...@@ -73,17 +82,17 @@ class ResultTest extends \PHPUnit_Framework_TestCase ...@@ -73,17 +82,17 @@ class ResultTest extends \PHPUnit_Framework_TestCase
'response' => array('numFound' => 0, 'start' => 0, 'docs' => array()) 'response' => array('numFound' => 0, 'start' => 0, 'docs' => array())
); );
$this->assertEquals($data, $this->_result->getData()); $this->assertEquals($data, $this->result->getData());
} }
public function testGetInvalidData() public function testGetInvalidData()
{ {
$data = 'invalid'; $data = 'invalid';
$this->_response = new \Solarium\Client\Response($data, $this->_headers); $this->response = new Response($data, $this->headers);
$this->_result = new \Solarium\Result\Result($this->_client, $this->_query, $this->_response); $this->result = new Result($this->client, $this->query, $this->response);
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
$this->_result->getData(); $this->result->getData();
} }
} }
\ No newline at end of file
...@@ -30,25 +30,27 @@ ...@@ -30,25 +30,27 @@
*/ */
namespace Solarium\Tests\Plugin; namespace Solarium\Tests\Plugin;
use Solarium\QueryType\Update\Query\Document; use Solarium\Query\Update\Query\Document;
use Solarium\Plugin\BufferedAdd;
use Solarium\Core\Client\Client;
class BufferedAddTest extends \PHPUnit_Framework_TestCase class BufferedAddTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium_Plugin_BufferedAdd * @var BufferedAdd
*/ */
protected $_plugin; protected $plugin;
public function setUp() public function setUp()
{ {
$this->_plugin = new \Solarium\Plugin\BufferedAdd(); $this->plugin = new BufferedAdd();
$this->_plugin->init(new \Solarium\Client\Client(), array()); $this->plugin->initPlugin(new Client(), array());
} }
public function testSetAndGetBufferSize() public function testSetAndGetBufferSize()
{ {
$this->_plugin->setBufferSize(500); $this->plugin->setBufferSize(500);
$this->assertEquals(500, $this->_plugin->getBufferSize()); $this->assertEquals(500, $this->plugin->getBufferSize());
} }
public function testAddDocument() public function testAddDocument()
...@@ -57,9 +59,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -57,9 +59,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$doc->id = '123'; $doc->id = '123';
$doc->name = 'test'; $doc->name = 'test';
$this->_plugin->addDocument($doc); $this->plugin->addDocument($doc);
$this->assertEquals(array($doc), $this->_plugin->getDocuments()); $this->assertEquals(array($doc), $this->plugin->getDocuments());
} }
public function testCreateDocument() public function testCreateDocument()
...@@ -67,9 +69,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -67,9 +69,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$data = array('id' => '123', 'name' => 'test'); $data = array('id' => '123', 'name' => 'test');
$doc = new Document($data); $doc = new Document($data);
$this->_plugin->createDocument($data); $this->plugin->createDocument($data);
$this->assertEquals(array($doc), $this->_plugin->getDocuments()); $this->assertEquals(array($doc), $this->plugin->getDocuments());
} }
public function testAddDocuments() public function testAddDocuments()
...@@ -84,9 +86,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -84,9 +86,9 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$docs = array($doc1, $doc2); $docs = array($doc1, $doc2);
$this->_plugin->addDocuments($docs); $this->plugin->addDocuments($docs);
$this->assertEquals($docs, $this->_plugin->getDocuments()); $this->assertEquals($docs, $this->plugin->getDocuments());
} }
public function testAddDocumentAutoFlush() public function testAddDocumentAutoFlush()
...@@ -114,15 +116,15 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -114,15 +116,15 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$doc->id = '123'; $doc->id = '123';
$doc->name = 'test'; $doc->name = 'test';
$this->_plugin->addDocument($doc); $this->plugin->addDocument($doc);
$this->_plugin->clear(); $this->plugin->clear();
$this->assertEquals(array(), $this->_plugin->getDocuments()); $this->assertEquals(array(), $this->plugin->getDocuments());
} }
public function testFlushEmptyBuffer() public function testFlushEmptyBuffer()
{ {
$this->assertEquals(false, $this->_plugin->flush()); $this->assertEquals(false, $this->plugin->flush());
} }
public function testFlush() public function testFlush()
...@@ -130,16 +132,16 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -130,16 +132,16 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$data = array('id' => '123', 'name' => 'test'); $data = array('id' => '123', 'name' => 'test');
$doc = new Document($data); $doc = new Document($data);
$mockUpdate = $this->getMock('Solarium\Query\Update', array('addDocuments')); $mockUpdate = $this->getMock('Solarium\Query\Update\Query\Query', array('addDocuments'));
$mockUpdate->expects($this->once())->method('addDocuments')->with($this->equalTo(array($doc)),$this->equalTo(true),$this->equalTo(12)); $mockUpdate->expects($this->once())->method('addDocuments')->with($this->equalTo(array($doc)),$this->equalTo(true),$this->equalTo(12));
$mockClient = $this->getMock('Solarium\Client', array('createUpdate', 'update', 'triggerEvent')); $mockClient = $this->getMock('Solarium\Core\Client\Client', array('createUpdate', 'update', 'triggerEvent'));
$mockClient->expects($this->exactly(2))->method('createUpdate')->will($this->returnValue($mockUpdate)); $mockClient->expects($this->exactly(2))->method('createUpdate')->will($this->returnValue($mockUpdate));
$mockClient->expects($this->once())->method('update')->will($this->returnValue('dummyResult')); $mockClient->expects($this->once())->method('update')->will($this->returnValue('dummyResult'));
$mockClient->expects($this->exactly(2))->method('triggerEvent'); $mockClient->expects($this->exactly(2))->method('triggerEvent');
$plugin = new \Solarium\Plugin\BufferedAdd(); $plugin = new BufferedAdd();
$plugin->init($mockClient, array()); $plugin->initPlugin($mockClient, array());
$plugin->addDocument($doc); $plugin->addDocument($doc);
$this->assertEquals('dummyResult', $plugin->flush(true,12)); $this->assertEquals('dummyResult', $plugin->flush(true,12));
...@@ -150,17 +152,17 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase ...@@ -150,17 +152,17 @@ class BufferedAddTest extends \PHPUnit_Framework_TestCase
$data = array('id' => '123', 'name' => 'test'); $data = array('id' => '123', 'name' => 'test');
$doc = new Document($data); $doc = new Document($data);
$mockUpdate = $this->getMock('Solarium\Query\Update', array('addDocuments', 'addCommit')); $mockUpdate = $this->getMock('Solarium\Core\Query\Update\Query\Query', array('addDocuments', 'addCommit'));
$mockUpdate->expects($this->once())->method('addDocuments')->with($this->equalTo(array($doc)),$this->equalTo(true)); $mockUpdate->expects($this->once())->method('addDocuments')->with($this->equalTo(array($doc)),$this->equalTo(true));
$mockUpdate->expects($this->once())->method('addCommit')->with($this->equalTo(false),$this->equalTo(true),$this->equalTo(false)); $mockUpdate->expects($this->once())->method('addCommit')->with($this->equalTo(false),$this->equalTo(true),$this->equalTo(false));
$mockClient = $this->getMock('Solarium\Client\Client', array('createUpdate', 'update', 'triggerEvent')); $mockClient = $this->getMock('Solarium\Core\Client\Client', array('createUpdate', 'update', 'triggerEvent'));
$mockClient->expects($this->exactly(2))->method('createUpdate')->will($this->returnValue($mockUpdate)); $mockClient->expects($this->exactly(2))->method('createUpdate')->will($this->returnValue($mockUpdate));
$mockClient->expects($this->once())->method('update')->will($this->returnValue('dummyResult')); $mockClient->expects($this->once())->method('update')->will($this->returnValue('dummyResult'));
$mockClient->expects($this->exactly(2))->method('triggerEvent'); $mockClient->expects($this->exactly(2))->method('triggerEvent');
$plugin = new \Solarium\Plugin\BufferedAdd(); $plugin = new BufferedAdd();
$plugin->init($mockClient, array()); $plugin->initPlugin($mockClient, array());
$plugin->addDocument($doc); $plugin->addDocument($doc);
$this->assertEquals('dummyResult', $plugin->commit(true, false, true, false)); $this->assertEquals('dummyResult', $plugin->commit(true, false, true, false));
......
...@@ -30,88 +30,89 @@ ...@@ -30,88 +30,89 @@
*/ */
namespace Solarium\Tests\Plugin\CustomizeRequest; namespace Solarium\Tests\Plugin\CustomizeRequest;
use Solarium\Plugin\CustomizeRequest\Customization;
class CustomizationTest extends \PHPUnit_Framework_TestCase class CustomizationTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Plugin\CustomizeRequest\Customization * @var Customization
*/ */
protected $_instance; protected $instance;
public function setUp() public function setUp()
{ {
$this->_instance = new \Solarium\Plugin\CustomizeRequest\Customization(); $this->instance = new Customization();
} }
public function testSetAndGetKey() public function testSetAndGetKey()
{ {
$value = 'mykey'; $value = 'mykey';
$this->_instance->setKey($value); $this->instance->setKey($value);
$this->assertEquals($value, $this->_instance->getKey()); $this->assertEquals($value, $this->instance->getKey());
} }
public function testSetAndGetName() public function testSetAndGetName()
{ {
$value = 'myname'; $value = 'myname';
$this->_instance->setName($value); $this->instance->setName($value);
$this->assertEquals($value, $this->_instance->getName()); $this->assertEquals($value, $this->instance->getName());
} }
public function testSetAndGetType() public function testSetAndGetType()
{ {
$value = 'mytype'; $value = 'mytype';
$this->_instance->setType($value); $this->instance->setType($value);
$this->assertEquals($value, $this->_instance->getType()); $this->assertEquals($value, $this->instance->getType());
} }
public function testSetAndGetValue() public function testSetAndGetValue()
{ {
$value = 'myvalue'; $value = 'myvalue';
$this->_instance->setValue($value); $this->instance->setValue($value);
$this->assertEquals($value, $this->_instance->getValue()); $this->assertEquals($value, $this->instance->getValue());
} }
public function testSetAndGetPersistence() public function testSetAndGetPersistence()
{ {
$value = true; $value = true;
$this->_instance->setPersistent($value); $this->instance->setPersistent($value);
$this->assertEquals($value, $this->_instance->getPersistent()); $this->assertEquals($value, $this->instance->getPersistent());
} }
public function testSetAndGetOverwrite() public function testSetAndGetOverwrite()
{ {
$value = false; $value = false;
$this->_instance->setOverwrite($value); $this->instance->setOverwrite($value);
$this->assertEquals($value, $this->_instance->getOverwrite()); $this->assertEquals($value, $this->instance->getOverwrite());
} }
public function testIsValid() public function testIsValid()
{ {
$this->_instance->setKey('mykey'); $this->instance->setKey('mykey');
$this->_instance->setType('param'); $this->instance->setType('param');
$this->_instance->setName('myname'); $this->instance->setName('myname');
$this->_instance->setValue('myvalue'); $this->instance->setValue('myvalue');
$this->assertTrue($this->_instance->isValid()); $this->assertTrue($this->instance->isValid());
} }
public function testIsValidWithInvalidType() public function testIsValidWithInvalidType()
{ {
$this->_instance->setKey('mykey'); $this->instance->setKey('mykey');
$this->_instance->setType('mytype'); $this->instance->setType('mytype');
$this->_instance->setName('myname'); $this->instance->setName('myname');
$this->_instance->setValue('myvalue'); $this->instance->setValue('myvalue');
$this->assertFalse($this->_instance->isValid()); $this->assertFalse($this->instance->isValid());
} }
public function testIsValidWithMissingValue() public function testIsValidWithMissingValue()
{ {
$this->_instance->setKey('mykey'); $this->instance->setKey('mykey');
$this->_instance->setType('param'); $this->instance->setType('param');
$this->_instance->setName('myname'); $this->instance->setName('myname');
$this->assertFalse($this->_instance->isValid()); $this->assertFalse($this->instance->isValid());
} }
} }
\ No newline at end of file
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
*/ */
namespace Solarium\Tests\Plugin\Loadbalancer; namespace Solarium\Tests\Plugin\Loadbalancer;
use Solarium\Plugin\Loadbalancer\WeightedRandomChoice;
class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -38,7 +39,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase ...@@ -38,7 +39,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
{ {
$choices = array('key1' => 1, 'key2' => 2, 'key3' => 3); $choices = array('key1' => 1, 'key2' => 2, 'key3' => 3);
$randomizer = new \Solarium\Plugin\Loadbalancer\WeightedRandomChoice($choices); $randomizer = new WeightedRandomChoice($choices);
$choice = $randomizer->getRandom(); $choice = $randomizer->getRandom();
$this->assertTrue( $this->assertTrue(
...@@ -60,7 +61,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase ...@@ -60,7 +61,7 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
$choices = array('key1' => 1, 'key2' => 1, 'key3' => 300); $choices = array('key1' => 1, 'key2' => 1, 'key3' => 300);
$excludes = array('key3'); $excludes = array('key3');
$randomizer = new \Solarium\Plugin\Loadbalancer\WeightedRandomChoice($choices); $randomizer = new WeightedRandomChoice($choices);
$key = $randomizer->getRandom($excludes); $key = $randomizer->getRandom($excludes);
...@@ -72,9 +73,9 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase ...@@ -72,9 +73,9 @@ class WeightedRandomChoiceTest extends \PHPUnit_Framework_TestCase
$choices = array('key1' => 1, 'key2' => 2, 'key3' => 3); $choices = array('key1' => 1, 'key2' => 2, 'key3' => 3);
$excludes = array_keys($choices); $excludes = array_keys($choices);
$randomizer = new \Solarium\Plugin\Loadbalancer\WeightedRandomChoice($choices); $randomizer = new WeightedRandomChoice($choices);
$this->setExpectedException('Solarium\Exception'); $this->setExpectedException('Solarium\Core\Exception');
$randomizer->getRandom($excludes); $randomizer->getRandom($excludes);
} }
......
...@@ -30,62 +30,64 @@ ...@@ -30,62 +30,64 @@
*/ */
namespace Solarium\Tests\Plugin; namespace Solarium\Tests\Plugin;
use Solarium\Plugin\ParallelExecution;
use Solarium\Core\Client\Client;
class ParallelExecutionTest extends \PHPUnit_Framework_TestCase class ParallelExecutionTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var \Solarium\Plugin\ParallelExecution * @var ParallelExecution
*/ */
protected $_plugin; protected $plugin;
public function setUp() public function setUp()
{ {
$this->_plugin = new \Solarium\Plugin\ParallelExecution(); $this->plugin = new ParallelExecution();
} }
public function testAddAndGetQueries() public function testAddAndGetQueries()
{ {
$client1 = new \Solarium\Client\Client(); $client1 = new Client();
$client2 = new \Solarium\Client\Client(array( $client2 = new Client(array(
'adapter' => 'MyAdapter', 'adapter' => 'MyAdapter',
'adapteroptions' => array( 'adapteroptions' => array(
'host' => 'myhost', 'host' => 'myhost',
) )
) )
); );
$this->_plugin->init($client1, array()); $this->plugin->initPlugin($client1, array());
$query1 = $client1->createSelect()->setQuery('test1'); $query1 = $client1->createSelect()->setQuery('test1');
$query2 = $client1->createSelect()->setQuery('test2'); $query2 = $client1->createSelect()->setQuery('test2');
$this->_plugin->addQuery(1, $query1); $this->plugin->addQuery(1, $query1);
$this->_plugin->addQuery(2, $query2, $client2); $this->plugin->addQuery(2, $query2, $client2);
$this->assertEquals( $this->assertEquals(
array( array(
1 => array('query' => $query1, 'client' => $client1), 1 => array('query' => $query1, 'client' => $client1),
2 => array('query' => $query2, 'client' => $client2), 2 => array('query' => $query2, 'client' => $client2),
), ),
$this->_plugin->getQueries() $this->plugin->getQueries()
); );
} }
public function testClearQueries() public function testClearQueries()
{ {
$client = new \Solarium\Client\Client(); $client = new Client();
$this->_plugin->init($client, array()); $this->plugin->initPlugin($client, array());
$query1 = $client->createSelect()->setQuery('test1'); $query1 = $client->createSelect()->setQuery('test1');
$query2 = $client->createSelect()->setQuery('test2'); $query2 = $client->createSelect()->setQuery('test2');
$this->_plugin->addQuery(1, $query1); $this->plugin->addQuery(1, $query1);
$this->_plugin->addQuery(2, $query2); $this->plugin->addQuery(2, $query2);
$this->_plugin->clearQueries(); $this->plugin->clearQueries();
$this->assertEquals( $this->assertEquals(
array(), array(),
$this->_plugin->getQueries() $this->plugin->getQueries()
); );
} }
......
...@@ -30,37 +30,41 @@ ...@@ -30,37 +30,41 @@
*/ */
namespace Solarium\Tests\Plugin; namespace Solarium\Tests\Plugin;
use Solarium\Plugin\PostBigRequest;
use Solarium\Core\Client\Client;
use Solarium\Query\Select\Query\Query;
use Solarium\Core\Client\Request;
class PostBigRequestTest extends \PHPUnit_Framework_TestCase class PostBigRequestTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Plugin\PostBigRequest * @var PostBigRequest
*/ */
protected $_plugin; protected $plugin;
/** /**
* @var Solarium\Client * @var Client
*/ */
protected $_client; protected $client;
/** /**
* @var Solarium\Query\Select\Select * @var Query
*/ */
protected $query; protected $query;
public function setUp() public function setUp()
{ {
$this->_plugin = new \Solarium\Plugin\PostBigRequest(); $this->plugin = new PostBigRequest();
$this->_client = new \Solarium\Client\Client(); $this->client = new Client();
$this->_query = $this->_client->createSelect(); $this->query = $this->client->createSelect();
} }
public function testSetAndGetMaxQueryStringLength() public function testSetAndGetMaxQueryStringLength()
{ {
$this->_plugin->setMaxQueryStringLength(512); $this->plugin->setMaxQueryStringLength(512);
$this->assertEquals(512, $this->_plugin->getMaxQueryStringLength()); $this->assertEquals(512, $this->plugin->getMaxQueryStringLength());
} }
public function testPostCreateRequest() public function testPostCreateRequest()
...@@ -71,35 +75,35 @@ class PostBigRequestTest extends \PHPUnit_Framework_TestCase ...@@ -71,35 +75,35 @@ class PostBigRequestTest extends \PHPUnit_Framework_TestCase
$fq .= ' OR price:'.$i; $fq .= ' OR price:'.$i;
} }
$fq = substr($fq, 4); $fq = substr($fq, 4);
$this->_query->createFilterQuery('fq')->setQuery($fq); $this->query->createFilterQuery('fq')->setQuery($fq);
$requestOutput = $this->_client->createRequest($this->_query); $requestOutput = $this->client->createRequest($this->query);
$requestInput = clone $requestOutput; $requestInput = clone $requestOutput;
$this->_plugin->postCreateRequest($this->_query, $requestOutput); $this->plugin->postCreateRequest($this->query, $requestOutput);
$this->assertEquals(\Solarium\Client\Request::METHOD_GET, $requestInput->getMethod()); $this->assertEquals(Request::METHOD_GET, $requestInput->getMethod());
$this->assertEquals(\Solarium\Client\Request::METHOD_POST, $requestOutput->getMethod()); $this->assertEquals(Request::METHOD_POST, $requestOutput->getMethod());
$this->assertEquals($requestInput->getQueryString(), $requestOutput->getRawData()); $this->assertEquals($requestInput->getQueryString(), $requestOutput->getRawData());
$this->assertEquals('', $requestOutput->getQueryString()); $this->assertEquals('', $requestOutput->getQueryString());
} }
public function testPostCreateRequestUnalteredSmallRequest() public function testPostCreateRequestUnalteredSmallRequest()
{ {
$requestOutput = $this->_client->createRequest($this->_query); $requestOutput = $this->client->createRequest($this->query);
$requestInput = clone $requestOutput; $requestInput = clone $requestOutput;
$this->_plugin->postCreateRequest($this->_query, $requestOutput); $this->plugin->postCreateRequest($this->query, $requestOutput);
$this->assertEquals($requestInput, $requestOutput); $this->assertEquals($requestInput, $requestOutput);
} }
public function testPostCreateRequestUnalteredPostRequest() public function testPostCreateRequestUnalteredPostRequest()
{ {
$query = $this->_client->createUpdate(); $query = $this->client->createUpdate();
$query->addDeleteById(1); $query->addDeleteById(1);
$requestOutput = $this->_client->createRequest($query); $requestOutput = $this->client->createRequest($query);
$requestInput = clone $requestOutput; $requestInput = clone $requestOutput;
$this->_plugin->postCreateRequest($query, $requestOutput); $this->plugin->postCreateRequest($query, $requestOutput);
$this->assertEquals($requestInput, $requestOutput); $this->assertEquals($requestInput, $requestOutput);
} }
......
...@@ -30,75 +30,79 @@ ...@@ -30,75 +30,79 @@
*/ */
namespace Solarium\Tests\Plugin; namespace Solarium\Tests\Plugin;
use Solarium\QueryType\Select\Result\Document; use Solarium\Query\Select\Result\Document;
use Solarium\Query\Select\Query\Query;
use Solarium\Query\Select\Result\Result;
use Solarium\Core\Client\Client;
use Solarium\Plugin\PrefetchIterator;
class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var \Solarium\Plugin\PrefetchIterator * @var PrefetchIterator
*/ */
protected $_plugin; protected $plugin;
/** /**
* @var \Solarium\Client\Client * @var Client
*/ */
protected $_client; protected $client;
/** /**
* @var \Solarium\Query\Select\Select * @var Query
*/ */
protected $_query; protected $query;
public function setUp() public function setUp()
{ {
$this->_plugin = new \Solarium\Plugin\PrefetchIterator(); $this->plugin = new PrefetchIterator();
$this->_client = new \Solarium\Client\Client(); $this->client = new Client();
$this->_query = $this->_client->createSelect(); $this->query = $this->client->createSelect();
} }
public function testSetAndGetPrefetch() public function testSetAndGetPrefetch()
{ {
$this->_plugin->setPrefetch(120); $this->plugin->setPrefetch(120);
$this->assertEquals(120, $this->_plugin->getPrefetch()); $this->assertEquals(120, $this->plugin->getPrefetch());
} }
public function testSetAndGetQuery() public function testSetAndGetQuery()
{ {
$this->_plugin->setQuery($this->_query); $this->plugin->setQuery($this->query);
$this->assertEquals($this->_query, $this->_plugin->getQuery()); $this->assertEquals($this->query, $this->plugin->getQuery());
} }
public function testCount() public function testCount()
{ {
$result = $this->_getResult(); $result = $this->getResult();
$mockClient = $this->getMock('Solarium\Client\Client', array('execute')); $mockClient = $this->getMock('Solarium\Core\Client\Client', array('execute'));
$mockClient->expects($this->exactly(1))->method('execute')->will($this->returnValue($result)); $mockClient->expects($this->exactly(1))->method('execute')->will($this->returnValue($result));
$this->_plugin->init($mockClient, array()); $this->plugin->initPlugin($mockClient, array());
$this->_plugin->setQuery($this->_query); $this->plugin->setQuery($this->query);
$this->assertEquals(5, count($this->_plugin)); $this->assertEquals(5, count($this->plugin));
} }
public function testIteratorAndRewind() public function testIteratorAndRewind()
{ {
$result = $this->_getResult(); $result = $this->getResult();
$mockClient = $this->getMock('Solarium\Client\Client', array('execute')); $mockClient = $this->getMock('Solarium\Core\Client\Client', array('execute'));
$mockClient->expects($this->exactly(1))->method('execute')->will($this->returnValue($result)); $mockClient->expects($this->exactly(1))->method('execute')->will($this->returnValue($result));
$this->_plugin->init($mockClient, array()); $this->plugin->initPlugin($mockClient, array());
$this->_plugin->setQuery($this->_query); $this->plugin->setQuery($this->query);
$results1 = array(); $results1 = array();
foreach($this->_plugin as $doc) { foreach($this->plugin as $doc) {
$results1[] = $doc; $results1[] = $doc;
} }
// the second foreach will trigger a rewind, this time include keys // the second foreach will trigger a rewind, this time include keys
$results2 = array(); $results2 = array();
foreach($this->_plugin as $key => $doc) { foreach($this->plugin as $key => $doc) {
$results2[$key] = $doc; $results2[$key] = $doc;
} }
...@@ -106,7 +110,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase ...@@ -106,7 +110,7 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($result->getDocuments(), $results2); $this->assertEquals($result->getDocuments(), $results2);
} }
public function _getResult() public function getResult()
{ {
$numFound = 5; $numFound = 5;
...@@ -123,17 +127,17 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase ...@@ -123,17 +127,17 @@ class PrefetchIteratorTest extends \PHPUnit_Framework_TestCase
} }
class SelectDummy extends \Solarium\QueryType\Select\Result\Result class SelectDummy extends Result
{ {
protected $_parsed = true; protected $parsed = true;
public function __construct($status, $queryTime, $numfound, $docs, $components) public function __construct($status, $queryTime, $numfound, $docs, $components)
{ {
$this->_numfound = $numfound; $this->numfound = $numfound;
$this->_documents = $docs; $this->documents = $docs;
$this->_components = $components; $this->components = $components;
$this->_queryTime = $queryTime; $this->queryTime = $queryTime;
$this->_status = $status; $this->status = $status;
} }
} }
\ No newline at end of file
...@@ -29,44 +29,46 @@ ...@@ -29,44 +29,46 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\Query; namespace Solarium\Tests\Query\Analysis\Query;
use Solarium\Query\Analysis\Query\Document;
use Solarium\Core\Client\Client;
class DocumentTest extends \PHPUnit_Framework_TestCase class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Query\Analysis\Document * @var Document
*/ */
protected $_query; protected $query;
public function setUp() public function setUp()
{ {
$this->_query = new \Solarium\QueryType\Analysis\Query\Document; $this->query = new Document;
} }
public function testGetType() public function testGetType()
{ {
$this->assertEquals(\Solarium\Client\Client::QUERYTYPE_ANALYSIS_DOCUMENT, $this->_query->getType()); $this->assertEquals(Client::QUERY_ANALYSIS_DOCUMENT, $this->query->getType());
} }
public function testAddAndGetDocument() public function testAddAndGetDocument()
{ {
$doc = new \Solarium\QueryType\Update\Query\Document(array('id' => 1)); $doc = new Document(array('id' => 1));
$this->_query->addDocument($doc); $this->query->addDocument($doc);
$this->assertEquals( $this->assertEquals(
array($doc), array($doc),
$this->_query->getDocuments() $this->query->getDocuments()
); );
} }
public function testAddAndGetDocuments() public function testAddAndGetDocuments()
{ {
$doc1 = new \Solarium\QueryType\Update\Query\Document(array('id' => 1)); $doc1 = new Document(array('id' => 1));
$doc2 = new \Solarium\QueryType\Update\Query\Document(array('id' => 2)); $doc2 = new Document(array('id' => 2));
$this->_query->addDocuments(array($doc1, $doc2)); $this->query->addDocuments(array($doc1, $doc2));
$this->assertEquals( $this->assertEquals(
array($doc1, $doc2), array($doc1, $doc2),
$this->_query->getDocuments() $this->query->getDocuments()
); );
} }
......
...@@ -29,45 +29,47 @@ ...@@ -29,45 +29,47 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\Query; namespace Solarium\Tests\Query\Analysis\Query;
use Solarium\Query\Analysis\Query\Field;
use Solarium\Core\Client\Client;
class FieldTest extends \PHPUnit_Framework_TestCase class FieldTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Query\Analysis\Field * @var Field
*/ */
protected $_query; protected $query;
public function setUp() public function setUp()
{ {
$this->_query = new \Solarium\QueryType\Analysis\Query\Field; $this->query = new Field;
} }
public function testGetType() public function testGetType()
{ {
$this->assertEquals(\Solarium\Client\Client::QUERYTYPE_ANALYSIS_FIELD, $this->_query->getType()); $this->assertEquals(Client::QUERY_ANALYSIS_FIELD, $this->query->getType());
} }
public function testSetAndGetFieldValue() public function testSetAndGetFieldValue()
{ {
$data = 'testdata'; $data = 'testdata';
$this->_query->setFieldValue($data); $this->query->setFieldValue($data);
$this->assertEquals($data, $this->_query->getFieldValue()); $this->assertEquals($data, $this->query->getFieldValue());
} }
public function testSetAndGetFieldType() public function testSetAndGetFieldType()
{ {
$data = 'testdata'; $data = 'testdata';
$this->_query->setFieldType($data); $this->query->setFieldType($data);
$this->assertEquals($data, $this->_query->getFieldType()); $this->assertEquals($data, $this->query->getFieldType());
} }
public function testSetAndGetFieldName() public function testSetAndGetFieldName()
{ {
$data = 'testdata'; $data = 'testdata';
$this->_query->setFieldName($data); $this->query->setFieldName($data);
$this->assertEquals($data, $this->_query->getFieldName()); $this->assertEquals($data, $this->query->getFieldName());
} }
} }
\ No newline at end of file
...@@ -29,42 +29,43 @@ ...@@ -29,42 +29,43 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\Query; namespace Solarium\Tests\Query\Analysis\Query;
use Solarium\Query\Analysis\Query\Query;
class QueryTest extends \PHPUnit_Framework_TestCase class QueryTest extends \PHPUnit_Framework_TestCase
{ {
protected $_query; protected $query;
public function setUp() public function setUp()
{ {
$this->_query = new TestAnalysisQuery; $this->query = new TestAnalysisQuery;
} }
public function testSetAndGetQuery() public function testSetAndGetQuery()
{ {
$querystring = 'test query values'; $querystring = 'test query values';
$this->_query->setQuery($querystring); $this->query->setQuery($querystring);
$this->assertEquals($querystring, $this->_query->getQuery()); $this->assertEquals($querystring, $this->query->getQuery());
} }
public function testSetAndGetQueryWithBind() public function testSetAndGetQueryWithBind()
{ {
$this->_query->setQuery('id:%1%', array(678)); $this->query->setQuery('id:%1%', array(678));
$this->assertEquals('id:678', $this->_query->getQuery()); $this->assertEquals('id:678', $this->query->getQuery());
} }
public function testSetAndGetShowMatch() public function testSetAndGetShowMatch()
{ {
$show = true; $show = true;
$this->_query->setShowMatch($show); $this->query->setShowMatch($show);
$this->assertEquals($show, $this->_query->getShowMatch()); $this->assertEquals($show, $this->query->getShowMatch());
} }
} }
class TestAnalysisQuery extends \Solarium\QueryType\Analysis\Query\Query{ class TestAnalysisQuery extends Query{
public function getType() public function getType()
{ {
......
...@@ -29,48 +29,52 @@ ...@@ -29,48 +29,52 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\RequestBuilder; namespace Solarium\Tests\Query\Analysis\RequestBuilder;
use Solarium\Query\Analysis\Query\Document;
use Solarium\Query\Analysis\RequestBuilder\Document as DocumentBuilder;
use Solarium\Core\Client\Request;
use Solarium\Query\Update\Query\Document as InputDocument;
class DocumentTest extends \PHPUnit_Framework_TestCase class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Query\Analysis\Document * @var Document
*/ */
protected $_query; protected $query;
/** /**
* @var Solarium\Client\RequestBuilder\Analysis\Document * @var DocumentBuilder
*/ */
protected $_builder; protected $builder;
public function setUp() public function setUp()
{ {
$this->_query = new \Solarium\QueryType\Analysis\Query\Document(); $this->query = new Document();
$this->_builder = new \Solarium\QueryType\Analysis\RequestBuilder\Document; $this->builder = new DocumentBuilder();
} }
public function testBuild() public function testBuild()
{ {
$request = $this->_builder->build($this->_query); $request = $this->builder->build($this->query);
$this->assertEquals(\Solarium\Client\Request::METHOD_POST, $request->getMethod()); $this->assertEquals(Request::METHOD_POST, $request->getMethod());
$this->assertEquals($this->_builder->getRawData($this->_query), $request->getRawData()); $this->assertEquals($this->builder->getRawData($this->query), $request->getRawData());
} }
public function testGetRawData() public function testGetRawData()
{ {
// this doc tests data escaping // this doc tests data escaping
$doc1 = new \Solarium\QueryType\Update\Query\Document(array('id' => 1, 'name' => 'doc1', 'cat' => 'my > cat')); $doc1 = new InputDocument(array('id' => 1, 'name' => 'doc1', 'cat' => 'my > cat'));
// this doc tests a multivalue field // this doc tests a multivalue field
$doc2 = new \Solarium\QueryType\Update\Query\Document(array('id' => 2, 'name' => 'doc2', 'cat' => array(1,2,3))); $doc2 = new InputDocument(array('id' => 2, 'name' => 'doc2', 'cat' => array(1,2,3)));
$this->_query->addDocuments(array($doc1, $doc2)); $this->query->addDocuments(array($doc1, $doc2));
$this->assertEquals( $this->assertEquals(
'<docs><doc><field name="id">1</field><field name="name">doc1</field><field name="cat">my &gt; cat</field></doc><doc><field name="id">2</field><field name="name">doc2</field><field name="cat">1</field><field name="cat">2</field><field name="cat">3</field></doc></docs>', '<docs><doc><field name="id">1</field><field name="name">doc1</field><field name="cat">my &gt; cat</field></doc><doc><field name="id">2</field><field name="name">doc2</field><field name="cat">1</field><field name="cat">2</field><field name="cat">3</field></doc></docs>',
$this->_builder->getRawData($this->_query) $this->builder->getRawData($this->query)
); );
} }
......
...@@ -29,25 +29,27 @@ ...@@ -29,25 +29,27 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\RequestBuilder; namespace Solarium\Tests\Query\Analysis\RequestBuilder;
use Solarium\Query\Analysis\Query\Field as FieldQuery;
use Solarium\Query\Analysis\RequestBuilder\Field as FieldBuilder;
class FieldTest extends \PHPUnit_Framework_TestCase class FieldTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Query\Analysis\Field * @var FieldQuery
*/ */
protected $_query; protected $query;
/** /**
* @var Solarium\Client\RequestBuilder\Analysis\Field * @var FieldBuilder
*/ */
protected $_builder; protected $builder;
public function setUp() public function setUp()
{ {
$this->_query = new \Solarium\QueryType\Analysis\Query\Field(); $this->query = new FieldQuery();
$this->_builder = new \Solarium\QueryType\Analysis\RequestBuilder\Field; $this->builder = new FieldBuilder();
} }
public function testBuild() public function testBuild()
...@@ -56,11 +58,11 @@ class FieldTest extends \PHPUnit_Framework_TestCase ...@@ -56,11 +58,11 @@ class FieldTest extends \PHPUnit_Framework_TestCase
$fieldName = 'myfield'; $fieldName = 'myfield';
$fieldType = 'text'; $fieldType = 'text';
$this->_query->setFieldValue($fieldValue) $this->query->setFieldValue($fieldValue)
->setFieldName($fieldName) ->setFieldName($fieldName)
->setFieldType($fieldType); ->setFieldType($fieldType);
$request = $this->_builder->build($this->_query); $request = $this->builder->build($this->query);
$this->assertEquals($fieldValue, $request->getParam('analysis.fieldvalue')); $this->assertEquals($fieldValue, $request->getParam('analysis.fieldvalue'));
$this->assertEquals($fieldName, $request->getParam('analysis.fieldname')); $this->assertEquals($fieldName, $request->getParam('analysis.fieldname'));
......
...@@ -29,25 +29,27 @@ ...@@ -29,25 +29,27 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\RequestBuilder; namespace Solarium\Tests\Query\Analysis\RequestBuilder;
use Solarium\Query\Analysis\Query\Field;
use Solarium\Query\Analysis\RequestBuilder\RequestBuilder;
class RequestBuilderTest extends \PHPUnit_Framework_TestCase class RequestBuilderTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Query\Analysis\Field * @var Field
*/ */
protected $_query; protected $query;
/** /**
* @var Solarium\Client\RequestBuilder\Analysis\Analysis * @var RequestBuilder
*/ */
protected $_builder; protected $builder;
public function setUp() public function setUp()
{ {
$this->_query = new \Solarium\QueryType\Analysis\Query\Field(); $this->query = new Field();
$this->_builder = new \Solarium\QueryType\Analysis\RequestBuilder\RequestBuilder(); $this->builder = new RequestBuilder();
} }
public function testBuild() public function testBuild()
...@@ -56,10 +58,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase ...@@ -56,10 +58,10 @@ class RequestBuilderTest extends \PHPUnit_Framework_TestCase
$showMatch = true; $showMatch = true;
$handler = 'myhandler'; $handler = 'myhandler';
$this->_query->setQuery($query) $this->query->setQuery($query)
->setShowMatch($showMatch) ->setShowMatch($showMatch)
->setHandler($handler); ->setHandler($handler);
$request = $this->_builder->build($this->_query); $request = $this->builder->build($this->query);
$this->assertEquals( $this->assertEquals(
array( array(
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\ResponseParser; namespace Solarium\Tests\Query\Analysis\ResponseParser;
class DocumentTest extends \PHPUnit_Framework_TestCase class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -47,14 +47,14 @@ class DocumentTest extends \PHPUnit_Framework_TestCase ...@@ -47,14 +47,14 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
) )
); );
$resultStub = $this->getMock('Solarium\Result\Result', array(), array(), '', false); $resultStub = $this->getMock('Solarium\Core\Query\Result\Result', array(), array(), '', false);
$resultStub->expects($this->once()) $resultStub->expects($this->once())
->method('getData') ->method('getData')
->will($this->returnValue($data)); ->will($this->returnValue($data));
$parserStub = $this->getMock('Solarium\QueryType\Analysis\ResponseParser\Document',array('_parseTypes')); $parserStub = $this->getMock('Solarium\Query\Analysis\ResponseParser\Document',array('parseTypes'));
$parserStub->expects($this->exactly(2)) $parserStub->expects($this->exactly(2))
->method('_parseTypes') ->method('parseTypes')
->will($this->returnValue('dummy')); ->will($this->returnValue('dummy'));
$result = $parserStub->parse($resultStub); $result = $parserStub->parse($resultStub);
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\ResponseParser; namespace Solarium\Tests\Query\Analysis\ResponseParser;
use Solarium\Query\Analysis\ResponseParser\Field as FieldParser;
class FieldTest extends \PHPUnit_Framework_TestCase class FieldTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -74,12 +75,12 @@ class FieldTest extends \PHPUnit_Framework_TestCase ...@@ -74,12 +75,12 @@ class FieldTest extends \PHPUnit_Framework_TestCase
) )
); );
$resultStub = $this->getMock('Solarium\Result\Result', array(), array(), '', false); $resultStub = $this->getMock('Solarium\Core\Query\Result\Result', array(), array(), '', false);
$resultStub->expects($this->once()) $resultStub->expects($this->once())
->method('getData') ->method('getData')
->will($this->returnValue($data)); ->will($this->returnValue($data));
$parser = new \Solarium\QueryType\Analysis\ResponseParser\Field(); $parser = new FieldParser();
$result = $parser->parse($resultStub); $result = $parser->parse($resultStub);
$docs = $result['items'][0]->getItems(); $docs = $result['items'][0]->getItems();
...@@ -101,12 +102,12 @@ class FieldTest extends \PHPUnit_Framework_TestCase ...@@ -101,12 +102,12 @@ class FieldTest extends \PHPUnit_Framework_TestCase
) )
); );
$resultStub = $this->getMock('Solarium\Result\Result', array(), array(), '', false); $resultStub = $this->getMock('Solarium\Core\Query\Result\Result', array(), array(), '', false);
$resultStub->expects($this->once()) $resultStub->expects($this->once())
->method('getData') ->method('getData')
->will($this->returnValue($data)); ->will($this->returnValue($data));
$parser = new \Solarium\QueryType\Analysis\ResponseParser\Field(); $parser = new FieldParser();
$result = $parser->parse($resultStub); $result = $parser->parse($resultStub);
$this->assertEquals( $this->assertEquals(
......
...@@ -29,50 +29,51 @@ ...@@ -29,50 +29,51 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\Result; namespace Solarium\Tests\Query\Analysis\Result;
use Solarium\Query\Analysis\Result\Document;
class DocumentTest extends \PHPUnit_Framework_TestCase class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Result\Analysis\Document * @var DocumentDummy
*/ */
protected $_result; protected $result;
protected $_items; protected $items;
public function setUp() public function setUp()
{ {
$this->_items = array('key1' => 'dummy1', 'key2' => 'dummy2', 'key3' => 'dummy3'); $this->items = array('key1' => 'dummy1', 'key2' => 'dummy2', 'key3' => 'dummy3');
$this->_result = new DocumentDummy(1, 12, $this->_items); $this->result = new DocumentDummy(1, 12, $this->items);
} }
public function testGetDocuments() public function testGetDocuments()
{ {
$this->assertEquals($this->_items, $this->_result->getDocuments()); $this->assertEquals($this->items, $this->result->getDocuments());
} }
public function testCount() public function testCount()
{ {
$this->assertEquals(count($this->_items), count($this->_result)); $this->assertEquals(count($this->items), count($this->result));
} }
public function testIterator() public function testIterator()
{ {
$docs = array(); $docs = array();
foreach($this->_result AS $key => $doc) foreach($this->result AS $key => $doc)
{ {
$docs[$key] = $doc; $docs[$key] = $doc;
} }
$this->assertEquals($this->_items, $docs); $this->assertEquals($this->items, $docs);
} }
public function testGetStatus() public function testGetStatus()
{ {
$this->assertEquals( $this->assertEquals(
1, 1,
$this->_result->getStatus() $this->result->getStatus()
); );
} }
...@@ -80,15 +81,15 @@ class DocumentTest extends \PHPUnit_Framework_TestCase ...@@ -80,15 +81,15 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
$this->assertEquals( $this->assertEquals(
12, 12,
$this->_result->getQueryTime() $this->result->getQueryTime()
); );
} }
public function testGetDocument() public function testGetDocument()
{ {
$this->assertEquals( $this->assertEquals(
$this->_items['key2'], $this->items['key2'],
$this->_result->getDocument('key2') $this->result->getDocument('key2')
); );
} }
...@@ -96,21 +97,21 @@ class DocumentTest extends \PHPUnit_Framework_TestCase ...@@ -96,21 +97,21 @@ class DocumentTest extends \PHPUnit_Framework_TestCase
{ {
$this->assertEquals( $this->assertEquals(
null, null,
$this->_result->getDocument('invalidkey') $this->result->getDocument('invalidkey')
); );
} }
} }
class DocumentDummy extends \Solarium\QueryType\Analysis\Result\Document class DocumentDummy extends Document
{ {
protected $_parsed = true; protected $parsed = true;
public function __construct($status, $queryTime, $items) public function __construct($status, $queryTime, $items)
{ {
$this->_items = $items; $this->items = $items;
$this->_queryTime = $queryTime; $this->queryTime = $queryTime;
$this->_status = $status; $this->status = $status;
} }
} }
\ No newline at end of file
...@@ -29,50 +29,51 @@ ...@@ -29,50 +29,51 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Analysis\Result; namespace Solarium\Tests\Query\Analysis\Result;
use Solarium\Query\Analysis\Result\Field;
class FieldTest extends \PHPUnit_Framework_TestCase class FieldTest extends \PHPUnit_Framework_TestCase
{ {
/** /**
* @var Solarium\Result\Analysis\Field * @var FieldDummy
*/ */
protected $_result; protected $result;
protected $_items; protected $items;
public function setUp() public function setUp()
{ {
$this->_items = array('key1' => 'dummy1', 'key2' => 'dummy2', 'key3' => 'dummy3'); $this->items = array('key1' => 'dummy1', 'key2' => 'dummy2', 'key3' => 'dummy3');
$this->_result = new FieldDummy(1, 12, $this->_items); $this->result = new FieldDummy(1, 12, $this->items);
} }
public function testGetLists() public function testGetLists()
{ {
$this->assertEquals($this->_items, $this->_result->getLists()); $this->assertEquals($this->items, $this->result->getLists());
} }
public function testCount() public function testCount()
{ {
$this->assertEquals(count($this->_items), count($this->_result)); $this->assertEquals(count($this->items), count($this->result));
} }
public function testIterator() public function testIterator()
{ {
$lists = array(); $lists = array();
foreach($this->_result AS $key => $list) foreach($this->result AS $key => $list)
{ {
$lists[$key] = $list; $lists[$key] = $list;
} }
$this->assertEquals($this->_items, $lists); $this->assertEquals($this->items, $lists);
} }
public function testGetStatus() public function testGetStatus()
{ {
$this->assertEquals( $this->assertEquals(
1, 1,
$this->_result->getStatus() $this->result->getStatus()
); );
} }
...@@ -80,21 +81,21 @@ class FieldTest extends \PHPUnit_Framework_TestCase ...@@ -80,21 +81,21 @@ class FieldTest extends \PHPUnit_Framework_TestCase
{ {
$this->assertEquals( $this->assertEquals(
12, 12,
$this->_result->getQueryTime() $this->result->getQueryTime()
); );
} }
} }
class FieldDummy extends \Solarium\QueryType\Analysis\Result\Field class FieldDummy extends Field
{ {
protected $_parsed = true; protected $parsed = true;
public function __construct($status, $queryTime, $items) public function __construct($status, $queryTime, $items)
{ {
$this->_items = $items; $this->items = $items;
$this->_queryTime = $queryTime; $this->queryTime = $queryTime;
$this->_status = $status; $this->status = $status;
} }
} }
\ No newline at end of file
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
namespace Solarium\Tests\QueryType\Select\Query\Component; namespace Solarium\Tests\Query\Select\Query\Component;
use Solarium\Query\Select\Query\Component\Component;
use Solarium\Query\Select\Query\Query;
class ComponentTest extends \PHPUnit_Framework_TestCase class ComponentTest extends \PHPUnit_Framework_TestCase
{ {
...@@ -42,7 +44,7 @@ class ComponentTest extends \PHPUnit_Framework_TestCase ...@@ -42,7 +44,7 @@ class ComponentTest extends \PHPUnit_Framework_TestCase
} }
class TestComponent extends \Solarium\QueryType\Select\Query\Component\Component{ class TestComponent extends Component{
protected $_type = 'testtype'; protected $type = 'testtype';
} }
\ 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