1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\ServerBundle\Tests\Functional; |
15
|
|
|
|
16
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
17
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
18
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
19
|
|
|
use Symfony\Component\Console\Input\StringInput; |
20
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
21
|
|
|
|
22
|
|
|
class DatabaseTestCase extends WebTestCase |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var Application |
26
|
|
|
*/ |
27
|
|
|
protected static $application; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var ManagerRegistry |
31
|
|
|
*/ |
32
|
|
|
protected static $registryManager; |
33
|
|
|
|
34
|
|
|
protected function setUp() |
35
|
|
|
{ |
36
|
|
|
self::bootKernel(); |
37
|
|
|
self::$application = new Application(static::$kernel); |
38
|
|
|
self::$application->setAutoExit(false); |
39
|
|
|
|
40
|
|
|
self::runCommand('doctrine:database:drop --force'); |
41
|
|
|
self::runCommand('doctrine:database:create'); |
42
|
|
|
self::runCommand('doctrine:schema:create'); |
43
|
|
|
self::runCommand('doctrine:fixtures:load --append --no-interaction'); |
44
|
|
|
|
45
|
|
|
self::$registryManager = self::$kernel->getContainer()->get('doctrine'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
protected static function runCommand(string $command, ?OutputInterface $output = null): void |
49
|
|
|
{ |
50
|
|
|
$command = sprintf('%s --quiet', $command); |
51
|
|
|
|
52
|
|
|
self::$application->run(new StringInput($command), $output); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
protected function tearDown() |
56
|
|
|
{ |
57
|
|
|
//self::runCommand('doctrine:database:drop --force'); |
|
|
|
|
58
|
|
|
parent::tearDown(); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.