open-orchestra/open-orchestra-cms-bundle

View on GitHub
UserAdminBundle/Tests/Form/Type/UserTypeTest.php

Summary

Maintainability
C
7 hrs
Test Coverage

Method testResolver has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testResolver()
    {
        $this->form->configureOptions($this->resolver);
        Phake::verify($this->resolver)->setDefaults(array(
            'data_class' => $this->class,
Severity: Minor
Found in UserAdminBundle/Tests/Form/Type/UserTypeTest.php - About 1 hr to fix

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

            Phake::verify($this->builder, Phake::times(2))->addEventSubscriber(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 'testBuilder'.
Open

        Phake::verify($this->builder, Phake::times($nbrAdd))->add(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 'testResolver'.
Open

        Phake::verify($this->resolver)->setDefaults(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 'provideOptions'.
Open

        $site = Phake::mock('OpenOrchestra\UserBundle\Model\UserInterface');

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

        $userGroupSubscriber = Phake::mock(UserGroupsSubscriber::class);

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

        Phake::verify($this->builder, Phake::times($nbrAdd))->add(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

        $translator = Phake::mock('Symfony\Component\Translation\TranslatorInterface');

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

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

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

        $userProfilSubscriber = Phake::mock(UserProfilSubscriber::class);

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($authorizationChecker)->isGranted(Phake::anyParameters())->thenReturn(true);

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

            Phake::verify($this->builder, Phake::times(2))->addEventSubscriber(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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->builder, Phake::times($nbrAdd))->add(Phake::anyParameters());

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->resolver)->setDefaults(Phake::anyParameters());

Call to method times from undeclared class \Phake
Open

            Phake::verify($this->builder, Phake::times(2))->addEventSubscriber(Phake::anyParameters());

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->resolver)->setDefaults(array(

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($authorizationChecker)->isGranted(Phake::anyParameters())->thenReturn(true);

Call to method mock from undeclared class \Phake
Open

        $translator = Phake::mock('Symfony\Component\Translation\TranslatorInterface');

Call to method anyParameters from undeclared class \Phake
Open

            Phake::verify($this->builder, Phake::times(2))->addEventSubscriber(Phake::anyParameters());

Call to method verify from undeclared class \Phake
Open

            Phake::verify($this->builder, Phake::times(2))->addEventSubscriber(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($authorizationChecker)->isGranted(Phake::anyParameters())->thenReturn(true);

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->builder, Phake::times($nbrAdd))->add(Phake::anyParameters());

Call to method when from undeclared class \Phake
Open

        Phake::when($site)->getLanguageBySites()->thenReturn(array('en' => 'fakeLanguage', 'fr' => 'fakeLanguage'));

Call to method mock from undeclared class \Phake
Open

        $userProfilSubscriber = Phake::mock(UserProfilSubscriber::class);

Call to method mock from undeclared class \Phake
Open

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->builder, Phake::times($nbrAdd))->add(Phake::anyParameters());

Call to method mock from undeclared class \Phake
Open

        $site = Phake::mock('OpenOrchestra\UserBundle\Model\UserInterface');

Call to undeclared method \OpenOrchestra\UserAdminBundle\Tests\Form\Type\UserTypeTest::assertSame
Open

        $this->assertSame('oo_user', $this->form->getName());

Call to method mock from undeclared class \Phake
Open

        $userGroupSubscriber = Phake::mock(UserGroupsSubscriber::class);

Call to method anyParameters from undeclared class \Phake
Open

        Phake::verify($this->resolver)->setDefaults(Phake::anyParameters());

Identical blocks of code found in 2 locations. Consider refactoring.
Open

        Phake::verify($this->resolver)->setDefaults(array(
            'data_class' => $this->class,
            'edit_groups' => true,
            'self_editing' => false,
            'group_enabled' => true,
Severity: Major
Found in UserAdminBundle/Tests/Form/Type/UserTypeTest.php and 1 other location - About 5 hrs to fix
UserAdminBundle/Form/Type/UserType.php on lines 139..185

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 200.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Line exceeds 120 characters; contains 155 characters
Open

            'with_groups_edition' => array(array('edit_groups' => 'true', 'required_password' => false, 'self_editing' => true, 'data' => $site), false, 7)

Line exceeds 120 characters; contains 123 characters
Open

        $authorizationChecker = Phake::mock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface');

Line exceeds 120 characters; contains 143 characters
Open

        $this->form = new UserType($this->class, $parameters, $userProfilSubscriber, $userGroupSubscriber, $translator, $authorizationChecker);

Line exceeds 120 characters; contains 161 characters
Open

            'without_groups_edition' => array(array('edit_groups' => 'false', 'required_password' => false, 'self_editing' => false, 'data' => $site,), true, 6),

There are no issues that match your filters.

Category
Status