YetiForceCompany/YetiForceCRM

View on GitHub
tests/Base/Z_MultiImage.php

Summary

Maintainability
A
3 hrs
Test Coverage
A
100%

Method testAttachImageToRecord has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function testAttachImageToRecord($module, $field, $file): void
    {
        switch ($module) {
            case 'Users':
                $record = self::$cache['Users'] ?? \App\User::getUserIdByName('admin');
Severity: Minor
Found in tests/Base/Z_MultiImage.php - About 1 hr to fix

    Method testAddMultiImage has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function testAddMultiImage(): void
        {
            $recordModel = \Vtiger_Record_Model::getInstanceById(\Tests\Base\C_RecordActions::createProductRecord(false)->getId(), 'Products');
            $attach = [];
            foreach (self::$files as $i => $name) {
    Severity: Minor
    Found in tests/Base/Z_MultiImage.php - About 1 hr to fix

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

              $attach[] = [
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '$hash' which will lead to PHP notices.
      Open

                      'key' => $hash[$i],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '$attach' which will lead to PHP notices.
      Open

              $recordModel->set($field, \App\Json::encode($attach));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '$hash' which will lead to PHP notices.
      Open

                  $hash[$i] = $fileObj->generateHash(true, $filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 static access to class '\Vtiger_Record_Model' in method 'testAttachImageToRecord'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\Vtiger_Record_Model' in method 'testAttachImageToRecord'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testAttachImageToRecord'.
      Open

      }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\User' in method 'testAttachImageToRecord'.
      Open

                      $record = self::$cache['Users'] ?? \App\User::getUserIdByName('admin');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Purifier' in method 'testAttachImageToRecord'.
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get($field), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Fields\File' in method 'testAttachImageToRecord'.
      Open

              $fileObj = \App\Fields\File::loadFromPath($filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testDeleteImage'.
      Open

              $data = \App\Json::decode($recordModel->get($field));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testAttachImageToRecord'.
      Open

              $recordModel->set($field, \App\Json::encode($attach));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Purifier' in method 'testAddMultiImage'.
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get('imagename'), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testAttachImageToRecord'.
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get($field), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\Vtiger_Record_Model' in method 'testAddMultiImage'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById(\Tests\Base\C_RecordActions::createProductRecord(false)->getId(), 'Products');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Fields\File' in method 'testAddMultiImage'.
      Open

                  $fileObj = \App\Fields\File::loadFromPath($filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\vtlib\Functions' in method 'tearDownAfterClass'.
      Open

              \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR, true);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testAddMultiImage'.
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get('imagename'), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\Vtiger_Record_Model' in method 'testDeleteImage'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById(self::$cache[$module], $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\Vtiger_Record_Model' in method 'testDeleteImage'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById(self::$cache[$module], $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      StaticAccess

      Since: 1.4.0

      Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

      Example

      class Foo
      {
          public function bar()
          {
              Bar::baz();
          }
      }

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

      Avoid using static access to class '\App\Json' in method 'testAddMultiImage'.
      Open

              $recordModel->set('imagename', \App\Json::encode($attach));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 '\Vtiger_Record_Model' in method 'testAddMultiImage'.
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById($recordModel->getId(), 'Products');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.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 "Users" 4 times.
      Open

                  $data[] = ['Users', 'imagename', $i];
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "Contacts" 4 times.
      Open

                  $data[] = ['Contacts', 'imagename', $i];
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "tests" 4 times.
      Open

              \mkdir(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage', 0777, true);
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "MultiImage" 4 times.
      Open

              \mkdir(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage', 0777, true);
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "Products" 7 times.
      Open

                  $data[] = ['Products', 'imagename', $i];
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "imagename" 10 times.
      Open

                  $data[] = ['Users', 'imagename', $i];
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 "File should exists" 3 times.
      Open

              $this->assertFileExists($dataPath, 'File should exists');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.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 method getUserIdByName from undeclared class \App\User (Did you mean class \Tests\App\User)
      Open

                      $record = self::$cache['Users'] ?? \App\User::getUserIdByName('admin');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame('', $recordModel->get($field), 'Value should be empty');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame(self::$files[$file], $data[0]['name'], 'File name should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

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

              $attach[] = [
      Severity: Info
      Found in tests/Base/Z_MultiImage.php by phan

      Argument 1 (str) is int but \md5() takes string
      Open

                  $filePathDst = 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR . md5(random_int(0, 9999)) . substr($name, \strpos($name, '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertFileExists
      Open

                  $this->assertFileExists($attach[$i]['path'], 'File should exists');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($hash, $data[0]['key'], 'Key should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($module, $url['module'], 'Module in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($record, $recordModel->getId(), 'Record ' . $record . '(' . $module . ') load error');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Vtiger_Base_UIType::getDisplayValueEncoded
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get('imagename'), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertFileExists
      Open

              $this->assertFileExists($dataPath, 'File should exists');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($field, $url['field'], 'Field name in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

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

                  $hash[$i] = $fileObj->generateHash(true, $filePathDst);
      Severity: Info
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Vtiger_Base_UIType::getDisplayValueEncoded
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get($field), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertNotEmpty
      Open

              $this->assertNotEmpty($data);
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame('Products', $url['module'], 'Module in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Assigning array{} to property but \Tests\Base\Z_MultiImage::$cache is bool
      Open

          private static $cache = [];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertFileExists
      Open

              $this->assertFileExists($data[0]['path'], 'File should exists');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($hash, $url['key'], 'Key in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame($fileObj->getSize(), $data[0]['size'], 'File size should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame($name, $data[$i]['name'], 'File name should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Argument 1 (str) is int but \md5() takes string
      Open

              $filePathDst = ROOT_DIRECTORY . '/storage/MultiImage/' . md5(random_int(0, 9999)) . substr(self::$files[$file], \strpos(self::$files[$file], '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertFileDoesNotExist
      Open

              $this->assertFileDoesNotExist($data[0]['path'], 'File should be removed');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame($attach[$i]['size'], $data[$i]['size'], 'File size should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Saw an @param annotation for record, but it was not found in the param list of function testAttachImageToRecord($module, $field, $file) : void
      Open

           * @param $record
      Severity: Info
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertNotEmpty
      Open

              $this->assertNotEmpty($data);
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

              $this->assertSame((string) $record, $url['record'], 'Record in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame($attach[$i]['key'], $data[$i]['key'], 'Key should be equal');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame($data[$i]['key'], $url['key'], 'Key in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame((string) $recordModel->getId(), $url['record'], 'Record in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertSame
      Open

                  $this->assertSame('imagename', $url['field'], 'Field name in image url should be equal to provided');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Call to undeclared method \Tests\Base\Z_MultiImage::assertFileDoesNotExist
      Open

                  $this->assertFileDoesNotExist($info['path'], 'File should be removed');
      Severity: Critical
      Found in tests/Base/Z_MultiImage.php by phan

      Remove the code after this "return".
      Open

                      return; // @codeCoverageIgnore
      Severity: Major
      Found in tests/Base/Z_MultiImage.php by sonar-php

      Jump statements (return, break, continue, and goto) and throw expressions move control flow out of the current code block. Typically, any statements in a block that come after a jump or throw are simply wasted keystrokes lying in wait to confuse the unwary.

      Rarely, as illustrated below, code after a jump or throw is reachable. However, such code is difficult to understand, and should be refactored.

      Noncompliant Code Example

      function fun($a) {
        $i = 10;
        return $i + $a;
        $i++;             // this is never executed
      }
      
      function foo($a) {
        if ($a == 5) {
          goto error;
        } else {
          // do the job
        }
        return;
      
        error:
          printf("don't use 5"); // this is reachable but unreadable
      
      }
      

      Compliant Solution

      function fun($a) {
        $i = 10;
        return $i + $a;
      }
      
      function foo($a) {
        if ($a == 5) {
          handleError();
        } else {
          // do the job
        }
        return;
      }
      

      See

      • MISRA C:2004, 14.1 - There shall be no unreachable code
      • MISRA C++:2008, 0-1-1 - A project shall not contain unreachable code
      • MISRA C++:2008, 0-1-9 - There shall be no dead code
      • MISRA C:2012, 2.1 - A project shall not contain unreachable code
      • MISRA C:2012, 2.2 - There shall be no dead code
      • MITRE, CWE-561 - Dead Code
      • CERT, MSC56-J. - Detect and remove superfluous code and values
      • CERT, MSC12-C. - Detect and remove code that has no effect or is never executed
      • CERT, MSC07-CPP. - Detect and remove dead code

      The class Z_MultiImage is not named in CamelCase.
      Open

      class Z_MultiImage extends \Tests\Base
      {
          /** @var string[] Files array. */
          public static $files = ['0.jpg', '1.png', '2.png', '3.jpg'];
      
      
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpmd

      CamelCaseClassName

      Since: 0.2

      It is considered best practice to use the CamelCase notation to name classes.

      Example

      class class_name {
      }

      Source

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

          /** @var string[] Files array. */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @return array
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              ];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  case 'Products':
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      return; // @codeCoverageIgnore
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get($field), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $dataPath = \App\Json::decode($recordModel->get($field))[0]['path'];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame(self::$files[$file], $data[0]['name'], 'File name should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      $record = self::$cache['Products'] ?? \Tests\Base\C_RecordActions::createProductRecord(false)->getId();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      break;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $hash = $fileObj->generateHash(true, $filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              ];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public static function setUpBeforeClass(): void
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->save();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $data = [];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $field
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById(self::$cache[$module], $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  case 'Contacts':
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      break;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              foreach (self::$files as $i => $name) {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $filePathDst = ROOT_DIRECTORY . '/storage/MultiImage/' . md5(random_int(0, 9999)) . substr(self::$files[$file], \strpos(self::$files[$file], '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $filePathSrc = 'tests' . \DIRECTORY_SEPARATOR . 'data' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR . $name;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->set($field, \App\Json::encode($attach));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $hash[$i] = $fileObj->generateHash(true, $filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 204 characters
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get($field), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      'key' => $hash[$i],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame('', $recordModel->get($field), 'Value should be empty');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @throws \App\Exceptions\AppException
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 136 characters
      Open

                  $filePathSrc = 'tests' . \DIRECTORY_SEPARATOR . 'data' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR . $name;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $record
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Delete record image test.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertFileExists($data[0]['path'], 'File should exists');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      'path' => $fileObj->getPath(),
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          private static $cache = [];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  ['Users', 'imagename'],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  case 'Users':
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      $record = self::$cache['Users'] ?? \App\User::getUserIdByName('admin');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($hash, $data[0]['key'], 'Key should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->set($field, '');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertFileDoesNotExist($data[0]['path'], 'File should be removed');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Add multi image test.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $attach[$i] = [
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById($recordModel->getId(), 'Products');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @dataProvider providerImageForRecord
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertNotEmpty($data);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @dataProvider providerDeleteImageForRecord
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById(self::$cache[$module], $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /** @var bool Cache */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @codeCoverageIgnore
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              switch ($module) {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $filePathSrc = ROOT_DIRECTORY . '/tests/data/MultiImage/' . self::$files[$file];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($record, $recordModel->getId(), 'Record ' . $record . '(' . $module . ') load error');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              parse_str(\parse_url($data[0]['imageSrc'])['query'], $url);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($module, $url['module'], 'Module in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $attach = [];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $filePathDst = 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR . md5(random_int(0, 9999)) . substr($name, \strpos($name, '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $fileObj = \App\Fields\File::loadFromPath($filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->save();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $data[] = ['Contacts', 'imagename', $i];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @return array
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @throws \App\Exceptions\AppException
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($field, $url['field'], 'Field name in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Setting of tests.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      break;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  ];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      break;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  'path' => $fileObj->getPath(),
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertFileExists($dataPath, 'File should exists');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public function testDeleteImage($module, $field): void
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public function testAddMultiImage(): void
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 139 characters
      Open

              $recordModel = \Vtiger_Record_Model::getInstanceById(\Tests\Base\C_RecordActions::createProductRecord(false)->getId(), 'Products');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public static $files = ['0.jpg', '1.png', '2.png', '3.jpg'];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              \mkdir(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage', 0777, true);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Data provider for the attach image to record test.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              return $data;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public function testAttachImageToRecord($module, $field, $file): void
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $attach[] = [
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame((string) $record, $url['record'], 'Record in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 191 characters
      Open

                  $filePathDst = 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR . md5(random_int(0, 9999)) . substr($name, \strpos($name, '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $data[] = ['Products', 'imagename', $i];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById($record, $module);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->save();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      'size' => $fileObj->getSize(),
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              return [
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  'name' => self::$files[$file],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  'key' => $hash,
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $data = \App\Json::decode($recordModel->get($field));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel = \Vtiger_Record_Model::getInstanceById(\Tests\Base\C_RecordActions::createProductRecord(false)->getId(), 'Products');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 145 characters
      Open

              \mkdir(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage', 0777, true);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              for ($i = 0; $i < 4; ++$i) {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $data[] = ['Users', 'imagename', $i];
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public function providerDeleteImageForRecord()
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $file
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      $record = self::$cache['Contacts'] ?? \Tests\Base\C_RecordActions::createContactRecord(false)->getId();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 155 characters
      Open

              $filePathDst = ROOT_DIRECTORY . '/storage/MultiImage/' . md5(random_int(0, 9999)) . substr(self::$files[$file], \strpos(self::$files[$file], '.'));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              \copy($filePathSrc, $filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $fileObj = \App\Fields\File::loadFromPath($filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  'size' => $fileObj->getSize(),
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($fileObj->getSize(), $data[0]['size'], 'File size should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $field
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                      'name' => $name,
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Data provider for the delete record images test.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @codeCoverageIgnore
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $module
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Attach image to record test.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  default:
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              self::$cache[$module] = $record;
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertSame($hash, $url['key'], 'Key in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  \copy($filePathSrc, $filePathDst);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->set('imagename', \App\Json::encode($attach));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @codeCoverageIgnore
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public function providerImageForRecord()
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  ['Contacts', 'imagename'],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  ['Products', 'imagename'],
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @param $module
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $fieldModel = $recordModel->getField($field);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * @throws \App\Exceptions\AppException
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              foreach ($attach as $info) {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $this->assertNotEmpty($data);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertFileExists($attach[$i]['path'], 'File should exists');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame((string) $recordModel->getId(), $url['record'], 'Record in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertFileDoesNotExist($info['path'], 'File should be removed');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR, true);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame($data[$i]['key'], $url['key'], 'Key in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 209 characters
      Open

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get('imagename'), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              foreach (self::$files as $i => $name) {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 129 characters
      Open

                  $this->assertSame((string) $recordModel->getId(), $url['record'], 'Record in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $fieldModel = $recordModel->getField('imagename');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame($attach[$i]['key'], $data[$i]['key'], 'Key should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame('Products', $url['module'], 'Module in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $data = \App\Json::decode(\App\Purifier::decodeHtml($fieldModel->getUITypeModel()->getDisplayValueEncoded($recordModel->get('imagename'), $recordModel->getId(), $fieldModel->getFieldInfo()['limit'])));
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame($attach[$i]['size'], $data[$i]['size'], 'File size should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame($name, $data[$i]['name'], 'File name should be equal');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  $this->assertSame('imagename', $url['field'], 'Field name in image url should be equal to provided');
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

              $recordModel->delete();
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

           * Cleaning after tests.
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          public static function tearDownAfterClass(): void
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Line exceeds 120 characters; contains 147 characters
      Open

              \vtlib\Functions::recurseDelete('tests' . \DIRECTORY_SEPARATOR . 'tmp' . \DIRECTORY_SEPARATOR . 'MultiImage' . \DIRECTORY_SEPARATOR, true);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

                  parse_str(\parse_url($data[$i]['imageSrc'])['query'], $url);
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      Class name "Z_MultiImage" is not in camel caps format
      Open

      class Z_MultiImage extends \Tests\Base
      Severity: Minor
      Found in tests/Base/Z_MultiImage.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status