YetiForceCompany/YetiForceCRM

View on GitHub
tests/Settings/CronTasks.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

Missing class import via use statement (line '31', column '52').
Open

        $this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '37', column '27').
Open

        $currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpmd

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class '\Settings_CronTasks_Module_Model' in method 'testGetLastCronIteration'.
Open

        $module = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
Severity: Minor
Found in tests/Settings/CronTasks.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_CronTasks_Record_Model' in method 'testRecordInstance'.
Open

        $recordModel = \Settings_CronTasks_Record_Model::getInstanceByName('LBL_BROWSING_HISTORY');
Severity: Minor
Found in tests/Settings/CronTasks.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_CronTasks_Module_Model' in method 'testUpdateTasksSequence'.
Open

        $moduleModel = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
Severity: Minor
Found in tests/Settings/CronTasks.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 "status" 3 times.
Open

        $this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Critical
Found in tests/Settings/CronTasks.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 \Tests\Settings\CronTasks::AssertSame
Open

        $this->AssertSame('LBL_BROWSING_HISTORY', $recordModel->getName());
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \Tests\Settings\CronTasks::AssertNotEmpty
Open

        $this->AssertNotEmpty($recordModel->getDuration(), 'Returned duration should be not empty');
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \Tests\Settings\CronTasks::assertIsInt
Open

        $this->assertIsInt($recordModel->getTimeDiff(), 'Returned time difference should be integer');
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \Tests\Settings\CronTasks::AssertNotEmpty
Open

            $this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty value');
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \App\Db\Query::select
Open

        $this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \App\Db\Query::select
Open

        $currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

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

        $this->assertSame($testSequence, $currentSequence, 'Current sequence is different from provided');
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Call to undeclared method \Tests\Settings\CronTasks::assertNotEmpty
Open

        $this->assertNotEmpty($module->getLastCronIteration(), 'Last cron iteration should be not empty');
Severity: Critical
Found in tests/Settings/CronTasks.php by phan

Expected 1 space before "as"; 0 found
Open

        foreach (['frequency', 'status', 'name', 'duration']as $fieldName) {
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

Line exceeds 120 characters; contains 126 characters
Open

            $this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty value');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

        $moduleModel = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $testSequence[1] = $testSequence[2];
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

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

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

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

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

        $this->AssertSame('LBL_BROWSING_HISTORY', $recordModel->getName());
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $testSequence[2] = $tmp;
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

        $recordModel = \Settings_CronTasks_Record_Model::getInstanceByName('LBL_BROWSING_HISTORY');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

     * Testing last cron iteration getter.
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $this->assertSame($testSequence, $currentSequence, 'Current sequence is different from provided');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $this->assertNotEmpty($module->getLastCronIteration(), 'Last cron iteration should be not empty');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        foreach (['frequency', 'status', 'name', 'duration']as $fieldName) {
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

        $this->assertIsInt($recordModel->getTimeDiff(), 'Returned time difference should be integer');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

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

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

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

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

        $this->AssertNotEmpty($recordModel->getDuration(), 'Returned duration should be not empty');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

Line exceeds 120 characters; contains 214 characters
Open

        $this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $moduleModel->updateSequence($testSequence);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $moduleModel->updateSequence($dbSequence);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $this->logs = $dbSequence = $testSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

Line exceeds 120 characters; contains 189 characters
Open

        $currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

            $this->AssertNotEmpty($recordModel->getDisplayValue($fieldName), 'Field ' . $fieldName . ' returned empty value');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

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

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

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

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

     * Testing cron tasks sequence update.
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

        $module = \Settings_CronTasks_Module_Model::getInstance('Settings:CronTasks');
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

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

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

        $tmp = $testSequence[1];
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

        $currentSequence = (new \App\Db\Query())->select(['sequence', 'id'])->from('vtiger_cron_task')->where(['status' => 1])->orderBy('sequence ASC')->createCommand()->queryAllByGroup(0);
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

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

     * Testing record instance functions.
Severity: Minor
Found in tests/Settings/CronTasks.php by phpcodesniffer

There are no issues that match your filters.

Category
Status