forked from joomla/joomla-cms
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[4.2] Convert tests to PSR-12 (joomla#38161)
* Convert tests to psr 12 where possible * fix rules * revert ignore
- Loading branch information
1 parent
4ff5e4f
commit fd5c2da
Showing
107 changed files
with
17,929 additions
and
17,751 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Tests | ||
* @subpackage Helper | ||
* | ||
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
namespace Helper; | ||
|
||
use Codeception\Module; | ||
|
@@ -21,58 +23,57 @@ | |
*/ | ||
class Api extends Module | ||
{ | ||
/** | ||
* Creates a user for API authentication and returns a bearer token. | ||
* | ||
* @return string The token | ||
* | ||
* @since 4.1.0 | ||
*/ | ||
public function getBearerToken(): string | ||
{ | ||
/** @var JoomlaDb $db */ | ||
$db = $this->getModule('Helper\\JoomlaDb'); | ||
/** | ||
* Creates a user for API authentication and returns a bearer token. | ||
* | ||
* @return string The token | ||
* | ||
* @since 4.1.0 | ||
*/ | ||
public function getBearerToken(): string | ||
{ | ||
/** @var JoomlaDb $db */ | ||
$db = $this->getModule('Helper\\JoomlaDb'); | ||
|
||
$desiredUserId = 3; | ||
$desiredUserId = 3; | ||
|
||
if (!$db->grabFromDatabase('users', 'id', ['id' => $desiredUserId])) | ||
{ | ||
$db->haveInDatabase( | ||
'users', | ||
[ | ||
'id' => $desiredUserId, | ||
'name' => 'API', | ||
'email' => '[email protected]', | ||
'username' => 'api', | ||
'password' => '123', | ||
'block' => 0, | ||
'registerDate' => '2000-01-01', | ||
'params' => '{}' | ||
], | ||
[] | ||
); | ||
$db->haveInDatabase('user_usergroup_map', ['user_id' => $desiredUserId, 'group_id' => 8]); | ||
$enabledData = ['user_id' => $desiredUserId, 'profile_key' => 'joomlatoken.enabled', 'profile_value' => 1]; | ||
$tokenData = ['user_id' => $desiredUserId, 'profile_key' => 'joomlatoken.token', 'profile_value' => 'dOi2m1NRrnBHlhaWK/WWxh3B5tqq1INbdf4DhUmYTI4=']; | ||
$db->haveInDatabase('user_profiles', $enabledData); | ||
$db->haveInDatabase('user_profiles', $tokenData); | ||
} | ||
if (!$db->grabFromDatabase('users', 'id', ['id' => $desiredUserId])) { | ||
$db->haveInDatabase( | ||
'users', | ||
[ | ||
'id' => $desiredUserId, | ||
'name' => 'API', | ||
'email' => '[email protected]', | ||
'username' => 'api', | ||
'password' => '123', | ||
'block' => 0, | ||
'registerDate' => '2000-01-01', | ||
'params' => '{}' | ||
], | ||
[] | ||
); | ||
$db->haveInDatabase('user_usergroup_map', ['user_id' => $desiredUserId, 'group_id' => 8]); | ||
$enabledData = ['user_id' => $desiredUserId, 'profile_key' => 'joomlatoken.enabled', 'profile_value' => 1]; | ||
$tokenData = ['user_id' => $desiredUserId, 'profile_key' => 'joomlatoken.token', 'profile_value' => 'dOi2m1NRrnBHlhaWK/WWxh3B5tqq1INbdf4DhUmYTI4=']; | ||
$db->haveInDatabase('user_profiles', $enabledData); | ||
$db->haveInDatabase('user_profiles', $tokenData); | ||
} | ||
|
||
return 'c2hhMjU2OjM6ZTJmMjJlYTNlNTU0NmM1MDJhYTIzYzMwN2MxYzAwZTQ5NzJhMWRmOTUyNjY5MTk2YjE5ODJmZWMwZTcxNzgwMQ=='; | ||
} | ||
return 'c2hhMjU2OjM6ZTJmMjJlYTNlNTU0NmM1MDJhYTIzYzMwN2MxYzAwZTQ5NzJhMWRmOTUyNjY5MTk2YjE5ODJmZWMwZTcxNzgwMQ=='; | ||
} | ||
|
||
/** | ||
* Creates a user for API authentication and returns a bearer token. | ||
* | ||
* @param string $name The name of the config key | ||
* @param string $module The module | ||
* | ||
* @return string The config key | ||
* | ||
* @since 4.1.0 | ||
*/ | ||
public function getConfig($name, $module = 'Helper\Api'): string | ||
{ | ||
return $this->getModule($module)->_getConfig()[$name]; | ||
} | ||
/** | ||
* Creates a user for API authentication and returns a bearer token. | ||
* | ||
* @param string $name The name of the config key | ||
* @param string $module The module | ||
* | ||
* @return string The config key | ||
* | ||
* @since 4.1.0 | ||
*/ | ||
public function getConfig($name, $module = 'Helper\Api'): string | ||
{ | ||
return $this->getModule($module)->_getConfig()[$name]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.