open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
A
1 hr
Test Coverage

Method provideEvent has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function provideEvent()
    {
        $formData0 = new ArrayCollection(array(
            'order0' => true,
            'order1' => true,

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

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

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

        $eventDispatcher = Phake::mock('Symfony\Component\EventDispatcher\EventDispatcherInterface');

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

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

Call to method when from undeclared class \Phake
Open

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

Possibly zero references to use statement for classlike/namespace FormEvent (\Symfony\Component\Form\FormEvent)
Open

use Symfony\Component\Form\FormEvent;

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

class SortableCollectionSubscriberTest extends AbstractBaseTestCase

Call to method when from undeclared class \Phake
Open

        Phake::when($config)->getModelTransformers()->thenReturn(array());

Call to method when from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $eventDispatcher = Phake::mock('Symfony\Component\EventDispatcher\EventDispatcherInterface');

Call to method getData from undeclared class \Symfony\Component\Form\Form
Open

        $newData = $form->getData();

Call to method when from undeclared class \Phake
Open

        Phake::when($config)->getEventDispatcher()->thenReturn($eventDispatcher);

Call to method mock from undeclared class \Phake
Open

        $config = Phake::mock('Symfony\Component\Form\FormConfigInterface');

Call to method setData from undeclared class \Symfony\Component\Form\Form
Open

        $form->setData($formData);

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

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

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

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

Call to undeclared method \OpenOrchestra\Backoffice\Tests\EventSubscriber\SortableCollectionSubscriberTest::assertEquals
Open

        $this->assertEquals($expectedOrder, array_keys($newData));

Call to method __construct from undeclared class \Symfony\Component\Form\Form
Open

        $form = new Form($config);

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

        $formData0 = new ArrayCollection(array(

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

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

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       $data1 = array(

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       ));

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       return array(

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       $expectedOrder = array(

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       );

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       );

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       );

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       );

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       $data0 = array(

Line indented incorrectly; expected at least 8 spaces, found 7
Open

       );

There are no issues that match your filters.

Category
Status