open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
1 hr
Test Coverage

Method provideEntityAndNodes has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideEntityAndNodes()
    {
        $blockWithoutNodeId = 'blockWithoutNodeId';
        $blockWithoutNode = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');
        Phake::when($blockWithoutNode)->getAttributes()->thenReturn(array());

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

        $linkTag = Phake::mock('OpenOrchestra\BBcodeBundle\ElementNode\BBcodeElementNodeInterface');

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->bbcodeParser = Phake::mock('OpenOrchestra\BBcodeBundle\Parser\BBcodeParserInterface');

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

        $blockWithNode1 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

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->nodeRepository = Phake::mock('OpenOrchestra\ModelInterface\Repository\NodeRepositoryInterface');

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

        $blockWithNode3 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

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->currentSiteManager = Phake::mock('OpenOrchestra\Backoffice\Context\ContextBackOfficeInterface');

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

        Phake::when($this->bbcodeParser)->getElementByTagName(Phake::anyParameters())->thenReturn(

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

        Phake::when($this->bbcodeParser)->parse(Phake::anyParameters())->thenReturn($this->bbcodeParser);

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

        $blockWithoutNode = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

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

        Phake::verify($this->nodeRepository, Phake::times(count($nodes)))->updateUseReference(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 'provideEntityAndNodes'.
Open

        $blockWithNodeTinymce = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

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

        $blockWithNode2 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

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

        Phake::verify($this->nodeRepository, Phake::times(count($nodes)))->updateUseReference(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 unused parameters such as '$entityId'.
Open

    public function testAddReferencesToEntity($entity, $entityId, array $nodes)

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Call to method when from undeclared class \Phake
Open

        Phake::when($this->bbcodeParser)->parse(Phake::anyParameters())->thenReturn($this->bbcodeParser);

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode1)->getId()->thenReturn($blockWithNode1Id);

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode3)->getAttributes()

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

        parent::checkRemoveReferencesToEntity($entity, $entityId, $nodes, BlockInterface::ENTITY_TYPE, $this->nodeRepository);

Call to method mock from undeclared class \Phake
Open

        $blockWithoutNode = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

Call to method mock from undeclared class \Phake
Open

        $linkTag = Phake::mock('OpenOrchestra\BBcodeBundle\ElementNode\BBcodeElementNodeInterface');

Call to method mock from undeclared class \Phake
Open

        $blockWithNodeTinymce = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->nodeRepository, Phake::times(count($nodes)))->updateUseReference(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithoutNode)->getAttributes()->thenReturn(array());

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode1)->getAttributes()

Call to method mock from undeclared class \Phake
Open

        $blockWithNode2 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode2)->getAttributes()

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->bbcodeParser)->getElementByTagName(Phake::anyParameters())->thenReturn(

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->nodeRepository, Phake::times(count($nodes)))->updateUseReference(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

        $blockWithNode1 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode3)->getId()->thenReturn($blockWithNode3Id);

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNode2)->getId()->thenReturn($blockWithNode2Id);

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNodeTinymce)->getId()->thenReturn($blockWithNodeTinymceId);

Call to method mock from undeclared class \Phake
Open

        $this->currentSiteManager = Phake::mock('OpenOrchestra\Backoffice\Context\ContextBackOfficeInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->bbcodeParser)->getElementByTagName(Phake::anyParameters())->thenReturn(

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->nodeRepository, Phake::times(count($nodes)))->updateUseReference(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $this->bbcodeParser = Phake::mock('OpenOrchestra\BBcodeBundle\Parser\BBcodeParserInterface');

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->bbcodeParser)->parse(Phake::anyParameters())->thenReturn($this->bbcodeParser);

Call to method when from undeclared class \Phake
Open

        Phake::when($linkTag)->getAttribute()->thenReturn(array('link'=> '{"label":"link","site": {"siteId":"2","nodeId":"nodeId4"}}'));

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithoutNode)->getId()->thenReturn($blockWithoutNodeId);

Call to method mock from undeclared class \Phake
Open

        $blockWithNode3 = Phake::mock('OpenOrchestra\ModelInterface\Model\BlockInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($blockWithNodeTinymce)->getAttributes()->thenReturn(array($bbCodeWithLink));

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

        $blockWithNodeTinymceId = 'blockIdTinymce';

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

Expected 1 space after comma in function call; 2 found
Open

        $this->strategy = new NodeInBlockReferenceStrategy($this->currentSiteManager, $this->bbcodeParser,  $this->nodeRepository);

Line exceeds 120 characters; contains 126 characters
Open

        parent::checkRemoveReferencesToEntity($entity, $entityId, $nodes, BlockInterface::ENTITY_TYPE, $this->nodeRepository);

Line exceeds 120 characters; contains 131 characters
Open

        $this->strategy = new NodeInBlockReferenceStrategy($this->currentSiteManager, $this->bbcodeParser,  $this->nodeRepository);

Line exceeds 120 characters; contains 128 characters
Open

        $bbCodeWithLink = 'Some [b]String[b] with [link={"label":"link","site": {"siteId":"2","nodeId":"nodeId4"}}]link[/link]';

Line exceeds 120 characters; contains 136 characters
Open

        Phake::when($linkTag)->getAttribute()->thenReturn(array('link'=> '{"label":"link","site": {"siteId":"2","nodeId":"nodeId4"}}'));

Line exceeds 120 characters; contains 124 characters
Open

            'Block with node (tinymce)' => array($blockWithNodeTinymce, $blockWithNodeTinymceId, array($nodeId4 => $node4)),

Expected 0 spaces before closing bracket; newline found
Open

            ->thenReturn(array(

Expected 0 spaces before closing bracket; newline found
Open

            ->thenReturn(array(

Expected 0 spaces before closing bracket; newline found
Open

            ->thenReturn(array(

There are no issues that match your filters.

Category
Status