setUpBeforeClass()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 38
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 5
Bugs 1 Features 3
Metric Value
c 5
b 1
f 3
dl 0
loc 38
rs 8.8571
cc 1
eloc 35
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 18 and the first side effect is on line 4.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
namespace Tpg\ExtjsBundle\Tests\Command;
3
4
include_once(__DIR__ . '/../app/AppKernel.php');
5
6
use Doctrine\Bundle\MongoDBBundle\Command\CreateSchemaDoctrineODMCommand;
7
use Doctrine\Bundle\MongoDBBundle\Command\DropSchemaDoctrineODMCommand;
8
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
9
use Doctrine\Bundle\DoctrineBundle\Command\CreateDatabaseDoctrineCommand;
10
use Doctrine\Bundle\DoctrineBundle\Command\DropDatabaseDoctrineCommand;
11
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\CreateSchemaDoctrineCommand;
12
13
use Symfony\Bundle\FrameworkBundle\Console\Application;
14
use Symfony\Component\Console\Tester\CommandTester;
15
use Symfony\Component\Routing\Router;
16
use Tpg\ExtjsBundle\Command\GenerateRestControllerCommand;
17
18
class BaseTestGeneratedRestController extends WebTestCase {
19
    public static function setUpBeforeClass() {
20
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
21
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/CarController.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
22
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/OrderController.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
23
        $kernel = new \AppKernel('test', true);
24
        $app = new Application($kernel);
25
        $app->addCommands(array(
26
            new GenerateRestControllerCommand(),
27
        ));
28
        $kernel->boot();
29
        $command = $app->find('generate:rest:controller');
30
        $commandTester = new CommandTester($command);
31
        $commandTester->execute(array(
32
            'command' => $command->getName(),
33
            '--controller' => 'TestTestBundle:Order',
34
            '--entity' => 'TestTestBundle:Order',
35
            '--mongo' => true,
36
        ), array('interactive'=>false));
37
        $kernel->shutdown();
38
        $kernel = new \AppKernel('test', true);
39
        $app = new Application($kernel);
40
        $app->addCommands(array(
41
            new GenerateRestControllerCommand(),
42
        ));
43
        $kernel->boot();
44
        $command = $app->find('generate:rest:controller');
45
        $commandTester = new CommandTester($command);
46
        $commandTester->execute(array(
47
            'command' => $command->getName(),
48
            '--controller' => 'TestTestBundle:Car',
49
            '--entity' => 'TestTestBundle:Car'
50
        ), array('interactive'=>false));
51
        $kernel->shutdown();
52
        @unlink(__DIR__.'/../app/cache/test/appTestUrlGenerator.php.meta');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
53
        @unlink(__DIR__.'/../app/cache/test/appTestUrlGenerator.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
54
        @unlink(__DIR__.'/../app/cache/test/appTestUrlMatcher.php.meta');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
55
        @unlink(__DIR__.'/../app/cache/test/appTestUrlMatcher.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
56
    }
57
58
    public static function tearDownAfterClass() {
59
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
60
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/CarController.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
61
        @unlink(__DIR__.'/../Fixtures/Test/TestBundle/Controller/OrderController.php');
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
62
    }
63
}