open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/Reference/Strategies/KeywordInContentTypeReferenceStrategyTest.php

Summary

Maintainability
A
1 hr
Test Coverage

Method provideEntityAndKeywords has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideEntityAndKeywords()
    {
        $nodeId = 'nodeId';
        $node = $this->createPhakeNode($nodeId);
        $contentId = 'contentId';

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

        $this->keywordRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\KeywordRepositoryInterface');

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 'provideEntityAndKeywords'.
Open

        $optionWithKeyword = Phake::Mock('OpenOrchestra\ModelInterface\Model\FieldOptionInterface');

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 'provideEntityAndKeywords'.
Open

        $fieldWithoutKeyword = Phake::mock('OpenOrchestra\ModelInterface\Model\FieldTypeInterface');

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 'provideEntityAndKeywords'.
Open

        $optionWithoutKeyword = Phake::Mock('OpenOrchestra\ModelInterface\Model\FieldOptionInterface');

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 'provideEntityAndKeywords'.
Open

        $fieldWithKeyword = Phake::mock('OpenOrchestra\ModelInterface\Model\FieldTypeInterface');

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 when from undeclared class \Phake
Open

        Phake::when($contentTypeWithoutKeyword)->getFields()->thenReturn(array($fieldWithoutKeyword));

Call to method when from undeclared class \Phake
Open

        Phake::when($fieldWithoutKeyword)->getOptions()->thenReturn(array($optionWithoutKeyword));

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

        parent::checkRemoveReferencesToEntity($entity, $entityId, $keywords, ContentTypeInterface::ENTITY_TYPE, $this->keywordRepository);

Call to method when from undeclared class \Phake
Open

        Phake::when($entity)->getKeywords()->thenReturn($keywords);

Call to method mock from undeclared class \Phake
Open

        $fieldWithoutKeyword = Phake::mock('OpenOrchestra\ModelInterface\Model\FieldTypeInterface');

Call to method mock from undeclared class \Phake
Open

        $fieldWithKeyword = Phake::mock('OpenOrchestra\ModelInterface\Model\FieldTypeInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($optionWithoutKeyword)->getValue()->thenReturn(array());

Call to method Mock from undeclared class \Phake
Open

        $optionWithoutKeyword = Phake::Mock('OpenOrchestra\ModelInterface\Model\FieldOptionInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($contentTypeWithKeyword)->getFields()->thenReturn(array($fieldWithoutKeyword, $fieldWithKeyword));

Call to method when from undeclared class \Phake
Open

        Phake::when($fieldWithKeyword)->getOptions()->thenReturn(array($optionWithoutKeyword, $optionWithKeyword));

Reference to constant ENTITY_TYPE from undeclared class \OpenOrchestra\ModelInterface\Model\ContentTypeInterface
Open

        parent::checkAddReferencesToEntity($entity, $entityId, $keywords, ContentTypeInterface::ENTITY_TYPE, $this->keywordRepository);

Call to method when from undeclared class \Phake
Open

        Phake::when($optionWithKeyword)->getValue()->thenReturn(array('keywords' => 'keyword AND fake'));

Call to method mock from undeclared class \Phake
Open

        $this->keywordRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\KeywordRepositoryInterface');

Call to method Mock from undeclared class \Phake
Open

        $optionWithKeyword = Phake::Mock('OpenOrchestra\ModelInterface\Model\FieldOptionInterface');

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

        $contentTypeWithoutKeyword = $this->createPhakeContentType($contentTypeWithoutKeywordId);

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

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

        $contentTypeWithKeyword = $this->createPhakeContentType($contentTypeWithKeywordId);

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

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

        $contentTypeWithoutKeywordId = 'contentTypeWithoutKeywordId';

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

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

        $contentTypeWithKeywordId = 'contentTypeWithKeywordId';

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

            'Content type with no keyword'   => array($contentTypeWithoutKeyword, $contentTypeWithoutKeywordId, array()),

Line exceeds 120 characters; contains 138 characters
Open

        parent::checkRemoveReferencesToEntity($entity, $entityId, $keywords, ContentTypeInterface::ENTITY_TYPE, $this->keywordRepository);

Line exceeds 120 characters; contains 136 characters
Open

            'Content type with one keyword'  => array($contentTypeWithKeyword, $contentTypeWithKeywordId, array($keywordId => $keyword))

Line exceeds 120 characters; contains 135 characters
Open

        parent::checkAddReferencesToEntity($entity, $entityId, $keywords, ContentTypeInterface::ENTITY_TYPE, $this->keywordRepository);

There are no issues that match your filters.

Category
Status