<?php require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '/../lib/SwiSolr.php'; SwiSolr::autoload('SolrConfiguration'); /** * Test class for Configuration. * Generated by PHPUnit on 2009-06-16 at 12:39:09. */ class ConfigurationTest extends PHPUnit_Framework_TestCase { /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { Configuration::reset(); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /**
<?php require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '/../lib/SwiSolr.php'; SwiSolr::autoload('SwiSolrQuery'); SwiSolr::autoload('SolrSimpleSearchField'); /** * Description of SwiSolrQueryTest * * @author developer */ class SwiSolrQueryTest extends PHPUnit_Framework_Testcase { private $queryString; function setUp() { $this->queryString = 'blog'; } /** * test successful initialization by string */ public function testInitilizationWithString() { $query = new SwiSolrQuery($this->queryString); $this->assertType('SolrQuery', $query); $this->assertType('SwiSolrQuery', $query); $this->assertEquals($this->queryString, $query->getQuery()); } /** * test successful initialization by SolrSearchField objects */
<?php require_once dirname(__FILE__) . '/lib/SwiSolr.php'; SwiSolr::autoload('SwiSolrQuery'); SwiSolr::autoload('SwiSolrSearchField'); SwiSolr::autoload('SolrSimpleSearchField'); $solr = SwiSolr::connect('http://127.0.0.1:9080/solr1'); // $solr = SwiSolr::connect(); /* first query with string */ // $query = new SwiSolrQuery("title:this^5.0 OR content:blog^1.0"); // $query->setFieldList(array('id', 'title', 'content', 'score')); // // $query->setRows(2); // print_r($solr); // $result = $solr->query($query); // // echo "<br />"; // echo 'found ' . $result->getNumFound() . ' documents total.' . "<br />\n"; // echo 'result set contains ' . count($result) . ' documents.' . "<br />\n"; // echo 'starting with document no. ' . $result->getStart() . '.' . "<br />\n"; // echo "<br />\n"; // // $hit = $result[0]; // // print_r($hit); // // /* second query */ // $query = new SwiSolrQuery(array( // new SolrSimpleSearchField('title', 'blog'), // new SolrSimpleSearchField('content', 'blog') // ));
<?php require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '/../lib/SwiSolr.php'; SwiSolr::autoload('SolrSimplePrioritySearchField'); /** * Description of SolrSimplePrioritySearchFieldTest * * @author developer */ class SolrSimplePrioritySearchFieldTest extends PHPUnit_Framework_Testcase { var $searchKeyword; function setUp() { $this->searchKeyword = "blog"; } function testSuccessfulInitialization() { $this->searchKeyword = 'blog'; $searchField = new SolrSimplePrioritySearchField($this->searchKeyword); $this->assertEquals($this->searchKeyword, $searchField->getKeyword()); } function testQueryBuildingAccordingToPriority() { $this->searchKeyword = 'blog'; $expecedQuery = 'title:blog^10.0 content:blog^1.0 '; $searchField = new SolrSimplePrioritySearchField($this->searchKeyword); $this->assertEquals($expecedQuery, $searchField->toQuery()); } }
<?php require_once 'PHPUnit/Framework.php'; require_once dirname(__FILE__) . '/../lib/SwiSolr.php'; SwiSolr::autoload('SolrCurrencyField'); /** * Description of SolrCurrencyFieldTest * * @author chowdhury ashabul yeameen * @since 28 May, 2009 */ class SolrCurrencyFieldTest extends PHPUnit_Framework_Testcase { private $fieldName; private $fieldValue; private $boost; function setUp() { $this->fieldName = 'fieldName'; $this->fieldValue = 123.12; $this->boost = 30.4; } /** * check if field initialization is successful with all valied * values and without boost value */ function testInitializationWithoutBoost() { // test without boost value $field = new SolrCurrencyField($this->fieldName, $this->fieldValue); // check if this is an instance of SolrField and has those values
public function __construct() { SwiSolr::autoload('SolrDocument'); SwiSolr::autoload('SolrConfiguration'); }