open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/EventSubscriber/UpdateChildNodePathSubscriberTest.php

Summary

Maintainability
A
1 hr
Test Coverage

Method testUpdatePath has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testUpdatePath()
    {
        $nodeId = 'node';
        $path = 'path';
        $parentNodeId = 'parent';

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

        $parent = 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 'testUpdatePath'.
Open

        $son3 = 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 'testUpdatePath'.
Open

        $node = 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 'testUpdatePath'.
Open

        $son1 = 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 'testUpdatePath'.
Open

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

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

        Phake::verify($this->eventDispatcher, Phake::times(4))->dispatch(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 'testUpdatePath'.
Open

        Phake::verify($this->eventDispatcher, Phake::times(4))->dispatch(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 'testUpdatePath'.
Open

        $son2 = 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 'testUpdatePath'.
Open

        $event = Phake::mock('OpenOrchestra\ModelInterface\Event\NodeEvent');

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

        $this->eventDispatcher = Phake::mock('Symfony\Component\EventDispatcher\EventDispatcher');

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

        Phake::when($this->nodeRepository)->findByNodeAndSite(Phake::anyParameters())->thenReturn(array($node));

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

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

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

Reference to constant NODE_MOVE from undeclared class \OpenOrchestra\ModelInterface\NodeEvents
Open

        $this->assertArrayHasKey(NodeEvents::NODE_MOVE, $this->subscriber->getSubscribedEvents());

Call to method when from undeclared class \Phake
Open

        Phake::when($son2)->getNodeId()->thenReturn($son2NodeId);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($son3)->setPath($parentPath . '/' . $nodeId . '/' . $son3NodeId);

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->eventDispatcher, Phake::times(4))->dispatch(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($parent)->getPath()->thenReturn($parentPath);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($son1)->setPath($parentPath . '/' . $nodeId . '/' . $son1NodeId);

Call to undeclared method \OpenOrchestra\Backoffice\Tests\EventSubscriber\UpdateChildNodePathSubscriberTest::assertArrayHasKey
Open

        $this->assertArrayHasKey(NodeEvents::NODE_MOVE, $this->subscriber->getSubscribedEvents());

Call to method when from undeclared class \Phake
Open

        Phake::when($parent)->getNodeId()->thenReturn($parentNodeId);

Call to method anyParameters from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->eventDispatcher, Phake::times(4))->dispatch(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $this->eventDispatcher = Phake::mock('Symfony\Component\EventDispatcher\EventDispatcher');

Call to method add from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

        $sons->add($son2);

Call to method anyParameters from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->findByNodeAndSite(Phake::anyParameters())->thenReturn(array($node));

Call to method when from undeclared class \Phake
Open

        Phake::when($this->nodeRepository)->findByNodeAndSite(Phake::anyParameters())->thenReturn(array($node));

Call to method mock from undeclared class \Phake
Open

        $event = Phake::mock('OpenOrchestra\ModelInterface\Event\NodeEvent');

Call to method when from undeclared class \Phake
Open

        Phake::when($node)->getNodeId()->thenReturn($nodeId);

Call to method when from undeclared class \Phake
Open

        Phake::when($son1)->getPath()->thenReturn($path.'/'.$son1NodeId);

Call to method __construct from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

        $sons = new ArrayCollection();

Call to undeclared method \OpenOrchestra\Backoffice\Tests\EventSubscriber\UpdateChildNodePathSubscriberTest::assertInstanceOf
Open

        $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->subscriber);

Call to method when from undeclared class \Phake
Open

        Phake::when($node)->getPath()->thenReturn($path);

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($son1)->getNodeId()->thenReturn($son1NodeId);

Call to method when from undeclared class \Phake
Open

        Phake::when($son3)->getNodeId()->thenReturn($son3NodeId);

Call to method add from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

        $sons->add($son1);

Call to method add from undeclared class \Doctrine\Common\Collections\ArrayCollection
Open

        $sons->add($son3);

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

class UpdateChildNodePathSubscriberTest extends AbstractBaseTestCase

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($son3)->getPath()->thenReturn($path.'/'.$son3NodeId);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($son2)->setPath($parentPath . '/' . $nodeId . '/' . $son2NodeId);

Call to method when from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->eventDispatcher, Phake::times(4))->dispatch(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($event)->getNode()->thenReturn($node);

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($son2)->getPath()->thenReturn($path.'/'.$son2NodeId);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->currentSiteManager)->getSiteId()->thenReturn($this->siteId);

Line exceeds 120 characters; contains 136 characters
Open

        $this->subscriber = new UpdateChildNodePathSubscriber($this->nodeRepository, $this->eventDispatcher, $this->currentSiteManager);

There are no issues that match your filters.

Category
Status