FOSElasticaBundle/Tests/Elastica/ClientTest.php
2015-03-12 21:20:00 +11:00

44 lines
1.3 KiB
PHP

<?php
namespace FOS\ElasticaBundle\Tests\Client;
use Elastica\Request;
use Elastica\Transport\Null as NullTransport;
class ClientTest extends \PHPUnit_Framework_TestCase
{
public function testRequestsAreLogged()
{
$transport = new NullTransport();
$connection = $this->getMock('Elastica\Connection');
$connection->expects($this->any())->method('getTransportObject')->will($this->returnValue($transport));
$connection->expects($this->any())->method('toArray')->will($this->returnValue(array()));
$logger = $this->getMock('FOS\ElasticaBundle\Logger\ElasticaLogger');
$logger
->expects($this->once())
->method('logQuery')
->with(
'foo',
Request::GET,
$this->isType('array'),
$this->isType('float'),
$this->isType('array'),
$this->isType('array')
);
$client = $this->getMockBuilder('FOS\ElasticaBundle\Elastica\Client')
->setMethods(array('getConnection'))
->getMock();
$client->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
$client->setLogger($logger);
$response = $client->request('foo');
$this->assertInstanceOf('Elastica\Response', $response);
}
}