2013-12-11 23:52:25 +01:00
|
|
|
<?php
|
|
|
|
|
2014-04-21 01:21:50 +02:00
|
|
|
namespace FOS\ElasticaBundle\Tests\Client;
|
2013-12-11 23:52:25 +01:00
|
|
|
|
|
|
|
use Elastica\Request;
|
|
|
|
use Elastica\Transport\Null as NullTransport;
|
|
|
|
|
2014-04-21 01:21:50 +02:00
|
|
|
class LoggingClientTest extends \PHPUnit_Framework_TestCase
|
2013-12-11 23:52:25 +01:00
|
|
|
{
|
|
|
|
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'),
|
2014-02-05 18:21:14 +01:00
|
|
|
$this->isType('array'),
|
2013-12-11 23:52:25 +01:00
|
|
|
$this->isType('array')
|
|
|
|
);
|
|
|
|
|
2014-04-21 01:21:50 +02:00
|
|
|
$client = $this->getMockBuilder('FOS\ElasticaBundle\Elastica\LoggingClient')
|
2013-12-11 23:52:25 +01:00
|
|
|
->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);
|
|
|
|
}
|
|
|
|
}
|