YetiForceCompany/YetiForceCRM

View on GitHub
tests/Settings/ApiAddress.php

Summary

Maintainability
A
0 mins
Test Coverage
A
100%

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

        $this->assertTrue($result, 'Error when saving global config var');
Severity: Critical
Found in tests/Settings/ApiAddress.php by phan

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

        $this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');
Severity: Critical
Found in tests/Settings/ApiAddress.php by phan

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

        $this->assertTrue($result, 'Error when setting global config var to default value');
Severity: Critical
Found in tests/Settings/ApiAddress.php by phan

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

        $this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');
Severity: Critical
Found in tests/Settings/ApiAddress.php by phan

Define a constant instead of duplicating this literal "global" 7 times.
Open

            ['name' => 'min_length', 'type' => 'global', 'val' => 5],
Severity: Critical
Found in tests/Settings/ApiAddress.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 "result_num" 5 times.
Open

            ['name' => 'result_num', 'type' => 'global', 'val' => 15],
Severity: Critical
Found in tests/Settings/ApiAddress.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 "min_length" 5 times.
Open

            ['name' => 'min_length', 'type' => 'global', 'val' => 5],
Severity: Critical
Found in tests/Settings/ApiAddress.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 "Settings:ApiAddress" 3 times.
Open

        $result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([
Severity: Critical
Found in tests/Settings/ApiAddress.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.

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

        $dataReference = ['min_length' => 5, 'result_num' => 15];

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

        $this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');

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

    public function testSaveConfig()

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

    /**

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

        $this->assertTrue($result, 'Error when setting global config var to default value');

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

        $this->assertTrue($result, 'Error when saving global config var');

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

        $result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->getConfig('global');

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

     * Reset to default values.

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

            ['name' => 'result_num', 'type' => 'global', 'val' => 10],

Line exceeds 120 characters; contains 154 characters
Open

        $this->assertSame((int) $result['global']['min_length'], $dataReference['min_length'], 'Global min_length config var is different from provided');

Line exceeds 120 characters; contains 154 characters
Open

        $this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');

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

     */

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

            ['name' => 'min_length', 'type' => 'global', 'val' => 3],

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

     */

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

        $this->assertSame((int) $result['global']['result_num'], $dataReference['result_num'], 'Global result_num config var is different from provided');

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

     * Testing global config getter.

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

     */

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

        ]);

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

    }

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

        $result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([

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

        ]);

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

    /**

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

    {

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

    {

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

            ['name' => 'min_length', 'type' => 'global', 'val' => 5],

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

    }

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

    public function testGetConfig()

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

    /**

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

        $result = \Settings_ApiAddress_Module_Model::getInstance('Settings:ApiAddress')->setConfig([

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

     * Testing global config save.

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

            ['name' => 'result_num', 'type' => 'global', 'val' => 15],

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

    public function testResetToDefault()

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

    {

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

    }

There are no issues that match your filters.

Category
Status