open-orchestra/open-orchestra-cms-bundle

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

Summary

Maintainability
F
3 days
Test Coverage

The class ContextManagerTest has 18 public methods. Consider refactoring ContextManagerTest to keep number of public methods under 10.
Open

class ContextManagerTest extends AbstractBaseTestCase
{
    /**
     * @var ContextManager
     */

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

ContextManagerTest has 24 functions (exceeds 20 allowed). Consider refactoring.
Open

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

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

        Phake::verify($this->session, Phake::times(1))->get(ContextManager::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->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 'testGetUserCurrentSiteDefaultLanguage'.
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 'testGetCurrentLocale'.
Open

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

        Phake::verify($this->session, Phake::times(1))->get(ContextManager::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 'testGetCurrentSiteLanguages'.
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 'testGetUserCurrentSiteDefaultLanguage'.
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 'testGetCurrentName'.
Open

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

        $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 'testGetCurrentSiteId'.
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 '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

        $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

        $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

        $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 '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 'testGetCurrentLocaleWhenNotInSession'.
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 'testGetCurrentLocaleWhenUserNoLanguage'.
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 'testGetCurrentName'.
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 'testGetUserCurrentSiteDefaultLanguage'.
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 '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 'testGetCurrentSiteLanguages'.
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextManager::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 '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 'testGetUserCurrentSiteDefaultLanguage'.
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 '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

        $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 'testGetCurrentSiteDefaultLanguage'.
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

Call to method mock from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentLocale() defined at /code/Backoffice/Context/ContextManager.php:19
Open

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

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($group2)->getSite()->thenReturn($site2);

Call to method verify from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentSiteName() defined at /code/Backoffice/Context/ContextManager.php:73
Open

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

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

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

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 deprecated class \OpenOrchestra\Backoffice\Context\ContextManager defined at /code/Backoffice/Context/ContextManager.php:12
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::setCurrentLocale() defined at /code/Backoffice/Context/ContextManager.php:29
Open

        $this->contextManager->setCurrentLocale($locale);

Call to method when from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

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\ContextManagerTest::assertEquals
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method anyParameters from undeclared class \Phake
Open

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

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

class ContextManagerTest extends AbstractBaseTestCase

Call to method mock from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentSiteLanguages() defined at /code/Backoffice/Context/ContextManager.php:104
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentLocale() defined at /code/Backoffice/Context/ContextManager.php:19
Open

        $localReturned = $this->contextManager->getCurrentLocale();

Call to method times from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentLocale() defined at /code/Backoffice/Context/ContextManager.php:19
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentSiteId() defined at /code/Backoffice/Context/ContextManager.php:63
Open

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

Call to method anyParameters from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getCurrentSiteDefaultLanguage() defined at /code/Backoffice/Context/ContextManager.php:83
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method times from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

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

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

Call to method when from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

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($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(array('siteId' => 'fakeId', 'name' => 'fakeName', 'defaultLanguage' => 'en', 'languages' => array('en')));

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

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

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

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

Call to method times from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($this->session)->get(ContextManager::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\ContextManagerTest::assertSame
Open

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

Call to method mock from undeclared class \Phake
Open

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

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($user)->getLanguage()->thenReturn(null);

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($this->token)->getRoles()->thenReturn(array());

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

Call to method mock from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getUserCurrentSiteDefaultLanguage() defined at /code/Backoffice/Context/ContextManager.php:93
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::setCurrentSite() defined at /code/Backoffice/Context/ContextManager.php:53
Open

        $this->contextManager->setCurrentSite($site['siteId'], $site['name'], $site['defaultLanguage'], $site['languages']);

Call to method times from undeclared class \Phake
Open

        Phake::verify($this->session, Phake::times(1))->get(ContextManager::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 when from undeclared class \Phake
Open

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

Call to deprecated function \OpenOrchestra\Backoffice\Context\ContextManager::getDefaultLocale() defined at /code/Backoffice/Context/ContextManager.php:39
Open

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

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

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

Call to method mock from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

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

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\ContextManagerTest::assertEquals
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method when from undeclared class \Phake
Open

        Phake::when($site1)->getId()->thenReturn('id1');

Call to method mock from undeclared class \Phake
Open

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

Call to method verify from undeclared class \Phake
Open

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

Call to method times from undeclared class \Phake
Open

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

Call to method mock from undeclared class \Phake
Open

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

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

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

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($site2)->getId()->thenReturn('id2');

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

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

Call to method anyParameters 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($user)->hasLanguageBySite(Phake::anyParameters())->thenReturn(true);

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

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

Call to method when from undeclared class \Phake
Open

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

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

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

Call to method verify from undeclared class \Phake
Open

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

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/ContextManagerTest.php and 1 other location - About 1 day to fix
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php on lines 131..151

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 testGetUserCurrentSiteDefaultLanguage($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/ContextManagerTest.php and 1 other location - About 4 hrs to fix
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php on lines 332..344

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/ContextManagerTest.php and 1 other location - About 3 hrs to fix
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php on lines 31..44

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/ContextManagerTest.php and 1 other location - About 1 hr to fix
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php on lines 170..178

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 testSetCurrentSite($site)
    {
        $this->contextManager->setCurrentSite($site['siteId'], $site['name'], $site['defaultLanguage'], $site['languages']);

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

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/ContextManagerTest.php and 1 other location - About 35 mins to fix
Backoffice/Tests/Context/ContextBackOfficeManagerTest.php on lines 316..322

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 testGetCurrentLocale($locale)
    {
        Phake::when($this->session)->get(ContextManager::KEY_LOCALE)->thenReturn($locale);

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

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

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

Line exceeds 120 characters; contains 129 characters
Open

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

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

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

Line exceeds 120 characters; contains 124 characters
Open

        $this->contextManager->setCurrentSite($site['siteId'], $site['name'], $site['defaultLanguage'], $site['languages']);

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

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

Line exceeds 120 characters; contains 121 characters
Open

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

There are no issues that match your filters.

Category
Status