Skip to content

Commit

Permalink
test Util::escapeTerm() in a query
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgalbu committed Aug 17, 2014
1 parent 07214ca commit 1f5c107
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/lib/Elastica/Test/Query/EscapeStringTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Elastica\Test\Query;

use Elastica\Document;
use Elastica\Index;
use Elastica\Type;
use Elastica\Util;
use Elastica\Query\QueryString;
use Elastica\Test\Base as BaseTest;

class EscapeStringTest extends BaseTest
{
public function testSearch()
{
$client = $this->_getClient();
$index = new Index($client, 'test');
$index->create(array(), true);
$index->getSettings()->setNumberOfReplicas(0);
//$index->getSettings()->setNumberOfShards(1);

$type = new Type($index, 'helloworld');

$doc = new Document(1, array(
'email' => 'test@test.com', 'username' => 'test 7/6 123', 'test' => array('2', '3', '5'))
);
$type->addDocument($doc);

// Refresh index
$index->refresh();

$queryString = new QueryString( Util::escapeTerm('test 7/6') );
$resultSet = $type->search($queryString);

$this->assertEquals(1, $resultSet->count());
}
}

0 comments on commit 1f5c107

Please sign in to comment.