open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
1 hr
Test Coverage

Method testPreSetData has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testPreSetData($id, $edit, $new)
    {
        $choices = array(
            'default' => 'default',
            'full_page' => 'full_page',

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

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

        $this->form = Phake::mock('Symfony\Component\Form\FormBuilder');

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

        Phake::verify($this->event->getForm(), Phake::times($edit))->add('template', 'choice', array(

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->form)->add(Phake::anyParameters())->thenReturn($this->form);

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

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeTemplateSelection', 'form', array(

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->event = Phake::mock('Symfony\Component\Form\FormEvent');

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->nodeManager = Phake::mock('OpenOrchestra\Backoffice\Manager\NodeManager');

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

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeSource', 'oo_node_choice', array(

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

        Phake::verify($this->nodeManager, Phake::times($nbrCall))->hydrateNodeFromNodeId(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 'testPreSetData'.
Open

        Phake::when($this->form)->get(Phake::anyParameters())->thenReturn($this->form);

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

        Phake::verify($this->event->getForm(), Phake::times($new))->add('template', 'choice', array(

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

        $site = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteInterface');

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->templateManager = Phake::mock('OpenOrchestra\Backoffice\Manager\TemplateManager');

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

        Phake::verify($this->nodeManager, Phake::times($nbrCall))->hydrateNodeFromNodeId(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 'setUp'.
Open

        $this->contextManager = 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

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

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($this->form)->get(Phake::anyParameters())->thenReturn($this->form);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->templateManager)->getTemplateSetParameters()->thenReturn(array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->node)->getId()->thenReturn($id);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeSource', 'oo_node_choice', array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->form)->getData()->thenReturn($this->node);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('template', 'choice', array(

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

        $this->assertArrayHasKey(FormEvents::PRE_SUBMIT, $this->subscriber->getSubscribedEvents());

Reference to constant PRE_SET_DATA from undeclared class \Symfony\Component\Form\FormEvents
Open

        $this->assertArrayHasKey(FormEvents::PRE_SET_DATA, $this->subscriber->getSubscribedEvents());

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $this->templateManager = Phake::mock('OpenOrchestra\Backoffice\Manager\TemplateManager');

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeTemplateSelection', 'form', array(

Call to method mock from undeclared class \Phake
Open

        $this->event = Phake::mock('Symfony\Component\Form\FormEvent');

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($edit))->add('template', 'choice', array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->event)->getData()->thenReturn($data);

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeSource', 'oo_node_choice', array(

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('nodeTemplateSelection', 'form', array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->node)->getId()->thenReturn($id);

Call to method mock from undeclared class \Phake
Open

        $this->form = Phake::mock('Symfony\Component\Form\FormBuilder');

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($new))->add('template', 'choice', array(

Call to method mock from undeclared class \Phake
Open

        $site = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteInterface');

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

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

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

        $this->assertArrayHasKey(FormEvents::PRE_SET_DATA, $this->subscriber->getSubscribedEvents());

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->form)->get(Phake::anyParameters())->thenReturn($this->form);

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->form)->add(Phake::anyParameters())->thenReturn($this->form);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->nodeManager, Phake::times($nbrCall))->hydrateNodeFromNodeId(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($site)->getTemplateSet()->thenReturn($this->templateSet);

Call to method when from undeclared class \Phake
Open

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

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->event->getForm(), Phake::times($edit))->add('template', 'choice', array(

Reference to constant PRE_SUBMIT from undeclared class \Symfony\Component\Form\FormEvents
Open

        $this->assertArrayHasKey(FormEvents::PRE_SUBMIT, $this->subscriber->getSubscribedEvents());

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->nodeManager, Phake::times($nbrCall))->hydrateNodeFromNodeId(Phake::anyParameters());

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->nodeManager, Phake::times($nbrCall))->hydrateNodeFromNodeId(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($this->form)->add(Phake::anyParameters())->thenReturn($this->form);

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($this->event)->getForm()->thenReturn($this->form);

Call to method mock from undeclared class \Phake
Open

        $this->nodeManager = Phake::mock('OpenOrchestra\Backoffice\Manager\NodeManager');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->siteRepository)->findOneBySiteId($this->siteId)->thenReturn($site);

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

class NodeTemplateSelectionSubscriberTest extends AbstractBaseTestCase

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    public function testPreSubmit($data, $id, $nbrCall)

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $id. Configured minimum length is 3.
Open

    public function testPreSetData($id, $edit, $new)

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

There are no issues that match your filters.

Category
Status