Method testLogIn2fa
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testLogIn2fa(): void
{
$request = $this->httpClient->get('Users/TwoFactorAuth', self::$requestOptions);
$this->logs = $body = $request->getBody()->getContents();
$response = \App\Json::decode($body);
Method testAddConfiguration
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function testAddConfiguration(): void
{
$app = \Settings_WebserviceApps_Record_Model::getCleanInstance();
$app->set('type', 'WebserviceStandard');
$app->set('status', 1);
The class WebserviceStandardTest has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13. Open
final class WebserviceStandardTest extends \Tests\Base
{
use AssertsTrait;
/**
- 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 '69', column '27'). Open
$this->httpClient = new \GuzzleHttp\Client(\App\Utils::merge(\App\RequestHttp::getOptions(), [
- 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 '21'). Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- 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 '21'). Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- 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 '122', column '15'). Open
$row = (new \App\Db\Query())->from('w_#__api_user')->where(['id' => self::$apiUserId])->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
Avoid using static access to class '\App\Encryption' in method 'testAddConfiguration'. Open
static::assertTrue(\App\Encryption::verifyPasswordHash('api', $row['password'], 'WebserviceStandard'));
- 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\Fields\ServerAccess' in method 'testAddConfiguration'. Open
$row = \App\Fields\ServerAccess::get(self::$serverId);
- 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\Utils' in method 'testLogIn2fa'. Open
$request = $this->httpClient->post('Users/TwoFactorAuth', \App\Utils::merge(
[
'json' => [
'methods' => 'TOPO',
'secret' => $secretKey,
- 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\Utils' in method 'setUp'. Open
$this->httpClient = new \GuzzleHttp\Client(\App\Utils::merge(\App\RequestHttp::getOptions(), [
'base_uri' => \App\Config::main('site_URL') . 'webservice/WebserviceStandard/',
'auth' => ['api', 'api'],
'Content-Type' => 'application/json',
'Accept' => 'application/json',
- 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_Field_Model' in method 'testAddConfiguration'. Open
$fieldModel = \Vtiger_Field_Model::init('Accounts', \App\Field::SYSTEM_FIELDS['share_externally']);
- 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_WebserviceApps_Record_Model' in method 'testAddConfiguration'. Open
$app = \Settings_WebserviceApps_Record_Model::getCleanInstance();
- 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\User' in method 'testAddConfiguration'. Open
'user_id' => \App\User::getActiveAdminId(),
- 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\Utils' in method 'testLogIn'. Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
[
'json' => [
'userName' => 'api@yetiforce.com',
'password' => 'api',
- 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\Json' in method 'testLogIn'. Open
$response = \App\Json::decode($body);
- 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\Json' in method 'testLogIn2fa'. Open
$response = \App\Json::decode($body);
- 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\Json' in method 'testLogIn2fa'. Open
$response = \App\Json::decode($body);
- 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\Encryption' in method 'testAddConfiguration'. Open
'password' => \App\Encryption::createPasswordHash('api', 'WebserviceStandard'),
- 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\Utils' in method 'testLogIn2fa'. Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
[
'json' => [
'userName' => 'api@yetiforce.com',
'password' => 'api',
- 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 'setUp'. Open
'base_uri' => \App\Config::main('site_URL') . 'webservice/WebserviceStandard/',
- 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_WebserviceUsers_Record_Model' in method 'testAddConfiguration'. Open
$user = \Settings_WebserviceUsers_Record_Model::getCleanInstance('WebserviceStandard');
- 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\Block' in method 'testAddConfiguration'. Open
$blockInstance = \vtlib\Block::getInstance('LBL_ACCOUNT_INFORMATION', 'Accounts');
- 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\Json' in method 'testLogIn2fa'. Open
$response = \App\Json::decode($body);
- 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\Json' in method 'testLogIn2fa'. Open
$response = \App\Json::decode($body);
- 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\Json' in method 'testLogout'. Open
$response = \App\Json::decode($body);
- 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\RequestHttp' in method 'setUp'. Open
$this->httpClient = new \GuzzleHttp\Client(\App\Utils::merge(\App\RequestHttp::getOptions(), [
- 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 "WebserviceStandard" 5 times. Open
$app->set('type', 'WebserviceStandard');
- 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 "/webservice/WebserviceStandard/Users/TwoFactorAuth" 3 times. Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'get', 200);
- 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 "Users/Login API error: " 4 times. Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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 "result" 5 times. Open
self::$authUserParams = $response['result'];
- 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 "Users/TwoFactorAuth" 3 times. Open
$request = $this->httpClient->get('Users/TwoFactorAuth', self::$requestOptions);
- 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 "password" 4 times. Open
'password' => \App\Encryption::createPasswordHash('api', 'WebserviceStandard'),
- 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 "Users/TwoFactorAuth API error: " 8 times. Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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.
Remove this unused "$recordId" private field. Open
private static $recordId;
- Read upRead up
- Exclude checks
If a private
field is declared but not used in the program, it can be considered dead code and should therefore be removed. This will
improve maintainability because developers will not wonder what the variable is used for.
Noncompliant Code Example
class MyClass { private $foo = 4; //foo is unused public function compute($a) { return $a * 4; } }
Compliant Solution
class MyClass { public function compute($a) { return $a * 4; } }
See
- CERT, MSC12-CPP. - Detect and remove code that has no effect
Define a constant instead of duplicating this literal "headers" 4 times. Open
'headers' => [
- 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 "status" 9 times. Open
$app->set('status', 1);
- 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 "api@yetiforce.com" 4 times. Open
'user_name' => 'api@yetiforce.com',
- 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 private fields such as '$recordId'. Open
private static $recordId;
- Read upRead up
- Exclude checks
UnusedPrivateField
Since: 0.2
Detects when a private field is declared and/or assigned a value, but not used.
Example
class Something
{
private static $FOO = 2; // Unused
private $i = 5; // Unused
private $j = 6;
public function addOne()
{
return $this->j++;
}
}
Source https://phpmd.org/rules/unusedcode.html#unusedprivatefield
Property \Tests\Integrations\WebserviceStandardTest::$schemaManager
has undeclared type \FR3D\SwaggerAssertions\SchemaManager
Open
protected static $schemaManager;
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame($row['type'], 'WebserviceStandard');
- Exclude checks
Call to method getActiveAdminId
from undeclared class \App\User
(Did you mean class \Tests\App\User) Open
'user_id' => \App\User::getActiveAdminId(),
- Exclude checks
Call to undeclared method \App\Db\Query::from
Open
$row = (new \App\Db\Query())->from('w_#__api_user')->where(['id' => self::$apiUserId])->one();
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Call to method delete
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->delete('Users/TwoFactorAuth', self::$requestOptions);
- Exclude checks
Call to method verifyPasswordHash
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
static::assertTrue(\App\Encryption::verifyPasswordHash('api', $row['password'], 'WebserviceStandard'));
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertTrue
Open
static::assertTrue($response['result'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertTrue
Open
static::assertTrue(\App\Encryption::verifyPasswordHash('api', $row['password'], 'WebserviceStandard'));
- Exclude checks
Call to method __construct
from undeclared class \PragmaRX\Google2FA\Google2FA
Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Property \Tests\Integrations\WebserviceStandardTest->httpClient
has undeclared type \GuzzleHttp\Client
Open
protected $httpClient;
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- Exclude checks
Call to method post
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertNotFalse
Open
static::assertNotFalse($row, 'No record id: ' . self::$serverId);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- Exclude checks
Class uses undeclared trait \FR3D\SwaggerAssertions\PhpUnit\AssertsTrait
Open
final class WebserviceStandardTest extends \Tests\Base
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame((int) $row['server_id'], self::$serverId);
- Exclude checks
Call to method __construct
from undeclared class \PragmaRX\Google2FA\Google2FA
Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame($row['pass'], 'api');
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Call to method post
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->post('Users/TwoFactorAuth', \App\Utils::merge(
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Call to method put
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->put('Users/Logout', self::$requestOptions);
- Exclude checks
Call to method __construct
from undeclared class \GuzzleHttp\Client
Open
$this->httpClient = new \GuzzleHttp\Client(\App\Utils::merge(\App\RequestHttp::getOptions(), [
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame($row['name'], 'api');
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Assigning int
to property but \Vtiger_Field_Model->fieldparams
is string
Open
$fieldModel->fieldparams = self::$serverId;
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame('TOTP', $response['result']['authMethods'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Call to method getCurrentOtp
from undeclared class \PragmaRX\Google2FA\Google2FA
Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'delete', 200);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame($row['status'], 1);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame($row['user_name'], 'api@yetiforce.com');
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'get', 200);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'post', 200);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Call to method createPasswordHash
from undeclared class \App\Encryption
(Did you mean class \Tests\App\Encryption) Open
'password' => \App\Encryption::createPasswordHash('api', 'WebserviceStandard'),
- Exclude checks
Assigning 'share_externally_api'
to property but \Vtiger_Field_Model->column
is false
Open
$fieldModel->column = $fieldModel->name = 'share_externally_api';
- Exclude checks
Call to method post
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Call to method getCurrentOtp
from undeclared class \PragmaRX\Google2FA\Google2FA
Open
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertResponseBodyMatch
Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Logout', 'put', 200);
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertNotFalse
Open
static::assertNotFalse($row, 'No record id: ' . self::$apiUserId);
- Exclude checks
Call to method get
from undeclared class \GuzzleHttp\Client
Open
$request = $this->httpClient->get('Users/TwoFactorAuth', self::$requestOptions);
- Exclude checks
Call to method __construct
from undeclared class \FR3D\SwaggerAssertions\SchemaManager
Open
self::$schemaManager = new SchemaManager(json_decode(file_get_contents(ROOT_DIRECTORY . \App\Installer\Developer::PATH . '/WebserviceStandard.json')));
- Exclude checks
Static call to undeclared method \Tests\Integrations\WebserviceStandardTest::assertSame
Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Similar blocks of code found in 3 locations. Consider refactoring. Open
public function testLogout(): void
{
$request = $this->httpClient->put('Users/Logout', self::$requestOptions);
$this->logs = $body = $request->getBody()->getContents();
$response = \App\Json::decode($body);
- 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 166.
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
Only one argument is allowed per line in a multi-line function call Open
], self::$requestOptions)
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
], self::$requestOptions)
- Exclude checks
Only one argument is allowed per line in a multi-line function call Open
], self::$requestOptions)
- 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
static::assertSame($row['status'], 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
private static $apiUserId;
- 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
'base_uri' => \App\Config::main('site_URL') . 'webservice/WebserviceStandard/',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app = \Settings_WebserviceApps_Record_Model::getCleanInstance();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->set('type', 'WebserviceStandard');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertNotFalse($row, 'No record id: ' . self::$serverId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'status' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crmid' => 0,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = (new \App\Db\Query())->from('w_#__api_user')->where(['id' => self::$apiUserId])->one();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertNotFalse($row, 'No record id: ' . self::$apiUserId);
- 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
protected static $schemaManager;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->set('name', 'api');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$row = \App\Fields\ServerAccess::get(self::$serverId);
- 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
protected $httpClient;
- 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
'type' => 1,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'popupReferenceModule' => 'Contacts',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'crmid_display' => '',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'user_id' => \App\User::getActiveAdminId(),
- 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
* Api server id.
- 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
private static $serverId;
- 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 $requestOptions = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private static $recordId;
- 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 add configuration.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'authy_methods' => 'PLL_AUTHY_TOTP',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame($row['user_name'], 'api@yetiforce.com');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$authUserParams = $response['result'];
- 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
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- 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
* Request options.
- 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
$this->httpClient = new \GuzzleHttp\Client(\App\Utils::merge(\App\RequestHttp::getOptions(), [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'timeout' => 60,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Test logon 2fa .
- 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
'json' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'secret' => $secretKey,
- 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::$requestOptions)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'post', 200);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Api user id.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Details about logged in user.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Content-Type' => 'application/json',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->set('url', '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->set('pass', 'api');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$requestOptions['headers']['x-api-key'] = $row['api_key'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user = \Settings_WebserviceUsers_Record_Model::getCleanInstance('WebserviceStandard');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel = \Vtiger_Field_Model::init('Accounts', \App\Field::SYSTEM_FIELDS['share_externally']);
- 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
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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
'code' => (new \PragmaRX\Google2FA\Google2FA())->getCurrentOtp($secretKey),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = $this->httpClient->delete('Users/TwoFactorAuth', self::$requestOptions);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = $this->httpClient->put('Users/Logout', self::$requestOptions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(1, $response['status'], 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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
'params' => ['language' => 'pl-PL'],
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'post', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], self::$requestOptions)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $body = $request->getBody()->getContents();
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'delete', 200);
- 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 SchemaManager */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'connect_timeout' => 60,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$serverId = (int) $app->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame($row['name'], 'api');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'user_name' => 'api@yetiforce.com',
- 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
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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
$request = $this->httpClient->get('Users/TwoFactorAuth', self::$requestOptions);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $body = $request->getBody()->getContents();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
self::$schemaManager = new SchemaManager(json_decode(file_get_contents(ROOT_DIRECTORY . \App\Installer\Developer::PATH . '/WebserviceStandard.json')));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected function setUp(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'headers' => [
- 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 testAddConfiguration(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'server_id' => self::$serverId,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$apiUserId = $user->getId();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame((int) $row['server_id'], self::$serverId);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->column = $fieldModel->name = 'share_externally_api';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance = \vtlib\Block::getInstance('LBL_ACCOUNT_INFORMATION', 'Accounts');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $body = $request->getBody()->getContents();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- 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
$request = $this->httpClient->post('Users/TwoFactorAuth', \App\Utils::merge(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Line exceeds 120 characters; contains 133 characters Open
static::assertSame(1, $response['status'], 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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
'auth' => ['api', 'api'],
- 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->set('status', 1);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$app->set('ips', '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->setData([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'password' => \App\Encryption::createPasswordHash('api', 'WebserviceStandard'),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$user->save();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testLogIn(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'json' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
use AssertsTrait;
- 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
'Accept' => 'application/json',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame($row['pass'], 'api');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'login_method' => 'PLL_PASSWORD',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userName' => 'api@yetiforce.com',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
], self::$requestOptions)
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$secretKey = $response['result']['secretKey'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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 \GuzzleHttp\Client */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$blockInstance->addField($fieldModel);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function setUpBeforeClass(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'password' => 'api',
- 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
'http_errors' => false,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$requestOptions['headers']['x-token'] = self::$authUserParams['token'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testLogIn2fa(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertTrue(\App\Encryption::verifyPasswordHash('api', $row['password'], 'WebserviceStandard'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing login.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'methods' => 'TOPO',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$authUserParams = $response['result'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $body = $request->getBody()->getContents();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$requestOptions['headers']['x-token'] = self::$authUserParams['token'];
- 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
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- 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->logs = $body = $request->getBody()->getContents();
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Testing Logout.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Logout', 'put', 200);
- 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 $authUserParams;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::$schemaManager = new SchemaManager(json_decode(file_get_contents(ROOT_DIRECTORY . \App\Installer\Developer::PATH . '/WebserviceStandard.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
static::assertSame($row['type'], 'WebserviceStandard');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldModel->fieldparams = self::$serverId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'json' => [
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'password' => 'api',
- 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
static::assertTrue($response['result'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'x-raw-data' => 1,
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'get', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'userName' => 'api@yetiforce.com',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'delete', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function testLogout(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = \App\Json::decode($body);
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->logs = $body = $request->getBody()->getContents();
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
static::assertSame(1, $response['status'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Logout', 'put', 200);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame('TOTP', $response['result']['authMethods'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
static::assertSame('TOTP', $response['result']['authMethods'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/TwoFactorAuth', 'get', 200);
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
static::assertTrue($response['result'], 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- 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
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Line exceeds 120 characters; contains 132 characters Open
static::assertSame(1, $response['status'], 'Users/Login API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
static::assertSame(200, $request->getStatusCode(), 'Users/Logout API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
self::assertResponseBodyMatch($response, self::$schemaManager, '/webservice/WebserviceStandard/Users/Login', 'post', 200);
- Exclude checks
Line exceeds 120 characters; contains 148 characters Open
static::assertSame(200, $request->getStatusCode(), 'Users/TwoFactorAuth API error: ' . PHP_EOL . $request->getReasonPhrase() . '|' . $body);
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 16 Open
], self::$requestOptions)
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
], self::$requestOptions)
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
], self::$requestOptions)
- Exclude checks
Closing parenthesis of a multi-line function call must be on a line by itself Open
], self::$requestOptions)
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$request = $this->httpClient->post('Users/Login', \App\Utils::merge(
- Exclude checks
Multi-line function call not indented correctly; expected 12 spaces but found 16 Open
[
- Exclude checks
Expected 0 spaces before closing bracket; newline found Open
$request = $this->httpClient->post('Users/TwoFactorAuth', \App\Utils::merge(
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
], self::$requestOptions)
- Exclude checks
Multi-line function call not indented correctly; expected 8 spaces but found 12 Open
], self::$requestOptions)
- Exclude checks