open-orchestra/open-orchestra-cms-bundle

View on GitHub
ApiBundle/Tests/Transformer/RedirectionCollectionTransformerTest.php

Summary

Maintainability
A
0 mins
Test Coverage

The method testReverseTransform uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn('ok');
            }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

Source https://phpmd.org/rules/cleancode.html#elseexpression

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facade1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facadeCollection1 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'setUp'.
Open

        $this->transformerManager = Phake::mock('OpenOrchestra\BaseApi\Transformer\TransformerManager');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'testReverseTransform'.
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facade3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facadeCollection3 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facadeCollection2 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'facadesProvider'.
Open

        $facade2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'testReverseTransform'.
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'setUp'.
Open

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Avoid using static access to class '\Phake' in method 'setUp'.
Open

        $this->redirectionTransformer = Phake::mock('OpenOrchestra\ApiBundle\Transformer\RedirectionTransformer');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

Source https://phpmd.org/rules/cleancode.html#staticaccess

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

        $facade1 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

Call to method mock from undeclared class \Phake
Open

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($facadeCollection2)->getRedirections()->thenReturn(array($facade1));

Call to method mock from undeclared class \Phake
Open

        $facadeCollection3 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

Saw an @param annotation for setCount, but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open

     * @param int              $setCount

Call to method when from undeclared class \Phake
Open

                Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn('ok');

Call to method when from undeclared class \Phake
Open

        Phake::when($facadeCollection3)->getRedirections()->thenReturn(array($facade1, $facade2, $facade3));

Saw an @param annotation for facade, but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open

     * @param FacadeInterface  $facade

Class extends undeclared class \OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractBaseTestCase
Open

class RedirectionCollectionTransformerTest extends AbstractBaseTestCase

Call to method mock from undeclared class \Phake
Open

        $this->transformerManager = Phake::mock('OpenOrchestra\BaseApi\Transformer\TransformerManager');

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($this->transformerManager)->get('redirection')->thenReturn($this->redirectionTransformer);

Call to undeclared method \OpenOrchestra\ApiBundle\Tests\Transformer\RedirectionCollectionTransformerTest::assertCount
Open

        $this->assertCount($expectedSize, $collection);

Call to method mock from undeclared class \Phake
Open

        $facade3 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

Call to method mock from undeclared class \Phake
Open

        $this->redirectionTransformer = Phake::mock('OpenOrchestra\ApiBundle\Transformer\RedirectionTransformer');

Call to method when from undeclared class \Phake
Open

        Phake::when($facadeCollection1)->getRedirections()->thenReturn(array());

Call to undeclared method \OpenOrchestra\ApiBundle\Transformer\RedirectionCollectionTransformer::setContext
Open

        $this->transformer->setContext($this->transformerManager);

Saw an @param annotation for searchCount, but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open

     * @param int              $searchCount

Call to method when from undeclared class \Phake
Open

                Phake::when($this->transformerManager)->reverseTransform('redirection', $facade)->thenReturn(null);

Call to method mock from undeclared class \Phake
Open

        $facade2 = Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionFacade');

Call with 2 arg(s) to \OpenOrchestra\ApiBundle\Transformer\RedirectionCollectionTransformer::__construct() which only takes 0 arg(s) defined at /code/ApiBundle/Transformer/RedirectionCollectionTransformer.php:13
Open

        $this->transformer = new RedirectionCollectionTransformer(

Saw an @param annotation for source, but it was not found in the param list of function testReverseTransform($facadeCollection, $withFirstTransfoNull, $transformationCount, $expectedSize)
Open

     * @param ContentInterface $source

Possibly zero references to use statement for classlike/namespace RedirectionCollectionFacade (\OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade)
Open

use OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade;

Call to method mock from undeclared class \Phake
Open

        $facadeCollection1 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

Call to method mock from undeclared class \Phake
Open

        $facadeCollection2 =  Phake::mock('OpenOrchestra\ApiBundle\Facade\RedirectionCollectionFacade');

Call to undeclared method \OpenOrchestra\ApiBundle\Tests\Transformer\RedirectionCollectionTransformerTest::assertSame
Open

        $this->assertSame('redirection_collection', $this->transformer->getName());

Avoid excessively long variable names like $redirectionTransformer. Keep variable name length under 20.
Open

    protected $redirectionTransformer;

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Line exceeds 120 characters; contains 127 characters
Open

        Phake::verify($this->transformerManager, Phake::times($transformationCount))->reverseTransform(Phake::anyParameters());

Line exceeds 120 characters; contains 123 characters
Open

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

There are no issues that match your filters.

Category
Status