YetiForceCompany/YetiForceCRM

View on GitHub
tests/Settings/Calendar.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Avoid using static access to class '\Settings_Calendar_Module_Model' in method 'testUpdateCalendarConfig'.
Open

        $result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testResetToDefault'.
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 0, 'id' => 'update_event']);
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testResetToDefault'.
Open

        $result = \Settings_Calendar_Module_Model::getNotWorkingDays();
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testUpdateCalendarConfig'.
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\App\Cache' in method 'testResetToDefault'.
Open

        \App\Cache::clear();
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testResetToDefault'.
Open

        \Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceNotWorkingDays]);
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\App\Cache' in method 'testGetPicklistValue'.
Open

        \App\Cache::clear();
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testUpdateNotWorkingDays'.
Open

        $result = \Settings_Calendar_Module_Model::getNotWorkingDays();
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testUpdateNotWorkingDays'.
Open

        \Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceData]);
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testGetPicklistValue'.
Open

        $this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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 '\Settings_Calendar_Module_Model' in method 'testResetToDefault'.
Open

        $result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

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

Define a constant instead of duplicating this literal "update_event" 4 times.
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
Severity: Critical
Found in tests/Settings/Calendar.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Define a constant instead of duplicating this literal "color" 3 times.
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
Severity: Critical
Found in tests/Settings/Calendar.php by sonar-php

Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

Noncompliant Code Example

With the default threshold of 3:

function run() {
  prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
  execute('action1');
  release('action1');
}

Compliant Solution

ACTION_1 = 'action1';

function run() {
  prepare(ACTION_1);
  execute(ACTION_1);
  release(ACTION_1);
}

Exceptions

To prevent generating some false-positives, literals having less than 5 characters are excluded.

Call to undeclared method \App\Db::createCommand
Open

        \App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertSame
Open

                $this->assertSame((int) $row['value'], 0, 'Calendar config value is different than provided');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertTrue
Open

        $this->assertTrue($found, 'Calendar config option not found');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \App\Db::createCommand
Open

        \App\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1,  'sortorderid' => 99, 'color' => 'A0B584'])->execute();
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertGreaterThan
Open

        $this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertSame
Open

        $this->assertSame($result, $referenceNotWorkingDays, 'Not working days should be empty');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertSame
Open

                $this->assertSame((int) $row['value'], 1, 'Calendar config value is different than provided');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertTrue
Open

        $this->assertTrue($found, 'Calendar config option not found');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Call to undeclared method \Tests\Settings\Calendar::assertSame
Open

        $this->assertSame($result, $referenceData, 'Not working days differs from provided');
Severity: Critical
Found in tests/Settings/Calendar.php by phan

Avoid excessively long variable names like $referenceNotWorkingDays. Keep variable name length under 20.
Open

        $referenceNotWorkingDays = [];
Severity: Minor
Found in tests/Settings/Calendar.php by phpmd

LongVariable

Since: 0.2

Detects when a field, formal or local variable is declared with a long name.

Example

class Something {
    protected $reallyLongIntName = -3; // VIOLATION - Field
    public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
        $otherReallyLongName = -5; // VIOLATION - Local
        for ($interestingIntIndex = 0; // VIOLATION - For
             $interestingIntIndex < 10;
             $interestingIntIndex++ ) {
        }
    }
}

Source https://phpmd.org/rules/naming.html#longvariable

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testUpdateCalendarConfig()
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($result as $row) {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertTrue($found, 'Calendar config option not found');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $referenceData = ['1', '3'];
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertSame($result, $referenceData, 'Not working days differs from provided');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = \Settings_Calendar_Module_Model::getNotWorkingDays();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 0, 'id' => 'update_event']);
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $found = true;
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $this->assertSame((int) $row['value'], 0, 'Calendar config value is different than provided');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $referenceNotWorkingDays = [];
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Line exceeds 120 characters; contains 190 characters
Open

        \App\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1,  'sortorderid' => 99, 'color' => 'A0B584'])->execute();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceNotWorkingDays]);
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testUpdateNotWorkingDays()
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testResetToDefault()
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Cache::clear();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            if ('update_event' === $row['name']) {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        foreach ($result as $row) {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $this->assertSame((int) $row['value'], 1, 'Calendar config value is different than provided');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    /**
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \Settings_Calendar_Module_Model::updateNotWorkingDays(['val' => $referenceData]);
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Reset to default values.
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    public function testGetPicklistValue()
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Line exceeds 120 characters; contains 143 characters
Open

        $this->assertGreaterThan(0, (\count(\Settings_Calendar_Module_Model::getPicklistValue())), 'Calendar activity type picklist is empty');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing calendar config save.
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \Settings_Calendar_Module_Model::updateCalendarConfig(['color' => 1, 'id' => 'update_event']);
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    }
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     */
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = \Settings_Calendar_Module_Model::getCalendarConfig('reminder');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

            if ('update_event' === $row['name']) {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $result = \Settings_Calendar_Module_Model::getNotWorkingDays();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $found = false;
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing getPicklistValue method.
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Line exceeds 120 characters; contains 130 characters
Open

        \App\Db::getInstance()->createCommand()->delete('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar'])->execute();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

                $found = true;
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

     * Testing not working days config save.
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertSame($result, $referenceNotWorkingDays, 'Not working days should be empty');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $this->assertTrue($found, 'Calendar config option not found');
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

    {
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Db::getInstance()->createCommand()->insert('vtiger_activitytype', ['activitytype' => 'UnitTestCalendar', 'presence' => 1,  'sortorderid' => 99, 'color' => 'A0B584'])->execute();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Cache::clear();
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

Spaces must be used to indent lines; tabs are not allowed
Open

        $found = false;
Severity: Minor
Found in tests/Settings/Calendar.php by phpcodesniffer

There are no issues that match your filters.

Category
Status