1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Abacaphiliac\DoctrineORMDiagnosticsModuleTest; |
4
|
|
|
|
5
|
|
|
use Abacaphiliac\DoctrineORMDiagnosticsModule\CheckCommand; |
6
|
|
|
use Abacaphiliac\DoctrineORMDiagnosticsModule\CheckOrm\CheckOrmInfoFactory; |
7
|
|
|
use Doctrine\ORM\Tools\Console\Command\InfoCommand; |
8
|
|
|
use Symfony\Component\Console\Application; |
9
|
|
|
use Zend\Console\Request; |
10
|
|
|
use Zend\ServiceManager\ServiceManager; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\CheckOrm\CheckOrmInfoFactory |
14
|
|
|
* @covers \Abacaphiliac\DoctrineORMDiagnosticsModule\AbstractCheckCommandFactory |
15
|
|
|
*/ |
16
|
|
View Code Duplication |
class CheckOrmInfoFactoryTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
/** @var Request */ |
19
|
|
|
private $request; |
20
|
|
|
|
21
|
|
|
/** @var \PHPUnit_Framework_MockObject_MockObject|InfoCommand */ |
22
|
|
|
private $command; |
23
|
|
|
|
24
|
|
|
/** @var ServiceManager */ |
25
|
|
|
private $serviceLocator; |
26
|
|
|
|
27
|
|
|
/** @var CheckOrmInfoFactory */ |
28
|
|
|
private $sut; |
29
|
|
|
|
30
|
|
|
protected function setUp() |
31
|
|
|
{ |
32
|
|
|
parent::setUp(); |
33
|
|
|
|
34
|
|
|
$this->serviceLocator = new ServiceManager(); |
35
|
|
|
|
36
|
|
|
$this->command = $this->getMockBuilder(InfoCommand::class) |
37
|
|
|
->disableOriginalConstructor() |
38
|
|
|
->getMock(); |
39
|
|
|
|
40
|
|
|
$this->request = new Request(); |
41
|
|
|
|
42
|
|
|
$this->sut = new CheckOrmInfoFactory(); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testCreateService() |
46
|
|
|
{ |
47
|
|
|
$this->serviceLocator->setService('doctrine.cli', new Application()); |
48
|
|
|
$this->serviceLocator->setService('doctrine.orm_cmd.info', $this->command); |
49
|
|
|
$this->serviceLocator->setService('Request', $this->request); |
50
|
|
|
|
51
|
|
|
$actual = $this->sut->createService($this->serviceLocator); |
52
|
|
|
|
53
|
|
|
self::assertInstanceOf(CheckCommand::class, $actual); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.