*/ /** * Provides base funcationality test for both Apache_Solr_Service and the * Apache_Solr_Service_Balancer classes. */ abstract class Apache_Solr_ServiceAbstractTest extends PHPUnit_Framework_TestCase { /** * Method that gets the appropriate instance for testing */ abstract public function getFixture(); /** * @dataProvider testEscapeDataProvider */ public function testEscape($input, $expectedOutput) { $fixture = $this->getFixture(); $this->assertEquals($expectedOutput, $fixture->escape($input)); } public function testEscapeDataProvider() { return array( array( "I should look the same", "I should look the same" ), array( "(There) are: ^lots \\ && of spec!al charaters", "\\(There\\) are\\: \\^lots \\\\ \\&& of spec\\!al charaters" ) ); } /** * @dataProvider testEscapePhraseDataProvider */ public function testEscapePhrase($input, $expectedOutput) { $fixture = $this->getFixture(); $this->assertEquals($expectedOutput, $fixture->escapePhrase($input)); } public function testEscapePhraseDataProvider() { return array( array( "I'm a simple phrase", "I'm a simple phrase" ), array( "I have \"phrase\" characters", 'I have \\"phrase\\" characters' ) ); } /** * @dataProvider testPhraseDataProvider */ public function testPhrase($input, $expectedOutput) { $fixture = $this->getFixture(); $this->assertEquals($expectedOutput, $fixture->phrase($input)); } public function testPhraseDataProvider() { return array( array( "I'm a simple phrase", '"I\'m a simple phrase"' ), array( "I have \"phrase\" characters", '"I have \\"phrase\\" characters"' ) ); } public function testGetCreateDocumentWithDefaultConstructor() { $fixture = $this->getFixture(); $this->assertTrue($fixture->getCreateDocuments()); } public function testSetCreateDocuments() { $fixture = $this->getFixture(); $fixture->setCreateDocuments(false); $this->assertFalse($fixture->getCreateDocuments()); } }