find() public method

{@inheritDoc}
public find ( ClassMetadata $class, $id, $options = [] )
$class Doctrine\Search\Mapping\ClassMetadata
Example #1
0
 public function testFind()
 {
     $index = $this->getMockBuilder('Elastica\\Index')->disableOriginalConstructor()->setMethods(array('getType'))->getMock();
     $result = $this->getMockBuilder('Elastica\\ResultSet')->disableOriginalConstructor()->getMock();
     $this->elasticaClient->expects($this->once())->method('getIndex')->with('comments')->will($this->returnValue($index));
     $type = $this->getMockBuilder('Elastica\\Type')->disableOriginalConstructor()->setMethods(array('getDocument'))->getMock();
     $index->expects($this->once())->method('getType')->with('comment')->will($this->returnValue($type));
     $document = $this->getMockBuilder('Elastica\\Document')->disableOriginalConstructor()->getMock();
     $type->expects($this->once())->method('getDocument')->with('123', array('foo' => 'bar'))->will($this->returnValue($document));
     $class = new ClassMetadata('Doctrine\\Tests\\Models\\Comments\\Comment');
     $class->index = 'comments';
     $class->type = 'comment';
     $this->assertSame($document, $this->client->find($class, '123', array('foo' => 'bar')));
 }