The class ModuleManager has 12 public methods. Consider refactoring ModuleManager to keep number of public methods under 10. Open
class ModuleManager extends \Tests\Base
{
/**
* Zip file name.
*
- Read upRead up
- Exclude checks
TooManyPublicMethods
Since: 0.1
A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.
By default it ignores methods starting with 'get' or 'set'.
Example
Source https://phpmd.org/rules/codesize.html#toomanypublicmethods
File ModuleManager.php
has 300 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* ModuleManager test class.
*
* @package Tests
Method testCreateNewField
has 74 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testCreateNewField($type, $param, $suffix = '')
{
$key = $type . $suffix;
$param['fieldType'] = $type;
$param['fieldLabel'] = $type . 'FL' . $suffix;
Function testCreateNewField
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
public function testCreateNewField($type, $param, $suffix = '')
{
$key = $type . $suffix;
$param['fieldType'] = $type;
$param['fieldLabel'] = $type . 'FL' . $suffix;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method testDeleteNewField
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testDeleteNewField($type, $param, $suffix = '')
{
$key = $type . $suffix;
$fieldInstance = \Settings_LayoutEditor_Field_Model::getInstance(self::$fieldsId[$key]);
$uitype = $fieldInstance->getUIType();
Function testDeleteNewField
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function testDeleteNewField($type, $param, $suffix = '')
{
$key = $type . $suffix;
$fieldInstance = \Settings_LayoutEditor_Field_Model::getInstance(self::$fieldsId[$key]);
$uitype = $fieldInstance->getUIType();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method testCreateNewField() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function testCreateNewField($type, $param, $suffix = '')
{
$key = $type . $suffix;
$param['fieldType'] = $type;
$param['fieldLabel'] = $type . 'FL' . $suffix;
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
The class ModuleManager has a coupling between objects value of 20. Consider to reduce the number of dependencies under 13. Open
class ModuleManager extends \Tests\Base
{
/**
* Zip file name.
*
- Read upRead up
- Exclude checks
CouplingBetweenObjects
Since: 1.1.0
A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability
Example
class Foo {
/**
* @var \foo\bar\X
*/
private $x = null;
/**
* @var \foo\bar\Y
*/
private $y = null;
/**
* @var \foo\bar\Z
*/
private $z = null;
public function setFoo(\Foo $foo) {}
public function setBar(\Bar $bar) {}
public function setBaz(\Baz $baz) {}
/**
* @return \SplObjectStorage
* @throws \OutOfRangeException
* @throws \InvalidArgumentException
* @throws \ErrorException
*/
public function process(\Iterator $it) {}
// ...
}
Source https://phpmd.org/rules/design.html#couplingbetweenobjects
Missing class import via use statement (line '325', column '29'). Open
$this->assertFalse((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'The record from "s_#__multireference" was not removed.');
- Read upRead up
- Exclude checks
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 '352', column '24'). Open
$packageExport = new \vtlib\PackageExport();
- Read upRead up
- Exclude checks
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 '98', column '21'). Open
$rowModule = (new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->one();
- Read upRead up
- Exclude checks
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->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => self::$fieldsId[$key]])->count(), $profilesId, "The field \"$type\" did not add correctly to the profiles");
- Read upRead up
- Exclude checks
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 '128', column '24'). Open
$blockInstance = new \Settings_LayoutEditor_Block_Model();
- Read upRead up
- Exclude checks
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 '187', column '29'). Open
$this->assertCount((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), $param['referenceModule'], 'Problem with table "vtiger_fieldmodulerel" in database');
- Read upRead up
- Exclude checks
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 '183', column '29'). Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => $rowExtra['fieldid']])->count(), $profilesId, "The \"extra\" field \"$type\" did not add correctly to the profiles");
- Read upRead up
- Exclude checks
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 '216', column '11'). Open
(new \App\Db\Query())->from('vtiger_role')->count() * \count($param['pickListValues']),
- Read upRead up
- Exclude checks
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 '205', column '12'). Open
(new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()
- Read upRead up
- Exclude checks
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 '319', column '11'). Open
(new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $columnName])->exists(),
- Read upRead up
- Exclude checks
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 '217', column '11'). Open
(new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => $rowPicklist['picklistid']])->count(),
- Read upRead up
- Exclude checks
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 '322', column '31'). Open
$this->assertSame(0, (new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => self::$pickList[$key]])->count(), 'All rows in the table "vtiger_role2picklist" have not been deleted');
- Read upRead up
- Exclude checks
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 '392', column '9'). Open
(new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => self::$treeId])->exists(),
- Read upRead up
- Exclude checks
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 '71', column '18'). Open
$package = new \vtlib\LanguageExport();
- Read upRead up
- Exclude checks
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 '307', column '29'). Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsExtraId[$key]])->exists(), 'The record "extra" was not removed from the database ID: ' . self::$fieldsExtraId[$key]);
- Read upRead up
- Exclude checks
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 '310', column '28'). Open
$this->assertSame((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), 0, 'Problem with table "vtiger_fieldmodulerel" in database');
- Read upRead up
- Exclude checks
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 '302', column '27'). Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key]])->exists(), 'The record was not removed from the database ID: ' . self::$fieldsId[$key]);
- Read upRead up
- Exclude checks
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 '169', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Read upRead up
- Exclude checks
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 '209', column '25'). Open
$rowPicklist = (new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $param['fieldName']])->one();
- Read upRead up
- Exclude checks
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 '420', column '31'). Open
$this->assertSame(1, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Read upRead up
- Exclude checks
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 '133', column '15'). Open
$row = (new \App\Db\Query())->from('vtiger_blocks')->where(['blockid' => self::$blockId])->one();
- Read upRead up
- Exclude checks
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 '181', column '22'). Open
$rowExtra = (new \App\Db\Query())->from('vtiger_field')->where(['fieldname' => $param['fieldName'] . '_extra'])->one();
- Read upRead up
- Exclude checks
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 '192', column '69'). Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Read upRead up
- Exclude checks
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 '222', column '28'). Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Read upRead up
- Exclude checks
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 '429', column '29'). Open
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
- Read upRead up
- Exclude checks
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 '388', column '9'). Open
(new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->exists(),
- Read upRead up
- Exclude checks
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 '415', column '29'). Open
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
- Read upRead up
- Exclude checks
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 '434', column '31'). Open
$this->assertSame(0, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Read upRead up
- Exclude checks
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_LayoutEditor_Field_Model' in method 'testDeleteNewField'. Open
$fieldInstance = \Settings_LayoutEditor_Field_Model::getInstance(self::$fieldsId[$key]);
- Read upRead up
- Exclude checks
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\Language' in method 'getLangPathToFile'. Open
$allLang = \App\Language::getAll();
- Read upRead up
- Exclude checks
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\Profile' in method 'testCreateNewField'. Open
$profilesId = \vtlib\Profile::getAllIds();
- Read upRead up
- Exclude checks
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_Module_Model' in method 'testCreateNewBlock'. Open
$moduleModel = \Vtiger_Module_Model::getInstance('TestModule');
- Read upRead up
- Exclude checks
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_Block_Model' in method 'testDeleteNewBlock'. Open
$blockInstance = \Vtiger_Block_Model::getInstance(self::$blockId);
- Read upRead up
- Exclude checks
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_ModuleManager_Module_Model' in method 'testCreateModule'. Open
$module = \Settings_ModuleManager_Module_Model::createModule([
'module_name' => 'TestModule',
'entityfieldname' => 'testmodule',
'module_label' => 'TestModule',
'entitytype' => \Vtiger_Module_Model::ADVANCED_TYPE,
- Read upRead up
- Exclude checks
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\Module' in method 'testCreateModule'. Open
$this->assertSame('TestModule', \App\Module::getModuleName($module->getId()), 'The name of the new module is missing: ' . $module->getId());
- Read upRead up
- Exclude checks
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\Module' in method 'testExportModule'. Open
$moduleModel = \vtlib\Module::getInstance('TestModule');
- Read upRead up
- Exclude checks
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\Module' in method 'getMRVField'. Open
$moduleInstance = \vtlib\Module::getInstance('Contacts');
- Read upRead up
- Exclude checks
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\Module' in method 'getMRVField'. Open
$source_Module = \vtlib\Module::getInstance('TestModule');
- Read upRead up
- Exclude checks
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_Block_Model' in method 'testDeleteNewBlock'. Open
$this->assertFalse(\Vtiger_Block_Model::checkFieldsExists(self::$blockId), 'Fields exists');
- Read upRead up
- Exclude checks
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_ModuleManager_Module_Model' in method 'testOffAllModule'. Open
$allModules = \Settings_ModuleManager_Module_Model::getAll();
- Read upRead up
- Exclude checks
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_ModuleManager_Module_Model' in method 'testOnAllModule'. Open
$allModules = \Settings_ModuleManager_Module_Model::getAll();
- Read upRead up
- Exclude checks
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_ModuleManager_Library_Model' in method 'testDownloadLibraryModule'. Open
$libraries = \Settings_ModuleManager_Library_Model::getAll();
- Read upRead up
- Exclude checks
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_ModuleManager_Library_Model' in method 'testDownloadLibraryModule'. Open
$this->assertTrue(\Settings_ModuleManager_Library_Model::download($key), "The library \"{$key}\" could not be downloaded");
- Read upRead up
- Exclude checks
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\Config' in method 'testDownloadLibraryModule'. Open
$mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : \App\Version::get($library['name']);
- Read upRead up
- Exclude checks
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\Module' in method 'testDeleteModule'. Open
$moduleInstance = \vtlib\Module::getInstance('TestModule');
- Read upRead up
- Exclude checks
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\Zip' in method 'testExportModule'. Open
$zip = \App\Zip::openFile(self::$zipFileName, ['checkFiles' => false]);
- Read upRead up
- Exclude checks
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\Version' in method 'testDownloadLibraryModule'. Open
$mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : \App\Version::get($library['name']);
- Read upRead up
- Exclude checks
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 "fieldName" 9 times. Open
$param['fieldName'] = strtolower($type . 'FL' . $suffix);
- Read upRead up
- Exclude checks
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 "" 4 times. Open
$this->assertNotNull(\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" does not exist');
- Read upRead up
- Exclude checks
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 "fieldTypeList" 21 times. Open
['Text', ['fieldTypeList' => 0, 'fieldLength' => 12]],
- Read upRead up
- Exclude checks
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 "/PL.zip" 4 times. Open
$package->exportLanguage('pl-PL', ROOT_DIRECTORY . '/PL.zip', 'PL.zip');
- Read upRead up
- Exclude checks
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 "presence" 4 times. Open
if (1 !== (int) $module->get('presence')) {
- Read upRead up
- Exclude checks
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 "vtiger_tab" 4 times. Open
$rowModule = (new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->one();
- Read upRead up
- Exclude checks
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 "TestModule" 17 times. Open
'module_name' => 'TestModule',
- Read upRead up
- Exclude checks
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 "pickListValues" 7 times. Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Read upRead up
- Exclude checks
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
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Read upRead up
- Exclude checks
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 "picklistid" 3 times. Open
(new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => $rowPicklist['picklistid']])->count(),
- Read upRead up
- Exclude checks
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 "fieldid" 9 times. Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Read upRead up
- Exclude checks
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 "vtiger_field" 4 times. Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Read upRead up
- Exclude checks
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 "TestModule.json" 3 times. Open
$langFileToCheck = $this->getLangPathToFile('TestModule.json');
- Read upRead up
- Exclude checks
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 "uitype" 4 times. Open
$this->assertSame($row['uitype'], $details['uitype']);
- Read upRead up
- Exclude checks
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" 5 times. Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Read upRead up
- Exclude checks
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 "fieldLength" 5 times. Open
['Text', ['fieldTypeList' => 0, 'fieldLength' => 12]],
- Read upRead up
- Exclude checks
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.
Avoid unused parameters such as '$param'. Open
public function testDeleteNewField($type, $param, $suffix = '')
- Read upRead up
- Exclude checks
UnusedFormalParameter
Since: 0.2
Avoid passing parameters to methods or constructors and then not using those parameters.
Example
class Foo
{
private function bar($howdy)
{
// $howdy is not used
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter
Avoid unused local variables such as '$lang'. Open
foreach ($allLang as $key => $lang) {
- Read upRead up
- Exclude checks
UnusedLocalVariable
Since: 0.2
Detects when a local variable is declared and/or assigned, but not used.
Example
class Foo {
public function doSomething()
{
$i = 5; // Unused
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable
Call to undeclared method \App\Db\Query::from
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => self::$fieldsId[$key]])->count(), $profilesId, "The field \"$type\" did not add correctly to the profiles");
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['blocklabel'], 'label block');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$rowExtra = (new \App\Db\Query())->from('vtiger_field')->where(['fieldname' => $param['fieldName'] . '_extra'])->one();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('vtiger_blocks')->where(['blockid' => self::$blockId])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['iscustom'], 1);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertCount
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => $rowExtra['fieldid']])->count(), $profilesId, "The \"extra\" field \"$type\" did not add correctly to the profiles");
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(2, $rowModule['premium']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue(file_exists(ROOT_DIRECTORY . '/PL.zip') && filesize(ROOT_DIRECTORY . '/PL.zip') > 0);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileExists
Open
$this->assertFileExists(ROOT_DIRECTORY . '/modules/TestModule/TestModule.php');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$rowModule = (new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->one();
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotFalse
Open
$this->assertNotFalse($rowModule);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['fieldname'], $param['fieldName']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotFalse
Open
$this->assertNotFalse($rowExtra, 'No "extra" record for uitype: ' . $row['uitype']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileExists
Open
$this->assertFileExists($pathToFile);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['typeofdata'], $details['typeofdata']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['uitype'], $details['uitype']);
- Exclude checks
@throws type of getLangPathToFile
has undeclared type \Tests\Settings\Exception
(Did you mean class \Exception) Open
private function getLangPathToFile($fileName)
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => $rowExtra['fieldid']])->count(), $profilesId, "The \"extra\" field \"$type\" did not add correctly to the profiles");
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: ' . self::$fieldsId[$key]);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(\Vtiger_Module_Model::ADVANCED_TYPE, $rowModule['type']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertCount
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => self::$fieldsId[$key]])->count(), $profilesId, "The field \"$type\" did not add correctly to the profiles");
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), $param['referenceModule'], 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertIsInt
Open
$this->assertIsInt($module->getId());
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame('TestModule', $rowModule['tablabel']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame('TestModule', \App\Module::getModuleName($module->getId()), 'The name of the new module is missing: ' . $module->getId());
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotFalse
Open
$this->assertNotFalse($row, 'No record id: ' . self::$blockId);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame($row['fieldlabel'], $param['fieldLabel']);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'The record from "s_#__multireference" was not removed.');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertCount
Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileDoesNotExist
Open
$this->assertFileDoesNotExist(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . $pathToFile);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertDoesNotMatchRegularExpression
Open
$this->assertDoesNotMatchRegularExpression('/404/', $header['Status'] ?? '', $library['url'] . "/archive/$mode.zip | " . print_r($header, true));
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertSame((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), 0, 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertSame(0, (new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => self::$pickList[$key]])->count(), 'All rows in the table "vtiger_role2picklist" have not been deleted');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertCount
Open
$this->assertCount((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), $param['referenceModule'], 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key]])->exists(), 'The record was not removed from the database ID: ' . self::$fieldsId[$key]);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse(\Vtiger_Block_Model::checkFieldsExists(self::$blockId), 'Fields exists');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileDoesNotExist
Open
$this->assertFileDoesNotExist(ROOT_DIRECTORY . '/modules/TestModule/TestModule.php');
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]),
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue($fieldInstance->isCustomField(), 'Field is not customized');
- Exclude checks
Call to undeclared method \App\Db::getSchema
Open
$schema = \App\Db::getInstance()->getSchema();
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertContains
Open
$this->assertContains('modules' . \DIRECTORY_SEPARATOR . 'TestModule' . \DIRECTORY_SEPARATOR . 'TestModule.php', $zipFiles);
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
(new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => self::$treeId])->exists(),
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileExists
Open
$this->assertFileExists(self::$zipFileName);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertContains
Open
$this->assertContains($pathToFile, $zipFiles);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotNull
Open
$this->assertNotNull(\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" does not exist');
- Exclude checks
Call to undeclared method \App\Db::getTableSchema
Open
$this->assertNotNull(\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" does not exist');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsExtraId[$key]])->exists(), 'The record "extra" was not removed from the database ID: ' . self::$fieldsExtraId[$key]);
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
(new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => $rowPicklist['picklistid']])->count(),
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFileExists
Open
$this->assertFileExists($library['dir'] . 'version.php');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotNull
Open
$this->assertNotNull(
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$rowPicklist = (new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $param['fieldName']])->one();
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
(new \App\Db\Query())->from('vtiger_role')->count() * \count($param['pickListValues']),
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNull
Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNull
Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
(new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $columnName])->exists(),
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$this->assertFalse((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'The record from "s_#__multireference" was not removed.');
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
(new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->exists(),
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertNotFalse
Open
$this->assertNotFalse(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key]])->exists(), 'The record was not removed from the database ID: ' . self::$fieldsId[$key]);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(0, (new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => self::$pickList[$key]])->count(), 'All rows in the table "vtiger_role2picklist" have not been deleted');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertContains
Open
$this->assertContains('manifest.xml', $zipFiles);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(0, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
(new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue($blockInstance->isCustomized(), 'Block is not customized');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse($moduleModel->isExportable(), 'Module exportable!');
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue($moduleModel->isExportable(), 'Module not exportable!');
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$this->assertSame(1, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Call to undeclared method \App\Db\Query::select
Open
$this->assertSame(0, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsExtraId[$key]])->exists(), 'The record "extra" was not removed from the database ID: ' . self::$fieldsExtraId[$key]);
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertCount
Open
$this->assertCount(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), 0, 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Argument 1 (fileName)
is string
but \App\Zip::openFile()
takes bool|false
defined at /code/app/Zip.php:51
Open
$zip = \App\Zip::openFile(self::$zipFileName, ['checkFiles' => false]);
- Exclude checks
Call to undeclared method \App\Db::getSchema
Open
\App\Db::getInstance()->getSchema()->refresh();
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertFalse
Open
$this->assertFalse(
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertTrue
Open
$this->assertTrue(\Settings_ModuleManager_Library_Model::download($key), "The library \"{$key}\" could not be downloaded");
- Exclude checks
Call to undeclared method \Tests\Settings\ModuleManager::assertSame
Open
$this->assertSame(1, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function testOnAllModule()
{
$allModules = \Settings_ModuleManager_Module_Model::getAll();
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
foreach ($allModules as $module) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 114.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function testOffAllModule()
{
$allModules = \Settings_ModuleManager_Module_Model::getAll();
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
foreach ($allModules as $module) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 114.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Array of fields id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $treeId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
unlink(ROOT_DIRECTORY . '/PL.zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Zip file name.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Block id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $blockId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $pickList;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue(file_exists(ROOT_DIRECTORY . '/PL.zip') && filesize(ROOT_DIRECTORY . '/PL.zip') > 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Tables name for uitype: 16, 15.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'entityfieldname' => 'testmodule',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $zipFileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $fieldsExtraId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing the module creation.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testCreateModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $tablesName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'module_name' => 'TestModule',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Id for picklist.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Id for field extra.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$module = \Settings_ModuleManager_Module_Model::createModule([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $fieldsId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Id for tree.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing language exports.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$package->exportLanguage('pl-PL', ROOT_DIRECTORY . '/PL.zip', 'PL.zip');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$package = new \vtlib\LanguageExport();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($rowModule);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(2, $rowModule['premium']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @throws Exception
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allLang as $key => $lang) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $langFileToCheck;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['MRVField'] = $this->getMRVField();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertCount((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), $param['referenceModule'], 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @var array()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testLanguageExport()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance = new \Settings_LayoutEditor_Block_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($param['sourceModule']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => self::$fieldsId[$key]])->count(), $profilesId, "The field \"$type\" did not add correctly to the profiles");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($rowExtra, 'No "extra" record for uitype: ' . $row['uitype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'entityfieldlabel' => 'TestModule',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists(ROOT_DIRECTORY . '/modules/TestModule/TestModule.php');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($langFileToCheck as $pathToFile) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Vtiger_Module_Model::getInstance('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->set('label', 'label block');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $suffix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$key = $type . $suffix;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['typeofdata'], $details['typeofdata']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('Tree' === $type || 'CategoryMultipicklist' === $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->from('vtiger_role')->count() * \count($param['pickListValues']),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 305: //MultiReferenceValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$blockId = $blockInstance->save($moduleModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['blockid'] = self::$blockId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allLang = \App\Language::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFileToCheck[] = 'languages' . \DIRECTORY_SEPARATOR . $key . \DIRECTORY_SEPARATOR . $fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing the creation of a new field for the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testCreateNewField($type, $param, $suffix = '')
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['sourceModule'] = 'TestModule';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['tree'] = self::$treeId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif ('MultiReferenceValue' === $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$details = $moduleModel->getTypeDetailsForAddField($type, $param);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($row['uitype']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 15: //Picklist
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowPicklist,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertIsInt($module->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getLangPathToFile($fileName)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'module_label' => 'TestModule',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowModule = (new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing the creation of a new block for the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$fieldsId[$key] = $fieldModel->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Add a tree if it does not exist
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 10: //Related1M
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['pickListValues'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowExtra = (new \App\Db\Query())->from('vtiger_field')->where(['fieldname' => $param['fieldName'] . '_extra'])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$rowPicklist = (new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $param['fieldName']])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Line exceeds 120 characters; contains 230 characters Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$rowPicklist = (new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $param['fieldName']])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 134 characters Open
(new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => $rowPicklist['picklistid']])->count(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->set('iscustom', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$tablesName[$key] = 'vtiger_' . $param['fieldName'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('vtiger_blocks')->where(['blockid' => self::$blockId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Table "' . self::$tablesName[$key] . '" does not exist'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule($param['sourceModule']);
- Exclude checks
Line exceeds 120 characters; contains 233 characters Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Wrong number of rows in the table "vtiger_role2picklist"'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = $moduleModel->addField($param['fieldType'], self::$blockId, $param);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerForField
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['fieldlabel'], $param['fieldLabel']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get Id of MultiReferenceValue field.
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
$row = (new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key], 'tabid' => $moduleModel->getId()])->one();
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$rowExtra = (new \App\Db\Query())->from('vtiger_field')->where(['fieldname' => $param['fieldName'] . '_extra'])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 33: //MultiSelectCombo
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertCount(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$tablesName[$key] = 'vtiger_' . $param['fieldName'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull(\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" does not exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertCount(0, array_diff($param['pickListValues'], (new \App\Db\Query())->select($param['fieldName'])->from(self::$tablesName[$key])->column()), 'Bad values in the table "' . self::$tablesName[$key] . '"');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'premium' => 2,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFileToCheck = $this->getLangPathToFile('TestModule.json');
- Exclude checks
Line exceeds 120 characters; contains 127 characters Open
self::$treeId = (new TreesManager())->testAddTree(1, \Vtiger_Module_Model::getInstance('TestModule')->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 11: //Phone
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotNull(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
0,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'No record in the table "s_yf_multireference" for type ' . $type);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'entitytype' => \Vtiger_Module_Model::ADVANCED_TYPE,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame('TestModule', \App\Module::getModuleName($module->getId()), 'The name of the new module is missing: ' . $module->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $fileName
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: ' . self::$blockId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['blocklabel'], 'label block');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['fieldName'] = strtolower($type . 'FL' . $suffix);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testCreateNewBlock()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$treeId = (new TreesManager())->testAddTree(1, \Vtiger_Module_Model::getInstance('TestModule')->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNotFalse($row, 'No record id: ' . self::$fieldsId[$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty(self::$treeId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['fieldname'], $param['fieldName']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => $rowExtra['fieldid']])->count(), $profilesId, "The \"extra\" field \"$type\" did not add correctly to the profiles");
- Exclude checks
Line exceeds 120 characters; contains 225 characters Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => $rowExtra['fieldid']])->count(), $profilesId, "The \"extra\" field \"$type\" did not add correctly to the profiles");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$fieldsExtraId[$key] = $rowExtra['fieldid'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 16: //Picklist
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'The record from "vtiger_picklist" not exists NAME: ' . $param['fieldName']
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => $rowPicklist['picklistid']])->count(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame('TestModule', $rowModule['tablabel']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['iscustom'], 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame($row['uitype'], $details['uitype']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Bad values in the table "' . self::$tablesName[$key] . '"'
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
$this->assertSame('TestModule', \App\Module::getModuleName($module->getId()), 'The name of the new module is missing: ' . $module->getId());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(\Vtiger_Module_Model::ADVANCED_TYPE, $rowModule['type']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $param
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$profilesId = \vtlib\Profile::getAllIds();
- Exclude checks
Line exceeds 120 characters; contains 208 characters Open
$this->assertCount((new \App\Db\Query())->from('vtiger_profile2field')->where(['fieldid' => self::$fieldsId[$key]])->count(), $profilesId, "The field \"$type\" did not add correctly to the profiles");
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$this->assertNotNull(\App\Db::getInstance()->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" does not exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists($pathToFile);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFileToCheck = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['fieldType'] = $type;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$param['fieldLabel'] = $type . 'FL' . $suffix;
- Exclude checks
Line exceeds 120 characters; contains 228 characters Open
$this->assertCount((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), $param['referenceModule'], 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
array_diff(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$pickList[$key] = $param['pickListValues'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Time', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @dataProvider providerForField
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Currency', ['fieldTypeList' => 0, 'fieldLength' => 4, 'decimal' => 3]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Skype', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
"The record from \"vtiger_picklist\" was not removed from the database: {$columnName}"
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing the deletion of a new block for the module.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip->close();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($langFileToCheck as $pathToFile) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDownloadLibraryModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : \App\Version::get($library['name']);
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$this->assertTrue(\Settings_ModuleManager_Library_Model::download($key), "The library \"{$key}\" could not be downloaded");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleManagerModel->enableModule($module->get('name'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance = \vtlib\Module::getInstance('Contacts');
- Exclude checks
Line exceeds 120 characters; contains 122 characters Open
['Picklist', ['fieldTypeList' => 0, 'pickListValues' => ['b1', 'b2', 'b3'], 'isRoleBasedPickList' => 1], '2'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing the deletion of a new field.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsExtraId[$key]])->exists(), 'The record "extra" was not removed from the database ID: ' . self::$fieldsExtraId[$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(0, (new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => self::$pickList[$key]])->count(), 'All rows in the table "vtiger_role2picklist" have not been deleted');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
default:
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipFiles[] = $fileName;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->from('vtiger_tab')->where(['name' => 'TestModule'])->exists(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$source_Module->setRelatedList($moduleInstance, 'TestRel123', ['ADD', 'SELECT'], 'getRelatedList');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Percent', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Picklist', ['fieldTypeList' => 0, 'pickListValues' => ['b1', 'b2', 'b3'], 'isRoleBasedPickList' => 1], '2'],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$uitype = $fieldInstance->getUIType();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 33: //MultiSelectCombo
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing module removal.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Db::getInstance()->getSchema()->refresh();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileDoesNotExist(ROOT_DIRECTORY . '/modules/TestModule/TestModule.php');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileDoesNotExist(ROOT_DIRECTORY . \DIRECTORY_SEPARATOR . $pathToFile);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse(
- Exclude checks
Line exceeds 120 characters; contains 157 characters Open
$this->assertDoesNotMatchRegularExpression('/404/', $header['Status'] ?? '', $library['url'] . "/archive/$mode.zip | " . print_r($header, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists($library['dir'] . 'version.php');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Picklist', ['fieldTypeList' => 0, 'pickListValues' => ['a1', 'a2', 'a3']]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['CategoryMultipicklist', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['MultiReferenceValue', ['fieldTypeList' => 0, 'MRVModule' => 'Contacts']],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @see https://phpunit.de/manual/3.7/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.data-providers
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
switch ($uitype) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 11: //Phone
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse($moduleModel->isExportable(), 'Module exportable!');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($moduleModel->isExportable(), 'Module not exportable!');
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$this->assertSame(1, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testOnAllModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Turn on the module if it is off
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function providerForField()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Text', ['fieldTypeList' => 0, 'fieldLength' => 12]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Decimal', ['fieldTypeList' => 0, 'fieldLength' => 6, 'decimal' => 2]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['MultiSelectCombo', ['fieldTypeList' => 0, 'pickListValues' => ['c1', 'c2', 'c3']]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$schema->refresh();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse(\Vtiger_Block_Model::checkFieldsExists(self::$blockId), 'Fields exists');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFileExists(self::$zipFileName);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header = get_headers($library['url'] . "/archive/$mode.zip", 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleManagerModel = new \Settings_ModuleManager_Module_Model();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 128 characters Open
$moduleModel = \Settings_LayoutEditor_Module_Model::getInstance('Settings:LayoutEditor')->setSourceModule('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Editor', ['fieldTypeList' => 0, 'fieldLength' => 100]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Related1M', ['fieldTypeList' => 0, 'referenceModule' => ['Contacts', 'Accounts', 'Leads']]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Tree', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDeleteNewField($type, $param, $suffix = '')
- Exclude checks
Line exceeds 120 characters; contains 203 characters Open
$this->assertSame((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), 0, 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($blockInstance->isCustomized(), 'Block is not customized');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$packageExport = new \vtlib\PackageExport();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertContains('manifest.xml', $zipFiles);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance = \vtlib\Module::getInstance('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'The test module exists in the database'
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertDoesNotMatchRegularExpression('/404/', $header['Status'] ?? '', $library['url'] . "/archive/$mode.zip | " . print_r($header, true));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allModules = \Settings_ModuleManager_Module_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allModules as $module) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Turn off the module if it is on
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getMRVField()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $param
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key]])->exists(), 'The record was not removed from the database ID: ' . self::$fieldsId[$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 305: //MultiReferenceValue
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => self::$treeId])->exists(),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$source_Module = \vtlib\Module::getInstance('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Integer', ['fieldTypeList' => 0, 'fieldLength' => 2]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$columnName = $fieldInstance->getColumnName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue($fieldInstance->isCustomField(), 'Field is not customized');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Line exceeds 120 characters; contains 217 characters Open
$this->assertSame(0, (new \App\Db\Query())->from('vtiger_role2picklist')->where(['picklistid' => self::$pickList[$key]])->count(), 'All rows in the table "vtiger_role2picklist" have not been deleted');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDeleteNewBlock()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance = \Vtiger_Block_Model::getInstance(self::$blockId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$zipFileName = $packageExport->getZipFileName();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fileName = $zip->getNameIndex($i);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertContains($pathToFile, $zipFiles);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($langFileToCheck as $pathToFile) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'The tree was not removed'
- Exclude checks
Line exceeds 120 characters; contains 150 characters Open
$this->assertSame(0, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Data provider for testCreateNewField and testDeleteNewField.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @codeCoverageIgnore
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Email', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Checkbox', ['fieldTypeList' => 0]],
- Exclude checks
Line exceeds 120 characters; contains 230 characters Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsExtraId[$key]])->exists(), 'The record "extra" was not removed from the database ID: ' . self::$fieldsExtraId[$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 10: //Related1M
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame((new \App\Db\Query())->from('vtiger_fieldmodulerel')->where(['fieldid' => self::$fieldsId[$key]])->count(), 0, 'Problem with table "vtiger_fieldmodulerel" in database');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Testing download librares.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertTrue(\Settings_ModuleManager_Library_Model::download($key), "The library \"{$key}\" could not be downloaded");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[] = $valF->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Phone', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance->delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 16: //Picklist
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->delete(false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel = \vtlib\Module::getInstance('TestModule');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleModel->allowExport = true;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFileToCheck = $this->getLangPathToFile('TestModule.json');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$libraries = \Settings_ModuleManager_Library_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($allModules as $module) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['Date', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldInstance = \Settings_LayoutEditor_Field_Model::getInstance(self::$fieldsId[$key]);
- Exclude checks
Line exceeds 120 characters; contains 226 characters Open
$this->assertFalse((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'The record from "s_#__multireference" was not removed.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zipFiles = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
for ($i = 0; $i < $zip->numFiles; ++$i) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$langFileToCheck = $this->getLangPathToFile('TestModule.json');
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : \App\Version::get($library['name']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (1 !== (int) $module->get('presence')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$allModules = \Settings_ModuleManager_Module_Model::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($moduleModel->getRelations() as $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['URL', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
['TextArea', ['fieldTypeList' => 0]],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param mixed $suffix
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
(new \App\Db\Query())->from('vtiger_picklist')->where(['name' => $columnName])->exists(),
- Exclude checks
Line exceeds 120 characters; contains 204 characters Open
$this->assertFalse((new \App\Db\Query())->from('vtiger_field')->where(['fieldid' => self::$fieldsId[$key]])->exists(), 'The record was not removed from the database ID: ' . self::$fieldsId[$key]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
case 15: //Picklist
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing module export.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testExportModule()
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
$this->assertContains('modules' . \DIRECTORY_SEPARATOR . 'TestModule' . \DIRECTORY_SEPARATOR . 'TestModule.php', $zipFiles);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(0, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleInstance->delete();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Testing module off.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertSame(1, (new \App\Db\Query())->select(['presence'])->from('vtiger_tab')->where(['tabid' => $module->getId()])->scalar());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testOffAllModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fields[0];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$schema = \App\Db::getInstance()->getSchema();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$packageExport->export($moduleModel, '', '', false);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testDeleteModule()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($libraries as $key => $library) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$moduleManagerModel->disableModule($module->get('name'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return int
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($value->getFields() as $valF) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$key = $type . $suffix;
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
$this->assertNull($schema->getTableSchema(self::$tablesName[$key]), 'Table "' . self::$tablesName[$key] . '" exist');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse((new \App\Db\Query())->from('s_#__multireference')->where(['source_module' => 'TestModule', 'dest_module' => 'Contacts'])->exists(), 'The record from "s_#__multireference" was not removed.');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$zip = \App\Zip::openFile(self::$zipFileName, ['checkFiles' => false]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertContains('modules' . \DIRECTORY_SEPARATOR . 'TestModule' . \DIRECTORY_SEPARATOR . 'TestModule.php', $zipFiles);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->assertFalse(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
//Check if remote file exists
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
// Testing module on.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 !== (int) $module->get('presence')) {
- Exclude checks
The variable $source_Module is not named in camelCase. Open
private function getMRVField()
{
$source_Module = \vtlib\Module::getInstance('TestModule');
$moduleInstance = \vtlib\Module::getInstance('Contacts');
$source_Module->setRelatedList($moduleInstance, 'TestRel123', ['ADD', 'SELECT'], 'getRelatedList');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $source_Module is not named in camelCase. Open
private function getMRVField()
{
$source_Module = \vtlib\Module::getInstance('TestModule');
$moduleInstance = \vtlib\Module::getInstance('Contacts');
$source_Module->setRelatedList($moduleInstance, 'TestRel123', ['ADD', 'SELECT'], 'getRelatedList');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}