Skip to content

Commit

Permalink
Added tests for hasFields()
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHash authored and leabaertschi committed Jan 8, 2014
1 parent 9fb43d5 commit a076c9c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changes.txt
Expand Up @@ -3,6 +3,9 @@ CHANGES
- Pass arguments to optimize as query
- Add refreshAll on Client

2013-12-07
- Added Result::hasFields() and Result::hasParam() methods for consistency with Document

2013-12-07
- Escape slash in Util::escapeTerm, as it is used for regexp from Elastic 0.90

Expand Down
15 changes: 15 additions & 0 deletions test/lib/Elastica/Test/ResultTest.php
Expand Up @@ -4,6 +4,7 @@

use Elastica\Client;
use Elastica\Document;
use Elastica\Result;
use Elastica\Type\Mapping;
use Elastica\Test\Base as BaseTest;

Expand Down Expand Up @@ -102,4 +103,18 @@ public function testGetTotalTimeReturnsExpectedResults()
'Total Time should be an integer'
);
}

public function testHasFields()
{
$result = new Result(array());
$this->assertFalse($result->hasFields());

$result = new Result(array('_source' => 'no fields'));
$this->assertFalse($result->hasFields());

$data = array('fields' => 'value set');
$result = new Result($data);
$this->assertTrue($result->hasFields());
$this->assertEquals($data, $result->getFields());
}
}

0 comments on commit a076c9c

Please sign in to comment.