Completed
Push — master ( e0017c...6b1304 )
by Tom
14s queued 11s
created

tests/DoctrineModuleTest/ModuleTest.php (6 issues)

calls to non-existent methods.

Bug Major

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModuleTest;
6
7
use DoctrineModule\Module;
8
use Laminas\Mvc\Application;
9
use Laminas\Mvc\MvcEvent;
10
use Laminas\ServiceManager\ServiceManager;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use function serialize;
15
use function unserialize;
16
17
/**
18
 * @covers \DoctrineModule\Module
19
 */
20
class ModuleTest extends TestCase
21
{
22
    /** @var PHPUnit_Framework_MockObject_MockObject|Application */
23
    private $application;
24
25
    /** @var PHPUnit_Framework_MockObject_MockObject|MvcEvent */
26
    private $event;
27
28
29
    /** @var PHPUnit_Framework_MockObject_MockObject|ServiceManager */
30
    private $serviceManager;
31
32
    /** @var PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Console\Application */
33
    private $cli;
34
35
    protected function setUp() : void
36
    {
37
        $this->application    = $this->getMockBuilder('Laminas\Mvc\Application')
38
            ->disableOriginalConstructor()
39
            ->getMock();
40
        $this->event          = $this->createMock('Laminas\Mvc\MvcEvent');
41
        $this->serviceManager = $this->createMock('Laminas\ServiceManager\ServiceManager');
42
        $this->cli            = $this->createPartialMock('Symfony\Component\Console\Application', ['run']);
43
44
        $this
45
            ->serviceManager
46
            ->expects($this->any())
0 ignored issues
show
The method any() does not seem to exist on object<DoctrineModuleTest\ModuleTest>.

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...
47
            ->method('get')
48
            ->with('doctrine.cli')
49
            ->will($this->returnValue($this->cli));
50
51
        $this
52
            ->application
53
            ->expects($this->any())
0 ignored issues
show
The method any() does not seem to exist on object<DoctrineModuleTest\ModuleTest>.

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...
54
            ->method('getServiceManager')
55
            ->will($this->returnValue($this->serviceManager));
56
57
        $this
58
            ->event
59
            ->expects($this->any())
0 ignored issues
show
The method any() does not seem to exist on object<DoctrineModuleTest\ModuleTest>.

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...
60
            ->method('getTarget')
61
            ->will($this->returnValue($this->application));
62
    }
63
64
    /**
65
     * @covers \DoctrineModule\Module::getConfig
66
     */
67
    public function testGetConfig() : void
68
    {
69
        $module = new Module();
70
71
        $config = $module->getConfig();
72
73
        $this->assertIsArray($config);
74
        $this->assertArrayHasKey('doctrine', $config);
75
        $this->assertArrayHasKey('doctrine_factories', $config);
76
        $this->assertArrayHasKey('service_manager', $config);
77
        $this->assertArrayHasKey('controllers', $config);
78
        $this->assertArrayHasKey('route_manager', $config);
79
        $this->assertArrayHasKey('console', $config);
80
81
        $this->assertSame($config, unserialize(serialize($config)));
82
    }
83
84
    /**
85
     * Should display the help message in plain message
86
     *
87
     * @covers \DoctrineModule\Module::getConsoleUsage
88
     */
89
    public function testGetConsoleUsage() : void
90
    {
91
        $this
0 ignored issues
show
The method expects() does not seem to exist on object<Symfony\Component\Console\Application>.

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...
92
            ->cli
93
            ->expects($this->once())
0 ignored issues
show
The method once() does not seem to exist on object<DoctrineModuleTest\ModuleTest>.

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...
94
            ->method('run')
95
            ->with(
96
                $this->isInstanceOf('Symfony\Component\Console\Input\InputInterface'),
97
                $this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface')
98
            )
99
            ->will($this->returnCallback(static function (InputInterface $input, OutputInterface $output) : void {
100
                $output->write($input->getFirstArgument() . ' - TEST');
101
                $output->write(' - More output');
102
            }));
103
104
        $module = new Module();
105
106
        $module->onBootstrap($this->event);
107
108
        $this->assertSame(
0 ignored issues
show
The method assertSame() does not seem to exist on object<DoctrineModuleTest\ModuleTest>.

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...
109
            'list - TEST - More output',
110
            $module->getConsoleUsage($this->createMock('Laminas\Console\Adapter\AdapterInterface'))
111
        );
112
    }
113
}
114