YetiForceCompany/YetiForceCRM

View on GitHub
tests/Settings/SharingAccess.php

Summary

Maintainability
A
1 hr
Test Coverage
A
100%

Method testAddSharedAccessPolicy has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testAddSharedAccessPolicy()
    {
        $sourceId = 'Groups:2';
        $targetId = 'Groups:2';
        $permission = 0;
Severity: Minor
Found in tests/Settings/SharingAccess.php - About 1 hr to fix

    Method saveRule has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        private function saveRule($forModule, $ruleId, $permission, $sourceId, $targetId)
    Severity: Minor
    Found in tests/Settings/SharingAccess.php - About 35 mins to fix

      Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices.
      Open

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$newValues' which will lead to PHP notices.
      Open

              $newValues['permission'] = $permission;
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices.
      Open

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$prevValues' which will lead to PHP notices.
      Open

              $prevValues['permission'] = $ruleModel->getPermission();
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$newValues' which will lead to PHP notices.
      Open

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices.
      Open

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$dataShareTableColArr' which will lead to PHP notices.
      Open

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Avoid using undefined variables such as '$prevValues' which will lead to PHP notices.
      Open

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      UndefinedVariable

      Since: 2.8.0

      Detects when a variable is used that has not been defined before.

      Example

      class Foo
      {
          private function bar()
          {
              // $message is undefined
              echo $message;
          }
      }

      Source https://phpmd.org/rules/cleancode.html#undefinedvariable

      Missing class import via use statement (line '84', column '21').
      Open

                  $ruleModel = new \Settings_SharingAccess_Rule_Model();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '120', column '27').
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '159', column '27').
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '55', column '16').
      Open

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '155', column '27').
      Open

              $this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '177', column '27').
      Open

                  $this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '44', column '15').
      Open

              $row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->one();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '167', column '15').
      Open

              $row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->one();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 '130', column '16').
      Open

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'saveRule'.
      Open

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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

      The method saveRule uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
              }
      Severity: Minor
      Found in tests/Settings/SharingAccess.php by phpmd

      ElseExpression

      Since: 1.4.0

      An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($flag) {
                  // one branch
              } else {
                  // another branch
              }
          }
      }

      Source https://phpmd.org/rules/cleancode.html#elseexpression

      Avoid using static access to class '\Settings_SharingAccess_RuleMember_Model' in method 'testEditSharedAccessPolicy'.
      Open

              $targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Module_Model' in method 'changePermissions'.
      Open

              \Settings_SharingAccess_Module_Model::recalculateSharingRules();
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Rule_Model' in method 'saveRule'.
      Open

                  $ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'saveRule'.
      Open

              \Settings_Vtiger_Tracker_Model::lockTracking(false);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'testDeleteSharedAccessPolicy'.
      Open

              \Settings_Vtiger_Tracker_Model::lockTracking(false);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Rule_Model' in method 'testDeleteSharedAccessPolicy'.
      Open

              $ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, self::$shareId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'testDeleteSharedAccessPolicy'.
      Open

              \Settings_Vtiger_Tracker_Model::addBasic('delete');
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'changePermissions'.
      Open

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $postValues);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Module_Model' in method 'testDeleteSharedAccessPolicy'.
      Open

              $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_RuleMember_Model' in method 'testAddSharedAccessPolicy'.
      Open

              $targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_RuleMember_Model' in method 'testEditSharedAccessPolicy'.
      Open

              $sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_Vtiger_Tracker_Model' in method 'saveRule'.
      Open

              \Settings_Vtiger_Tracker_Model::addBasic('save');
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_RuleMember_Model' in method 'testAddSharedAccessPolicy'.
      Open

              $sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Module_Model' in method 'saveRule'.
      Open

              $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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_SharingAccess_Module_Model' in method 'changePermissions'.
      Open

                  $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($tabId);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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 "relationtype" 4 times.
      Open

              self::$relationType = $ruleModel->get('relationtype');
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "No record id: " 3 times.
      Open

              $this->assertNotFalse($row, 'No record id: ' . self::$shareId);
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "source_id" 3 times.
      Open

              $sourceColumnName = $tableColumnInfo['source_id'];
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "tabid" 3 times.
      Open

              $this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "Groups:2" 3 times.
      Open

              $sourceId = 'Groups:2';
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "Accounts" 3 times.
      Open

              $forModule = 'Accounts';
      Severity: Critical
      Found in tests/Settings/SharingAccess.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.

      Rename "$relationType" which has the same name as the field declared at line 24.
      Open

              $relationType = implode('::', [$sourceType, $targetType]);
      Severity: Major
      Found in tests/Settings/SharingAccess.php by sonar-php

      Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

      Noncompliant Code Example

      class Foo {
        public $myField;
      
        public function doSomething() {
          $myField = 0;
          ...
        }
      }
      

      See

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

              $targetColumnName = $tableColumnInfo['target_id'];
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "permission" 10 times.
      Open

              $this->assertSame($permission, $row2['permission']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "table" 5 times.
      Open

              $tableName = $tableColumnInfo['table'];
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "Record id " 3 times.
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.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 "shareid" 7 times.
      Open

              self::$shareId = $ruleModel->get('shareid');
      Severity: Critical
      Found in tests/Settings/SharingAccess.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.

      Rename "$relationType" which has the same name as the field declared at line 24.
      Open

              $relationType = $ruleModel->get('relationtype');
      Severity: Major
      Found in tests/Settings/SharingAccess.php by sonar-php

      Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

      Noncompliant Code Example

      class Foo {
        public $myField;
      
        public function doSomething() {
          $myField = 0;
          ...
        }
      }
      

      See

      Define a constant instead of duplicating this literal " should not exist" 3 times.
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.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\SharingAccess::assertSame
      Open

              $this->assertSame($relationType, $row['relationtype']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to method get on non-class type array
      Open

              $relationType = $ruleModel->get('relationtype');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
      Open

              $this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->one();
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
      Open

              $this->assertNotFalse($row, 'No record id: ' . self::$shareId);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Variable $newValues was undeclared, but array fields are being added to it.
      Open

              $newValues['permission'] = $permission;
      Severity: Info
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
      Open

              $this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

                  $this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
      Open

              $this->assertNotFalse($row2, 'No record id: ' . self::$shareId);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Variable $prevValues was undeclared, but array fields are being added to it.
      Open

              $prevValues['permission'] = $ruleModel->getPermission();
      Severity: Info
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to method delete on non-class type array
      Open

              $ruleModel->delete();
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertNotFalse
      Open

              $this->assertNotFalse($row, 'No record id: 6');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

                  $this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->one();
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to method getId on non-class type string
      Open

              $this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame($permission, $row2['permission']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

      Call to undeclared method \Tests\Settings\SharingAccess::assertFalse
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame($permission, $row2['permission']);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);
      Severity: Critical
      Found in tests/Settings/SharingAccess.php by phan

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

              $relationTypeComponents = explode('::', self::$relationType);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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

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

              $relationTypeComponents = \explode('::', self::$relationType);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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

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

              $relationTypeComponents = explode('::', $relationType);
      Severity: Minor
      Found in tests/Settings/SharingAccess.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

          /**

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

          private static $relationType;

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

              $this->assertSame($ruleModel->getModule()->getId(), $row['tabid']);

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

              $sourceColumnName = $tableColumnInfo['source_id'];

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

              $forModule = 'Accounts';

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

              $targetType = $relationTypeComponents[1];

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

          /**

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

              $permission = 0;

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

              $ruleModel = $this->saveRule($forModule, $ruleId, $permission, $sourceId, $targetId);

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

           */

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

              $sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);

      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

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();

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

              $this->assertSame($permission, $row2['permission']);

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

           * Share id.

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

              $sourceId = 'Groups:2';

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

              $targetId = 'Groups:2';

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

              $this->assertNotFalse($row, 'No record id: ' . self::$shareId);

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

           */

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

              self::$shareId = $ruleModel->get('shareid');

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

              $relationTypeComponents = \explode('::', self::$relationType);

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

              $targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);

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

           * Testing add shared access policy.

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

              $sourceType = $relationTypeComponents[0];

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

              $relationType = implode('::', [$sourceType, $targetType]);

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

              $ruleId = 0;

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

              $targetColumnName = $tableColumnInfo['target_id'];

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

          public function testAddSharedAccessPolicy()

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

              $this->assertNotFalse($row2, 'No record id: ' . self::$shareId);

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

              self::$relationType = $ruleModel->get('relationtype');

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

              $tableName = $tableColumnInfo['table'];

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

          private static $shareId;

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

              $row = (new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->one();

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

              $this->assertSame($relationType, $row['relationtype']);

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

           * Relation type.

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

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];

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

           * @param string $forModule

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

           * @param int    $permission

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

           * @return \Settings_SharingAccess_Rule_Model

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

              \Settings_Vtiger_Tracker_Model::lockTracking(false);

      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->changePermissions($modulePermissions);

      Line exceeds 120 characters; contains 158 characters
      Open

                  $this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);

      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

              \Settings_Vtiger_Tracker_Model::addBasic('save');

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

          public function testEditSharedAccessPolicy()

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

              $targetId = 'Roles:H6';

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

              $permission = 1;

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

          /**

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

              $row = (new \App\Db\Query())->from('vtiger_def_org_share')->where(['tabid' => 6])->one();

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

                      $prevValues[$tabId] = $permissionOld;

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

              $ruleModel->save();

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

          {

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

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];

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

              $tableName = $tableColumnInfo['table'];

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

              $ruleModel->delete();

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

          }

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

          private function saveRule($forModule, $ruleId, $permission, $sourceId, $targetId)

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

              if (empty($ruleId)) {

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

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $newValues);

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

              $targetColumnName = $tableColumnInfo['target_id'];

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

              $this->assertNotFalse($row2, 'No record id: ' . self::$shareId);

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

              $this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);

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

              $this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');

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

                  $this->assertSame((new \App\Db\Query())->select(['permission'])->from('vtiger_def_org_share')->where(['tabid' => $tabId])->scalar(), $permission);

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

           * @param array $modulePermissions

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

          private function changePermissions($modulePermissions)

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

                  $permission = (int) $permission;

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

          /**

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

                  $ruleModel = new \Settings_SharingAccess_Rule_Model();

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

              $prevValues['permission'] = $ruleModel->getPermission();

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

           * Testing edit shared access policy.

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

              $forModule = 'Accounts';

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

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');

      Line exceeds 120 characters; contains 199 characters
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableName . ' should not exist');

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

              $this->assertSame($permission, $row2['permission']);

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

              \Settings_Vtiger_Tracker_Model::addBasic('delete');

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

          /**

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

              $modulePermissions[4] = $modulePermissions[6];

      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

                  $ruleModel->setModuleFromInstance($moduleModel);

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

                  $ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, $ruleId);

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

              $newValues['permission'] = $permission;

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

              $ruleModel->set('target_id', $targetId);

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

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];

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

           *

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

                  $permissionOld = (int) $moduleModel->get('permission');

      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

              $ruleModel->set('source_id', $sourceId);

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

              $relationTypeComponents = explode('::', $relationType);

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

           * Save permissions.

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

              $sourceIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($sourceId);

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

          public function testDeleteSharedAccessPolicy()

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

              $this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');

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

              $this->changePermissions($modulePermissions);

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

          {

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

              $sourceType = $relationTypeComponents[0];

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

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$sourceType][$targetType];

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

              $this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);

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

              $relationType = $ruleModel->get('relationtype');

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

              $oldPermission = $row['permission'];

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

              foreach ($modulePermissions as $tabId => $permission) {

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

           * @param int    $ruleId

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

           * @param string $sourceId

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

              $relationTypeComponents = explode('::', self::$relationType);

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

              $targetType = $relationTypeComponents[1];

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

              $newPermission = 2 === $oldPermission ? 1 : 2;

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

              foreach ($modulePermissions as $tabId => $permission) {

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

                      $postValues[$tabId] = (int) $moduleModel->get('permission');

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

              $this->assertSame((string) $targetIdComponents[1], (string) $row2[$targetColumnName]);

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

           */

      Line exceeds 120 characters; contains 141 characters
      Open

              $tableColumnInfo = \Settings_SharingAccess_Rule_Model::$dataShareTableColArr[$relationTypeComponents[0]][$relationTypeComponents[1]];

      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

              \Settings_SharingAccess_Module_Model::recalculateSharingRules();

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

           */

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

              $sourceId = 'Groups:2';

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

              $sourceType = $relationTypeComponents[0];

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

          }

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

              $forModule = 'Accounts';

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

                  }

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

                  $moduleModel->save();

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

              $this->assertSame((string) $sourceIdComponents[1], (string) $row2[$sourceColumnName]);

      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

              return $ruleModel;

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

          }

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

              $row2 = (new \App\Db\Query())->from($tableName)->where(['shareid' => self::$shareId])->one();

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

              $targetIdComponents = \Settings_SharingAccess_RuleMember_Model::getIdComponentsFromQualifiedId($targetId);

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

          public function testChangePermissions()

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

              $modulePermissions = [6 => $oldPermission, 4 => $oldPermission];

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

              $prevValues = [];

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

                  $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($tabId);

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

              $targetType = $relationTypeComponents[1];

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

          {

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

              \Settings_Vtiger_Tracker_Model::lockTracking(false);

      Line exceeds 120 characters; contains 188 characters
      Open

              $this->assertFalse((new \App\Db\Query())->from('vtiger_datashare_module_rel')->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' should not exist');

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

              }

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

           * Change of permissions.

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

              $postValues = [];

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

                  if ($permissionOld !== $permission) {

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

              $ruleModel->set('permission', $permission);

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

              $ruleModel = $this->saveRule($forModule, self::$shareId, $permission, $sourceId, $targetId);

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

              $relationTypeComponents = \explode('::', $ruleModel->get('relationtype'));

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

              $sourceColumnName = $tableColumnInfo['source_id'];

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

           * Testing delete shared access policy.

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

              $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);

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

           * Testing permission changes.

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

              $this->assertNotFalse($row, 'No record id: 6');

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

              $modulePermissions = [6 => $newPermission, 4 => $newPermission];

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

                  $moduleModel->set('permission', $permission);

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

           * @param string $targetId

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

              $moduleModel = \Settings_SharingAccess_Module_Model::getInstance($forModule);

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

              } else {

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

          /**

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

              $tableName = $tableColumnInfo['table'];

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

              $ruleModel = \Settings_SharingAccess_Rule_Model::getInstance($moduleModel, self::$shareId);

      Line exceeds 120 characters; contains 229 characters
      Open

              $this->assertFalse((new \App\Db\Query())->from($tableColumnInfo['table'])->where(['shareid' => self::$shareId])->exists(), 'Record id ' . self::$shareId . ' from table ' . $tableColumnInfo['table'] . ' should not exist');

      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

              \Settings_Vtiger_Tracker_Model::addDetail($prevValues, $postValues);

      There are no issues that match your filters.

      Category
      Status