open-orchestra/open-orchestra-cms-bundle

View on GitHub
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php

Summary

Maintainability
F
3 days
Test Coverage

The class ContextBackOfficeManagerTest has 17 public methods. Consider refactoring ContextBackOfficeManagerTest to keep number of public methods under 10.
Open

class ContextBackOfficeManagerTest extends AbstractBaseTestCase
{
    /**
     * @var ContextBackOfficeManager
     */

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

ContextBackOfficeManagerTest has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class ContextBackOfficeManagerTest extends AbstractBaseTestCase
{
    /**
     * @var ContextBackOfficeManager
     */
Severity: Minor
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php - About 2 hrs to fix

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

        $this->token = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');

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

        $group1 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

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

        $user = Phake::mock('OpenOrchestra\UserBundle\Document\User');

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

        Phake::when($this->session)->get(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 'testGetSiteName'.
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_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 'testGetSiteDefaultLanguage'.
Open

        Phake::when($this->session)->get(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

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

        $site1 = 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 'testGetAvailableSites'.
Open

        $group2 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

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

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_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 'testGetSiteContributionLanguage'.
Open

        Phake::when($user)->getLanguageBySite(Phake::anyParameters())->thenReturn($userLocale);

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

        Phake::when($this->session)->get(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 'testGetSiteContributionLanguage'.
Open

        Phake::when($user)->hasLanguageBySite(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 'setUp'.
Open

        $this->session = Phake::mock('Symfony\Component\HttpFoundation\Session\Session');

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

        $user = 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 'testGetSiteContributionLanguage'.
Open

        $user = Phake::mock($userClass);

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

        $group3 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

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

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_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 'testGetSiteContributionLanguage'.
Open

        Phake::when($this->session)->get(Phake::anyParameters())->thenReturn(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

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

        $site2 = 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->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 'testGetBackOfficeLanguage'.
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_LOCALE);

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

        $site2 = 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 'testGetAvailableSitesWithSuperAdmin'.
Open

        $site1 = 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 'testGetSiteId'.
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_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

        $this->tokenStorage = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');

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

        Phake::when($this->session)->get(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 'testGetBackOfficeLanguageWhenNotInSession'.
Open

        $user = Phake::mock($userClass);

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->token)->getUser()->thenReturn($user);

Call to method when from undeclared class \Phake
Open

        Phake::when($group1)->getSite()->thenReturn($site1);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->siteRepository)->findByDeleted(false)->thenReturn(array($site1, $site2));

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals(array($site1, $site2), $this->contextManager->getAvailableSites());

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method when from undeclared class \Phake
Open

        Phake::when($user)->getLanguage()->thenReturn(null);

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->session)->get(Phake::anyParameters())->thenReturn(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

Call to method mock from undeclared class \Phake
Open

        $user = Phake::mock($userClass);

Call to method when from undeclared class \Phake
Open

        Phake::when($user)->getLanguageBySite(Phake::anyParameters())->thenReturn($userLocale);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getUser()->thenReturn($user);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals($domain, $this->contextManager->getSiteName());

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertSame
Open

        $this->assertSame($expectedLocale, $this->contextManager->getSiteContributionLanguage());

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_LOCALE);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals(array($site1, $site2), array_values($this->contextManager->getAvailableSites()));

Call to method when from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($user)->hasLanguageBySite(Phake::anyParameters())->thenReturn(true);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->session)->get(ContextBackOfficeInterface::KEY_LOCALE)->thenReturn($locale);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getUser()->thenReturn($user);

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertSame
Open

        $this->assertSame($this->defaultLocale, $this->contextManager->getBackOfficeLanguage());

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getUser()->thenReturn($user);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session)->set(ContextBackOfficeInterface::KEY_SITE, array(

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->token)->setAuthenticated(false);

Call to method mock from undeclared class \Phake
Open

        $user = Phake::mock('OpenOrchestra\UserBundle\Document\User');

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method when from undeclared class \Phake
Open

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

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals($languages, $this->contextManager->getSiteLanguages());

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($user)->getLanguageBySite(Phake::anyParameters())->thenReturn($userLocale);

Call to method mock from undeclared class \Phake
Open

        $this->session = Phake::mock('Symfony\Component\HttpFoundation\Session\Session');

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEmpty
Open

        $this->assertEmpty($this->contextManager->getAvailableSites());

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method when from undeclared class \Phake
Open

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

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

class ContextBackOfficeManagerTest extends AbstractBaseTestCase

Call to method when from undeclared class \Phake
Open

        Phake::when($this->tokenStorage)->getToken()->thenReturn($this->token);

Call to method mock from undeclared class \Phake
Open

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

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertSame
Open

        $this->assertSame($expectedLocale, $this->contextManager->getBackOfficeLanguage());

Call to method mock from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($this->authorizationChecker)->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)->thenReturn(true);

Call to method anyParameters from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

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

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals($domain, $this->contextManager->getSiteDefaultLanguage());

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_LOCALE);

Call to method mock from undeclared class \Phake
Open

        $group3 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

Call to method mock from undeclared class \Phake
Open

        $this->tokenStorage = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');

Call to method anyParameters from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

        $group1 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($site2)->getId()->thenReturn('id2');

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals($siteId, $this->contextManager->getSiteId());

Call to method anyParameters from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session)->remove(ContextBackOfficeInterface::KEY_LOCALE);

Call to method mock from undeclared class \Phake
Open

        $this->token = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');

Call to method mock from undeclared class \Phake
Open

        $user = Phake::mock($userClass);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getRoles()->thenReturn(array());

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session)->set(ContextBackOfficeInterface::KEY_LOCALE, $locale);

Call to method mock from undeclared class \Phake
Open

        $group2 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');

Call to method when from undeclared class \Phake
Open

        Phake::when($group3)->getSite()->thenReturn($site2);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getUser()->thenReturn(null);

Call to method when from undeclared class \Phake
Open

        Phake::when($this->token)->getRoles()->thenReturn(array());

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($site1)->getId()->thenReturn('id1');

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($group2)->getSite()->thenReturn($site2);

Call to method when from undeclared class \Phake
Open

        Phake::when($user)->getGroups()->thenReturn($groups);

Call to method mock from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($this->session)->get(Phake::anyParameters())->thenReturn(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

Call to undeclared method \OpenOrchestra\BackOffice\Tests\Context\ContextBackOfficeManagerTest::assertEquals
Open

        $this->assertEquals($locale, $localReturned);

Call to method when from undeclared class \Phake
Open

        Phake::when($user)->getLanguage()->thenReturn($userLocale);

Call to method mock from undeclared class \Phake
Open

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

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextBackOfficeInterface::KEY_SITE);

Call to method anyParameters from undeclared class \Phake
Open

        Phake::when($user)->hasLanguageBySite(Phake::anyParameters())->thenReturn(true);

Call to method verify from undeclared class \Phake
Open

        Phake::verify($this->session)->remove(ContextBackOfficeInterface::KEY_SITE);

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

    public function testGetAvailableSites()
    {
        $site1 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteInterface');
        Phake::when($site1)->getId()->thenReturn('id1');
        $group1 = Phake::mock('OpenOrchestra\Backoffice\Model\GroupInterface');
Severity: Major
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 1 day to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 138..158

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 293.

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

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

    public function testGetSiteContributionLanguage($expectedLocale, $userLocale, $userClass)
    {

        Phake::when($this->session)->get(Phake::anyParameters())->thenReturn(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

Severity: Major
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 4 hrs to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 339..351

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 176.

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

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

    public function setUp()
    {
        $this->token = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\TokenInterface');
        $this->tokenStorage = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');
        Phake::when($this->tokenStorage)->getToken()->thenReturn($this->token);
Severity: Major
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 3 hrs to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 30..43

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 154.

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

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

    public function testGetAvailableSitesWithSuperAdmin()
    {
        $site1 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteInterface');
        $site2 = Phake::mock('OpenOrchestra\ModelInterface\Model\SiteInterface');
        Phake::when($this->siteRepository)->findByDeleted(false)->thenReturn(array($site1, $site2));
Severity: Major
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 1 hr to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 177..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 120.

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

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

    public function testSetSite($site)
    {
        $this->contextManager->setSite($site['siteId'], $site['name'], $site['defaultLanguage'], $site['languages']);

        Phake::verify($this->session)->set(ContextBackOfficeInterface::KEY_SITE, array(
Severity: Major
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 1 hr to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 193..203

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 105.

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

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

    public function siteLanguagesProvider()
    {
        return array(
            array(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')), array('en')),
            array(array('siteId' => 'id', 'name' => 'name', 'defaultLanguage' => 'fr', 'languages' => array('en', 'de')), array('en', 'de')),
Severity: Minor
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 35 mins to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 323..329

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 92.

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

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

    public function testGetBackOfficeLanguage($locale)
    {
        Phake::when($this->session)->get(ContextBackOfficeInterface::KEY_LOCALE)->thenReturn($locale);

        $localReturned = $this->contextManager->getBackOfficeLanguage();
Severity: Minor
Found in Backoffice/Tests/Context/ContextBackOfficeManagerTest.php and 1 other location - About 30 mins to fix
Backoffice/Tests/Context/ContextManagerTest.php on lines 58..66

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 90.

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 128 characters
Open

            array(array('siteId' => 'id', 'name' => 'name', 'defaultLanguage' => 'en', 'languages' => array('fr', 'en', 'de'))),

Line exceeds 120 characters; contains 141 characters
Open

            array(array('siteId' => 'id', 'name' => 'name', 'defaultLanguage' => 'fr', 'languages' => array('en', 'de')), array('en', 'de')),

Line exceeds 120 characters; contains 128 characters
Open

        $this->tokenStorage = Phake::mock('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface');

Line exceeds 120 characters; contains 129 characters
Open

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

Line exceeds 120 characters; contains 183 characters
Open

        Phake::when($this->session)->get(Phake::anyParameters())->thenReturn(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

Line exceeds 120 characters; contains 136 characters
Open

            array(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('fr', 'en', 'de'))),

Line exceeds 120 characters; contains 137 characters
Open

            array(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')), array('en')),

Line exceeds 120 characters; contains 121 characters
Open

        Phake::when($this->authorizationChecker)->isGranted(ContributionRoleInterface::PLATFORM_ADMIN)->thenReturn(true);

Line exceeds 120 characters; contains 172 characters
Open

        $this->contextManager = new ContextBackOfficeManager($this->session, $this->tokenStorage, $this->defaultLocale, $this->siteRepository, $this->authorizationChecker);

There are no issues that match your filters.

Category
Status