Commit 4af9b5d1 authored by Bas de Nooijer's avatar Bas de Nooijer

- unittest improvements

parent 151b7dc3
...@@ -358,7 +358,6 @@ class Solarium_Client extends Solarium_Configurable ...@@ -358,7 +358,6 @@ class Solarium_Client extends Solarium_Configurable
$request = $this->createRequest($query); $request = $this->createRequest($query);
$response = $this->executeRequest($request); $response = $this->executeRequest($request);
$result = $this->createResult($query, $response); $result = $this->createResult($query, $response);
$this->_callPlugins('postExecute', array($query, $result)); $this->_callPlugins('postExecute', array($query, $result));
...@@ -397,8 +396,7 @@ class Solarium_Client extends Solarium_Configurable ...@@ -397,8 +396,7 @@ class Solarium_Client extends Solarium_Configurable
* @see Solarium_Query_Ping * @see Solarium_Query_Ping
* *
* @internal This is a convenience method that forwards the query to the * @internal This is a convenience method that forwards the query to the
* adapter and returns the adapter result, thus allowing for an easy to use * execute method, thus allowing for an easy to use and clean API.
* and clean API.
* *
* @param Solarium_Query_Ping $query * @param Solarium_Query_Ping $query
* @return boolean * @return boolean
...@@ -423,8 +421,7 @@ class Solarium_Client extends Solarium_Configurable ...@@ -423,8 +421,7 @@ class Solarium_Client extends Solarium_Configurable
* @see Solarium_Result_Update * @see Solarium_Result_Update
* *
* @internal This is a convenience method that forwards the query to the * @internal This is a convenience method that forwards the query to the
* adapter and returns the adapter result, thus allowing for an easy to use * execute method, thus allowing for an easy to use and clean API.
* and clean API.
* *
* @param Solarium_Query_Update $query * @param Solarium_Query_Update $query
* @return Solarium_Result_Update * @return Solarium_Result_Update
...@@ -448,8 +445,7 @@ class Solarium_Client extends Solarium_Configurable ...@@ -448,8 +445,7 @@ class Solarium_Client extends Solarium_Configurable
* @see Solarium_Result_Select * @see Solarium_Result_Select
* *
* @internal This is a convenience method that forwards the query to the * @internal This is a convenience method that forwards the query to the
* adapter and returns the adapter result, thus allowing for an easy to use * execute method, thus allowing for an easy to use and clean API.
* and clean API.
* *
* @param Solarium_Query_Select $query * @param Solarium_Query_Select $query
* @return Solarium_Result_Select * @return Solarium_Result_Select
......
...@@ -75,7 +75,7 @@ class Solarium_Client_Request extends Solarium_Configurable ...@@ -75,7 +75,7 @@ class Solarium_Client_Request extends Solarium_Configurable
* *
* @var array * @var array
*/ */
protected $_params; protected $_params = array();
/** /**
* Raw POST data * Raw POST data
......
...@@ -56,7 +56,7 @@ class Solarium_Client_ResponseParser_Update extends Solarium_Client_ResponsePars ...@@ -56,7 +56,7 @@ class Solarium_Client_ResponseParser_Update extends Solarium_Client_ResponsePars
return array( return array(
'status' => $data['responseHeader']['status'], 'status' => $data['responseHeader']['status'],
'querytime' => $data['responseHeader']['QTime'], 'queryTime' => $data['responseHeader']['QTime'],
); );
} }
......
...@@ -72,6 +72,8 @@ class Solarium_Result_QueryType extends Solarium_Result ...@@ -72,6 +72,8 @@ class Solarium_Result_QueryType extends Solarium_Result
$responseParserClass = $queryTypes[$queryType]['responseparser']; $responseParserClass = $queryTypes[$queryType]['responseparser'];
$responseParser = new $responseParserClass; $responseParser = new $responseParserClass;
$this->_mapData($responseParser->parse($this)); $this->_mapData($responseParser->parse($this));
$this->_parsed = true;
} }
} }
......
...@@ -196,6 +196,6 @@ class Solarium_Result_Select extends Solarium_Result_QueryType ...@@ -196,6 +196,6 @@ class Solarium_Result_Select extends Solarium_Result_QueryType
*/ */
public function getFacetSet() public function getFacetSet()
{ {
return $this->getComponent(Solarium_Query_Select::COMPONENT_HIGHLIGHTING); return $this->getComponent(Solarium_Query_Select::COMPONENT_FACETSET);
} }
} }
\ No newline at end of file
...@@ -47,7 +47,51 @@ ...@@ -47,7 +47,51 @@
* @package Solarium * @package Solarium
* @subpackage Result * @subpackage Result
*/ */
class Solarium_Result_Update extends Solarium_Result class Solarium_Result_Update extends Solarium_Result_QueryType
{ {
/**
* Status code returned by Solr
*
* @var int
*/
protected $_status;
/**
* Solr index queryTime
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @var int
*/
protected $_queryTime;
/**
* Get Solr status code
*
* This is not the HTTP status code! The normal value for success is 0.
*
* @return int
*/
public function getStatus()
{
$this->_parseResponse();
return $this->_status;
}
/**
* Get Solr query time
*
* This doesn't include things like the HTTP responsetime. Purely the Solr
* query execution time.
*
* @return int
*/
public function getQueryTime()
{
$this->_parseResponse();
return $this->_queryTime;
}
} }
\ No newline at end of file
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class Solarium_Client_RequestBuilder_Select_Component_DisMaxTest extends PHPUnit_Framework_TestCase
{
public function testBuild()
{
$builder = new Solarium_Client_RequestBuilder_Select_Component_DisMax;
$request = new Solarium_Client_Request();
$component = new Solarium_Query_Select_Component_DisMax();
$component->setQueryAlternative('test');
$component->setQueryFields('content,name');
$component->setMinimumMatch('75%');
$component->setPhraseFields('content,description');
$component->setPhraseSlop(1);
$component->setQueryPhraseSlop(2);
$component->setTie(0.5);
$component->setBoostQuery('cat:1');
$component->setBoostFunctions('functionX(price)');
$request = $builder->build($component, $request);
$this->assertEquals(
array(
'defType' => 'dismax',
'q.alt' => 'test',
'qf' => 'content,name',
'mm' => '75%',
'pf' => 'content,description',
'ps' => 1,
'qs' => 2,
'tie' => 0.5,
'bq' => 'cat:1',
'bf' => 'functionX(price)',
),
$request->getParams()
);
}
}
\ No newline at end of file
<?php
/**
* Copyright 2011 Bas de Nooijer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this listof conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are
* those of the authors and should not be interpreted as representing official
* policies, either expressed or implied, of the copyright holder.
*/
class Solarium_Client_RequestBuilder_Select_Component_FacetSetTest extends PHPUnit_Framework_TestCase
{
/**
* @var Solarium_Client_RequestBuilder_Select_Component_FacetSet
*/
protected $_builder;
/**
* @var Solarium_Client_Request
*/
protected $_request;
/**
* @var Solarium_Query_Select_Component_FacetSet();
*/
protected $_component;
public function setUp()
{
$this->_builder = new Solarium_Client_RequestBuilder_Select_Component_FacetSet;
$this->_request = new Solarium_Client_Request();
$this->_component = new Solarium_Query_Select_Component_FacetSet();
}
public function testBuildEmptyFacetSet()
{
$request = $this->_builder->build($this->_component, $this->_request);
$this->assertEquals(
array(),
$request->getParams()
);
}
public function testBuildWithFacets()
{
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Field(array('key' => 'f1', 'field' => 'owner')));
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Query(array('key' => 'f2', 'query' => 'category:23')));
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_MultiQuery(array('key' => 'f3', 'query' => array('f4' => array('query' => 'category:40')))));
$request = $this->_builder->build($this->_component, $this->_request);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'?facet=true&facet.field={!key=f1}owner&facet.query={!key=f2}category:23&facet.query={!key=f4}category:40',
urldecode($request->getUri())
);
}
public function testBuildWithRangeFacet()
{
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Range(
array(
'key' => 'f1',
'field' => 'price',
'start' => '1',
'end' => 100,
'gap' => 10,
'other' => 'all',
'include' => 'outer'
)
));
$request = $this->_builder->build($this->_component, $this->_request);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'?facet=true&facet.range={!key=f1}price&f.price.facet.range.start=1&f.price.facet.range.end=100&f.price.facet.range.gap=10&f.price.facet.range.other=all&f.price.facet.range.include=outer',
urldecode($request->getUri())
);
}
public function testBuildWithFacetsAndGlobalFacetSettings()
{
$this->_component->setMissing(true);
$this->_component->setLimit(10);
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Field(array('key' => 'f1', 'field' => 'owner')));
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_Query(array('key' => 'f2', 'query' => 'category:23')));
$this->_component->addFacet(new Solarium_Query_Select_Component_Facet_MultiQuery(array('key' => 'f3', 'query' => array('f4' =>array('query' => 'category:40')))));
$request = $this->_builder->build($this->_component, $this->_request);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'?facet=true&facet.missing=1&facet.limit=10&facet.field={!key=f1}owner&facet.query={!key=f2}category:23&facet.query={!key=f4}category:40',
urldecode($request->getUri())
);
}
public function testBuildUnknownFacetType()
{
$this->_component->addFacet(new UnknownFacet(array('key' => 'f1', 'field' => 'owner')));
$this->setExpectedException('Solarium_Exception');
$request = $this->_builder->build($this->_component, $this->_request);
$request->getUri();
}
}
class UnknownFacet extends Solarium_Query_Select_Component_Facet_Field{
public function getType()
{
return 'unknown';
}
}
\ No newline at end of file
...@@ -108,87 +108,4 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa ...@@ -108,87 +108,4 @@ class Solarium_Client_RequestBuilder_SelectTest extends PHPUnit_Framework_TestCa
); );
} }
public function testSelectUrlWithFacets()
{
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_Field(array('key' => 'f1', 'field' => 'owner')));
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_Query(array('key' => 'f2', 'query' => 'category:23')));
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_MultiQuery(array('key' => 'f3', 'query' => array('f4' => array('query' => 'category:40')))));
$request = $this->_builder->build($this->_query);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json&facet=true&facet.field={!key=f1}owner&facet.query={!key=f2}category:23&facet.query={!key=f4}category:40',
urldecode($request->getUri())
);
}
public function testSelectUrlWithRangeFacet()
{
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_Range(
array(
'key' => 'f1',
'field' => 'price',
'start' => '1',
'end' => 100,
'gap' => 10,
'other' => 'all',
'include' => 'outer'
)
));
$request = $this->_builder->build($this->_query);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json&facet=true&facet.range={!key=f1}price&f.price.facet.range.start=1&f.price.facet.range.end=100&f.price.facet.range.gap=10&f.price.facet.range.other=all&f.price.facet.range.include=outer',
urldecode($request->getUri())
);
}
public function testSelectUrlWithFacetsAndGlobalFacetSettings()
{
$this->_query->getFacetSet()->setMissing(true);
$this->_query->getFacetSet()->setLimit(10);
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_Field(array('key' => 'f1', 'field' => 'owner')));
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_Query(array('key' => 'f2', 'query' => 'category:23')));
$this->_query->getFacetSet()->addFacet(new Solarium_Query_Select_Component_Facet_MultiQuery(array('key' => 'f3', 'query' => array('f4' =>array('query' => 'category:40')))));
$request = $this->_builder->build($this->_query);
$this->assertEquals(
null,
$request->getRawData()
);
$this->assertEquals(
'select?q=*:*&start=0&rows=10&fl=*,score&wt=json&facet=true&facet.missing=1&facet.limit=10&facet.field={!key=f1}owner&facet.query={!key=f2}category:23&facet.query={!key=f4}category:40',
urldecode($request->getUri())
);
}
public function testUnknownFacetType()
{
$this->_query->getFacetSet()->addFacet(new UnknownFacet(array('key' => 'f1', 'field' => 'owner')));
$this->setExpectedException('Solarium_Exception');
$request = $this->_builder->build($this->_query);
$request->getUri();
}
}
class UnknownFacet extends Solarium_Query_Select_Component_Facet_Field{
public function getType()
{
return 'unknown';
}
} }
\ No newline at end of file
...@@ -100,6 +100,14 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase ...@@ -100,6 +100,14 @@ class Solarium_Client_RequestTest extends PHPUnit_Framework_TestCase
); );
} }
public function testGetInvalidParam()
{
$this->assertEquals(
null,
$this->_request->getParam('invalidname')
);
}
public function testAddParam() public function testAddParam()
{ {
$params = array( $params = array(
......
...@@ -99,6 +99,20 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase ...@@ -99,6 +99,20 @@ class Solarium_ClientTest extends PHPUnit_Framework_TestCase
); );
} }
public function testRegisterInvalidPlugin()
{
$this->setExpectedException('Solarium_Exception');
$this->_client->registerPlugin('testplugin','MyInvalidClientPlugin');
}
public function testGetInvalidPlugin()
{
$this->assertEquals(
null,
$this->_client->getPlugin('invalidplugin')
);
}
public function testRemoveAndGetPlugins() public function testRemoveAndGetPlugins()
{ {
$options = array('option1' => 1); $options = array('option1' => 1);
...@@ -205,3 +219,7 @@ class myConfig{ ...@@ -205,3 +219,7 @@ class myConfig{
class MyClientPlugin extends Solarium_Plugin_Abstract{ class MyClientPlugin extends Solarium_Plugin_Abstract{
} }
class MyInvalidClientPlugin{
}
\ No newline at end of file
...@@ -31,25 +31,70 @@ ...@@ -31,25 +31,70 @@
class Solarium_Result_QueryTypeTest extends PHPUnit_Framework_TestCase class Solarium_Result_QueryTypeTest extends PHPUnit_Framework_TestCase
{ {
/**
* @var Solarium_Result_QueryTypeDummy
*/
protected $_result;
public function testParseLazyLoading() public function setUp()
{ {
$client = new Solarium_Client;
$query = new Solarium_Query_Update;
$response = new Solarium_Client_Response('{"responseHeader":{"status":1,"QTime":12}}',array('HTTP 1.1 200 OK'));
$this->_result = new Solarium_Result_QueryTypeDummy($client, $query, $response);
} }
public function testParseResponse() public function testParseResponse()
{ {
$this->_result->parse();
$this->assertEquals(12, $this->_result->getVar('queryTime'));
$this->assertEquals(1, $this->_result->getVar('status'));
}
public function testParseLazyLoading()
{
$this->assertEquals(0,$this->_result->parseCount);
$this->_result->parse();
$this->assertEquals(1,$this->_result->parseCount);
$this->_result->parse();
$this->assertEquals(1,$this->_result->parseCount);
} }
public function testMapData() public function testMapData()
{ {
$this->_result->mapData(array('dummyvar' => 'dummyvalue'));
$this->assertEquals('dummyvalue',$this->_result->getVar('dummyvar'));
} }
} }
class TestQueryType extends Solarium_Result_QueryType class Solarium_Result_QueryTypeDummy extends Solarium_Result_QueryType
{ {
public $parseCount = 0;
public function parse()
{
$this->_parseResponse();
}
public function _mapData($data)
{
$this->parseCount++;
parent::_mapData($data);
}
public function mapData($data)
{
$this->_mapData($data);
}
public function getVar($name)
{
return $this->{'_'.$name};
}
} }
\ No newline at end of file
...@@ -29,34 +29,41 @@ ...@@ -29,34 +29,41 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest class Solarium_Result_SelectTest extends PHPUnit_Framework_TestCase
{ {
/*
protected $_result, $_docs, $_facets; /**
* @var Solarium_Result_Select
*/
protected $_result;
protected $_numFound, $_docs, $_components, $_facetSet, $_moreLikeThis, $_highlighting;
public function setUp() public function setUp()
{ {
$this->_numFound = 11;
$this->_docs = array( $this->_docs = array(
new Solarium_Document_ReadOnly(array('id'=>1,'name'=>'test1')), new Solarium_Document_ReadOnly(array('id'=>1,'title'=>'doc1')),
new Solarium_Document_ReadOnly(array('id'=>2,'name'=>'test2')), new Solarium_Document_ReadOnly(array('id'=>1,'title'=>'doc1')),
new Solarium_Document_ReadOnly(array('id'=>3,'name'=>'test3')),
); );
$this->_facets = array( $this->_facetSet = 'dummy-facetset-value';
'f1' => new Solarium_Result_Select_Facet_Field(array('a' => 14)), $this->_moreLikeThis = 'dummy-facetset-value';
'f2' => new Solarium_Result_Select_Facet_Field(array('b' => 5)), $this->_highlighting = 'dummy-highlighting-value';
);
$this->_components = array( $this->_components = array(
Solarium_Query_Select::COMPONENT_MORELIKETHIS => new Solarium_Result_Select_MoreLikeThis(array()) Solarium_Query_Select::COMPONENT_FACETSET => $this->_facetSet,
Solarium_Query_Select::COMPONENT_MORELIKETHIS => $this->_moreLikeThis,
Solarium_Query_Select::COMPONENT_HIGHLIGHTING => $this->_highlighting
); );
$this->_result = new Solarium_Result_Select(0,45,100, $this->_docs, $this->_facets, $this->_components); $this->_result = new Solarium_Result_SelectDummy($this->_numFound, $this->_docs, $this->_components);
} }
public function testGetNumFound() public function testGetNumFound()
{ {
$this->assertEquals(100, $this->_result->getNumFound()); $this->assertEquals($this->_numFound, $this->_result->getNumFound());
} }
public function testGetDocuments() public function testGetDocuments()
...@@ -64,24 +71,14 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest ...@@ -64,24 +71,14 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest
$this->assertEquals($this->_docs, $this->_result->getDocuments()); $this->assertEquals($this->_docs, $this->_result->getDocuments());
} }
public function testGetFacets() public function testGetFacetSet()
{ {
$this->assertEquals($this->_facets, $this->_result->getFacets()); $this->assertEquals($this->_facetSet, $this->_result->getFacetSet());
}
public function testGetFacetByKey()
{
$this->assertEquals($this->_facets['f2'], $this->_result->getFacet('f2'));
}
public function testGetFacetByInvalidKey()
{
$this->assertEquals(null, $this->_result->getFacet('f2123123'));
} }
public function testCount() public function testCount()
{ {
$this->assertEquals(3, count($this->_result)); $this->assertEquals(count($this->_docs), count($this->_result));
} }
public function testGetComponents() public function testGetComponents()
...@@ -113,6 +110,14 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest ...@@ -113,6 +110,14 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest
); );
} }
public function testGetHighlighting()
{
$this->assertEquals(
$this->_components[Solarium_Query_Select::COMPONENT_HIGHLIGHTING],
$this->_result->getHighlighting()
);
}
public function testIterator() public function testIterator()
{ {
$docs = array(); $docs = array();
...@@ -123,5 +128,19 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest ...@@ -123,5 +128,19 @@ class Solarium_Result_SelectTest extends Solarium_Result_QueryTypeTest
$this->assertEquals($this->_docs, $docs); $this->assertEquals($this->_docs, $docs);
} }
*/
}
class Solarium_Result_SelectDummy extends Solarium_Result_Select
{
protected $_parsed = true;
public function __construct($numfound, $docs, $components)
{
$this->_numfound = $numfound;
$this->_documents = $docs;
$this->_components = $components;
}
} }
\ No newline at end of file
...@@ -29,12 +29,45 @@ ...@@ -29,12 +29,45 @@
* policies, either expressed or implied, of the copyright holder. * policies, either expressed or implied, of the copyright holder.
*/ */
class Solarium_Result_UpdateTest extends Solarium_Result_QueryTypeTest class Solarium_Result_UpdateTest extends PHPUnit_Framework_TestCase
{ {
/**
* @var Solarium_Result_Update
*/
protected $_result;
public function setUp() public function setUp()
{ {
$this->_result = new Solarium_Result_UpdateDummy();
}
public function testGetStatus()
{
$this->assertEquals(
1,
$this->_result->getStatus()
);
}
public function testGetQueryTime()
{
$this->assertEquals(
12,
$this->_result->getQueryTime()
);
}
}
class Solarium_Result_UpdateDummy extends Solarium_Result_Update
{
protected $_parsed = true;
public function __construct()
{
$this->_status = 1;
$this->_queryTime = 12;
} }
} }
\ 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