XhprofCollectorTestable::createRun()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 2
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));
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Symfony\Component...ion\ContainerInterface>.

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.

Loading history...
36
        $this->container->method('getParameter')->will($this->returnValueMap(array(
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Symfony\Component...ion\ContainerInterface>.

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.

Loading history...
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)));
0 ignored issues
show
Bug introduced by
The method method() does not seem to exist on object<Doctrine\Common\P...stence\ManagerRegistry>.

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.

Loading history...
42
        $xhprof_runs = $this->collector->createRun('serverName', 'uri');
0 ignored issues
show
Bug introduced by
The method createRun() cannot be called from this context as it is declared protected in class Jns\Bundle\XhprofBundle\...llector\XhprofCollector.

This check looks for access to methods that are not accessible from the current context.

If you need to make a method accessible to another context you can raise its visibility level in the defining class.

Loading history...
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
}