/
DbalStatsCollectorTest.php
41 lines (33 loc) · 1.41 KB
/
DbalStatsCollectorTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Liuggio\StatsDClientBundle\Tests\StatsCollector;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
use Liuggio\StatsDClientBundle\StatsCollector\DbalStatsCollector;
use Liuggio\StatsDClientBundle\StatsCollector\StatsCollector;
use Liuggio\StatsDClientBundle\Model\StatsDataInterface;
class DbalStatsCollectorTest extends WebTestCase
{
public function mockStatsDFactory($compare)
{
$phpunit = $this;
$statsDFactory = $this->getMockBuilder('Liuggio\StatsDClientBundle\Service\StatsDataFactory')
->disableOriginalConstructor()
->setMethods(array('increment'))
->getMock();
$dataMock = $this->getMock('Liuggio\StatsDClientBundle\Model\StatsDataInterface');
$statsDFactory->expects($this->any())
->method('increment')
->will($this->returnCallback(function ($input) use ($phpunit, $compare, $dataMock) {
$phpunit->assertEquals($compare, $input);
return $dataMock;
}));
return $statsDFactory;
}
public function testCollect()
{
$c = new DbalStatsCollector('prefix', $this->mockStatsDFactory('prefix.select'));
$c->startQuery('select * from liuggio where me in (Rome)');
}
}