open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/BusinessRules/Strategies/NodeStrategyTest.php

Summary

Maintainability
A
0 mins
Test Coverage

The class NodeStrategyTest has 11 public methods. Consider refactoring NodeStrategyTest to keep number of public methods under 10.
Open

class NodeStrategyTest extends AbstractBaseTestCase
{
    protected $nodeRepository;
    protected $strategy;
    protected $mainUrlArguments = array(

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

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

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        Phake::when($this->nodeRepository)->countByParentId(Phake::anyParameters())->thenReturn($countByParentId);

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

        $block = 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 'testCanDelete'.
Open

        Phake::when($this->nodeRepository)->hasNodeIdWithoutAutoUnpublishToState(Phake::anyParameters())->thenReturn($isWithoutAutoUnpublishToState);

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

        $status1 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        Phake::when($this->nodeRepository)->countNotDeletedVersions(Phake::anyParameters())->thenReturn($nbrVersions);

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

        $status0 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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

        $status0 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        $status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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->generateFormManager = Phake::mock('OpenOrchestra\BackofficeBundle\StrategyManager\GenerateFormManager');

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

        $status1 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

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

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        $area = Phake::mock('OpenOrchestra\ModelInterface\Model\AreaInterface');

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

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

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

        Phake::when($this->generateFormManager)->getRequiredUriParameter(Phake::anyParameters())->thenReturn($this->mainUrlArguments);

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

        $this->generateFormManager = Phake::mock('OpenOrchestra\BackofficeBundle\StrategyManager\GenerateFormManager');

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getStatus()->thenReturn($status1);

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->countByParentId(Phake::anyParameters())->thenReturn($countByParentId);

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getNodeId()->thenReturn('fakeNodeId1');

Call to method mock from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest->generateFormManager
Open

        Phake::when($this->generateFormManager)->getRequiredUriParameter(Phake::anyParameters())->thenReturn($this->mainUrlArguments);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertSame
Open

        $this->assertSame($isGranted, $this->strategy->canDelete($node, array()));

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function testCanEdit(NodeInterface $node, $isGranted)

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertSame
Open

        $this->assertSame($isGranted, $this->strategy->canEdit($node, array()));

Call to method when from undeclared class \Phake
Open

        Phake::when($status0)->isBlockedEdition()->thenReturn(false);

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function testCanDelete(NodeInterface $node, $isWithoutAutoUnpublishToState, $countByParentId, $isGranted)

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getNodeId()->thenReturn(NodeInterface::ROOT_NODE_ID);

Call to method mock from undeclared class \Phake
Open

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getStatus()->thenReturn($status);

Reference to undeclared property \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest->generateFormManager
Open

        $this->strategy = new NodeStrategy($this->nodeRepository, $this->generateFormManager);

Call to method mock from undeclared class \Phake
Open

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getStatus()->thenReturn($status0);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->hasNodeIdWithoutAutoUnpublishToState(Phake::anyParameters())->thenReturn($isWithoutAutoUnpublishToState);

Call to method mock from undeclared class \Phake
Open

        $status0 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method mock from undeclared class \Phake
Open

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to method mock from undeclared class \Phake
Open

        $status1 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method mock from undeclared class \Phake
Open

        $status1 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getStatus()->thenReturn($status1);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->countByParentId(Phake::anyParameters())->thenReturn($countByParentId);

Call to method when from undeclared class \Phake
Open

        Phake::when($status1)->isPublishedState()->thenReturn(true);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertSame
Open

        $this->assertSame($isGranted, $this->strategy->canChangeStatus($node, array()));

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->hasNodeIdWithoutAutoUnpublishToState(Phake::anyParameters())->thenReturn($isWithoutAutoUnpublishToState);

Call to method mock from undeclared class \Phake
Open

        $area = Phake::mock('OpenOrchestra\ModelInterface\Model\AreaInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getRoutePattern()->thenReturn('');

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertEquals
Open

        $this->assertEquals(NodeInterface::ENTITY_TYPE, $this->strategy->getType());

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->countNotDeletedVersions(Phake::anyParameters())->thenReturn($nbrVersions);

Call to method when from undeclared class \Phake
Open

        Phake::when($status)->isPublishedState()->thenReturn(array(true));

Call to method mock from undeclared class \Phake
Open

        $status0 = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method mock from undeclared class \Phake
Open

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertSame
Open

        $this->assertSame($isGranted, $this->strategy->canChangeToPublishStatus($node, array()));

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function testCanChangeStatus(NodeInterface $node, $isGranted)

Call to method when from undeclared class \Phake
Open

        Phake::when($area)->getBlocks()->thenReturn(array($block));

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

        $this->assertEquals(NodeInterface::ENTITY_TYPE, $this->strategy->getType());

Call to method when from undeclared class \Phake
Open

        Phake::when($status1)->isBlockedEdition()->thenReturn(true);

Call to method when from undeclared class \Phake
Open

        Phake::when($status0)->isPublishedState()->thenReturn(false);

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getStatus()->thenReturn($status0);

Call to method mock from undeclared class \Phake
Open

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function testCanChangeToPublishStatus(NodeInterface $node, $isGranted)

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getAreas()->thenReturn(array($area));

Call to method when from undeclared class \Phake
Open

        Phake::when($node0)->getStatus()->thenReturn($status);

Call to method mock from undeclared class \Phake
Open

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Reference to undeclared property \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest->generateFormManager
Open

        $this->generateFormManager = Phake::mock('OpenOrchestra\BackofficeBundle\StrategyManager\GenerateFormManager');

Reference to constant ROOT_NODE_ID from undeclared class \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

        Phake::when($node0)->getNodeId()->thenReturn(NodeInterface::ROOT_NODE_ID);

Parameter $node has undeclared type \OpenOrchestra\ModelInterface\Model\NodeInterface
Open

    public function testCanDeleteVersion(NodeInterface $node, $nbrVersions, $isGranted)

Call to method when from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->countNotDeletedVersions(Phake::anyParameters())->thenReturn($nbrVersions);

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $node0 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to method mock from undeclared class \Phake
Open

        $node1 = Phake::mock('OpenOrchestra\ModelInterface\Model\NodeInterface');

Call to method mock from undeclared class \Phake
Open

        $status = Phake::mock('OpenOrchestra\ModelInterface\Model\StatusInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getAreas()->thenReturn(array($area));

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertEquals
Open

        $this->assertEquals(array(

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

class NodeStrategyTest extends AbstractBaseTestCase

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->generateFormManager)->getRequiredUriParameter(Phake::anyParameters())->thenReturn($this->mainUrlArguments);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->generateFormManager)->getRequiredUriParameter(Phake::anyParameters())->thenReturn($this->mainUrlArguments);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\BusinessRules\Strategies\NodeStrategyTest::assertSame
Open

        $this->assertSame($isGranted, $this->strategy->canDeleteVersion($node, array()));

Call to method when from undeclared class \Phake
Open

        Phake::when($node1)->getRoutePattern()->thenReturn(implode($mainUrlArguments));

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

    public function testCanDelete(NodeInterface $node, $isWithoutAutoUnpublishToState, $countByParentId, $isGranted)

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

        Phake::when($this->generateFormManager)->getRequiredUriParameter(Phake::anyParameters())->thenReturn($this->mainUrlArguments);

Line exceeds 120 characters; contains 149 characters
Open

        Phake::when($this->nodeRepository)->hasNodeIdWithoutAutoUnpublishToState(Phake::anyParameters())->thenReturn($isWithoutAutoUnpublishToState);

There are no issues that match your filters.

Category
Status