open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
1 hr
Test Coverage

Method setUp has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function setUp()
    {
        $siteAlias1 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');
        Phake::when($siteAlias1)->getDomain()->thenReturn($this->siteDomain1);
        $siteAlias2 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');
Severity: Minor
Found in Backoffice/Tests/EventSubscriber/SiteSubscriberTest.php - About 1 hr to fix

Avoid using static access to class '\Phake' in method 'setUp'.
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 'setUp'.
Open

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

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

        $siteAlias2 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');

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

        Phake::when($this->configNodeForm)->getOption(Phake::anyParameters())->thenReturn(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->formAlias = Phake::mock('Symfony\Component\Form\FormInterface');

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

        $siteAlias1 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');

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

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

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

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

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->configAliasForm)->getOption(Phake::anyParameters())->thenReturn(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->siteRepository)->findOneBySiteId(Phake::anyParameters())->thenReturn($site);

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->nodeRepository)->findOnePublished(Phake::anyParameters())->thenReturn($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 'setUp'.
Open

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

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

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

Call to method anyParameters from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->configNodeForm
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($this->formAlias)->getConfig()->thenReturn($this->configAliasForm);

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->event
Open

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

Call to method when from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

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

Call to method mock from undeclared class \Phake
Open

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

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

class SiteSubscriberTest extends AbstractBaseTestCase

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->configAliasForm)->getOption(Phake::anyParameters())->thenReturn(array(

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

        Phake::when($this->form)->get('aliasId')->thenReturn($this->formAlias);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->form)->get('nodeId')->thenReturn($this->formNode);

Call to method when from undeclared class \Phake
Open

        Phake::when($siteAlias1)->getDomain()->thenReturn($this->siteDomain1);

Call to method when from undeclared class \Phake
Open

        Phake::when($site)->getAliases()->thenReturn(array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->formNode)->getConfig()->thenReturn($this->configNodeForm);

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->nodeRepository (Did you mean expr->siteRepository)
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->event
Open

        Phake::when($this->event)->getData()->thenReturn(array('siteId' => 'fakeSiteId'));

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

                FormEvents::PRE_SUBMIT,

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->configNodeForm
Open

        Phake::when($this->configNodeForm)->getOption(Phake::anyParameters())->thenReturn(array());

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

        Phake::when($this->form)->get('nodeId')->thenReturn($this->formNode);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->configNodeForm)->getOption(Phake::anyParameters())->thenReturn(array());

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->nodeRepository (Did you mean expr->siteRepository)
Open

        $this->subscriber = new SiteSubscriber($this->siteRepository, $this->nodeRepository, array());

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

        Phake::verify($this->form)->add('aliasId', 'choice', array(

Call to method when from undeclared class \Phake
Open

        Phake::when($this->event)->getData()->thenReturn(array('siteId' => 'fakeSiteId'));

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

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

Call to method when from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $siteAlias2 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

        Phake::verify($this->form)->add('wildcard', 'collection', array(

Call to method mock from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->configNodeForm)->getOption(Phake::anyParameters())->thenReturn(array());

Call to method when from undeclared class \Phake
Open

        Phake::when($this->form)->get('aliasId')->thenReturn($this->formAlias);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->form)->add('aliasId', 'choice', array(

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->form)->add('nodeId', 'oo_node_choice', array(

Call to method when from undeclared class \Phake
Open

        Phake::when($siteAlias2)->getDomain()->thenReturn($this->siteDomain2);

Call to method when from undeclared class \Phake
Open

        Phake::when($node)->getRoutePattern()->thenReturn('/{contentId}');

Call to method when from undeclared class \Phake
Open

        Phake::when($this->configAliasForm)->getOption(Phake::anyParameters())->thenReturn(array(

Call to method mock from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->nodeRepository (Did you mean expr->siteRepository)
Open

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

Call to method mock from undeclared class \Phake
Open

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

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

        $this->assertArrayHasKey($eventName, $this->subscriber->getSubscribedEvents());

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

                FormEvents::POST_SET_DATA,

Call to method mock from undeclared class \Phake
Open

        $siteAlias1 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteAliasInterface');

Call to method mock from undeclared class \Phake
Open

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

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->event
Open

        $this->subscriber->preSubmit($this->event);

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->form
Open

        Phake::verify($this->form)->add('nodeId', 'oo_node_choice', array(

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->event
Open

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

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->form)->add('wildcard', 'collection', array(

Reference to undeclared property \OpenOrchestra\Backoffice\Tests\EventSubscriber\SiteSubscriberTest->configNodeForm
Open

        Phake::when($this->formNode)->getConfig()->thenReturn($this->configNodeForm);

Function closing brace must go on the next line following the body; found 1 blank lines before brace
Open

    }

There are no issues that match your filters.

Category
Status