1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jns\Bundle\XhprofBundle\Tests\DataCollector; |
4
|
|
|
|
5
|
|
|
use Jns\Bundle\XhprofBundle\DataCollector\XhprofCollector; |
6
|
|
|
|
7
|
|
|
class XhprofCollectorTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var XhprofCollector |
11
|
|
|
*/ |
12
|
|
|
private $collector; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var \Symfony\Component\DependencyInjection\ContainerInterface |
16
|
|
|
*/ |
17
|
|
|
private $container; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var \Doctrine\Common\Persistence\ManagerRegistry |
21
|
|
|
*/ |
22
|
|
|
private $doctrine; |
23
|
|
|
|
24
|
|
|
public function setUp() { |
25
|
|
|
parent::setUp(); |
26
|
|
|
$this->container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->disableOriginalConstructor()->getMock(); |
27
|
|
|
$this->doctrine = $this->getMock('Doctrine\Common\Persistence\ManagerRegistry'); |
28
|
|
|
$this->collector = new XhprofCollectorTestable($this->container, null, $this->doctrine); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @dataProvider data_createRun |
33
|
|
|
*/ |
34
|
|
|
public function test_createRun($enable_xhgui, $manager_class, $runs_class) { |
35
|
|
|
$this->container->method('get')->with('manager_registry')->will($this->returnValue($this->doctrine)); |
|
|
|
|
36
|
|
|
$this->container->method('getParameter')->will($this->returnValueMap(array( |
|
|
|
|
37
|
|
|
array('jns_xhprof.enable_xhgui', $enable_xhgui), |
38
|
|
|
array('jns_xhprof.entity_manager', 'entity_manager'), |
39
|
|
|
array('jns_xhprof.manager_registry', 'manager_registry'), |
40
|
|
|
))); |
41
|
|
|
$this->doctrine->method('getManager')->with('entity_manager')->will($this->returnValue(!$manager_class ?: $this->getMock($manager_class))); |
|
|
|
|
42
|
|
|
$xhprof_runs = $this->collector->createRun('serverName', 'uri'); |
|
|
|
|
43
|
|
|
$this->assertInstanceOf($runs_class, $xhprof_runs); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function data_createRun() { |
47
|
|
|
return array( |
48
|
|
|
array(false, null, '\XHProfRuns_Default'), |
49
|
|
|
array(true, '\Doctrine\ODM\MongoDB\DocumentManager', '\Jns\Bundle\XhprofBundle\Document\XhguiRuns'), |
50
|
|
|
array(true, '\Doctrine\ORM\EntityManager', '\Jns\Bundle\XhprofBundle\Entity\XhguiRuns'), |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
class XhprofCollectorTestable extends XhprofCollector |
56
|
|
|
{ |
57
|
|
|
public function createRun($serverName, $uri) { |
58
|
|
|
return parent::createRun($serverName, $uri); |
59
|
|
|
} |
60
|
|
|
} |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.