open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/Form/DataTransformer/ChoicesOptionToArrayTransformerTest.php

Summary

Maintainability
A
0 mins
Test Coverage

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

        $this->suppressSpecialCharacterHelper = Phake::mock('OpenOrchestra\ModelInterface\Helper\SuppressSpecialCharacterHelperInterface');

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 undeclared method \OpenOrchestra\Backoffice\Tests\Form\DataTransformer\ChoicesOptionToArrayTransformerTest::assertSame
Open

        $this->assertSame($transformData, $this->transformer->transform($data));

Call to undeclared method \OpenOrchestra\Backoffice\Tests\Form\DataTransformer\ChoicesOptionToArrayTransformerTest::assertInstanceOf
Open

        $this->assertInstanceOf('Symfony\Component\Form\DataTransformerInterface', $this->transformer);

Call to undeclared method \OpenOrchestra\Backoffice\Tests\Form\DataTransformer\ChoicesOptionToArrayTransformerTest::assertSame
Open

        $this->assertSame(null, $this->transformer->reverseTransform($data));

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('choice2', array('_','.'))->thenReturn('choice2');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('translate.choice_1', array('_','.'))->thenReturn('translate.choice_1');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('translate.choîce@=!_2', array('_','.'))->thenReturn('translate.choice_2');

Call to method mock from undeclared class \Phake
Open

        $this->suppressSpecialCharacterHelper = Phake::mock('OpenOrchestra\ModelInterface\Helper\SuppressSpecialCharacterHelperInterface');

Call to undeclared method \OpenOrchestra\Backoffice\Tests\Form\DataTransformer\ChoicesOptionToArrayTransformerTest::assertSame
Open

        $this->assertSame($transformData, $this->transformer->reverseTransform($data));

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

class ChoicesOptionToArrayTransformerTest extends AbstractBaseTestCase

Argument 1 (arrayChoices) is null but \OpenOrchestra\Backoffice\Form\DataTransformer\ChoicesOptionToArrayTransformer::transform() takes array defined at /code/Backoffice/Form/DataTransformer/ChoicesOptionToArrayTransformer.php:28
Open

        $this->assertSame('', $this->transformer->transform(null));

Call to undeclared method \OpenOrchestra\Backoffice\Tests\Form\DataTransformer\ChoicesOptionToArrayTransformerTest::assertSame
Open

        $this->assertSame('', $this->transformer->transform(null));

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('choice', array('_','.'))->thenReturn('choice');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('choîce@=!', array('_','.'))->thenReturn('choice');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('', array('_','.'))->thenReturn('');

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

    protected $suppressSpecialCharacterHelper;

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 142 characters
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('translate.choice_1', array('_','.'))->thenReturn('translate.choice_1');

Line exceeds 120 characters; contains 122 characters
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('choîce@=!', array('_','.'))->thenReturn('choice');

Line exceeds 120 characters; contains 146 characters
Open

        Phake::when($this->suppressSpecialCharacterHelper)->transform('translate.choîce@=!_2', array('_','.'))->thenReturn('translate.choice_2');

Line exceeds 120 characters; contains 139 characters
Open

        $this->suppressSpecialCharacterHelper = Phake::mock('OpenOrchestra\ModelInterface\Helper\SuppressSpecialCharacterHelperInterface');

Opening brace should be on a new line
Open

    public function testReverseTransformWithStringData($data, $transformData){

There are no issues that match your filters.

Category
Status