Page MenuHomePhorge

D5238.1775287928.diff
No OneTemporary

Authored By
Unknown
Size
2 MB
Referenced Files
None
Subscribers
None

D5238.1775287928.diff

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/.arc/arc-phpstan/__phutil_library_init__.php b/.arc/arc-phpstan/__phutil_library_init__.php
deleted file mode 100755
--- a/.arc/arc-phpstan/__phutil_library_init__.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-/*
- Copyright 2017-present Appsinet. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-phutil_register_library('phpstan', __FILE__);
diff --git a/.arc/arc-phpstan/__phutil_library_map__.php b/.arc/arc-phpstan/__phutil_library_map__.php
deleted file mode 100755
--- a/.arc/arc-phpstan/__phutil_library_map__.php
+++ /dev/null
@@ -1,18 +0,0 @@
-<?php
-
-/**
- * This file is automatically generated. Use 'arc liberate' to rebuild it.
- *
- * @generated
- * @phutil-library-version 2
- */
-phutil_register_library_map(array(
- '__library_version__' => 2,
- 'class' => array(
- 'PhpstanLinter' => 'lint/linter/PhpstanLinter.php',
- ),
- 'function' => array(),
- 'xmap' => array(
- 'PhpstanLinter' => 'ArcanistExternalLinter',
- ),
-));
diff --git a/.arc/arc-phpstan/lint/linter/PhpstanLinter.php b/.arc/arc-phpstan/lint/linter/PhpstanLinter.php
deleted file mode 100755
--- a/.arc/arc-phpstan/lint/linter/PhpstanLinter.php
+++ /dev/null
@@ -1,242 +0,0 @@
-<?php
-/**
- * @copyright Copyright 2017-present Appsinet. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-/** Uses phpstan to lint php files */
-final class PhpstanLinter extends ArcanistExternalLinter
-{
-
- /**
- * @var string Config file path
- */
- private $configFile = null;
-
- /**
- * @var string Rule level
- */
- private $level = null;
-
- /**
- * @var string Autoload file path
- */
- private $autoloadFile = null;
-
- public function getInfoName()
- {
- return 'phpstan';
- }
-
- public function getInfoURI()
- {
- return '';
- }
-
- public function getInfoDescription()
- {
- return pht('Use phpstan for processing specified files.');
- }
-
- public function getLinterConfigurationName()
- {
- return 'phpstan';
- }
-
- public function getDefaultBinary()
- {
- return 'phpstan';
- }
-
- public function getInstallInstructions()
- {
- return pht('Install phpstan following the official guide at https://github.com/phpstan/phpstan#installation');
- }
-
- public function shouldExpectCommandErrors()
- {
- return true;
- }
-
- public function getVersion()
- {
- list($stdout) = execx('%C --version', $this->getExecutableCommand());
-
- $matches = array();
- $regex = '/(?P<version>\d+\.\d+\.\d+)/';
- if (preg_match($regex, $stdout, $matches)) {
- return $matches['version'];
- } else {
- return false;
- }
- }
-
- protected function getMandatoryFlags()
- {
- $flags = array(
- 'analyse',
- '--no-progress',
- '--error-format=checkstyle',
- '--memory-limit=1G'
- );
- if (null !== $this->configFile) {
- array_push($flags, '-c', $this->configFile);
- }
- if (null !== $this->level) {
- array_push($flags, '-l', $this->level);
- }
- if (null !== $this->autoloadFile) {
- array_push($flags, '-a', $this->autoloadFile);
- }
-
- return $flags;
- }
-
- public function getLinterConfigurationOptions()
- {
- $options = array(
- 'config' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'The path to your phpstan.neon file. Will be provided as -c <path> to phpstan.'
- ),
- ),
- 'level' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'Rule level used (0 loosest - max strictest). Will be provided as -l <level> to phpstan.'
- ),
- ),
- 'autoload' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'The path to the auto load file. Will be provided as -a <autoload_file> to phpstan.'),
- ),
- );
- return $options + parent::getLinterConfigurationOptions();
- }
-
- public function setLinterConfigurationValue($key, $value)
- {
- switch ($key) {
- case 'config':
- $this->configFile = $value;
- return;
- case 'level':
- $this->level = $value;
- return;
- case 'autoload':
- $this->autoloadFile = $value;
- return;
- default:
- parent::setLinterConfigurationValue($key, $value);
- return;
- }
- }
-
- protected function getDefaultMessageSeverity($code)
- {
- return ArcanistLintSeverity::SEVERITY_WARNING;
- }
-
- protected function parseLinterOutput($path, $err, $stdout, $stderr)
- {
- $result = array();
- if (!empty($stdout)) {
- $stdout = substr($stdout, strpos($stdout, '<?xml'));
- $checkstyleOutpout = new SimpleXMLElement($stdout);
- $errors = $checkstyleOutpout->xpath('//file/error');
- foreach($errors as $error) {
- $violation = $this->parseViolation($error);
- $violation['path'] = $path;
- $result[] = ArcanistLintMessage::newFromDictionary($violation);
- }
- }
-
- return $result;
- }
-
- /**
- * Checkstyle returns output of the form
- *
- * <checkstyle>
- * <file name="${sPath}">
- * <error line="12" column="10" severity="${sSeverity}" message="${sMessage}" source="${sSource}">
- * ...
- * </file>
- * </checkstyle>
- *
- * Of this, we need to extract
- * - Line
- * - Column
- * - Severity
- * - Message
- * - Source (name)
- *
- * @param SimpleXMLElement $violation The XML Entity containing the issue
- *
- * @return array of the form
- * [
- * 'line' => {int},
- * 'column' => {int},
- * 'severity' => {string},
- * 'message' => {string}
- * ]
- */
- private function parseViolation(SimpleXMLElement $violation)
- {
- return array(
- 'code' => $this->getLinterName(),
- 'name' => (string)$violation['message'],
- 'line' => (int)$violation['line'],
- 'char' => (int)$violation['column'],
- 'severity' => $this->getMatchSeverity((string)$violation['severity']),
- 'description' => (string)$violation['message']
- );
- }
-
- /**
- * @return string Linter name
- */
- public function getLinterName()
- {
- return 'phpstan';
- }
-
- /**
- * Map the regex matching groups to a message severity. We look for either
- * a nonempty severity name group like 'error', or a group called 'severity'
- * with a valid name.
- *
- * @param string $severity_name dict Captured groups from regex.
- *
- * @return string @{class:ArcanistLintSeverity} constant.
- *
- * @task parse
- */
- private function getMatchSeverity($severity_name)
- {
- $map = array(
- 'error' => ArcanistLintSeverity::SEVERITY_ERROR,
- 'warning' => ArcanistLintSeverity::SEVERITY_WARNING,
- 'info' => ArcanistLintSeverity::SEVERITY_ADVICE,
- );
- foreach ($map as $name => $severity) {
- if ($severity_name == $name) {
- return $severity;
- }
- }
- return ArcanistLintSeverity::SEVERITY_ERROR;
- }
-}
diff --git a/.arc/src/extensions/PhpstanLinter.php b/.arc/src/extensions/PhpstanLinter.php
deleted file mode 100755
--- a/.arc/src/extensions/PhpstanLinter.php
+++ /dev/null
@@ -1,242 +0,0 @@
-<?php
-/**
- * @copyright Copyright 2017-present Appsinet. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-/** Uses phpstan to lint php files */
-final class PhpstanLinter extends ArcanistExternalLinter
-{
-
- /**
- * @var string Config file path
- */
- private $configFile = null;
-
- /**
- * @var string Rule level
- */
- private $level = null;
-
- /**
- * @var string Autoload file path
- */
- private $autoloadFile = null;
-
- public function getInfoName()
- {
- return 'phpstan';
- }
-
- public function getInfoURI()
- {
- return '';
- }
-
- public function getInfoDescription()
- {
- return pht('Use phpstan for processing specified files.');
- }
-
- public function getLinterConfigurationName()
- {
- return 'phpstan';
- }
-
- public function getDefaultBinary()
- {
- return 'phpstan';
- }
-
- public function getInstallInstructions()
- {
- return pht('Install phpstan following the official guide at https://github.com/phpstan/phpstan#installation');
- }
-
- public function shouldExpectCommandErrors()
- {
- return true;
- }
-
- public function getVersion()
- {
- list($stdout) = execx('%C --version', $this->getExecutableCommand());
-
- $matches = array();
- $regex = '/(?P<version>\d+\.\d+\.\d+)/';
- if (preg_match($regex, $stdout, $matches)) {
- return $matches['version'];
- } else {
- return false;
- }
- }
-
- protected function getMandatoryFlags()
- {
- $flags = array(
- 'analyse',
- '--no-progress',
- '--error-format=checkstyle',
- '--memory-limit=1G'
- );
- if (null !== $this->configFile) {
- array_push($flags, '-c', $this->configFile);
- }
- if (null !== $this->level) {
- array_push($flags, '-l', $this->level);
- }
- if (null !== $this->autoloadFile) {
- array_push($flags, '-a', $this->autoloadFile);
- }
-
- return $flags;
- }
-
- public function getLinterConfigurationOptions()
- {
- $options = array(
- 'config' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'The path to your phpstan.neon file. Will be provided as -c <path> to phpstan.'
- ),
- ),
- 'level' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'Rule level used (0 loosest - max strictest). Will be provided as -l <level> to phpstan.'
- ),
- ),
- 'autoload' => array(
- 'type' => 'optional string',
- 'help' => pht(
- 'The path to the auto load file. Will be provided as -a <autoload_file> to phpstan.'),
- ),
- );
- return $options + parent::getLinterConfigurationOptions();
- }
-
- public function setLinterConfigurationValue($key, $value)
- {
- switch ($key) {
- case 'config':
- $this->configFile = $value;
- return;
- case 'level':
- $this->level = $value;
- return;
- case 'autoload':
- $this->autoloadFile = $value;
- return;
- default:
- parent::setLinterConfigurationValue($key, $value);
- return;
- }
- }
-
- protected function getDefaultMessageSeverity($code)
- {
- return ArcanistLintSeverity::SEVERITY_WARNING;
- }
-
- protected function parseLinterOutput($path, $err, $stdout, $stderr)
- {
- $result = array();
- if (!empty($stdout)) {
- $stdout = substr($stdout, strpos($stdout, '<?xml'));
- $checkstyleOutpout = new SimpleXMLElement($stdout);
- $errors = $checkstyleOutpout->xpath('//file/error');
- foreach($errors as $error) {
- $violation = $this->parseViolation($error);
- $violation['path'] = $path;
- $result[] = ArcanistLintMessage::newFromDictionary($violation);
- }
- }
-
- return $result;
- }
-
- /**
- * Checkstyle returns output of the form
- *
- * <checkstyle>
- * <file name="${sPath}">
- * <error line="12" column="10" severity="${sSeverity}" message="${sMessage}" source="${sSource}">
- * ...
- * </file>
- * </checkstyle>
- *
- * Of this, we need to extract
- * - Line
- * - Column
- * - Severity
- * - Message
- * - Source (name)
- *
- * @param SimpleXMLElement $violation The XML Entity containing the issue
- *
- * @return array of the form
- * [
- * 'line' => {int},
- * 'column' => {int},
- * 'severity' => {string},
- * 'message' => {string}
- * ]
- */
- private function parseViolation(SimpleXMLElement $violation)
- {
- return array(
- 'code' => $this->getLinterName(),
- 'name' => (string)$violation['message'],
- 'line' => (int)$violation['line'],
- 'char' => (int)$violation['column'],
- 'severity' => $this->getMatchSeverity((string)$violation['severity']),
- 'description' => (string)$violation['message']
- );
- }
-
- /**
- * @return string Linter name
- */
- public function getLinterName()
- {
- return 'phpstan';
- }
-
- /**
- * Map the regex matching groups to a message severity. We look for either
- * a nonempty severity name group like 'error', or a group called 'severity'
- * with a valid name.
- *
- * @param string $severity_name dict Captured groups from regex.
- *
- * @return string @{class:ArcanistLintSeverity} constant.
- *
- * @task parse
- */
- private function getMatchSeverity($severity_name)
- {
- $map = array(
- 'error' => ArcanistLintSeverity::SEVERITY_ERROR,
- 'warning' => ArcanistLintSeverity::SEVERITY_WARNING,
- 'info' => ArcanistLintSeverity::SEVERITY_ADVICE,
- );
- foreach ($map as $name => $severity) {
- if ($severity_name == $name) {
- return $severity;
- }
- }
- return ArcanistLintSeverity::SEVERITY_ERROR;
- }
-}
diff --git a/.arcconfig b/.arcconfig
--- a/.arcconfig
+++ b/.arcconfig
@@ -1,4 +1,4 @@
{
"phabricator.uri": "https://git.kolab.org",
- "load": [".arc/arc-phpstan"]
+ "load": ["src/vendor/diablomedia/arcanist-extensions/extensions/"]
}
diff --git a/.arclint b/.arclint
--- a/.arclint
+++ b/.arclint
@@ -3,11 +3,14 @@
"php": {
"type": "php"
},
- "phpcs": {
- "type": "phpcs",
- "bin": "src/vendor/bin/phpcs",
- "include": "(\\.php$)",
- "exclude": "(^.arc/)"
+ "php-cs-fixer": {
+ "type": "php-cs-fixer",
+ "bin": "src/vendor/bin/php-cs-fixer",
+ "flags": [
+ "--path-mode=intersection"
+ ],
+ "config": "src/.php-cs-fixer.php",
+ "include": "(\\.php$)"
},
"phpstan": {
"type": "phpstan",
@@ -15,7 +18,10 @@
"exclude": "(^.arc/)",
"config": "src/phpstan.neon",
"bin": "src/vendor/bin/phpstan",
- "level": "4"
+ "flags": [
+ "--memory-limit=1G"
+ ],
+ "level": "5"
}
}
}
diff --git a/bin/phpcs b/bin/phpcs
--- a/bin/phpcs
+++ b/bin/phpcs
@@ -2,10 +2,15 @@
cwd=$(dirname $0)
-pushd ${cwd}/../src/
+pushd ${cwd}/../src
-php -dmemory_limit=500M \
- vendor/bin/phpcs \
- -s
+if [ -z $1 ]
+then
+ cmd="fix --dry-run"
+else
+ cmd=$1
+fi
+
+php vendor/bin/php-cs-fixer $cmd --using-cache=no --diff --verbose
popd
diff --git a/phpcs.xml b/phpcs.xml
deleted file mode 100644
--- a/phpcs.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<ruleset name="Kolab">
- <description>Custom ruleset for Kolab</description>
-
- <arg name="extensions" value="php,inc,phtml"/>
-
- <rule ref="PSR1"/>
- <rule ref="PSR12"/>
-
- <file>src/app/</file>
- <file>src/tests/</file>
- <file>src/database/</file>
-</ruleset>
diff --git a/src/.php-cs-fixer.php b/src/.php-cs-fixer.php
new file mode 100644
--- /dev/null
+++ b/src/.php-cs-fixer.php
@@ -0,0 +1,82 @@
+<?php
+
+use PhpCsFixer\Config;
+use PhpCsFixer\Finder;
+use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
+
+$finder = Finder::create()
+ ->name('*.php')
+ ->in([__DIR__])
+ ->exclude('cache')
+ ->exclude('include')
+ ->exclude('node_modules')
+ ->exclude('public')
+ ->exclude('storage')
+ ->exclude('vendor');
+
+return (new Config())
+ ->setParallelConfig(ParallelConfigFactory::detect())
+ ->setRiskyAllowed(true)
+ ->setRules([
+ '@PhpCsFixer' => true,
+ '@PhpCsFixer:risky' => true,
+ '@PHP82Migration' => true,
+ '@PHP82Migration:risky' => true,
+
+ // required by PSR-12
+ 'concat_space' => [
+ 'spacing' => 'one',
+ ],
+
+ // disable some too strict rules
+ 'yoda_style' => [
+ 'equal' => false,
+ 'identical' => false,
+ ],
+ 'native_constant_invocation' => [
+ 'include' => [
+ ],
+ ],
+ 'native_function_invocation' => false,
+ 'void_return' => false,
+ 'combine_consecutive_issets' => false,
+ 'combine_consecutive_unsets' => false,
+ 'multiline_whitespace_before_semicolons' => false,
+ 'ordered_class_elements' => false,
+ 'return_assignment' => false,
+ 'comment_to_phpdoc' => false,
+ 'use_arrow_functions' => false,
+ 'blank_line_before_statement' => false,
+ 'declare_strict_types' => false,
+ 'increment_style' => [
+ 'style' => 'post',
+ ],
+ 'strict_comparison' => false,
+ 'single_quote' => false,
+ 'strict_param' => false,
+
+ 'php_unit_internal_class' => false,
+ 'php_unit_test_class_requires_covers' => false,
+ 'php_unit_test_case_static_method_calls' => false,
+
+ 'phpdoc_add_missing_param_annotation' => false,
+ 'phpdoc_summary' => false,
+ 'phpdoc_types_order' => [
+ 'null_adjustment' => 'always_last',
+ 'sort_algorithm' => 'none',
+ ],
+ 'phpdoc_types' => [
+ 'groups' => ['simple', 'alias'],
+ ],
+
+ // https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues/8628
+ 'fully_qualified_strict_types' => false,
+
+ // Traits must be in specific order, not alphabetical (e.g. App\Resource)
+ 'ordered_traits' => false,
+
+ // HTTP macros cannot be static
+ 'static_lambda' => false,
+ ])
+ ->setFinder($finder)
+ ->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
diff --git a/src/app/Auth/IdentityEntity.php b/src/app/Auth/IdentityEntity.php
--- a/src/app/Auth/IdentityEntity.php
+++ b/src/app/Auth/IdentityEntity.php
@@ -19,6 +19,7 @@
/**
* The identity repository creates this entity and provides the user id
+ *
* @param mixed $identifier
*/
public function setIdentifier($identifier): void
diff --git a/src/app/Auth/PassportClient.php b/src/app/Auth/PassportClient.php
--- a/src/app/Auth/PassportClient.php
+++ b/src/app/Auth/PassportClient.php
@@ -2,12 +2,12 @@
namespace App\Auth;
-use Illuminate\Database\Eloquent\Collection;
+use Laravel\Passport\Client;
/**
* Passport Client extended with allowed scopes
*/
-class PassportClient extends \Laravel\Passport\Client
+class PassportClient extends Client
{
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
diff --git a/src/app/Auth/SecondFactor.php b/src/app/Auth/SecondFactor.php
--- a/src/app/Auth/SecondFactor.php
+++ b/src/app/Auth/SecondFactor.php
@@ -3,8 +3,11 @@
namespace App\Auth;
use App\Support\Facades\Roundcube;
-use Illuminate\Support\Facades\Auth;
+use App\User;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Http\Request;
use Kolab2FA\Driver\Base as DriverBase;
+use Kolab2FA\Driver\TOTP;
use Kolab2FA\Storage\Base as StorageBase;
/**
@@ -18,11 +21,10 @@
'keymap' => [],
];
-
/**
* Class constructor
*
- * @param \App\User $user User object
+ * @param User $user User object
*/
public function __construct($user)
{
@@ -35,7 +37,7 @@
/**
* Validate 2-factor authentication code
*
- * @param string $secondfactor The 2-factor authentication code.
+ * @param string $secondfactor the 2-factor authentication code
*
* @throws \Exception on validation failure
*/
@@ -67,11 +69,11 @@
/**
* Validate 2-factor authentication code
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse|null
+ * @return JsonResponse|null
*/
- public function requestHandler(\Illuminate\Http\Request $request)
+ public function requestHandler(Request $request)
{
try {
$this->validate($request->secondfactor);
@@ -92,7 +94,7 @@
$this->cache = [];
$prefs = [];
- $prefs[$this->key2property('blob')] = null;
+ $prefs[$this->key2property('blob')] = null;
$prefs[$this->key2property('factors')] = null;
return $this->savePrefs($prefs);
@@ -137,7 +139,7 @@
*/
protected function getDriver(string $factor)
{
- list($method) = explode(':', $factor, 2);
+ [$method] = explode(':', $factor, 2);
$config = \config('2fa.' . $method, []);
@@ -168,7 +170,7 @@
'kolab_2fa_factors' => [
'totp:8132a46b1f741f88de25f47e',
// 'dummy:dummy',
- ]
+ ],
];
Roundcube::dbh()->table('users')->updateOrInsert(
@@ -186,18 +188,17 @@
*/
public static function code(string $email): string
{
- $sf = new self(\App\User::where('email', $email)->first());
+ $sf = new self(User::where('email', $email)->first());
- /** @var \Kolab2FA\Driver\TOTP $driver */
+ /** @var TOTP $driver */
$driver = $sf->getDriver('totp:8132a46b1f741f88de25f47e');
return (string) $driver->get_code();
}
-
- //******************************************************
+ // ******************************************************
// Methods required by Kolab2FA Storage Base
- //******************************************************
+ // ******************************************************
/**
* Initialize the storage driver with the given config options
@@ -213,7 +214,7 @@
public function enumerate()
{
if ($factors = $this->getFactors()) {
- return array_keys(array_filter($factors, function ($prop) {
+ return array_keys(array_filter($factors, static function ($prop) {
return !empty($prop['active']);
}));
}
@@ -228,7 +229,7 @@
{
if (!isset($this->cache[$key])) {
$factors = $this->getFactors();
- $this->cache[$key] = isset($factors[$key]) ? $factors[$key] : null;
+ $this->cache[$key] = $factors[$key] ?? null;
}
return $this->cache[$key];
@@ -253,9 +254,6 @@
return $this->write($key, null);
}
- /**
- *
- */
protected function getFactors(): array
{
$prefs = $this->getPrefs();
@@ -264,9 +262,6 @@
return isset($prefs[$key]) ? (array) $prefs[$key] : [];
}
- /**
- *
- */
protected function key2property($key)
{
// map key to configured property name
@@ -304,7 +299,7 @@
}
$prefs = array_merge($old_prefs, $prefs);
- $prefs = array_filter($prefs, fn($v) => !is_null($v));
+ $prefs = array_filter($prefs, static fn ($v) => $v !== null);
Roundcube::dbh()->table('users')
->where('username', strtolower($this->user->email))
diff --git a/src/app/AuthAttempt.php b/src/app/AuthAttempt.php
--- a/src/app/AuthAttempt.php
+++ b/src/app/AuthAttempt.php
@@ -24,8 +24,8 @@
public const REASON_2FA = '2fa';
public const REASON_2FA_GENERIC = '2fa-generic';
- private const STATUS_ACCEPTED = 'ACCEPTED';
- private const STATUS_DENIED = 'DENIED';
+ private const STATUS_ACCEPTED = 'ACCEPTED';
+ private const STATUS_DENIED = 'DENIED';
/** @var list<string> The attributes that can be not set */
protected $nullable = ['reason'];
@@ -43,17 +43,13 @@
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
'expires_at' => 'datetime',
- 'last_seen' => 'datetime'
+ 'last_seen' => 'datetime',
];
/**
* Prepare a date for array / JSON serialization.
*
* Required to not omit timezone and match the format of update_at/created_at timestamps.
- *
- * @param \DateTimeInterface $date
- *
- * @return string
*/
protected function serializeDate(\DateTimeInterface $date): string
{
@@ -62,8 +58,6 @@
/**
* Returns true if the authentication attempt is accepted.
- *
- * @return bool
*/
public function isAccepted(): bool
{
@@ -72,8 +66,6 @@
/**
* Returns true if the authentication attempt is denied.
- *
- * @return bool
*/
public function isDenied(): bool
{
@@ -83,7 +75,7 @@
/**
* Accept the authentication attempt.
*/
- public function accept($reason = AuthAttempt::REASON_NONE)
+ public function accept($reason = self::REASON_NONE)
{
$this->expires_at = Carbon::now()->addHours(8);
$this->status = self::STATUS_ACCEPTED;
@@ -94,7 +86,7 @@
/**
* Deny the authentication attempt.
*/
- public function deny($reason = AuthAttempt::REASON_NONE)
+ public function deny($reason = self::REASON_NONE)
{
$this->status = self::STATUS_DENIED;
$this->reason = $reason;
@@ -127,7 +119,7 @@
$confirmationTimeout = 120;
$timeout = Carbon::now()->addSeconds($confirmationTimeout);
- do {
+ while (true) {
if ($this->isDenied()) {
\Log::debug("The authentication attempt was denied {$this->id}");
return false;
@@ -145,23 +137,23 @@
sleep(2);
$this->refresh();
- } while (true);
+ }
}
/**
* Record a new authentication attempt or update an existing one.
*
- * @param \App\User $user The user attempting to authenticate.
- * @param string $clientIP The ip the authentication attempt is coming from.
+ * @param User $user the user attempting to authenticate
+ * @param string $clientIP the ip the authentication attempt is coming from
*
- * @return \App\AuthAttempt
+ * @return AuthAttempt
*/
public static function recordAuthAttempt(User $user, $clientIP)
{
- $authAttempt = AuthAttempt::where('ip', $clientIP)->where('user_id', $user->id)->first();
+ $authAttempt = self::where('ip', $clientIP)->where('user_id', $user->id)->first();
if (!$authAttempt) {
- $authAttempt = new AuthAttempt();
+ $authAttempt = new self();
$authAttempt->ip = $clientIP;
$authAttempt->user_id = $user->id;
}
diff --git a/src/app/Backends/DAV.php b/src/app/Backends/DAV.php
--- a/src/app/Backends/DAV.php
+++ b/src/app/Backends/DAV.php
@@ -2,6 +2,7 @@
namespace App\Backends;
+use App\Auth\Utils;
use App\User;
use Illuminate\Http\Client\RequestException;
use Illuminate\Support\Facades\Http;
@@ -25,7 +26,6 @@
protected $responseHeaders = [];
protected $homes;
-
/**
* Get object instance for user/password/location
*
@@ -35,7 +35,7 @@
*
* @return DAV DAV client instance
*/
- public static function getInstance($user, $password, $url = null): DAV
+ public static function getInstance($user, $password, $url = null): self
{
$dav = new self();
$dav->setCredentials($user, $password);
@@ -62,7 +62,7 @@
*/
public function setCredentials($user, $password): void
{
- $this->user = $user;
+ $this->user = $user;
$this->password = $password;
}
@@ -77,7 +77,7 @@
return $this->homes;
}
- $path = parse_url($this->url, PHP_URL_PATH);
+ $path = parse_url($this->url, \PHP_URL_PATH);
$body = '<?xml version="1.0" encoding="utf-8"?>'
. '<d:propfind xmlns:d="DAV:">'
@@ -204,7 +204,7 @@
}
// Note: Cyrus CardDAV service requires Depth:1 (CalDAV works without it)
- $headers = ['Depth' => 1, 'Prefer' => 'return-minimal'];
+ $headers = ['Depth' => 1, 'Prefer' => 'return-minimal'];
$response = $this->request($root_href, 'PROPFIND', DAV\Folder::propfindXML(), $headers);
@@ -396,7 +396,7 @@
foreach ($folders as $props) {
$folder = new DAV\Folder();
- $folder->href = $props['type'] . 's' . '/user/' . $user->email . '/' . $props['path'];
+ $folder->href = $props['type'] . 's/user/' . $user->email . '/' . $props['path'];
$folder->types = ['collection', $props['type']];
$folder->name = $props['displayname'] ?? '';
$folder->components = $props['components'] ?? [];
@@ -582,7 +582,7 @@
if (!empty($acl[$type])) {
$folders[] = [
- 'href' => $folder['type'] . 's' . '/user/' . $user->email . '/' . $folder['path'],
+ 'href' => $folder['type'] . 's/user/' . $user->email . '/' . $folder['path'],
'acl' => $acl[$type] == 'read-write'
? DAV\ShareResource::ACCESS_READ_WRITE : DAV\ShareResource::ACCESS_READ,
];
@@ -731,12 +731,12 @@
/**
* Create DAV client instance for a user (using generated auth token as password)
*/
- protected static function getClientForUser(User $user): DAV
+ protected static function getClientForUser(User $user): self
{
// Cyrus DAV does not support proxy authorization via DAV. Even though it has
// the Authorize-As header, it is used only for cummunication with Murder backends.
// We use a one-time token instead. It's valid for 10 seconds, assume it's enough time.
- $password = \App\Auth\Utils::tokenCreate((string) $user->id);
+ $password = Utils::tokenCreate((string) $user->id);
if ($password === null) {
throw new \Exception("Failed to create an authentication token for DAV");
@@ -830,7 +830,7 @@
// TODO: This might need to be configurable or discovered somehow,
// maybe get it from current-user-principal property that we read in discover()
$path = '/principals/user/';
- if ($host_path = parse_url($this->url, PHP_URL_PATH)) {
+ if ($host_path = parse_url($this->url, \PHP_URL_PATH)) {
$path = '/' . trim($host_path, '/') . $path;
}
@@ -849,7 +849,7 @@
// Remove the duplicate path prefix
if ($path) {
- $rootPath = parse_url($url, PHP_URL_PATH);
+ $rootPath = parse_url($url, \PHP_URL_PATH);
$path = '/' . ltrim($path, '/');
if ($rootPath && str_starts_with($path, $rootPath)) {
@@ -877,7 +877,7 @@
if ($debug) {
$body = $this->debugBody($body, $headers);
- \Log::debug("C: {$method}: {$url}" . (strlen($body) > 0 ? "\n$body" : ''));
+ \Log::debug("C: {$method}: {$url}" . (strlen($body) > 0 ? "\n{$body}" : ''));
}
$response = $client->send($method, $url);
diff --git a/src/app/Backends/DAV/CommonObject.php b/src/app/Backends/DAV/CommonObject.php
--- a/src/app/Backends/DAV/CommonObject.php
+++ b/src/app/Backends/DAV/CommonObject.php
@@ -19,7 +19,6 @@
/** @var array Custom properties (key->value) */
public $custom = [];
-
/**
* Create DAV object from a DOMElement element
*
diff --git a/src/app/Backends/DAV/Folder.php b/src/app/Backends/DAV/Folder.php
--- a/src/app/Backends/DAV/Folder.php
+++ b/src/app/Backends/DAV/Folder.php
@@ -36,7 +36,6 @@
/** @var ?string Folder owner (email) */
public $owner;
-
/**
* Create Folder object from a DOMElement element
*
@@ -46,7 +45,7 @@
*/
public static function fromDomElement(\DOMElement $element)
{
- $folder = new Folder();
+ $folder = new self();
if ($href = $element->getElementsByTagName('href')->item(0)) {
$folder->href = $href->nodeValue;
@@ -76,7 +75,7 @@
$types = [];
if ($type_element = $element->getElementsByTagName('resourcetype')->item(0)) {
foreach ($type_element->childNodes as $node) {
- if ($node->nodeType == XML_ELEMENT_NODE) {
+ if ($node->nodeType == \XML_ELEMENT_NODE) {
$_type = explode(':', $node->nodeName);
$types[] = count($_type) > 1 ? $_type[1] : $_type[0];
}
@@ -187,7 +186,7 @@
}
if ($this->name !== null) {
- $props .= '<d:displayname>' . htmlspecialchars($this->name, ENT_XML1, 'UTF-8') . '</d:displayname>';
+ $props .= '<d:displayname>' . htmlspecialchars($this->name, \ENT_XML1, 'UTF-8') . '</d:displayname>';
}
if ($this->color !== null) {
@@ -197,7 +196,7 @@
}
$ns .= ' xmlns:a="http://apple.com/ns/ical/"';
- $props .= '<a:calendar-color>' . htmlspecialchars($color, ENT_XML1, 'UTF-8') . '</a:calendar-color>';
+ $props .= '<a:calendar-color>' . htmlspecialchars($color, \ENT_XML1, 'UTF-8') . '</a:calendar-color>';
}
return '<?xml version="1.0" encoding="utf-8"?>'
diff --git a/src/app/Backends/DAV/InviteReply.php b/src/app/Backends/DAV/InviteReply.php
--- a/src/app/Backends/DAV/InviteReply.php
+++ b/src/app/Backends/DAV/InviteReply.php
@@ -16,7 +16,6 @@
/** @var ?string Invite reply comment */
public $comment;
-
/**
* Create Notification object from a DOMElement element
*
@@ -39,7 +38,7 @@
// Note: <create-in> and <slug> are ignored by Cyrus
if (!empty($this->comment)) {
- $reply .= '<d:comment>' . htmlspecialchars($this->comment, ENT_XML1, 'UTF-8') . '</d:comment>';
+ $reply .= '<d:comment>' . htmlspecialchars($this->comment, \ENT_XML1, 'UTF-8') . '</d:comment>';
}
return '<?xml version="1.0" encoding="utf-8"?>'
diff --git a/src/app/Backends/DAV/Notification.php b/src/app/Backends/DAV/Notification.php
--- a/src/app/Backends/DAV/Notification.php
+++ b/src/app/Backends/DAV/Notification.php
@@ -36,7 +36,6 @@
/** @var ?string Notification (invitation) principal (organizer) */
public $principal;
-
/**
* Create Notification object from a DOMElement element
*
@@ -72,8 +71,8 @@
if ($href = $organizer->getElementsByTagName('href')->item(0)) {
$notification->principal = $href->nodeValue;
}
- // There should be also 'displayname', but Cyrus uses 'common-name',
- // we'll ignore it for now anyway.
+ // There should be also 'displayname', but Cyrus uses 'common-name',
+ // we'll ignore it for now anyway.
} elseif ($principal = $element->getElementsByTagName('principal')->item(0)) {
if ($href = $principal->getElementsByTagName('href')->item(0)) {
$notification->principal = $href->nodeValue;
diff --git a/src/app/Backends/DAV/SearchCompFilter.php b/src/app/Backends/DAV/SearchCompFilter.php
--- a/src/app/Backends/DAV/SearchCompFilter.php
+++ b/src/app/Backends/DAV/SearchCompFilter.php
@@ -2,14 +2,11 @@
namespace App\Backends\DAV;
-use App\Backends\DAV;
-
class SearchCompFilter
{
public $name;
public $filters = [];
-
public function __construct($name, $filters = [])
{
$this->name = $name;
diff --git a/src/app/Backends/DAV/SearchFilter.php b/src/app/Backends/DAV/SearchFilter.php
--- a/src/app/Backends/DAV/SearchFilter.php
+++ b/src/app/Backends/DAV/SearchFilter.php
@@ -2,8 +2,6 @@
namespace App\Backends\DAV;
-use App\Backends\DAV;
-
class SearchFilter
{
public $filters = [];
diff --git a/src/app/Backends/DAV/SearchPropFilter.php b/src/app/Backends/DAV/SearchPropFilter.php
--- a/src/app/Backends/DAV/SearchPropFilter.php
+++ b/src/app/Backends/DAV/SearchPropFilter.php
@@ -2,8 +2,6 @@
namespace App\Backends\DAV;
-use App\Backends\DAV;
-
class SearchPropFilter
{
public const IS_NOT_DEFINED = 'is-not-defined';
@@ -19,7 +17,6 @@
public $negate = false;
public $value;
-
public function __construct(string $name, string $type, ?string $value = null, ?string $collation = null)
{
$this->name = $name;
@@ -50,7 +47,7 @@
$filter .= ' negate-condition="yes"';
}
- $filter .= '>' . htmlspecialchars($this->value, ENT_XML1, 'UTF-8') . '</c:text-match>';
+ $filter .= '>' . htmlspecialchars($this->value, \ENT_XML1, 'UTF-8') . '</c:text-match>';
}
$filter .= '</c:prop-filter>';
diff --git a/src/app/Backends/DAV/ShareResource.php b/src/app/Backends/DAV/ShareResource.php
--- a/src/app/Backends/DAV/ShareResource.php
+++ b/src/app/Backends/DAV/ShareResource.php
@@ -17,7 +17,6 @@
/** @var ?array Resource sharees list */
public $sharees;
-
/**
* Create Share Resource object from a DOMElement element
*
@@ -44,16 +43,16 @@
}
$props .= '<d:sharee>'
- . '<d:href>' . htmlspecialchars($href, ENT_XML1, 'UTF-8') . '</d:href>'
+ . '<d:href>' . htmlspecialchars($href, \ENT_XML1, 'UTF-8') . '</d:href>'
. '<d:share-access><d:' . ($sharee['access'] ?? self::ACCESS_NONE) . '/></d:share-access>';
if (isset($sharee['comment']) && strlen($sharee['comment'])) {
- $props .= '<d:comment>' . htmlspecialchars($sharee['comment'], ENT_XML1, 'UTF-8') . '</d:comment>';
+ $props .= '<d:comment>' . htmlspecialchars($sharee['comment'], \ENT_XML1, 'UTF-8') . '</d:comment>';
}
if (isset($sharee['displayname']) && strlen($sharee['displayname'])) {
$props .= '<d:prop><d:displayname>'
- . htmlspecialchars($sharee['comment'], ENT_XML1, 'UTF-8')
+ . htmlspecialchars($sharee['comment'], \ENT_XML1, 'UTF-8')
. '</d:displayname></d:prop>';
}
diff --git a/src/app/Backends/DAV/Vcard.php b/src/app/Backends/DAV/Vcard.php
--- a/src/app/Backends/DAV/Vcard.php
+++ b/src/app/Backends/DAV/Vcard.php
@@ -3,8 +3,8 @@
namespace App\Backends\DAV;
use Illuminate\Support\Str;
-use Sabre\VObject\Reader;
use Sabre\VObject\Property;
+use Sabre\VObject\Reader;
use Sabre\VObject\Writer;
class Vcard extends CommonObject
@@ -25,7 +25,6 @@
private $vobject;
-
/**
* Create event object from a DOMElement element
*
@@ -74,7 +73,7 @@
];
foreach ($vobject->children() as $prop) {
- if (!($prop instanceof Property)) {
+ if (!$prop instanceof Property) {
continue;
}
@@ -91,7 +90,6 @@
$props['email'] = (string) $prop;
$this->email[] = $props;
break;
-
case 'MEMBER':
foreach ($prop as $member) {
$value = (string) $member;
@@ -100,7 +98,6 @@
}
}
break;
-
default:
// map string properties
if (in_array($prop->name, $string_properties)) {
diff --git a/src/app/Backends/DAV/Vevent.php b/src/app/Backends/DAV/Vevent.php
--- a/src/app/Backends/DAV/Vevent.php
+++ b/src/app/Backends/DAV/Vevent.php
@@ -4,8 +4,8 @@
use Illuminate\Support\Str;
use Sabre\VObject\Component;
-use Sabre\VObject\Reader;
use Sabre\VObject\Property;
+use Sabre\VObject\Reader;
use Sabre\VObject\Writer;
class Vevent extends CommonObject
@@ -42,7 +42,6 @@
private $vobject;
-
/**
* Create event object from a DOMElement element
*
@@ -75,7 +74,7 @@
return;
}
- $selfType = strtoupper(class_basename(get_class($this)));
+ $selfType = strtoupper(class_basename(static::class));
if (!empty($this->vobject->PRODID)) {
$this->prodid = (string) $this->vobject->PRODID;
@@ -133,7 +132,7 @@
// map other properties
foreach ($vobject->children() as $prop) {
- if (!($prop instanceof Property)) {
+ if (!$prop instanceof Property) {
continue;
}
@@ -147,7 +146,6 @@
// These are of type Sabre\VObject\Property\ICalendar\DateTime
$this->{$key} = $prop;
break;
-
case 'RRULE':
$params = [];
@@ -165,13 +163,11 @@
$this->rrule = array_filter($params);
break;
-
case 'EXDATE':
case 'RDATE':
$key = strtolower($prop->name);
$this->{$key}[] = $prop;
break;
-
case 'ATTENDEE':
case 'ORGANIZER':
$attendee = [
@@ -189,11 +185,11 @@
$attendee[$key] = strtolower($value) == 'true';
break;
case 'CN':
- $attendee[$key] = str_replace('\,', ',', strval($value));
+ $attendee[$key] = str_replace('\,', ',', (string) $value);
break;
default:
if (in_array($name, $attendeeProps)) {
- $attendee[$key] = strval($value);
+ $attendee[$key] = (string) $value;
}
break;
}
@@ -209,7 +205,6 @@
}
break;
-
default:
if (\str_starts_with($prop->name, 'X-')) {
$this->custom[$prop->name] = (string) $prop;
@@ -234,12 +229,12 @@
// Find alarms
foreach ($vobject->select('VALARM') as $valarm) {
- $action = 'DISPLAY';
+ $action = 'DISPLAY';
$trigger = null;
- $alarm = [];
+ $alarm = [];
foreach ($valarm->children() as $prop) {
- $value = strval($prop);
+ $value = (string) $prop;
switch ($prop->name) {
case 'TRIGGER':
@@ -251,34 +246,30 @@
$alarm['related'] = $param->getValue();
}
}
- /*
- if (!$trigger && ($values = libcalendaring::parse_alarm_value($value))) {
- $trigger = $values[2];
- }
- */
+ /*
+ if (!$trigger && ($values = libcalendaring::parse_alarm_value($value))) {
+ $trigger = $values[2];
+ }
+ */
if (empty($alarm['trigger'])) {
- $alarm['trigger'] = rtrim(preg_replace('/([A-Z])0[WDHMS]/', '\\1', $value), 'T');
+ $alarm['trigger'] = rtrim(preg_replace('/([A-Z])0[WDHMS]/', '\1', $value), 'T');
// if all 0-values have been stripped, assume 'at time'
if ($alarm['trigger'] == 'P') {
$alarm['trigger'] = 'PT0S';
}
}
break;
-
case 'ACTION':
$action = $alarm['action'] = strtoupper($value);
break;
-
case 'SUMMARY':
case 'DESCRIPTION':
case 'DURATION':
$alarm[strtolower($prop->name)] = $value;
break;
-
case 'REPEAT':
$alarm['repeat'] = (int) $value;
break;
-
case 'ATTENDEE':
$alarm['attendees'][] = preg_replace('!^mailto:!i', '', $value);
break;
diff --git a/src/app/Backends/DAV/Vtodo.php b/src/app/Backends/DAV/Vtodo.php
--- a/src/app/Backends/DAV/Vtodo.php
+++ b/src/app/Backends/DAV/Vtodo.php
@@ -2,7 +2,6 @@
namespace App\Backends\DAV;
-use Illuminate\Support\Str;
use Sabre\VObject\Component;
use Sabre\VObject\Property;
@@ -23,7 +22,7 @@
// map other properties
foreach ($vobject->children() as $prop) {
- if (!($prop instanceof Property)) {
+ if (!$prop instanceof Property) {
continue;
}
@@ -32,7 +31,6 @@
// This is of type Sabre\VObject\Property\ICalendar\DateTime
$this->due = $prop;
break;
-
case 'PERCENT-COMPLETE':
$this->percentComplete = $prop->getValue();
break;
diff --git a/src/app/Backends/IMAP.php b/src/app/Backends/IMAP.php
--- a/src/app/Backends/IMAP.php
+++ b/src/app/Backends/IMAP.php
@@ -17,13 +17,13 @@
'full' => 'lrswipkxtecdn',
];
-
/**
* Create a mailbox.
*
- * @param \App\User $user User
+ * @param User $user User
*
* @return bool True if a mailbox was created successfully, False otherwise
+ *
* @throws \Exception
*/
public static function createUser(User $user): bool
@@ -49,7 +49,7 @@
// Wait until it's propagated (for Cyrus Murder setup)
// FIXME: Do we still need this?
- if (strpos($imap->conn->data['GREETING'] ?? '', 'Cyrus IMAP Murder') !== false) {
+ if (str_contains($imap->conn->data['GREETING'] ?? '', 'Cyrus IMAP Murder')) {
$tries = 30;
while ($tries-- > 0) {
$folders = $imap->listMailboxes('', $mailbox);
@@ -78,7 +78,7 @@
/**
* Create default folders for the user.
*
- * @param \App\User $user User
+ * @param User $user User
*/
public static function createDefaultFolders(User $user): void
{
@@ -101,9 +101,10 @@
/**
* Delete a group.
*
- * @param \App\Group $group Group
+ * @param Group $group Group
*
* @return bool True if a group was deleted successfully, False otherwise
+ *
* @throws \Exception
*/
public static function deleteGroup(Group $group): bool
@@ -137,9 +138,9 @@
// Ignore the error if the folder doesn't exist (maybe it was removed already).
if (
$result === false && $imap->errornum == $imap::ERROR_NO
- && strpos($imap->error, 'Mailbox does not exist') !== false
+ && str_contains($imap->error, 'Mailbox does not exist')
) {
- \Log::info("The mailbox to delete was already removed: $mailbox");
+ \Log::info("The mailbox to delete was already removed: {$mailbox}");
$result = true;
} else {
// Delete the mailbox (no need to delete subfolders?)
@@ -174,9 +175,10 @@
/**
* Delete a user mailbox.
*
- * @param \App\User $user User
+ * @param User $user User
*
* @return bool True if a mailbox was deleted successfully, False otherwise
+ *
* @throws \Exception
*/
public static function deleteUser(User $user): bool
@@ -189,9 +191,10 @@
/**
* Update a mailbox (quota).
*
- * @param \App\User $user User
+ * @param User $user User
*
* @return bool True if a mailbox was updated successfully, False otherwise
+ *
* @throws \Exception
*/
public static function updateUser(User $user): bool
@@ -216,9 +219,10 @@
/**
* Create a resource.
*
- * @param \App\Resource $resource Resource
+ * @param Resource $resource Resource
*
* @return bool True if a resource was created successfully, False otherwise
+ *
* @throws \Exception
*/
public static function createResource(Resource $resource): bool
@@ -247,10 +251,11 @@
/**
* Update a resource.
*
- * @param \App\Resource $resource Resource
- * @param array $props Old resource properties
+ * @param Resource $resource Resource
+ * @param array $props Old resource properties
*
* @return bool True if a resource was updated successfully, False otherwise
+ *
* @throws \Exception
*/
public static function updateResource(Resource $resource, array $props = []): bool
@@ -291,9 +296,10 @@
/**
* Delete a resource.
*
- * @param \App\Resource $resource Resource
+ * @param Resource $resource Resource
*
* @return bool True if a resource was deleted successfully, False otherwise
+ *
* @throws \Exception
*/
public static function deleteResource(Resource $resource): bool
@@ -307,9 +313,10 @@
/**
* Create a shared folder.
*
- * @param \App\SharedFolder $folder Shared folder
+ * @param SharedFolder $folder Shared folder
*
* @return bool True if a falder was created successfully, False otherwise
+ *
* @throws \Exception
*/
public static function createSharedFolder(SharedFolder $folder): bool
@@ -332,10 +339,11 @@
/**
* Update a shared folder.
*
- * @param \App\SharedFolder $folder Shared folder
- * @param array $props Old folder properties
+ * @param SharedFolder $folder Shared folder
+ * @param array $props Old folder properties
*
* @return bool True if a falder was updated successfully, False otherwise
+ *
* @throws \Exception
*/
public static function updateSharedFolder(SharedFolder $folder, array $props = []): bool
@@ -372,9 +380,10 @@
/**
* Delete a shared folder.
*
- * @param \App\SharedFolder $folder Shared folder
+ * @param SharedFolder $folder Shared folder
*
* @return bool True if a falder was deleted successfully, False otherwise
+ *
* @throws \Exception
*/
public static function deleteSharedFolder(SharedFolder $folder): bool
@@ -429,6 +438,7 @@
* @param string $targetMailbox Target Mailbox
*
* @return bool True if the mailbox was renamed successfully, False otherwise
+ *
* @throws \Exception
*/
public static function renameMailbox($sourceMailbox, $targetMailbox): bool
@@ -468,6 +478,7 @@
* @param string $user The user
*
* @return array List of mailboxes
+ *
* @throws \Exception
*/
public static function listMailboxes(string $user): array
@@ -508,7 +519,7 @@
}
foreach (\config('services.imap.default_folders') as $folder_name => $props) {
- [$type, ] = explode('.', $props['metadata']['/private/vendor/kolab/folder-type'] ?? 'mail');
+ [$type] = explode('.', $props['metadata']['/private/vendor/kolab/folder-type'] ?? 'mail');
if (!empty($acl[$type])) {
$folders[$folder_name] = $acl[$type];
}
@@ -536,7 +547,7 @@
// Subscribe folders for the delegatee
$imap = self::initIMAP($config, $to->email);
- [$local, ] = explode('@', $user->email);
+ [$local] = explode('@', $user->email);
foreach ($folders as $folder => $rights) {
// Note: This code assumes that "Other Users/" is the namespace prefix
@@ -597,7 +608,7 @@
{
$config = self::getConfig();
$imap = self::initIMAP($config, $user->email);
- [$local, ] = explode('@', $email);
+ [$local] = explode('@', $email);
// FIXME: should we unsubscribe all or only default folders (ones that we auto-subscribe on delegation)?
$root = "Other Users/{$local}";
@@ -691,7 +702,7 @@
$domain = explode('@', $ident, 2)[1];
}
- $callback = function ($folder) use ($imap, $ident) {
+ $callback = static function ($folder) use ($imap, $ident) {
$acl = $imap->getACL($folder);
if (is_array($acl) && isset($acl[$ident])) {
\Log::info("Cleanup: Removing {$ident} from ACL on {$folder}");
@@ -739,7 +750,7 @@
->concat(['anyone', 'anonymous', $config['user']])
->all();
- $callback = function ($folder) use ($imap, $idents, $dry_run) {
+ $callback = static function ($folder) use ($imap, $idents, $dry_run) {
$acl = $imap->getACL($folder);
if (is_array($acl)) {
$owner = null;
@@ -787,13 +798,14 @@
/**
* Create a folder and set some default properties
*
- * @param \rcube_imap_generic $imap The imap instance
- * @param string $mailbox Mailbox name
- * @param bool $subscribe Subscribe to the folder
- * @param array $metadata Metadata to set on the folder
- * @param array $acl Acl to set on the folder
+ * @param \rcube_imap_generic $imap The imap instance
+ * @param string $mailbox Mailbox name
+ * @param bool $subscribe Subscribe to the folder
+ * @param array $metadata Metadata to set on the folder
+ * @param array $acl Acl to set on the folder
+ *
+ * @return bool true when having a folder created, False if it already existed
*
- * @return bool True when having a folder created, False if it already existed.
* @throws \Exception
*/
private static function createFolder($imap, string $mailbox, $subscribe = false, $metadata = null, $acl = null)
@@ -831,8 +843,8 @@
}
return \collect($acl)
- ->mapWithKeys(function ($item, $key) {
- list($user, $rights) = explode(',', $item, 2);
+ ->mapWithKeys(static function ($item, $key) {
+ [$user, $rights] = explode(',', $item, 2);
$rights = trim($rights);
return [trim($user) => self::ACL_MAP[$rights] ?? $rights];
})
@@ -879,7 +891,7 @@
/**
* Initialize connection to IMAP
*/
- private static function initIMAP(array $config, string $login_as = null)
+ private static function initIMAP(array $config, ?string $login_as = null)
{
$imap = new \rcube_imap_generic();
@@ -938,7 +950,7 @@
'ssl' => [
'verify_peer' => \config('services.imap.verify_peer'),
'verify_peer_name' => \config('services.imap.verify_peer'),
- 'verify_host' => \config('services.imap.verify_host')
+ 'verify_host' => \config('services.imap.verify_host'),
],
],
],
diff --git a/src/app/Backends/LDAP.php b/src/app/Backends/LDAP.php
--- a/src/app/Backends/LDAP.php
+++ b/src/app/Backends/LDAP.php
@@ -14,7 +14,6 @@
/** @var ?\Net_LDAP3 LDAP connection object */
protected static $ldap;
-
/**
* Starts a new LDAP connection that will be used by all methods
* until you call self::disconnect() explicitely. Normally every
@@ -56,19 +55,19 @@
$result = $ldap->search($mgmtRootDN, '', 'base');
if (!$result || $result->count() != 1) {
- self::throwException($ldap, "Failed to find the configured management domain $mgmtRootDN");
+ self::throwException($ldap, "Failed to find the configured management domain {$mgmtRootDN}");
}
$result = $ldap->search($hostedRootDN, '', 'base');
if (!$result || $result->count() != 1) {
- self::throwException($ldap, "Failed to find the configured hosted domain $hostedRootDN");
+ self::throwException($ldap, "Failed to find the configured hosted domain {$hostedRootDN}");
}
}
/**
* Create a domain in LDAP.
*
- * @param \App\Domain $domain The domain to create.
+ * @param Domain $domain the domain to create
*
* @throws \Exception
*/
@@ -97,7 +96,7 @@
'(targetattr = "*")'
. '(version 3.0;acl "Kolab Administrators";allow (all)'
. '(roledn = "ldap:///cn=kolab-admin,' . $domainBaseDN
- . ' || ldap:///cn=kolab-admin,' . $mgmtRootDN . '");)'
+ . ' || ldap:///cn=kolab-admin,' . $mgmtRootDN . '");)',
];
$entry = [
@@ -107,7 +106,7 @@
'objectclass' => [
'top',
'domainrelatedobject',
- 'inetdomain'
+ 'inetdomain',
],
];
@@ -129,12 +128,12 @@
'description' => $domain->namespace,
'objectclass' => [
'top',
- 'organizationalunit'
+ 'organizationalunit',
],
'ou' => $domain->namespace,
];
- $entry['aci'] = array(
+ $entry['aci'] = [
'(targetattr = "*")'
. '(version 3.0;acl "Deny Unauthorized"; deny (all)'
. '(userdn != "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN
@@ -163,7 +162,7 @@
'(target = "ldap:///cn=*,' . $domainBaseDN . '")(targetattr="objectclass || cn")'
. '(version 3.0;acl "Allow Domain Role Registration"; allow (add)'
. '(userdn = "ldap:///uid=kolab-service,ou=Special Users,' . $mgmtRootDN . '");)',
- );
+ ];
if (!$ldap->get_entry($domainBaseDN)) {
self::addEntry(
@@ -182,8 +181,8 @@
'description' => $item,
'objectclass' => [
'top',
- 'organizationalunit'
- ]
+ 'organizationalunit',
+ ],
];
self::addEntry(
@@ -206,8 +205,8 @@
'ldapsubentry',
'nsmanagedroledefinition',
'nsroledefinition',
- 'nssimpleroledefinition'
- ]
+ 'nssimpleroledefinition',
+ ],
];
self::addEntry(
@@ -229,7 +228,7 @@
/**
* Create a group in LDAP.
*
- * @param \App\Group $group The group to create.
+ * @param Group $group the group to create
*
* @throws \Exception
*/
@@ -247,7 +246,7 @@
'objectclass' => [
'top',
'groupofuniquenames',
- 'kolabgroupofuniquenames'
+ 'kolabgroupofuniquenames',
],
];
@@ -270,7 +269,7 @@
/**
* Create a resource in LDAP.
*
- * @param \App\Resource $resource The resource to create.
+ * @param Resource $resource the resource to create
*
* @throws \Exception
*/
@@ -313,7 +312,7 @@
/**
* Create a shared folder in LDAP.
*
- * @param \App\SharedFolder $folder The shared folder to create.
+ * @param SharedFolder $folder the shared folder to create
*
* @throws \Exception
*/
@@ -369,7 +368,7 @@
*
* 3) The Directory Manager account.
*
- * @param \App\User $user The user account to create.
+ * @param User $user the user account to create
*
* @throws \Exception
*/
@@ -385,11 +384,11 @@
'inetuser',
'kolabinetorgperson',
'mailrecipient',
- 'person'
+ 'person',
],
'mail' => $user->email,
'uid' => $user->email,
- 'nsroledn' => []
+ 'nsroledn' => [],
];
if (!self::getUserEntry($ldap, $user->email, $dn)) {
@@ -415,7 +414,7 @@
/**
* Delete a domain from LDAP.
*
- * @param \App\Domain $domain The domain to delete
+ * @param Domain $domain The domain to delete
*
* @throws \Exception
*/
@@ -458,7 +457,7 @@
/**
* Delete a group from LDAP.
*
- * @param \App\Group $group The group to delete.
+ * @param Group $group the group to delete
*
* @throws \Exception
*/
@@ -486,7 +485,7 @@
/**
* Delete a resource from LDAP.
*
- * @param \App\Resource $resource The resource to delete.
+ * @param Resource $resource the resource to delete
*
* @throws \Exception
*/
@@ -514,7 +513,7 @@
/**
* Delete a shared folder from LDAP.
*
- * @param \App\SharedFolder $folder The shared folder to delete.
+ * @param SharedFolder $folder the shared folder to delete
*
* @throws \Exception
*/
@@ -542,7 +541,7 @@
/**
* Delete a user from LDAP.
*
- * @param \App\User $user The user account to delete.
+ * @param User $user the user account to delete
*
* @throws \Exception
*/
@@ -573,6 +572,7 @@
* @param string $namespace The domain name
*
* @return array|false|null
+ *
* @throws \Exception
*/
public static function getDomain(string $namespace)
@@ -596,9 +596,10 @@
/**
* Get a group data from LDAP.
*
- * @param string $email The group email.
+ * @param string $email the group email
*
* @return array|false|null
+ *
* @throws \Exception
*/
public static function getGroup(string $email)
@@ -618,9 +619,10 @@
/**
* Get a resource data from LDAP.
*
- * @param string $email The resource email.
+ * @param string $email the resource email
*
* @return array|false|null
+ *
* @throws \Exception
*/
public static function getResource(string $email)
@@ -640,9 +642,10 @@
/**
* Get a shared folder data from LDAP.
*
- * @param string $email The resource email.
+ * @param string $email the resource email
*
* @return array|false|null
+ *
* @throws \Exception
*/
public static function getSharedFolder(string $email)
@@ -662,9 +665,10 @@
/**
* Get a user data from LDAP.
*
- * @param string $email The user email.
+ * @param string $email the user email
*
* @return array|false|null
+ *
* @throws \Exception
*/
public static function getUser(string $email)
@@ -684,7 +688,7 @@
/**
* Update a domain in LDAP.
*
- * @param \App\Domain $domain The domain to update.
+ * @param Domain $domain the domain to update
*
* @throws \Exception
*/
@@ -728,7 +732,7 @@
/**
* Update a group in LDAP.
*
- * @param \App\Group $group The group to update
+ * @param Group $group The group to update
*
* @throws \Exception
*/
@@ -765,7 +769,7 @@
/**
* Update a resource in LDAP.
*
- * @param \App\Resource $resource The resource to update
+ * @param Resource $resource The resource to update
*
* @throws \Exception
*/
@@ -802,7 +806,7 @@
/**
* Update a shared folder in LDAP.
*
- * @param \App\SharedFolder $folder The shared folder to update
+ * @param SharedFolder $folder The shared folder to update
*
* @throws \Exception
*/
@@ -839,7 +843,7 @@
/**
* Update a user in LDAP.
*
- * @param \App\User $user The user account to update.
+ * @param User $user the user account to update
*
* @throws \Exception
*/
@@ -945,7 +949,7 @@
$validMembers = [];
foreach ($group->members as $member) {
- list($local, $domainName) = explode('@', $member);
+ [$local, $domainName] = explode('@', $member);
$memberDN = "uid={$member},ou=People,{$domainBaseDN}";
$memberEntry = $ldap->get_entry($memberDN);
@@ -964,9 +968,9 @@
'top',
'inetorgperson',
'organizationalperson',
- 'person'
+ 'person',
],
- 'sn' => 'unknown'
+ 'sn' => 'unknown',
];
$ldap->add_entry($memberDN, $memberEntry);
@@ -1096,11 +1100,9 @@
switch ($entitlement->sku->title) {
case "mailbox":
break;
-
case "storage":
$entry['mailquota'] += 1048576;
break;
-
default:
$roles[] = $entitlement->sku->title;
break;
@@ -1154,7 +1156,7 @@
* @param string $email Group email (mail)
* @param string $dn Reference to group DN
*
- * @return null|array Group entry, NULL if not found
+ * @return array|null Group entry, NULL if not found
*/
private static function getGroupEntry($ldap, $email, &$dn = null)
{
@@ -1166,7 +1168,7 @@
// For groups we're using search() instead of get_entry() because
// a group name is not constant, so e.g. on update we might have
// the new name, but not the old one. Email address is constant.
- return self::searchEntry($ldap, $base_dn, "(mail=$email)", $attrs, $dn);
+ return self::searchEntry($ldap, $base_dn, "(mail={$email})", $attrs, $dn);
}
/**
@@ -1176,7 +1178,7 @@
* @param string $email Resource email (mail)
* @param string $dn Reference to the resource DN
*
- * @return null|array Resource entry, NULL if not found
+ * @return array|null Resource entry, NULL if not found
*/
private static function getResourceEntry($ldap, $email, &$dn = null)
{
@@ -1189,7 +1191,7 @@
// For resources we're using search() instead of get_entry() because
// a resource name is not constant, so e.g. on update we might have
// the new name, but not the old one. Email address is constant.
- return self::searchEntry($ldap, $base_dn, "(mail=$email)", $attrs, $dn);
+ return self::searchEntry($ldap, $base_dn, "(mail={$email})", $attrs, $dn);
}
/**
@@ -1199,7 +1201,7 @@
* @param string $email Resource email (mail)
* @param string $dn Reference to the shared folder DN
*
- * @return null|array Shared folder entry, NULL if not found
+ * @return array|null Shared folder entry, NULL if not found
*/
private static function getSharedFolderEntry($ldap, $email, &$dn = null)
{
@@ -1211,7 +1213,7 @@
// For shared folders we're using search() instead of get_entry() because
// a folder name is not constant, so e.g. on update we might have
// the new name, but not the old one. Email address is constant.
- return self::searchEntry($ldap, $base_dn, "(mail=$email)", $attrs, $dn);
+ return self::searchEntry($ldap, $base_dn, "(mail={$email})", $attrs, $dn);
}
/**
@@ -1222,7 +1224,7 @@
* @param string $dn Reference to user DN
* @param bool $full Get extra attributes, e.g. nsroledn
*
- * @return null|array User entry, NULL if not found
+ * @return array|null User entry, NULL if not found
*/
private static function getUserEntry($ldap, $email, &$dn, $full = false)
{
@@ -1251,9 +1253,9 @@
{
if (
(
- $level == LOG_INFO
- || $level == LOG_DEBUG
- || $level == LOG_NOTICE
+ $level == \LOG_INFO
+ || $level == \LOG_DEBUG
+ || $level == \LOG_NOTICE
)
&& !\config('app.debug')
) {
@@ -1261,28 +1263,28 @@
}
switch ($level) {
- case LOG_CRIT:
+ case \LOG_CRIT:
$function = 'critical';
break;
- case LOG_EMERG:
+ case \LOG_EMERG:
$function = 'emergency';
break;
- case LOG_ERR:
+ case \LOG_ERR:
$function = 'error';
break;
- case LOG_ALERT:
+ case \LOG_ALERT:
$function = 'alert';
break;
- case LOG_WARNING:
+ case \LOG_WARNING:
$function = 'warning';
break;
- case LOG_INFO:
+ case \LOG_INFO:
$function = 'info';
break;
- case LOG_DEBUG:
+ case \LOG_DEBUG:
$function = 'debug';
break;
- case LOG_NOTICE:
+ case \LOG_NOTICE:
$function = 'notice';
break;
default:
@@ -1340,7 +1342,7 @@
* @param array $attrs Result attributes
* @param string $dn Reference to a DN of the found entry
*
- * @return null|array LDAP entry, NULL if not found
+ * @return array|null LDAP entry, NULL if not found
*/
private static function searchEntry($ldap, $base_dn, $filter, $attrs, &$dn = null)
{
@@ -1385,7 +1387,7 @@
*
* @return string Full base DN
*/
- private static function baseDN($ldap, string $domainName, string $ouName = null): string
+ private static function baseDN($ldap, string $domainName, ?string $ouName = null): string
{
$dn = $ldap->domain_root_dn($domainName);
diff --git a/src/app/Backends/OpenExchangeRates.php b/src/app/Backends/OpenExchangeRates.php
--- a/src/app/Backends/OpenExchangeRates.php
+++ b/src/app/Backends/OpenExchangeRates.php
@@ -14,11 +14,11 @@
public static function retrieveRates($baseCurrency)
{
$baseCurrency = strtoupper($baseCurrency);
- $apiKey = \config('services.openexchangerates.api_key');
- $query = http_build_query(['app_id' => $apiKey, 'base' => 'USD']);
- $url = 'https://openexchangerates.org/api/latest.json?' . $query;
- $html = file_get_contents($url, false);
- $rates = [];
+ $apiKey = \config('services.openexchangerates.api_key');
+ $query = http_build_query(['app_id' => $apiKey, 'base' => 'USD']);
+ $url = 'https://openexchangerates.org/api/latest.json?' . $query;
+ $html = file_get_contents($url, false);
+ $rates = [];
if ($html && ($result = json_decode($html, true)) && !empty($result['rates'])) {
foreach ($result['rates'] as $code => $rate) {
@@ -64,7 +64,7 @@
$html = file_get_contents($url, false);
if ($html && ($result = json_decode($html, true)) && !empty($result['status'])) {
- print($result);
+ echo $result;
}
throw new \Exception("Failed to retrieve exchange rates status");
diff --git a/src/app/Backends/PGP.php b/src/app/Backends/PGP.php
--- a/src/app/Backends/PGP.php
+++ b/src/app/Backends/PGP.php
@@ -2,7 +2,10 @@
namespace App\Backends;
+use App\PowerDNS\Domain;
+use App\PowerDNS\Record;
use App\User;
+use App\Utils;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
@@ -14,12 +17,11 @@
/** @var array Crypt_GPG configuration */
private static $config = [];
-
/**
* Remove all files from the user homedir
*
- * @param \App\User $user User object
- * @param bool $del Delete also the homedir itself
+ * @param User $user User object
+ * @param bool $del Delete also the homedir itself
*/
public static function homedirCleanup(User $user, bool $del = false): void
{
@@ -46,8 +48,8 @@
* Generate a keypair.
* This will also initialize the user GPG homedir content.
*
- * @param \App\User $user User object
- * @param string $email Email address to use for the key
+ * @param User $user User object
+ * @param string $email Email address to use for the key
*
* @throws \Exception
*/
@@ -85,8 +87,8 @@
/**
* Delete a keypair from DNS and Enigma keyring.
*
- * @param \App\User $user User object
- * @param string $email Email address of the key
+ * @param User $user User object
+ * @param string $email Email address of the key
*
* @throws \Exception
*/
@@ -98,18 +100,18 @@
// Remove the whole Enigma keyring (if it's a delete user account)
if ($user->email === $email) {
self::homedirCleanup($user);
- $user->aliases()->pluck('alias')->each(fn ($alias) => self::keyUnregister($alias));
- } else {
- // TODO: remove only the alias key from Enigma keyring
+ $user->aliases()->pluck('alias')->each(static fn ($alias) => self::keyUnregister($alias));
}
+ // TODO: remove only the alias key from Enigma keyring
}
/**
* List (public and private) keys from a user keyring.
*
- * @param \App\User $user User object
+ * @param User $user User object
*
* @returns \Crypt_GPG_Key[] List of keys
+ *
* @throws \Exception
*/
public static function listKeys(User $user): array
@@ -124,7 +126,7 @@
*/
public static function logDebug($msg): void
{
- \Log::debug("[GPG] $msg");
+ \Log::debug("[GPG] {$msg}");
}
/**
@@ -135,19 +137,19 @@
*/
private static function keyRegister(string $email, string $key): void
{
- list($local, $domain) = \App\Utils::normalizeAddress($email, true);
+ [$local, $domain] = Utils::normalizeAddress($email, true);
DB::beginTransaction();
- $domain = \App\PowerDNS\Domain::firstOrCreate([
- 'name' => '_woat.' . $domain,
+ $domain = Domain::firstOrCreate([
+ 'name' => '_woat.' . $domain,
]);
- \App\PowerDNS\Record::create([
- 'domain_id' => $domain->id,
- 'name' => sha1($local) . '.' . $domain->name,
- 'type' => 'TXT',
- 'content' => 'v=woat1,public_key=' . $key
+ Record::create([
+ 'domain_id' => $domain->id,
+ 'name' => sha1($local) . '.' . $domain->name,
+ 'type' => 'TXT',
+ 'content' => 'v=woat1,public_key=' . $key,
]);
DB::commit();
@@ -160,9 +162,9 @@
*/
private static function keyUnregister(string $email): void
{
- list($local, $domain) = \App\Utils::normalizeAddress($email, true);
+ [$local, $domain] = Utils::normalizeAddress($email, true);
- $domain = \App\PowerDNS\Domain::where('name', '_woat.' . $domain)->first();
+ $domain = Domain::where('name', '_woat.' . $domain)->first();
if ($domain) {
$fqdn = sha1($local) . '.' . $domain->name;
@@ -181,9 +183,9 @@
return;
}
- $debug = \config('app.debug');
- $binary = \config('pgp.binary');
- $agent = \config('pgp.agent');
+ $debug = \config('app.debug');
+ $binary = \config('pgp.binary');
+ $agent = \config('pgp.agent');
$gpgconf = \config('pgp.gpgconf');
$dir = self::setHomedir($user);
diff --git a/src/app/Backends/Roundcube.php b/src/app/Backends/Roundcube.php
--- a/src/app/Backends/Roundcube.php
+++ b/src/app/Backends/Roundcube.php
@@ -3,6 +3,8 @@
namespace App\Backends;
use App\User;
+use App\UserAlias;
+use Illuminate\Database\ConnectionInterface;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
@@ -15,11 +17,10 @@
/** @var array List of GnuPG files to store */
private static $enigma_files = ['pubring.gpg', 'secring.gpg', 'pubring.kbx'];
-
/**
* Return connection to the Roundcube database
*
- * @return \Illuminate\Database\ConnectionInterface
+ * @return ConnectionInterface
*/
public static function dbh()
{
@@ -138,16 +139,16 @@
$data = $record ? base64_decode($record->data) : false;
if ($data === false) {
- \Log::error("Failed to sync $file ({$file_id}). Decode error.");
+ \Log::error("Failed to sync {$file} ({$file_id}). Decode error.");
continue;
}
if ($fs->put($file, $data, true)) {
// Note: Laravel Filesystem API does not provide touch method
- touch("$root/$file", $record->mtime);
+ touch("{$root}/{$file}", $record->mtime);
if ($debug) {
- \Log::debug("[SYNC] Fetched file: $file");
+ \Log::debug("[SYNC] Fetched file: {$file}");
}
}
}
@@ -159,7 +160,7 @@
if ($fs->delete($file)) {
if ($debug) {
- \Log::debug("[SYNC] Removed file: $file");
+ \Log::debug("[SYNC] Removed file: {$file}");
}
}
}
@@ -203,23 +204,23 @@
if ($mtime && (empty($existing) || $mtime > $existing->mtime)) {
$data = base64_encode($fs->get($file));
-/*
- if (empty($maxsize)) {
- $maxsize = min($db->get_variable('max_allowed_packet', 1048500), 4*1024*1024) - 2000;
- }
-
- if (strlen($data) > $maxsize) {
- \Log::error("Failed to save $file. Size exceeds max_allowed_packet.");
- continue;
- }
-*/
+ /*
+ if (empty($maxsize)) {
+ $maxsize = min($db->get_variable('max_allowed_packet', 1048500), 4*1024*1024) - 2000;
+ }
+
+ if (strlen($data) > $maxsize) {
+ \Log::error("Failed to save $file. Size exceeds max_allowed_packet.");
+ continue;
+ }
+ */
$result = $db->table(self::FILESTORE_TABLE)->updateOrInsert(
['user_id' => $user_id, 'context' => 'enigma', 'filename' => $filename],
['mtime' => $mtime, 'data' => $data]
);
if ($debug) {
- \Log::debug("[SYNC] Pushed file: $file");
+ \Log::debug("[SYNC] Pushed file: {$file}");
}
}
}
@@ -234,7 +235,7 @@
->delete();
if ($debug) {
- \Log::debug("[SYNC] Removed file: $file");
+ \Log::debug("[SYNC] Removed file: {$file}");
}
}
}
@@ -279,7 +280,7 @@
// Collect email addresses
$users = $user->delegators()->pluck('email', 'user_id')->all();
$users[$user->id] = $user->email;
- $aliases = \App\UserAlias::whereIn('user_id', array_keys($users))->pluck('alias')->all();
+ $aliases = UserAlias::whereIn('user_id', array_keys($users))->pluck('alias')->all();
$all_addresses = array_merge(array_values($users), $aliases);
// Delete excessive identities
@@ -326,11 +327,11 @@
$username = User::where('email', $email)->first()->name();
$db->table(self::IDENTITIES_TABLE)->insert([
- 'user_id' => $user_id,
- 'email' => $email,
- 'name' => $username,
- 'changed' => now()->toDateTimeString(),
- 'standard' => 1,
+ 'user_id' => $user_id,
+ 'email' => $email,
+ 'name' => $username,
+ 'changed' => now()->toDateTimeString(),
+ 'standard' => 1,
]);
return $user_id;
diff --git a/src/app/Backends/Storage.php b/src/app/Backends/Storage.php
--- a/src/app/Backends/Storage.php
+++ b/src/app/Backends/Storage.php
@@ -4,6 +4,7 @@
use App\Fs\Chunk;
use App\Fs\Item;
+use App\Utils;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage as LaravelStorage;
@@ -15,7 +16,6 @@
/** @const How long the resumable upload "token" is valid (in seconds) */
public const UPLOAD_TTL = 60 * 60 * 6;
-
/**
* Check if we can connect to the backend
*
@@ -33,7 +33,7 @@
/**
* Delete a file.
*
- * @param \App\Fs\Item $file File object
+ * @param Item $file File object
*
* @throws \Exception
*/
@@ -53,7 +53,7 @@
/**
* Delete a file chunk.
*
- * @param \App\Fs\Chunk $chunk File chunk object
+ * @param Chunk $chunk File chunk object
*
* @throws \Exception
*/
@@ -71,7 +71,7 @@
/**
* File download handler.
*
- * @param \App\Fs\Item $file File object
+ * @param Item $file File object
*
* @throws \Exception
*/
@@ -87,12 +87,12 @@
$disposition = $response->headers->makeDisposition('attachment', $props['name'], $fallbackName);
$response->headers->replace([
- 'Content-Type' => $props['mimetype'],
- 'Content-Disposition' => $disposition,
+ 'Content-Type' => $props['mimetype'],
+ 'Content-Disposition' => $disposition,
]);
- $response->setCallback(function () use ($file) {
- $file->chunks()->orderBy('sequence')->get()->each(function ($chunk) use ($file) {
+ $response->setCallback(static function () use ($file) {
+ $file->chunks()->orderBy('sequence')->get()->each(static function ($chunk) use ($file) {
$disk = LaravelStorage::disk(\config('filesystems.default'));
$path = Storage::chunkLocation($chunk->chunk_id, $file);
@@ -109,7 +109,7 @@
/**
* File content getter.
*
- * @param \App\Fs\Item $file File object
+ * @param Item $file File object
*
* @throws \Exception
*/
@@ -117,7 +117,7 @@
{
$output = '';
- $file->chunks()->orderBy('sequence')->get()->each(function ($chunk) use ($file, &$output) {
+ $file->chunks()->orderBy('sequence')->get()->each(static function ($chunk) use ($file, &$output) {
$disk = LaravelStorage::disk(\config('filesystems.default'));
$path = Storage::chunkLocation($chunk->chunk_id, $file);
@@ -130,14 +130,15 @@
/**
* File upload handler
*
- * @param resource $stream File input stream
- * @param array $params Request parameters
- * @param ?\App\Fs\Item $file The file object
+ * @param resource $stream File input stream
+ * @param array $params Request parameters
+ * @param ?Item $file The file object
*
* @return array File/Response attributes
+ *
* @throws \Exception
*/
- public static function fileInput($stream, array $params, Item $file = null): array
+ public static function fileInput($stream, array $params, ?Item $file = null): array
{
if (!empty($params['uploadId'])) {
return self::fileInputResumable($stream, $params, $file);
@@ -145,7 +146,7 @@
$disk = LaravelStorage::disk(\config('filesystems.default'));
- $chunkId = \App\Utils::uuidStr();
+ $chunkId = Utils::uuidStr();
$path = self::chunkLocation($chunkId, $file);
@@ -160,17 +161,17 @@
// Update the file type and size information
$file->setProperties([
- 'size' => $fileSize,
- // Pick the client-supplied mimetype if available, otherwise detect.
- 'mimetype' => !empty($params['mimetype']) ? $params['mimetype'] : self::mimetype($path),
+ 'size' => $fileSize,
+ // Pick the client-supplied mimetype if available, otherwise detect.
+ 'mimetype' => !empty($params['mimetype']) ? $params['mimetype'] : self::mimetype($path),
]);
// Assign the node to the file, "unlink" any old nodes of this file
$file->chunks()->delete();
$file->chunks()->create([
- 'chunk_id' => $chunkId,
- 'sequence' => 0,
- 'size' => $fileSize,
+ 'chunk_id' => $chunkId,
+ 'sequence' => 0,
+ 'size' => $fileSize,
]);
return ['id' => $file->id];
@@ -179,14 +180,15 @@
/**
* Resumable file upload handler
*
- * @param resource $stream File input stream
- * @param array $params Request parameters
- * @param ?\App\Fs\Item $file The file object
+ * @param resource $stream File input stream
+ * @param array $params Request parameters
+ * @param ?Item $file The file object
*
* @return array File/Response attributes
+ *
* @throws \Exception
*/
- protected static function fileInputResumable($stream, array $params, Item $file = null): array
+ protected static function fileInputResumable($stream, array $params, ?Item $file = null): array
{
// Initial request, save file metadata, return uploadId
if ($params['uploadId'] == 'resumable') {
@@ -194,7 +196,7 @@
throw new \Exception("Missing parameters of resumable file upload.");
}
- $params['uploadId'] = \App\Utils::uuidStr();
+ $params['uploadId'] = Utils::uuidStr();
$upload = [
'fileId' => $file->id,
@@ -234,7 +236,7 @@
}
$disk = LaravelStorage::disk(\config('filesystems.default'));
- $chunkId = \App\Utils::uuidStr();
+ $chunkId = Utils::uuidStr();
$path = self::chunkLocation($chunkId, $file);
@@ -251,10 +253,10 @@
// Create the chunk record
$file->chunks()->create([
- 'chunk_id' => $chunkId,
- 'sequence' => count($upload['chunks']),
- 'size' => $chunkSize,
- 'deleted_at' => \now(), // not yet active chunk
+ 'chunk_id' => $chunkId,
+ 'sequence' => count($upload['chunks']),
+ 'size' => $chunkSize,
+ 'deleted_at' => \now(), // not yet active chunk
]);
$upload['chunks'][] = $chunkId;
@@ -269,8 +271,8 @@
// Update file metadata
$file->setProperties([
- 'size' => $upload['uploaded'],
- 'mimetype' => $upload['mimetype'] ?: 'application/octet-stream',
+ 'size' => $upload['uploaded'],
+ 'mimetype' => $upload['mimetype'] ?: 'application/octet-stream',
]);
// Assign uploaded chunks to the file, "unlink" any old chunks of this file
@@ -316,8 +318,8 @@
/**
* Node location in the storage
*
- * @param string $chunkId Chunk identifier
- * @param \App\Fs\Item $file File the chunk belongs to
+ * @param string $chunkId Chunk identifier
+ * @param Item $file File the chunk belongs to
*
* @return string Chunk location
*/
diff --git a/src/app/CompanionApp.php b/src/app/CompanionApp.php
--- a/src/app/CompanionApp.php
+++ b/src/app/CompanionApp.php
@@ -2,9 +2,11 @@
namespace App;
+use App\Auth\PassportClient;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Http;
+use Laravel\Passport\Client;
/**
* The eloquent definition of a CompanionApp.
@@ -28,10 +30,11 @@
* Send a notification via firebase.
*
* @param array $deviceIds A list of device id's to send the notification to
- * @param array $data The data to include in the notification.
+ * @param array $data the data to include in the notification
*
- * @throws \Exception on notification failure
* @return bool true if a notification has been sent
+ *
+ * @throws \Exception on notification failure
*/
private static function pushFirebaseNotification($deviceIds, $data): bool
{
@@ -58,12 +61,13 @@
/**
* Send a notification to a user.
*
- * @throws \Exception on notification failure
* @return bool true if a notification has been sent
+ *
+ * @throws \Exception on notification failure
*/
public static function notifyUser($userId, $data): bool
{
- $notificationTokens = CompanionApp::where('user_id', $userId)
+ $notificationTokens = self::where('user_id', $userId)
->where('mfa_enabled', true)
->pluck('notification_token')
->all();
@@ -78,8 +82,6 @@
/**
* Returns whether this companion app is paired with a device.
- *
- * @return bool
*/
public function isPaired(): bool
{
@@ -89,19 +91,19 @@
/**
* The PassportClient of this CompanionApp
*
- * @return \App\Auth\PassportClient|null
+ * @return PassportClient|null
*/
public function passportClient()
{
- return \App\Auth\PassportClient::find($this->oauth_client_id);
+ return PassportClient::find($this->oauth_client_id);
}
/**
* Set the PassportClient of this CompanionApp
*
- * @param \Laravel\Passport\Client $client The client object
+ * @param Client $client The client object
*/
- public function setPassportClient(\Laravel\Passport\Client $client)
+ public function setPassportClient(Client $client)
{
return $this->oauth_client_id = $client->id;
}
diff --git a/src/app/Console/Command.php b/src/app/Console/Command.php
--- a/src/app/Console/Command.php
+++ b/src/app/Console/Command.php
@@ -2,7 +2,16 @@
namespace App\Console;
+use App\Domain;
+use App\Group;
+use App\Resource;
+use App\SharedFolder;
+use App\Tenant;
+use App\Traits\BelongsToTenantTrait;
+use App\User;
+use App\Wallet;
use Illuminate\Support\Facades\DB;
+use Symfony\Component\Console\Helper\ProgressBar;
abstract class Command extends \Illuminate\Console\Command
{
@@ -25,7 +34,7 @@
*
* * a command will result in the permanent, irrecoverable loss of data.
*
- * @var boolean
+ * @var bool
*/
protected $dangerous = false;
@@ -39,7 +48,6 @@
/** @var bool Adds --tenant option handler */
protected $withTenant = false;
-
/**
* Apply current tenant context to the query
*
@@ -58,12 +66,12 @@
}
$modelsWithOwner = [
- \App\Wallet::class,
+ Wallet::class,
];
// Add tenant filter
- if (in_array(\App\Traits\BelongsToTenantTrait::class, class_uses($object::class))) {
- $context = new \App\User();
+ if (in_array(BelongsToTenantTrait::class, class_uses($object::class))) {
+ $context = new User();
$context->tenant_id = $this->tenantId;
$object = $object->withObjectTenantContext($context);
@@ -85,7 +93,7 @@
* @param int $count Number of progress steps
* @param string $message The description
*
- * @return \Symfony\Component\Console\Helper\ProgressBar
+ * @return ProgressBar
*/
protected function createProgressBar($count, $message = null)
{
@@ -109,11 +117,11 @@
* @param string $domain Domain ID or namespace
* @param bool $withDeleted Include deleted
*
- * @return \App\Domain|null
+ * @return Domain|null
*/
public function getDomain($domain, $withDeleted = false)
{
- return $this->getObject(\App\Domain::class, $domain, 'namespace', $withDeleted);
+ return $this->getObject(Domain::class, $domain, 'namespace', $withDeleted);
}
/**
@@ -122,19 +130,19 @@
* @param string $group Group ID or email
* @param bool $withDeleted Include deleted
*
- * @return \App\Group|null
+ * @return Group|null
*/
public function getGroup($group, $withDeleted = false)
{
- return $this->getObject(\App\Group::class, $group, 'email', $withDeleted);
+ return $this->getObject(Group::class, $group, 'email', $withDeleted);
}
/**
* Find an object.
*
* @param string $objectClass The name of the class
- * @param string $objectIdOrTitle The name of a database field to match.
- * @param string|null $objectTitle An additional database field to match.
+ * @param string $objectIdOrTitle the name of a database field to match
+ * @param string|null $objectTitle an additional database field to match
* @param bool $withDeleted Act as if --with-deleted was used
*
* @return mixed
@@ -185,11 +193,11 @@
* @param string $resource Resource ID or email
* @param bool $withDeleted Include deleted
*
- * @return \App\Resource|null
+ * @return Resource|null
*/
public function getResource($resource, $withDeleted = false)
{
- return $this->getObject(\App\Resource::class, $resource, 'email', $withDeleted);
+ return $this->getObject(Resource::class, $resource, 'email', $withDeleted);
}
/**
@@ -198,11 +206,11 @@
* @param string $folder Folder ID or email
* @param bool $withDeleted Include deleted
*
- * @return \App\SharedFolder|null
+ * @return SharedFolder|null
*/
public function getSharedFolder($folder, $withDeleted = false)
{
- return $this->getObject(\App\SharedFolder::class, $folder, 'email', $withDeleted);
+ return $this->getObject(SharedFolder::class, $folder, 'email', $withDeleted);
}
/**
@@ -211,11 +219,11 @@
* @param string $user User ID or email
* @param bool $withDeleted Include deleted
*
- * @return \App\User|null
+ * @return User|null
*/
public function getUser($user, $withDeleted = false)
{
- return $this->getObject(\App\User::class, $user, 'email', $withDeleted);
+ return $this->getObject(User::class, $user, 'email', $withDeleted);
}
/**
@@ -223,11 +231,11 @@
*
* @param string $wallet Wallet ID
*
- * @return \App\Wallet|null
+ * @return Wallet|null
*/
public function getWallet($wallet)
{
- return $this->getObject(\App\Wallet::class, $wallet);
+ return $this->getObject(Wallet::class, $wallet);
}
/**
@@ -254,7 +262,7 @@
// @phpstan-ignore-next-line
if ($this->withTenant && $this->hasOption('tenant') && ($tenantId = $this->option('tenant'))) {
- $tenant = $this->getObject(\App\Tenant::class, $tenantId, 'title');
+ $tenant = $this->getObject(Tenant::class, $tenantId, 'title');
if (!$tenant) {
$this->error("Tenant {$tenantId} not found");
return 1;
@@ -275,16 +283,13 @@
*/
protected function toString($entry)
{
- /**
- * Haven't figured out yet, how to test if this command implements an option for additional
- * attributes.
- if (!in_array('attr', $this->options())) {
- return $entry->{$entry->getKeyName()};
- }
- */
+ // Haven't figured out yet, how to test if this command implements an option for additional attributes.
+ // if (!in_array('attr', $this->options())) {
+ // return $entry->{$entry->getKeyName()};
+ // }
$str = [
- $entry->{$entry->getKeyName()}
+ $entry->{$entry->getKeyName()},
];
// @phpstan-ignore-next-line
diff --git a/src/app/Console/Commands/AuthAttempt/DeleteCommand.php b/src/app/Console/Commands/AuthAttempt/DeleteCommand.php
--- a/src/app/Console/Commands/AuthAttempt/DeleteCommand.php
+++ b/src/app/Console/Commands/AuthAttempt/DeleteCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\AuthAttempt;
+use App\AuthAttempt;
use App\Console\ObjectDeleteCommand;
class DeleteCommand extends ObjectDeleteCommand
@@ -9,7 +10,7 @@
protected $dangerous = false;
protected $hidden = false;
- protected $objectClass = \App\AuthAttempt::class;
+ protected $objectClass = AuthAttempt::class;
protected $objectName = 'authattempt';
protected $objectTitle = 'id';
}
diff --git a/src/app/Console/Commands/AuthAttempt/ListCommand.php b/src/app/Console/Commands/AuthAttempt/ListCommand.php
--- a/src/app/Console/Commands/AuthAttempt/ListCommand.php
+++ b/src/app/Console/Commands/AuthAttempt/ListCommand.php
@@ -2,8 +2,8 @@
namespace App\Console\Commands\AuthAttempt;
-use App\Console\Command;
use App\AuthAttempt;
+use App\Console\Command;
class ListCommand extends Command
{
@@ -32,7 +32,7 @@
$authAttempts->each(
function ($authAttempt) {
- $this->info($authAttempt->toJson(JSON_PRETTY_PRINT));
+ $this->info($authAttempt->toJson(\JSON_PRETTY_PRINT));
}
);
}
diff --git a/src/app/Console/Commands/AuthAttempt/PurgeCommand.php b/src/app/Console/Commands/AuthAttempt/PurgeCommand.php
--- a/src/app/Console/Commands/AuthAttempt/PurgeCommand.php
+++ b/src/app/Console/Commands/AuthAttempt/PurgeCommand.php
@@ -2,8 +2,8 @@
namespace App\Console\Commands\AuthAttempt;
-use App\Console\Command;
use App\AuthAttempt;
+use App\Console\Command;
use Carbon\Carbon;
class PurgeCommand extends Command
diff --git a/src/app/Console/Commands/CompanionApp/DeleteCommand.php b/src/app/Console/Commands/CompanionApp/DeleteCommand.php
--- a/src/app/Console/Commands/CompanionApp/DeleteCommand.php
+++ b/src/app/Console/Commands/CompanionApp/DeleteCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\CompanionApp;
+use App\CompanionApp;
use App\Console\ObjectDeleteCommand;
class DeleteCommand extends ObjectDeleteCommand
@@ -9,7 +10,7 @@
protected $dangerous = false;
protected $hidden = false;
- protected $objectClass = \App\CompanionApp::class;
+ protected $objectClass = CompanionApp::class;
protected $objectName = 'companion-app';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/CompanionApp/ListCommand.php b/src/app/Console/Commands/CompanionApp/ListCommand.php
--- a/src/app/Console/Commands/CompanionApp/ListCommand.php
+++ b/src/app/Console/Commands/CompanionApp/ListCommand.php
@@ -2,11 +2,12 @@
namespace App\Console\Commands\CompanionApp;
+use App\CompanionApp;
use App\Console\ObjectListCommand;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\CompanionApp::class;
+ protected $objectClass = CompanionApp::class;
protected $objectName = 'companion-app';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Contact/ImportCommand.php b/src/app/Console/Commands/Contact/ImportCommand.php
--- a/src/app/Console/Commands/Contact/ImportCommand.php
+++ b/src/app/Console/Commands/Contact/ImportCommand.php
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Contact;
-use App\Contact;
use App\Console\Command;
+use App\Contact;
class ImportCommand extends Command
{
@@ -122,7 +122,7 @@
*/
protected function getFileType(string $header): ?string
{
- [$line, ] = preg_split('/\r?\n/', $header);
+ [$line] = preg_split('/\r?\n/', $header);
// TODO: vCard, LDIF
@@ -133,7 +133,7 @@
if (
($arr[0] == 'Email' && $arr[1] == 'Name')
|| in_array('Email', $arr)
- || strpos($arr[0], '@') !== false
+ || str_contains($arr[0], '@')
) {
return 'csv';
}
@@ -175,7 +175,7 @@
if ($fields === null) {
$filtered = array_filter(
array_map('strtolower', $data),
- fn ($h) => in_array($h, $all_props)
+ static fn ($h) => in_array($h, $all_props)
);
if (count($filtered) == 1 || count($filtered) == 2) {
@@ -186,9 +186,8 @@
}
continue;
- } else {
- $fields = ['email' => 0, 'name' => 1];
}
+ $fields = ['email' => 0, 'name' => 1];
}
$contact = new Contact();
diff --git a/src/app/Console/Commands/DB/ExpungeCommand.php b/src/app/Console/Commands/DB/ExpungeCommand.php
--- a/src/app/Console/Commands/DB/ExpungeCommand.php
+++ b/src/app/Console/Commands/DB/ExpungeCommand.php
@@ -2,6 +2,10 @@
namespace App\Console\Commands\DB;
+use App\Policy\Greylist\Connect;
+use App\Policy\Greylist\Whitelist;
+use App\Policy\RateLimit;
+use App\SignupCode;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
@@ -29,16 +33,16 @@
*/
public function handle()
{
- \App\Policy\Greylist\Connect::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
+ Connect::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
->delete();
- \App\Policy\Greylist\Whitelist::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
+ Whitelist::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
->delete();
- \App\Policy\RateLimit::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
+ RateLimit::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
->delete();
- \App\SignupCode::where('created_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
+ SignupCode::where('created_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
->forceDelete();
DB::table('failed_jobs')->where('failed_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))
diff --git a/src/app/Console/Commands/DB/PingCommand.php b/src/app/Console/Commands/DB/PingCommand.php
--- a/src/app/Console/Commands/DB/PingCommand.php
+++ b/src/app/Console/Commands/DB/PingCommand.php
@@ -33,7 +33,7 @@
try {
$result = DB::select("SELECT 1");
- if (sizeof($result) > 0) {
+ if (count($result) > 0) {
break;
}
} catch (\Exception $exception) {
diff --git a/src/app/Console/Commands/DB/VerifyTimezoneCommand.php b/src/app/Console/Commands/DB/VerifyTimezoneCommand.php
--- a/src/app/Console/Commands/DB/VerifyTimezoneCommand.php
+++ b/src/app/Console/Commands/DB/VerifyTimezoneCommand.php
@@ -28,7 +28,7 @@
*/
public function handle()
{
- $result = \Illuminate\Support\Facades\DB::select("SHOW VARIABLES WHERE Variable_name = 'time_zone'");
+ $result = DB::select("SHOW VARIABLES WHERE Variable_name = 'time_zone'");
$appTimezone = \config('app.timezone');
diff --git a/src/app/Console/Commands/Data/Import/CountriesCommand.php b/src/app/Console/Commands/Data/Import/CountriesCommand.php
--- a/src/app/Console/Commands/Data/Import/CountriesCommand.php
+++ b/src/app/Console/Commands/Data/Import/CountriesCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Data\Import;
use App\Console\Command;
+use App\Utils;
use Carbon\Carbon;
class CountriesCommand extends Command
@@ -45,7 +46,7 @@
//
$file = storage_path("countries-{$today}.json");
- \App\Utils::downloadFile($countrySource, $file);
+ Utils::downloadFile($countrySource, $file);
$countryJson = file_get_contents($file);
@@ -66,7 +67,7 @@
//
$file = storage_path("currencies-{$today}.json");
- \App\Utils::downloadFile($currencySource, $file);
+ Utils::downloadFile($currencySource, $file);
// fetch currency table and create an index by country page url
$currencyJson = file_get_contents($file);
diff --git a/src/app/Console/Commands/Data/Import/IP4NetsCommand.php b/src/app/Console/Commands/Data/Import/IP4NetsCommand.php
--- a/src/app/Console/Commands/Data/Import/IP4NetsCommand.php
+++ b/src/app/Console/Commands/Data/Import/IP4NetsCommand.php
@@ -3,6 +3,8 @@
namespace App\Console\Commands\Data\Import;
use App\Console\Command;
+use App\IP4Net;
+use App\Utils;
use Carbon\Carbon;
class IP4NetsCommand extends Command
@@ -33,7 +35,7 @@
'apnic' => 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest',
'arin' => 'http://ftp.arin.net/pub/stats/arin/delegated-arin-extended-latest',
'lacnic' => 'http://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest',
- 'ripencc' => 'https://ftp.ripe.net/ripe/stats/delegated-ripencc-latest'
+ 'ripencc' => 'https://ftp.ripe.net/ripe/stats/delegated-ripencc-latest',
];
$today = Carbon::now()->toDateString();
@@ -41,7 +43,7 @@
foreach ($rirs as $rir => $url) {
$file = storage_path("{$rir}-{$today}");
- \App\Utils::downloadFile($url, $file);
+ Utils::downloadFile($url, $file);
$serial = $this->serialFromStatsFile($file);
@@ -76,7 +78,7 @@
$items = explode('|', $line);
- if (sizeof($items) < 7) {
+ if (count($items) < 7) {
continue;
}
@@ -97,7 +99,7 @@
$mask = 32 - log((float) $items[4], 2);
$broadcast = long2ip((ip2long($items[3]) + 2 ** (32 - $mask)) - 1);
- $net = \App\IP4Net::where(
+ $net = IP4Net::where(
[
'net_number' => inet_pton($items[3]),
'net_mask' => $mask,
@@ -129,17 +131,17 @@
'country' => $items[1],
'serial' => $serial,
'created_at' => Carbon::parse($items[5], 'UTC'),
- 'updated_at' => Carbon::now()
+ 'updated_at' => Carbon::now(),
];
- if (sizeof($nets) >= 100) {
- \App\IP4Net::insert($nets);
+ if (count($nets) >= 100) {
+ IP4Net::insert($nets);
$nets = [];
}
}
- if (sizeof($nets) > 0) {
- \App\IP4Net::insert($nets);
+ if (count($nets) > 0) {
+ IP4Net::insert($nets);
$nets = [];
}
@@ -162,7 +164,7 @@
$items = explode('|', $line);
- if (sizeof($items) < 3) {
+ if (count($items) < 3) {
continue;
}
@@ -187,12 +189,12 @@
$items = explode('|', $line);
- if (sizeof($items) < 2) {
+ if (count($items) < 2) {
continue;
}
- if ((int)$items[2]) {
- $serial = (int)$items[2];
+ if ((int) $items[2]) {
+ $serial = (int) $items[2];
break;
}
}
diff --git a/src/app/Console/Commands/Data/Import/IP6NetsCommand.php b/src/app/Console/Commands/Data/Import/IP6NetsCommand.php
--- a/src/app/Console/Commands/Data/Import/IP6NetsCommand.php
+++ b/src/app/Console/Commands/Data/Import/IP6NetsCommand.php
@@ -3,6 +3,8 @@
namespace App\Console\Commands\Data\Import;
use App\Console\Command;
+use App\IP6Net;
+use App\Utils;
use Carbon\Carbon;
class IP6NetsCommand extends Command
@@ -33,7 +35,7 @@
'apnic' => 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest',
'arin' => 'http://ftp.arin.net/pub/stats/arin/delegated-arin-extended-latest',
'lacnic' => 'http://ftp.lacnic.net/pub/stats/lacnic/delegated-lacnic-latest',
- 'ripencc' => 'https://ftp.ripe.net/ripe/stats/delegated-ripencc-latest'
+ 'ripencc' => 'https://ftp.ripe.net/ripe/stats/delegated-ripencc-latest',
];
$today = Carbon::now()->toDateString();
@@ -41,7 +43,7 @@
foreach ($rirs as $rir => $url) {
$file = storage_path("{$rir}-{$today}");
- \App\Utils::downloadFile($url, $file);
+ Utils::downloadFile($url, $file);
$serial = $this->serialFromStatsFile($file);
@@ -76,7 +78,7 @@
$items = explode('|', $line);
- if (sizeof($items) < 7) {
+ if (count($items) < 7) {
continue;
}
@@ -94,12 +96,12 @@
$bar->advance();
- $broadcast = \App\Utils::ip6Broadcast($items[3], (int)$items[4]);
+ $broadcast = Utils::ip6Broadcast($items[3], (int) $items[4]);
- $net = \App\IP6Net::where(
+ $net = IP6Net::where(
[
'net_number' => inet_pton($items[3]),
- 'net_mask' => (int)$items[4],
+ 'net_mask' => (int) $items[4],
'net_broadcast' => inet_pton($broadcast),
]
)->first();
@@ -123,22 +125,22 @@
$nets[] = [
'rir_name' => $rir,
'net_number' => inet_pton($items[3]),
- 'net_mask' => (int)$items[4],
+ 'net_mask' => (int) $items[4],
'net_broadcast' => inet_pton($broadcast),
'country' => $items[1],
'serial' => $serial,
'created_at' => Carbon::parse($items[5], 'UTC'),
- 'updated_at' => Carbon::now()
+ 'updated_at' => Carbon::now(),
];
- if (sizeof($nets) >= 100) {
- \App\IP6Net::insert($nets);
+ if (count($nets) >= 100) {
+ IP6Net::insert($nets);
$nets = [];
}
}
- if (sizeof($nets) > 0) {
- \App\IP6Net::insert($nets);
+ if (count($nets) > 0) {
+ IP6Net::insert($nets);
$nets = [];
}
@@ -159,7 +161,7 @@
$items = explode('|', $line);
- if (sizeof($items) < 3) {
+ if (count($items) < 3) {
continue;
}
@@ -184,12 +186,12 @@
$items = explode('|', $line);
- if (sizeof($items) < 2) {
+ if (count($items) < 2) {
continue;
}
- if ((int)$items[2]) {
- $serial = (int)$items[2];
+ if ((int) $items[2]) {
+ $serial = (int) $items[2];
break;
}
}
diff --git a/src/app/Console/Commands/Data/Import/LdifCommand.php b/src/app/Console/Commands/Data/Import/LdifCommand.php
--- a/src/app/Console/Commands/Data/Import/LdifCommand.php
+++ b/src/app/Console/Commands/Data/Import/LdifCommand.php
@@ -3,6 +3,16 @@
namespace App\Console\Commands\Data\Import;
use App\Console\Command;
+use App\Domain;
+use App\Group;
+use App\Package;
+use App\Resource;
+use App\SharedFolder;
+use App\Sku;
+use App\Tenant;
+use App\User;
+use App\Utils;
+use App\Wallet;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
@@ -35,13 +45,12 @@
/** @var array Packages information */
protected $packages = [];
- /** @var ?\App\Wallet A wallet of the account owner */
+ /** @var ?Wallet A wallet of the account owner */
protected $wallet;
/** @var string Temp table name */
protected static $table = 'tmp_ldif_import';
-
/**
* Execute the console command.
*
@@ -50,7 +59,7 @@
public function handle()
{
if ($tenantId = $this->option('tenant')) {
- $tenant = $this->getObject(\App\Tenant::class, $tenantId, 'title');
+ $tenant = $this->getObject(Tenant::class, $tenantId, 'title');
if (!$tenant) {
$this->error("Tenant {$tenantId} not found");
return 1;
@@ -65,7 +74,7 @@
Schema::dropIfExists(self::$table);
Schema::create(
self::$table,
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('dn')->index();
$table->string('type')->nullable()->index();
@@ -120,7 +129,7 @@
{
$file = $this->argument('file');
- $numLines = \App\Utils::countLines($file);
+ $numLines = Utils::countLines($file);
$bar = $this->createProgressBar($numLines, "Parsing input file");
@@ -166,7 +175,7 @@
$entry[$lastAttr] .= ltrim($line);
}
} else {
- list ($attr, $remainder) = explode(':', $line, 2);
+ [$attr, $remainder] = explode(':', $line, 2);
$attr = strtolower($attr);
if ($remainder[0] === ':') {
@@ -210,16 +219,16 @@
$data = json_decode($_domain->data);
- $domain = \App\Domain::withTrashed()->where('namespace', $data->namespace)->first();
+ $domain = Domain::withTrashed()->where('namespace', $data->namespace)->first();
if ($domain) {
$this->setImportWarning($_domain->id, "Domain already exists");
continue;
}
- $domain = new \App\Domain();
+ $domain = new Domain();
$domain->namespace = $data->namespace;
- $domain->type = \App\Domain::TYPE_EXTERNAL;
+ $domain->type = Domain::TYPE_EXTERNAL;
$domain->tenant_id = $this->tenantId;
$domain->save();
@@ -231,16 +240,16 @@
if (!empty($data->aliases)) {
foreach ($data->aliases as $alias) {
$alias = strtolower($alias);
- $domain = \App\Domain::withTrashed()->where('namespace', $alias)->first();
+ $domain = Domain::withTrashed()->where('namespace', $alias)->first();
if ($domain) {
$this->setImportWarning($_domain->id, "Domain already exists");
continue;
}
- $domain = new \App\Domain();
+ $domain = new Domain();
$domain->namespace = $alias;
- $domain->type = \App\Domain::TYPE_EXTERNAL;
+ $domain->type = Domain::TYPE_EXTERNAL;
$domain->tenant_id = $this->tenantId;
$domain->save();
@@ -279,7 +288,7 @@
continue;
}
- $group = \App\Group::withTrashed()->where('email', $data->email)->first();
+ $group = Group::withTrashed()->where('email', $data->email)->first();
if ($group) {
$this->setImportWarning($_group->id, "Group already exists");
@@ -292,7 +301,7 @@
continue;
}
- $group = new \App\Group();
+ $group = new Group();
$group->name = $data->name;
$group->email = $data->email;
$group->members = $members;
@@ -326,7 +335,7 @@
$data = json_decode($_resource->data);
- $resource = \App\Resource::withTrashed()
+ $resource = Resource::withTrashed()
->where('name', $data->name)
->where('email', 'like', '%@' . $data->domain)
->first();
@@ -354,7 +363,7 @@
continue;
}
- $resource = new \App\Resource();
+ $resource = new Resource();
$resource->name = $data->name;
$resource->domainName = $data->domain;
$resource->tenant_id = $this->tenantId;
@@ -392,7 +401,7 @@
$data = json_decode($_folder->data);
- $folder = \App\SharedFolder::withTrashed()
+ $folder = SharedFolder::withTrashed()
->where('name', $data->name)
->where('email', 'like', '%@' . $data->domain)
->first();
@@ -408,7 +417,7 @@
continue;
}
- $folder = new \App\SharedFolder();
+ $folder = new SharedFolder();
$folder->name = $data->name;
$folder->type = $data->type ?? 'mail';
$folder->domainName = $data->domain;
@@ -507,7 +516,7 @@
{
$data = json_decode($ldap_user->data);
- $user = \App\User::withTrashed()->where('email', $data->email)->first();
+ $user = User::withTrashed()->where('email', $data->email)->first();
if ($user) {
$this->setImportWarning($ldap_user->id, "User already exists");
@@ -520,7 +529,7 @@
return;
}
- $user = \App\User::create(['email' => $data->email]);
+ $user = User::create(['email' => $data->email]);
// Entitlements
$user->assignPackageAndWallet($this->packages['user'], $this->wallet ?: $user->wallets()->first());
@@ -548,7 +557,7 @@
// Update password
if ($data->password != $user->password_ldap) {
- \App\User::where('id', $user->id)->update(['password_ldap' => $data->password]);
+ User::where('id', $user->id)->update(['password_ldap' => $data->password]);
}
// Import aliases
@@ -599,7 +608,7 @@
if (empty($error)) {
$method = 'parseLDAP' . ucfirst($type);
- list($data, $error) = $this->{$method}($entry);
+ [$data, $error] = $this->{$method}($entry);
if (empty($data['domain']) && !empty($data['email'])) {
$data['domain'] = explode('@', $data['email'])[1];
@@ -846,7 +855,7 @@
->where('type', 'user')
->whereNull('error')
->get()
- ->map(function ($user) {
+ ->map(static function ($user) {
$mdata = json_decode($user->data);
return $mdata->email;
})
@@ -858,7 +867,7 @@
// Get email addresses for existing Kolab4 users
if (!empty($users)) {
- $users = \App\User::whereIn('email', $users)->get()->pluck('email')->all();
+ $users = User::whereIn('email', $users)->get()->pluck('email')->all();
}
return $users;
@@ -970,15 +979,15 @@
// TODO: We should probably make package titles configurable with command options
$this->packages = [
- 'user' => \App\Package::where('title', 'kolab')->where('tenant_id', $this->tenantId)->first(),
- 'domain' => \App\Package::where('title', 'domain-hosting')->where('tenant_id', $this->tenantId)->first(),
+ 'user' => Package::where('title', 'kolab')->where('tenant_id', $this->tenantId)->first(),
+ 'domain' => Package::where('title', 'domain-hosting')->where('tenant_id', $this->tenantId)->first(),
];
// Count storage skus
$sku = $this->packages['user']->skus()->where('title', 'storage')->first();
$this->packages['quota'] = $sku ? $sku->pivot->qty : 0;
- $this->packages['storage'] = \App\Sku::where('title', 'storage')->where('tenant_id', $this->tenantId)->first();
+ $this->packages['storage'] = Sku::where('title', 'storage')->where('tenant_id', $this->tenantId)->first();
}
/**
diff --git a/src/app/Console/Commands/Data/Import/LicensesCommand.php b/src/app/Console/Commands/Data/Import/LicensesCommand.php
--- a/src/app/Console/Commands/Data/Import/LicensesCommand.php
+++ b/src/app/Console/Commands/Data/Import/LicensesCommand.php
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Data\Import;
-use App\License;
use App\Console\Command;
+use App\License;
class LicensesCommand extends Command
{
@@ -37,14 +37,14 @@
$type = $this->argument('type');
if (!file_exists($file)) {
- $this->error("File '$file' does not exist");
+ $this->error("File '{$file}' does not exist");
return 1;
}
$list = file($file);
if (empty($list)) {
- $this->error("File '$file' is empty");
+ $this->error("File '{$file}' is empty");
return 1;
}
@@ -55,9 +55,9 @@
// Import licenses
foreach ($list as $key) {
License::create([
- 'key' => $key,
- 'type' => $type,
- 'tenant_id' => $this->tenantId,
+ 'key' => $key,
+ 'type' => $type,
+ 'tenant_id' => $this->tenantId,
]);
$bar->advance();
diff --git a/src/app/Console/Commands/Data/Import/OpenExchangeRatesCommand.php b/src/app/Console/Commands/Data/Import/OpenExchangeRatesCommand.php
--- a/src/app/Console/Commands/Data/Import/OpenExchangeRatesCommand.php
+++ b/src/app/Console/Commands/Data/Import/OpenExchangeRatesCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\Data\Import;
+use App\Backends\OpenExchangeRates;
use App\Console\Command;
class OpenExchangeRatesCommand extends Command
@@ -29,9 +30,9 @@
{
foreach (['CHF', 'EUR'] as $sourceCurrency) {
try {
- $rates = \App\Backends\OpenExchangeRates::retrieveRates($sourceCurrency);
+ $rates = OpenExchangeRates::retrieveRates($sourceCurrency);
- $file = resource_path("exchangerates-$sourceCurrency.php");
+ $file = resource_path("exchangerates-{$sourceCurrency}.php");
$out = "<?php return [\n";
@@ -43,7 +44,7 @@
file_put_contents($file, $out);
} catch (\Exception $exception) {
- $this->error("Failed to import $sourceCurrency: " . $exception->getMessage());
+ $this->error("Failed to import {$sourceCurrency}: " . $exception->getMessage());
}
}
}
diff --git a/src/app/Console/Commands/Data/Import/SignupTokensCommand.php b/src/app/Console/Commands/Data/Import/SignupTokensCommand.php
--- a/src/app/Console/Commands/Data/Import/SignupTokensCommand.php
+++ b/src/app/Console/Commands/Data/Import/SignupTokensCommand.php
@@ -2,9 +2,10 @@
namespace App\Console\Commands\Data\Import;
+use App\Console\Command;
use App\Plan;
use App\SignupToken;
-use App\Console\Command;
+use App\UserSetting;
class SignupTokensCommand extends Command
{
@@ -49,14 +50,14 @@
$file = $this->argument('file');
if (!file_exists($file)) {
- $this->error("File '$file' does not exist");
+ $this->error("File '{$file}' does not exist");
return 1;
}
$list = file($file);
if (empty($list)) {
- $this->error("File '$file' is empty");
+ $this->error("File '{$file}' is empty");
return 1;
}
@@ -72,7 +73,7 @@
unset($list[$idx]);
} elseif (strlen($token) > 191) {
$bar->finish();
- $this->error("Token '$token' is too long");
+ $this->error("Token '{$token}' is too long");
return 1;
} elseif (SignupToken::find($token)) {
// Skip existing tokens
@@ -98,11 +99,11 @@
// Import tokens
foreach ($list as $token) {
$plan->signupTokens()->create([
- 'id' => $token,
- // This allows us to update counter when importing old tokens in migration.
- // It can be removed later
- 'counter' => \App\UserSetting::where('key', 'signup_token')
- ->whereRaw('UPPER(value) = ?', [$token])->count(),
+ 'id' => $token,
+ // This allows us to update counter when importing old tokens in migration.
+ // It can be removed later
+ 'counter' => UserSetting::where('key', 'signup_token')
+ ->whereRaw('UPPER(value) = ?', [$token])->count(),
]);
$bar->advance();
diff --git a/src/app/Console/Commands/Data/Import/VatRatesCommand.php b/src/app/Console/Commands/Data/Import/VatRatesCommand.php
--- a/src/app/Console/Commands/Data/Import/VatRatesCommand.php
+++ b/src/app/Console/Commands/Data/Import/VatRatesCommand.php
@@ -2,8 +2,8 @@
namespace App\Console\Commands\Data\Import;
-use App\VatRate;
use App\Console\Command;
+use App\VatRate;
class VatRatesCommand extends Command
{
@@ -69,9 +69,9 @@
if (!$existing || $existing->rate != $rate) {
VatRate::create([
- 'start' => $date,
- 'rate' => $rate,
- 'country' => strtoupper($country),
+ 'start' => $date,
+ 'rate' => $rate,
+ 'country' => strtoupper($country),
]);
$this->info("Added {$country}:{$rate}");
diff --git a/src/app/Console/Commands/Data/ImportCommand.php b/src/app/Console/Commands/Data/ImportCommand.php
--- a/src/app/Console/Commands/Data/ImportCommand.php
+++ b/src/app/Console/Commands/Data/ImportCommand.php
@@ -31,7 +31,7 @@
Import\CountriesCommand::class,
Import\OpenExchangeRatesCommand::class,
Import\IP4NetsCommand::class,
- Import\IP6NetsCommand::class
+ Import\IP6NetsCommand::class,
];
foreach ($commands as $command) {
diff --git a/src/app/Console/Commands/Data/InitCommand.php b/src/app/Console/Commands/Data/InitCommand.php
--- a/src/app/Console/Commands/Data/InitCommand.php
+++ b/src/app/Console/Commands/Data/InitCommand.php
@@ -38,13 +38,13 @@
{
$user = User::where(['email' => \config('services.imap.admin_login')])->first();
if (!$user) {
- $user = new \App\User();
+ $user = new User();
$user->email = \config('services.imap.admin_login');
$user->password = \config('services.imap.admin_password');
- $user->role = \App\User::ROLE_SERVICE;
+ $user->role = User::ROLE_SERVICE;
} else {
$user->password = \config('services.imap.admin_password');
- $user->role = \App\User::ROLE_SERVICE;
+ $user->role = User::ROLE_SERVICE;
}
$user->save();
}
@@ -54,13 +54,13 @@
if (!empty(\config('mail.mailers.smtp.username'))) {
$user = User::where(['email' => \config('mail.mailers.smtp.username')])->first();
if (!$user) {
- $user = new \App\User();
+ $user = new User();
$user->email = \config('mail.mailers.smtp.username');
$user->password = \config('mail.mailers.smtp.password');
- $user->role = \App\User::ROLE_SERVICE;
+ $user->role = User::ROLE_SERVICE;
} else {
$user->password = \config('mail.mailers.smtp.password');
- $user->role = \App\User::ROLE_SERVICE;
+ $user->role = User::ROLE_SERVICE;
}
$user->save();
}
@@ -77,8 +77,8 @@
// Create a password grant client for the webapp
if (
- !empty(\config('auth.proxy.client_secret')) &&
- !Passport::client()->where('id', \config('auth.proxy.client_id'))->exists()
+ !empty(\config('auth.proxy.client_secret'))
+ && !Passport::client()->where('id', \config('auth.proxy.client_id'))->exists()
) {
$client = Passport::client()->forceFill([
'user_id' => null,
@@ -96,15 +96,15 @@
// Create a client for Webmail SSO
if (
- !empty(\config('auth.sso.client_secret')) &&
- !Passport::client()->where('id', \config('auth.sso.client_id'))->exists()
+ !empty(\config('auth.sso.client_secret'))
+ && !Passport::client()->where('id', \config('auth.sso.client_id'))->exists()
) {
$client = Passport::client()->forceFill([
'user_id' => null,
'name' => 'Webmail SSO client',
'secret' => \config('auth.sso.client_secret'),
'provider' => 'users',
- 'redirect' => (str_starts_with(\config('app.webmail_url'), 'http') ? '' : 'https://' . $domain)
+ 'redirect' => (str_starts_with(\config('app.webmail_url'), 'http') ? '' : 'https://' . $domain)
. \config('app.webmail_url') . 'index.php/login/oauth',
'personal_access_client' => 0,
'password_client' => 0,
@@ -117,8 +117,8 @@
// Create a client for synapse oauth
if (
- !empty(\config('auth.synapse.client_secret')) &&
- !Passport::client()->where('id', \config('auth.synapse.client_id'))->exists()
+ !empty(\config('auth.synapse.client_secret'))
+ && !Passport::client()->where('id', \config('auth.synapse.client_id'))->exists()
) {
$client = Passport::client()->forceFill([
'user_id' => null,
diff --git a/src/app/Console/Commands/Data/MigrateCommand.php b/src/app/Console/Commands/Data/MigrateCommand.php
--- a/src/app/Console/Commands/Data/MigrateCommand.php
+++ b/src/app/Console/Commands/Data/MigrateCommand.php
@@ -35,8 +35,8 @@
{--folder-filter=* : Exact folder name match before mapping}
{--skip-folder=* : Exact folder name match before mapping}
{--folder-mapping=* : Folder mapping in the form "source:target"}';
-// {--export-only : Only export data}
-// {--import-only : Only import previously exported data}';
+ // {--export-only : Only export data}
+ // {--import-only : Only import previously exported data}';
/**
* The console command description.
diff --git a/src/app/Console/Commands/Data/Reports/VatCommand.php b/src/app/Console/Commands/Data/Reports/VatCommand.php
--- a/src/app/Console/Commands/Data/Reports/VatCommand.php
+++ b/src/app/Console/Commands/Data/Reports/VatCommand.php
@@ -2,10 +2,13 @@
namespace App\Console\Commands\Data\Reports;
+use App\Mail\Helper;
+use App\Mail\Mailable;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\HtmlString;
class VatCommand extends Command
{
@@ -58,29 +61,29 @@
$this->period = $period;
$result = DB::select(
- <<<SQL
- SELECT
- DATE_FORMAT(p.created_at, '%Y-%m-%d %H:%I') AS timestamp,
- v.country AS country,
- p.id AS payment_id,
- ROUND((amount / 100), 2) AS income_gross,
- ROUND(((amount - (amount / (100 + v.rate) * v.rate)) / 100), 2) AS income_net,
- ROUND(((amount / (100 + v.rate) * v.rate) / 100), 2) AS income_vat
- FROM
- payments p
- INNER JOIN vat_rates v
- ON p.vat_rate_id = v.id
- INNER JOIN wallets w
- ON p.wallet_id = w.id
- INNER JOIN user_settings us
- ON w.user_id = us.user_id
- WHERE
- p.status = 'paid'
- AND us.`key` = 'country'
- AND p.created_at >= ?
- AND p.created_at <= ?
- ORDER BY timestamp, country
- SQL,
+ <<<'SQL'
+ SELECT
+ DATE_FORMAT(p.created_at, '%Y-%m-%d %H:%I') AS timestamp,
+ v.country AS country,
+ p.id AS payment_id,
+ ROUND((amount / 100), 2) AS income_gross,
+ ROUND(((amount - (amount / (100 + v.rate) * v.rate)) / 100), 2) AS income_net,
+ ROUND(((amount / (100 + v.rate) * v.rate) / 100), 2) AS income_vat
+ FROM
+ payments p
+ INNER JOIN vat_rates v
+ ON p.vat_rate_id = v.id
+ INNER JOIN wallets w
+ ON p.wallet_id = w.id
+ INNER JOIN user_settings us
+ ON w.user_id = us.user_id
+ WHERE
+ p.status = 'paid'
+ AND us.`key` = 'country'
+ AND p.created_at >= ?
+ AND p.created_at <= ?
+ ORDER BY timestamp, country
+ SQL,
[$start->toDateTimeString(), $end->toDateTimeString()]
);
@@ -105,16 +108,16 @@
$plainBody = 'See the attached report!';
$filename = "Report-{$this->period}.csv";
- $attachment = Attachment::fromData(fn () => $csv, $filename)->withMime('text/csv');
+ $attachment = Attachment::fromData(static fn () => $csv, $filename)->withMime('text/csv');
- $mail = new \App\Mail\Mailable();
+ $mail = new Mailable();
$mail->subject('VAT Report')
// This hack allows as to use plain text body instead of a Laravel view
- ->text(new \Illuminate\Support\HtmlString($plainBody))
+ ->text(new HtmlString($plainBody))
->to($recipient)
->attach($attachment);
- \App\Mail\Helper::sendMail($mail);
+ Helper::sendMail($mail);
}
}
diff --git a/src/app/Console/Commands/Data/Stats/CollectorCommand.php b/src/app/Console/Commands/Data/Stats/CollectorCommand.php
--- a/src/app/Console/Commands/Data/Stats/CollectorCommand.php
+++ b/src/app/Console/Commands/Data/Stats/CollectorCommand.php
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Data\Stats;
use App\Http\Controllers\API\V4\Admin\StatsController;
-use App\Payment;
use App\Transaction;
use App\User;
use App\Wallet;
@@ -57,10 +56,10 @@
// Count all non-degraded and non-deleted users that are payers
$counts = DB::table('users')
->selectRaw('count(*) as total, users.tenant_id')
- ->joinSub($wallets, 'wallets', function ($join) {
+ ->joinSub($wallets, 'wallets', static function ($join) {
$join->on('users.id', '=', 'wallets.user_id');
})
- ->joinSub($transactions, 'transactions', function ($join) {
+ ->joinSub($transactions, 'transactions', static function ($join) {
$join->on('wallets.id', '=', 'transactions.wallet_id');
})
->whereNull('users.deleted_at')
@@ -69,7 +68,7 @@
->groupBy('users.tenant_id')
->havingRaw('count(*) > 0')
->get()
- ->each(function ($record) {
+ ->each(static function ($record) {
DB::table('stats')->insert([
'tenant_id' => $record->tenant_id,
'type' => StatsController::TYPE_PAYERS,
diff --git a/src/app/Console/Commands/Discount/ListCommand.php b/src/app/Console/Commands/Discount/ListCommand.php
--- a/src/app/Console/Commands/Discount/ListCommand.php
+++ b/src/app/Console/Commands/Discount/ListCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Discount;
use App\Console\ObjectListCommand;
+use App\Discount;
/**
* List discounts.
@@ -29,7 +30,7 @@
*/
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Discount::class;
+ protected $objectClass = Discount::class;
protected $objectName = 'discount';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Discount/MergeCommand.php b/src/app/Console/Commands/Discount/MergeCommand.php
--- a/src/app/Console/Commands/Discount/MergeCommand.php
+++ b/src/app/Console/Commands/Discount/MergeCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Discount;
use App\Console\Command;
+use App\Discount;
/**
* Merge one discount (source) with another discount (target), and delete the source discount.
@@ -40,8 +41,8 @@
*
* @var string
*/
- protected $description = 'Merge one discount in to another discount, ' .
- 'optionally set the description, and delete the source discount';
+ protected $description = 'Merge one discount in to another discount, '
+ . 'optionally set the description, and delete the source discount';
/**
* Execute the console command.
@@ -50,14 +51,14 @@
*/
public function handle()
{
- $source = $this->getObject(\App\Discount::class, $this->argument('source'));
+ $source = $this->getObject(Discount::class, $this->argument('source'));
if (!$source) {
$this->error("No such source discount: {$source}");
return 1;
}
- $target = $this->getObject(\App\Discount::class, $this->argument('target'));
+ $target = $this->getObject(Discount::class, $this->argument('target'));
if (!$target) {
$this->error("No such target discount: {$target}");
diff --git a/src/app/Console/Commands/Domain/CreateCommand.php b/src/app/Console/Commands/Domain/CreateCommand.php
--- a/src/app/Console/Commands/Domain/CreateCommand.php
+++ b/src/app/Console/Commands/Domain/CreateCommand.php
@@ -55,7 +55,7 @@
$entitlement = Entitlement::withTrashed()->where(
[
'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'entitleable_type' => Domain::class,
]
)->first();
diff --git a/src/app/Console/Commands/Domain/DeleteCommand.php b/src/app/Console/Commands/Domain/DeleteCommand.php
--- a/src/app/Console/Commands/Domain/DeleteCommand.php
+++ b/src/app/Console/Commands/Domain/DeleteCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Domain;
use App\Console\ObjectDeleteCommand;
+use App\Domain;
class DeleteCommand extends ObjectDeleteCommand
{
protected $dangerous = false;
protected $hidden = false;
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
protected $objectTitle = 'namespace';
diff --git a/src/app/Console/Commands/Domain/ListCommand.php b/src/app/Console/Commands/Domain/ListCommand.php
--- a/src/app/Console/Commands/Domain/ListCommand.php
+++ b/src/app/Console/Commands/Domain/ListCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Domain;
use App\Console\ObjectListCommand;
+use App\Domain;
/**
* List domains.
@@ -29,7 +30,7 @@
*/
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
protected $objectTitle = 'namespace';
}
diff --git a/src/app/Console/Commands/Domain/StatusCommand.php b/src/app/Console/Commands/Domain/StatusCommand.php
--- a/src/app/Console/Commands/Domain/StatusCommand.php
+++ b/src/app/Console/Commands/Domain/StatusCommand.php
@@ -3,7 +3,6 @@
namespace App\Console\Commands\Domain;
use App\Console\Command;
-use App\Domain;
class StatusCommand extends Command
{
diff --git a/src/app/Console/Commands/Domain/SuspendCommand.php b/src/app/Console/Commands/Domain/SuspendCommand.php
--- a/src/app/Console/Commands/Domain/SuspendCommand.php
+++ b/src/app/Console/Commands/Domain/SuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Domain;
use App\Console\Command;
+use App\EventLog;
class SuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$domain->suspend();
- \App\EventLog::createFor($domain, \App\EventLog::TYPE_SUSPENDED, $this->option('comment'));
+ EventLog::createFor($domain, EventLog::TYPE_SUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/Domain/UnsuspendCommand.php b/src/app/Console/Commands/Domain/UnsuspendCommand.php
--- a/src/app/Console/Commands/Domain/UnsuspendCommand.php
+++ b/src/app/Console/Commands/Domain/UnsuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Domain;
use App\Console\Command;
+use App\EventLog;
class UnsuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$domain->unsuspend();
- \App\EventLog::createFor($domain, \App\EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
+ EventLog::createFor($domain, EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/Domain/UsersCommand.php b/src/app/Console/Commands/Domain/UsersCommand.php
--- a/src/app/Console/Commands/Domain/UsersCommand.php
+++ b/src/app/Console/Commands/Domain/UsersCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Domain;
use App\Console\ObjectRelationListCommand;
+use App\Domain;
class UsersCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
protected $objectTitle = 'namespace';
protected $objectRelation = 'users';
diff --git a/src/app/Console/Commands/EntitlementsCommand.php b/src/app/Console/Commands/EntitlementsCommand.php
--- a/src/app/Console/Commands/EntitlementsCommand.php
+++ b/src/app/Console/Commands/EntitlementsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\Entitlement;
class EntitlementsCommand extends ObjectListCommand
{
- protected $objectClass = \App\Entitlement::class;
+ protected $objectClass = Entitlement::class;
protected $objectName = 'entitlement';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Group/AddMemberCommand.php b/src/app/Console/Commands/Group/AddMemberCommand.php
--- a/src/app/Console/Commands/Group/AddMemberCommand.php
+++ b/src/app/Console/Commands/Group/AddMemberCommand.php
@@ -45,7 +45,7 @@
$owner = $group->wallet()->owner;
if ($error = GroupsController::validateMemberEmail($member, $owner)) {
- $this->error("{$member}: $error");
+ $this->error("{$member}: {$error}");
return 1;
}
diff --git a/src/app/Console/Commands/Group/CreateCommand.php b/src/app/Console/Commands/Group/CreateCommand.php
--- a/src/app/Console/Commands/Group/CreateCommand.php
+++ b/src/app/Console/Commands/Group/CreateCommand.php
@@ -38,7 +38,7 @@
$email = $this->argument('email');
$members = $this->option('member');
- list($local, $domainName) = explode('@', $email, 2);
+ [$local, $domainName] = explode('@', $email, 2);
$domain = $this->getDomain($domainName);
@@ -57,7 +57,7 @@
// Validate members addresses
foreach ($members as $i => $member) {
if ($error = GroupsController::validateMemberEmail($member, $owner)) {
- $this->error("{$member}: $error");
+ $this->error("{$member}: {$error}");
return 1;
}
if (\strtolower($member) === \strtolower($email)) {
diff --git a/src/app/Console/Commands/Group/ListCommand.php b/src/app/Console/Commands/Group/ListCommand.php
--- a/src/app/Console/Commands/Group/ListCommand.php
+++ b/src/app/Console/Commands/Group/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Group;
use App\Console\ObjectListCommand;
+use App\Group;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Group::class;
+ protected $objectClass = Group::class;
protected $objectName = 'group';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Group/ResyncCommand.php b/src/app/Console/Commands/Group/ResyncCommand.php
--- a/src/app/Console/Commands/Group/ResyncCommand.php
+++ b/src/app/Console/Commands/Group/ResyncCommand.php
@@ -4,6 +4,9 @@
use App\Console\Command;
use App\Group;
+use App\Jobs\Group\CreateJob;
+use App\Jobs\Group\DeleteJob;
+use App\Jobs\Group\UpdateJob;
class ResyncCommand extends Command
{
@@ -45,7 +48,7 @@
if ($deleted_only) {
$groups->whereNotNull('deleted_at')
- ->where(function ($query) {
+ ->where(static function ($query) {
$query->where('status', '&', Group::STATUS_LDAP_READY);
});
}
@@ -70,7 +73,7 @@
}
// TODO: Do this not asyncronously as an option or when a signle group is requested?
- \App\Jobs\Group\DeleteJob::dispatch($group->id);
+ DeleteJob::dispatch($group->id);
$this->info("{$group->email}: pushed");
} else {
@@ -87,7 +90,7 @@
continue;
}
- \App\Jobs\Group\CreateJob::dispatch($group->id);
+ CreateJob::dispatch($group->id);
$this->info("{$group->email}: pushed");
} elseif (!empty($req_group)) {
@@ -98,7 +101,7 @@
// We push the update only if a specific group is requested,
// We don't want to flood the database/backend with an update of all groups
- \App\Jobs\Group\UpdateJob::dispatch($group->id);
+ UpdateJob::dispatch($group->id);
$this->info("{$group->email}: pushed");
} else {
diff --git a/src/app/Console/Commands/Group/SuspendCommand.php b/src/app/Console/Commands/Group/SuspendCommand.php
--- a/src/app/Console/Commands/Group/SuspendCommand.php
+++ b/src/app/Console/Commands/Group/SuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Group;
use App\Console\Command;
+use App\EventLog;
class SuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$group->suspend();
- \App\EventLog::createFor($group, \App\EventLog::TYPE_SUSPENDED, $this->option('comment'));
+ EventLog::createFor($group, EventLog::TYPE_SUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/Group/UnsuspendCommand.php b/src/app/Console/Commands/Group/UnsuspendCommand.php
--- a/src/app/Console/Commands/Group/UnsuspendCommand.php
+++ b/src/app/Console/Commands/Group/UnsuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Group;
use App\Console\Command;
+use App\EventLog;
class UnsuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$group->unsuspend();
- \App\EventLog::createFor($group, \App\EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
+ EventLog::createFor($group, EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/Imap/ListCommand.php b/src/app/Console/Commands/Imap/ListCommand.php
--- a/src/app/Console/Commands/Imap/ListCommand.php
+++ b/src/app/Console/Commands/Imap/ListCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Imap;
use App\Console\Command;
+use App\Support\Facades\IMAP;
class ListCommand extends Command
{
@@ -28,8 +29,8 @@
public function handle()
{
$user = $this->argument('user');
- foreach (\App\Support\Facades\IMAP::listMailboxes($user) as $mailbox) {
- $this->info("$mailbox");
+ foreach (IMAP::listMailboxes($user) as $mailbox) {
+ $this->info("{$mailbox}");
}
}
}
diff --git a/src/app/Console/Commands/JobExecuteCommand.php b/src/app/Console/Commands/JobExecuteCommand.php
--- a/src/app/Console/Commands/JobExecuteCommand.php
+++ b/src/app/Console/Commands/JobExecuteCommand.php
@@ -44,7 +44,7 @@
return 1;
}
- $job = 'App\\Jobs\\' . $job;
+ $job = 'App\Jobs\\' . $job;
$job::dispatchSync($object->id);
}
diff --git a/src/app/Console/Commands/LicensesCommand.php b/src/app/Console/Commands/LicensesCommand.php
--- a/src/app/Console/Commands/LicensesCommand.php
+++ b/src/app/Console/Commands/LicensesCommand.php
@@ -3,12 +3,13 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\License;
/**
* List licenses.
*/
class LicensesCommand extends ObjectListCommand
{
- protected $objectClass = \App\License::class;
+ protected $objectClass = License::class;
protected $objectName = 'license';
}
diff --git a/src/app/Console/Commands/Meet/RoomsCommand.php b/src/app/Console/Commands/Meet/RoomsCommand.php
--- a/src/app/Console/Commands/Meet/RoomsCommand.php
+++ b/src/app/Console/Commands/Meet/RoomsCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Meet;
use App\Console\Command;
+use App\Meet\Room;
class RoomsCommand extends Command
{
@@ -27,7 +28,7 @@
*/
public function handle()
{
- $rooms = \App\Meet\Room::all();
+ $rooms = Room::all();
foreach ($rooms as $room) {
$this->info("{$room->name}");
diff --git a/src/app/Console/Commands/Meet/SessionsCommand.php b/src/app/Console/Commands/Meet/SessionsCommand.php
--- a/src/app/Console/Commands/Meet/SessionsCommand.php
+++ b/src/app/Console/Commands/Meet/SessionsCommand.php
@@ -5,6 +5,7 @@
use App\Console\Command;
use App\Meet\Room;
use App\Meet\Service;
+use Carbon\Carbon;
class SessionsCommand extends Command
{
@@ -46,7 +47,7 @@
"Session: %s for %s since %s (by %s)",
$session['roomId'],
$roomName,
- \Carbon\Carbon::parse($session['createdAt'], 'UTC'),
+ Carbon::parse($session['createdAt'], 'UTC'),
$owner
)
);
diff --git a/src/app/Console/Commands/MigratePrices.php b/src/app/Console/Commands/MigratePrices.php
--- a/src/app/Console/Commands/MigratePrices.php
+++ b/src/app/Console/Commands/MigratePrices.php
@@ -3,6 +3,9 @@
namespace App\Console\Commands;
use App\Console\Command;
+use App\Package;
+use App\Sku;
+use App\User;
class MigratePrices extends Command
{
@@ -37,33 +40,33 @@
// 1. Set the list price for the SKU 'mailbox' to 500.
$bar->advance();
- $mailbox_sku = \App\Sku::where('title', 'mailbox')->first();
+ $mailbox_sku = Sku::where('title', 'mailbox')->first();
$mailbox_sku->cost = 500;
$mailbox_sku->save();
// 2. Set the list price for the SKU 'groupware' to 490.
$bar->advance();
- $groupware_sku = \App\Sku::where('title', 'groupware')->first();
+ $groupware_sku = Sku::where('title', 'groupware')->first();
$groupware_sku->cost = 490;
$groupware_sku->save();
// 3. Set the list price for the SKU 'activesync' to 0.
$bar->advance();
- $activesync_sku = \App\Sku::where('title', 'activesync')->first();
+ $activesync_sku = Sku::where('title', 'activesync')->first();
$activesync_sku->cost = 0;
$activesync_sku->save();
// 4. Set the units free for the SKU 'storage' to 5.
$bar->advance();
- $storage_sku = \App\Sku::where('title', 'storage')->first();
+ $storage_sku = Sku::where('title', 'storage')->first();
$storage_sku->units_free = 5;
$storage_sku->save();
// 5. Set the number of units for storage to 5 for the 'lite' and 'kolab' packages.
$bar->advance();
- $kolab_package = \App\Package::where('title', 'kolab')->first();
+ $kolab_package = Package::where('title', 'kolab')->first();
$kolab_package->skus()->updateExistingPivot($storage_sku, ['qty' => 5], false);
- $lite_package = \App\Package::where('title', 'lite')->first();
+ $lite_package = Package::where('title', 'lite')->first();
$lite_package->skus()->updateExistingPivot($storage_sku, ['qty' => 5], false);
// 6. Set the cost for the 'mailbox' unit for the 'lite' and 'kolab' packages to 500.
@@ -86,14 +89,14 @@
private function updateEntitlements()
{
- $users = \App\User::all();
+ $users = User::all();
$bar = $this->createProgressBar(count($users), "Updating entitlements");
- $groupware_sku = \App\Sku::where('title', 'groupware')->first();
- $activesync_sku = \App\Sku::where('title', 'activesync')->first();
- $storage_sku = \App\Sku::where('title', 'storage')->first();
- $mailbox_sku = \App\Sku::where('title', 'mailbox')->first();
+ $groupware_sku = Sku::where('title', 'groupware')->first();
+ $activesync_sku = Sku::where('title', 'activesync')->first();
+ $storage_sku = Sku::where('title', 'storage')->first();
+ $mailbox_sku = Sku::where('title', 'mailbox')->first();
foreach ($users as $user) {
$bar->advance();
diff --git a/src/app/Console/Commands/MollieInfo.php b/src/app/Console/Commands/MollieInfo.php
--- a/src/app/Console/Commands/MollieInfo.php
+++ b/src/app/Console/Commands/MollieInfo.php
@@ -65,7 +65,7 @@
$this->info("Auto-payment: none");
}
- // TODO: List user payments history
+ // TODO: List user payments history
} else {
$this->info("Available payment methods:");
diff --git a/src/app/Console/Commands/OwnerSwapCommand.php b/src/app/Console/Commands/OwnerSwapCommand.php
--- a/src/app/Console/Commands/OwnerSwapCommand.php
+++ b/src/app/Console/Commands/OwnerSwapCommand.php
@@ -123,14 +123,14 @@
/**
* Update user/wallet metadata at payment provider
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*/
- private function updatePaymentCustomer(\App\Wallet $wallet): void
+ private function updatePaymentCustomer(Wallet $wallet): void
{
if ($mollie_id = $wallet->getSetting('mollie_id')) {
Mollie::api()->customers->update($mollie_id, [
- 'name' => $wallet->owner->name(),
- 'email' => $wallet->id . '@private.' . \config('app.domain'),
+ 'name' => $wallet->owner->name(),
+ 'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
}
diff --git a/src/app/Console/Commands/Package/ListCommand.php b/src/app/Console/Commands/Package/ListCommand.php
--- a/src/app/Console/Commands/Package/ListCommand.php
+++ b/src/app/Console/Commands/Package/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Package;
use App\Console\ObjectListCommand;
+use App\Package;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Package::class;
+ protected $objectClass = Package::class;
protected $objectName = 'package';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Package/SkusCommand.php b/src/app/Console/Commands/Package/SkusCommand.php
--- a/src/app/Console/Commands/Package/SkusCommand.php
+++ b/src/app/Console/Commands/Package/SkusCommand.php
@@ -21,7 +21,7 @@
*/
protected $description = "List SKUs for packages.";
- /** @var bool Adds --tenant option handler */
+ /** @var bool Adds --tenant option handler */
protected $withTenant = true;
/**
diff --git a/src/app/Console/Commands/PasswordRetentionCommand.php b/src/app/Console/Commands/PasswordRetentionCommand.php
--- a/src/app/Console/Commands/PasswordRetentionCommand.php
+++ b/src/app/Console/Commands/PasswordRetentionCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands;
use App\Console\Command;
+use App\Jobs\Mail\PasswordRetentionJob;
use App\User;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
@@ -45,7 +46,7 @@
. ") as password_update")
)
->get()
- ->each(function ($user) use ($account) {
+ ->each(static function ($user) use ($account) {
/** @var User $user */
// Skip incomplete or suspended users
if (!$user->isImapReady() || $user->isSuspended()) {
@@ -77,7 +78,7 @@
// Send a warning if it wasn't sent yet or 7 days passed since the last warning.
// Which means that we send the email 14 and 7 days before the password expires.
if (empty($warnedOn) || $warnedOn->diffInDays(Carbon::now(), false) > 7) {
- \App\Jobs\Mail\PasswordRetentionJob::dispatch($user, $nextUpdate->toDateString());
+ PasswordRetentionJob::dispatch($user, $nextUpdate->toDateString());
}
}
});
diff --git a/src/app/Console/Commands/Plan/ListCommand.php b/src/app/Console/Commands/Plan/ListCommand.php
--- a/src/app/Console/Commands/Plan/ListCommand.php
+++ b/src/app/Console/Commands/Plan/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Plan;
use App\Console\ObjectListCommand;
+use App\Plan;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Plan::class;
+ protected $objectClass = Plan::class;
protected $objectName = 'plan';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Plan/PackagesCommand.php b/src/app/Console/Commands/Plan/PackagesCommand.php
--- a/src/app/Console/Commands/Plan/PackagesCommand.php
+++ b/src/app/Console/Commands/Plan/PackagesCommand.php
@@ -21,7 +21,7 @@
*/
protected $description = "List packages for plans.";
- /** @var bool Adds --tenant option handler */
+ /** @var bool Adds --tenant option handler */
protected $withTenant = true;
/**
diff --git a/src/app/Console/Commands/Policy/Greylist/ExpungeCommand.php b/src/app/Console/Commands/Policy/Greylist/ExpungeCommand.php
--- a/src/app/Console/Commands/Policy/Greylist/ExpungeCommand.php
+++ b/src/app/Console/Commands/Policy/Greylist/ExpungeCommand.php
@@ -2,6 +2,9 @@
namespace App\Console\Commands\Policy\Greylist;
+use App\Policy\Greylist\Connect;
+use App\Policy\Greylist\Whitelist;
+use Carbon\Carbon;
use Illuminate\Console\Command;
class ExpungeCommand extends Command
@@ -27,10 +30,10 @@
*/
public function handle()
{
- \App\Policy\Greylist\Connect::where('updated_at', '<', \Carbon\Carbon::now()->subMonthsWithoutOverflow(2))
+ Connect::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(2))
->delete();
- \App\Policy\Greylist\Whitelist::where('updated_at', '<', \Carbon\Carbon::now()->subMonthsWithoutOverflow(2))
+ Whitelist::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(2))
->delete();
}
}
diff --git a/src/app/Console/Commands/Policy/RateLimit/ExpungeCommand.php b/src/app/Console/Commands/Policy/RateLimit/ExpungeCommand.php
--- a/src/app/Console/Commands/Policy/RateLimit/ExpungeCommand.php
+++ b/src/app/Console/Commands/Policy/RateLimit/ExpungeCommand.php
@@ -2,6 +2,8 @@
namespace App\Console\Commands\Policy\RateLimit;
+use App\Policy\RateLimit;
+use Carbon\Carbon;
use Illuminate\Console\Command;
class ExpungeCommand extends Command
@@ -27,6 +29,6 @@
*/
public function handle()
{
- \App\Policy\RateLimit::where('updated_at', '<', \Carbon\Carbon::now()->subMonthsWithoutOverflow(6))->delete();
+ RateLimit::where('updated_at', '<', Carbon::now()->subMonthsWithoutOverflow(6))->delete();
}
}
diff --git a/src/app/Console/Commands/Policy/RateLimit/Whitelist/CreateCommand.php b/src/app/Console/Commands/Policy/RateLimit/Whitelist/CreateCommand.php
--- a/src/app/Console/Commands/Policy/RateLimit/Whitelist/CreateCommand.php
+++ b/src/app/Console/Commands/Policy/RateLimit/Whitelist/CreateCommand.php
@@ -3,6 +3,9 @@
namespace App\Console\Commands\Policy\RateLimit\Whitelist;
use App\Console\Command;
+use App\Domain;
+use App\Policy\RateLimit\Whitelist;
+use App\User;
class CreateCommand extends Command
{
@@ -29,7 +32,7 @@
{
$object = $this->argument('object');
- if (strpos($object, '@') === false) {
+ if (!str_contains($object, '@')) {
$domain = $this->getDomain($object);
if (!$domain) {
@@ -38,7 +41,7 @@
}
$id = $domain->id;
- $type = \App\Domain::class;
+ $type = Domain::class;
} else {
$user = $this->getUser($object);
@@ -48,13 +51,13 @@
}
$id = $user->id;
- $type = \App\User::class;
+ $type = User::class;
}
- \App\Policy\RateLimit\Whitelist::create(
+ Whitelist::create(
[
'whitelistable_id' => $id,
- 'whitelistable_type' => $type
+ 'whitelistable_type' => $type,
]
);
}
diff --git a/src/app/Console/Commands/Policy/RateLimit/Whitelist/DeleteCommand.php b/src/app/Console/Commands/Policy/RateLimit/Whitelist/DeleteCommand.php
--- a/src/app/Console/Commands/Policy/RateLimit/Whitelist/DeleteCommand.php
+++ b/src/app/Console/Commands/Policy/RateLimit/Whitelist/DeleteCommand.php
@@ -3,6 +3,9 @@
namespace App\Console\Commands\Policy\RateLimit\Whitelist;
use App\Console\Command;
+use App\Domain;
+use App\Policy\RateLimit\Whitelist;
+use App\User;
class DeleteCommand extends Command
{
@@ -29,7 +32,7 @@
{
$object = $this->argument('object');
- if (strpos($object, '@') === false) {
+ if (!str_contains($object, '@')) {
$domain = $this->getDomain($object);
if (!$domain) {
@@ -38,7 +41,7 @@
}
$id = $domain->id;
- $type = \App\Domain::class;
+ $type = Domain::class;
} else {
$user = $this->getUser($object);
@@ -48,13 +51,13 @@
}
$id = $user->id;
- $type = \App\User::class;
+ $type = User::class;
}
- \App\Policy\RateLimit\Whitelist::where(
+ Whitelist::where(
[
'whitelistable_id' => $id,
- 'whitelistable_type' => $type
+ 'whitelistable_type' => $type,
]
)->delete();
}
diff --git a/src/app/Console/Commands/Policy/RateLimit/Whitelist/ReadCommand.php b/src/app/Console/Commands/Policy/RateLimit/Whitelist/ReadCommand.php
--- a/src/app/Console/Commands/Policy/RateLimit/Whitelist/ReadCommand.php
+++ b/src/app/Console/Commands/Policy/RateLimit/Whitelist/ReadCommand.php
@@ -2,6 +2,9 @@
namespace App\Console\Commands\Policy\RateLimit\Whitelist;
+use App\Domain;
+use App\Policy\RateLimit\Whitelist;
+use App\User;
use Illuminate\Console\Command;
class ReadCommand extends Command
@@ -27,13 +30,13 @@
*/
public function handle()
{
- \App\Policy\RateLimit\Whitelist::each(
+ Whitelist::each(
function ($item) {
$whitelistable = $item->whitelistable;
- if ($whitelistable instanceof \App\Domain) {
+ if ($whitelistable instanceof Domain) {
$this->info("{$item->id}: {$item->whitelistable_type} {$whitelistable->namespace}");
- } elseif ($whitelistable instanceof \App\User) {
+ } elseif ($whitelistable instanceof User) {
$this->info("{$item->id}: {$item->whitelistable_type} {$whitelistable->email}");
}
}
diff --git a/src/app/Console/Commands/Policy/RateLimitsCommand.php b/src/app/Console/Commands/Policy/RateLimitsCommand.php
--- a/src/app/Console/Commands/Policy/RateLimitsCommand.php
+++ b/src/app/Console/Commands/Policy/RateLimitsCommand.php
@@ -3,11 +3,12 @@
namespace App\Console\Commands\Policy;
use App\Console\ObjectListCommand;
+use App\Policy\RateLimit;
class RateLimitsCommand extends ObjectListCommand
{
protected $commandPrefix = 'policy';
- protected $objectClass = \App\Policy\RateLimit::class;
+ protected $objectClass = RateLimit::class;
protected $objectName = 'ratelimit';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/PowerDNS/Domain/CreateCommand.php b/src/app/Console/Commands/PowerDNS/Domain/CreateCommand.php
--- a/src/app/Console/Commands/PowerDNS/Domain/CreateCommand.php
+++ b/src/app/Console/Commands/PowerDNS/Domain/CreateCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\PowerDNS\Domain;
+use App\PowerDNS\Domain;
use Illuminate\Console\Command;
class CreateCommand extends Command
@@ -39,13 +40,13 @@
return 1;
}
- $domain = \App\PowerDNS\Domain::where('name', $name)->first();
+ $domain = Domain::where('name', $name)->first();
if ($domain) {
\Log::error("Domain already exists");
return 1;
}
- \App\PowerDNS\Domain::create(['name' => $name]);
+ Domain::create(['name' => $name]);
}
}
diff --git a/src/app/Console/Commands/PowerDNS/Domain/DeleteCommand.php b/src/app/Console/Commands/PowerDNS/Domain/DeleteCommand.php
--- a/src/app/Console/Commands/PowerDNS/Domain/DeleteCommand.php
+++ b/src/app/Console/Commands/PowerDNS/Domain/DeleteCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\PowerDNS\Domain;
+use App\PowerDNS\Domain;
use Illuminate\Console\Command;
class DeleteCommand extends Command
@@ -29,7 +30,7 @@
{
$name = $this->argument('domain');
- $domain = \App\PowerDNS\Domain::where('name', $name)->first();
+ $domain = Domain::where('name', $name)->first();
if (!$domain) {
return 1;
diff --git a/src/app/Console/Commands/PowerDNS/Domain/ReadCommand.php b/src/app/Console/Commands/PowerDNS/Domain/ReadCommand.php
--- a/src/app/Console/Commands/PowerDNS/Domain/ReadCommand.php
+++ b/src/app/Console/Commands/PowerDNS/Domain/ReadCommand.php
@@ -2,6 +2,7 @@
namespace App\Console\Commands\PowerDNS\Domain;
+use App\PowerDNS\Domain;
use Illuminate\Console\Command;
class ReadCommand extends Command
@@ -29,7 +30,7 @@
{
$name = $this->argument('domain');
- $domain = \App\PowerDNS\Domain::where('name', $name)->first();
+ $domain = Domain::where('name', $name)->first();
if (!$domain) {
return 1;
diff --git a/src/app/Console/Commands/Resource/ListCommand.php b/src/app/Console/Commands/Resource/ListCommand.php
--- a/src/app/Console/Commands/Resource/ListCommand.php
+++ b/src/app/Console/Commands/Resource/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Resource;
use App\Console\ObjectListCommand;
+use App\Resource;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Resource::class;
+ protected $objectClass = Resource::class;
protected $objectName = 'resource';
protected $objectTitle = 'name';
}
diff --git a/src/app/Console/Commands/Resource/VerifyCommand.php b/src/app/Console/Commands/Resource/VerifyCommand.php
--- a/src/app/Console/Commands/Resource/VerifyCommand.php
+++ b/src/app/Console/Commands/Resource/VerifyCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Resource;
use App\Console\Command;
+use App\Jobs\Resource\VerifyJob;
class VerifyCommand extends Command
{
@@ -34,7 +35,7 @@
return 1;
}
- \App\Jobs\Resource\VerifyJob::dispatchSync($resource->id);
+ VerifyJob::dispatchSync($resource->id);
// TODO: We should check the job result and print an error on failure
}
diff --git a/src/app/Console/Commands/Scalpel/Contact/CreateCommand.php b/src/app/Console/Commands/Scalpel/Contact/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/Contact/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Contact/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Contact;
use App\Console\ObjectCreateCommand;
+use App\Contact;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Contact::class;
+ protected $objectClass = Contact::class;
protected $objectName = 'contact';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Contact/DeleteCommand.php b/src/app/Console/Commands/Scalpel/Contact/DeleteCommand.php
--- a/src/app/Console/Commands/Scalpel/Contact/DeleteCommand.php
+++ b/src/app/Console/Commands/Scalpel/Contact/DeleteCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Scalpel\Contact;
use App\Console\ObjectDeleteCommand;
+use App\Contact;
class DeleteCommand extends ObjectDeleteCommand
{
@@ -10,7 +11,7 @@
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Contact::class;
+ protected $objectClass = Contact::class;
protected $objectName = 'contact';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Contact/ReadCommand.php b/src/app/Console/Commands/Scalpel/Contact/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Contact/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Contact/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Contact;
use App\Console\ObjectReadCommand;
+use App\Contact;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Contact::class;
+ protected $objectClass = Contact::class;
protected $objectName = 'contact';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Contact/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Contact/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Contact/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Contact/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Contact;
use App\Console\ObjectUpdateCommand;
+use App\Contact;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Contact::class;
+ protected $objectClass = Contact::class;
protected $objectName = 'contact';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Discount/CreateCommand.php b/src/app/Console/Commands/Scalpel/Discount/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/Discount/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Discount/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Discount;
use App\Console\ObjectCreateCommand;
+use App\Discount;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Discount::class;
+ protected $objectClass = Discount::class;
protected $objectName = 'discount';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Discount/DeleteCommand.php b/src/app/Console/Commands/Scalpel/Discount/DeleteCommand.php
--- a/src/app/Console/Commands/Scalpel/Discount/DeleteCommand.php
+++ b/src/app/Console/Commands/Scalpel/Discount/DeleteCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Scalpel\Discount;
use App\Console\ObjectDeleteCommand;
+use App\Discount;
class DeleteCommand extends ObjectDeleteCommand
{
@@ -10,7 +11,7 @@
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Discount::class;
+ protected $objectClass = Discount::class;
protected $objectName = 'discount';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Discount/ReadCommand.php b/src/app/Console/Commands/Scalpel/Discount/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Discount/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Discount/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Discount;
use App\Console\ObjectReadCommand;
+use App\Discount;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Discount::class;
+ protected $objectClass = Discount::class;
protected $objectName = 'discount';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Discount/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Discount/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Discount/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Discount/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Discount;
use App\Console\ObjectUpdateCommand;
+use App\Discount;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Discount::class;
+ protected $objectClass = Discount::class;
protected $objectName = 'discount';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Domain/CreateCommand.php b/src/app/Console/Commands/Scalpel/Domain/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/Domain/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Domain/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Domain;
use App\Console\ObjectCreateCommand;
+use App\Domain;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Domain/ReadCommand.php b/src/app/Console/Commands/Scalpel/Domain/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Domain/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Domain/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Domain;
use App\Console\ObjectReadCommand;
+use App\Domain;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
protected $objectTitle = 'namespace';
}
diff --git a/src/app/Console/Commands/Scalpel/Domain/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Domain/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Domain/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Domain/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Domain;
use App\Console\ObjectUpdateCommand;
+use App\Domain;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Domain::class;
+ protected $objectClass = Domain::class;
protected $objectName = 'domain';
protected $objectTitle = 'namespace';
}
diff --git a/src/app/Console/Commands/Scalpel/Entitlement/CreateCommand.php b/src/app/Console/Commands/Scalpel/Entitlement/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/Entitlement/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Entitlement/CreateCommand.php
@@ -3,15 +3,18 @@
namespace App\Console\Commands\Scalpel\Entitlement;
use App\Console\ObjectCreateCommand;
+use App\Entitlement;
+use App\Sku;
+use App\Wallet;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Entitlement::class;
+ protected $objectClass = Entitlement::class;
protected $objectName = 'entitlement';
- protected $objectTitle = null;
+ protected $objectTitle;
public function handle()
{
@@ -33,7 +36,7 @@
}
if (array_key_exists('sku_id', $this->properties)) {
- $sku = \App\Sku::find($this->properties['sku_id']);
+ $sku = Sku::find($this->properties['sku_id']);
if (!$sku) {
$this->error("No such SKU {$this->properties['sku_id']}");
@@ -46,7 +49,7 @@
}
if (array_key_exists('wallet_id', $this->properties)) {
- $wallet = \App\Wallet::find($this->properties['wallet_id']);
+ $wallet = Wallet::find($this->properties['wallet_id']);
if (!$wallet) {
$this->error("No such wallet {$this->properties['wallet_id']}");
diff --git a/src/app/Console/Commands/Scalpel/Entitlement/ReadCommand.php b/src/app/Console/Commands/Scalpel/Entitlement/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Entitlement/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Entitlement/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Entitlement;
use App\Console\ObjectReadCommand;
+use App\Entitlement;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Entitlement::class;
+ protected $objectClass = Entitlement::class;
protected $objectName = 'entitlement';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Entitlement/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Entitlement/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Entitlement/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Entitlement/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Entitlement;
use App\Console\ObjectUpdateCommand;
+use App\Entitlement;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Entitlement::class;
+ protected $objectClass = Entitlement::class;
protected $objectName = 'entitlement';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Group/CreateCommand.php b/src/app/Console/Commands/Scalpel/Group/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/Group/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Group/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Group;
use App\Console\ObjectCreateCommand;
+use App\Group;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Group::class;
+ protected $objectClass = Group::class;
protected $objectName = 'group';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/Group/ReadCommand.php b/src/app/Console/Commands/Scalpel/Group/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Group/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Group/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Group;
use App\Console\ObjectReadCommand;
+use App\Group;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Group::class;
+ protected $objectClass = Group::class;
protected $objectName = 'group';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/Group/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Group/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Group/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Group/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Group;
use App\Console\ObjectUpdateCommand;
+use App\Group;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Group::class;
+ protected $objectClass = Group::class;
protected $objectName = 'group';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/Package/ReadCommand.php b/src/app/Console/Commands/Scalpel/Package/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Package/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Package/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Package;
use App\Console\ObjectReadCommand;
+use App\Package;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Package::class;
+ protected $objectClass = Package::class;
protected $objectName = 'package';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Scalpel/Plan/ReadCommand.php b/src/app/Console/Commands/Scalpel/Plan/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Plan/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Plan/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Plan;
use App\Console\ObjectReadCommand;
+use App\Plan;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Plan::class;
+ protected $objectClass = Plan::class;
protected $objectName = 'plan';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Scalpel/ReferralProgram/CreateCommand.php b/src/app/Console/Commands/Scalpel/ReferralProgram/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/ReferralProgram/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/ReferralProgram/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\ReferralProgram;
use App\Console\ObjectCreateCommand;
+use App\ReferralProgram;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\ReferralProgram::class;
+ protected $objectClass = ReferralProgram::class;
protected $objectName = 'referral-program';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/ReferralProgram/DeleteCommand.php b/src/app/Console/Commands/Scalpel/ReferralProgram/DeleteCommand.php
--- a/src/app/Console/Commands/Scalpel/ReferralProgram/DeleteCommand.php
+++ b/src/app/Console/Commands/Scalpel/ReferralProgram/DeleteCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Scalpel\ReferralProgram;
use App\Console\ObjectDeleteCommand;
+use App\ReferralProgram;
class DeleteCommand extends ObjectDeleteCommand
{
@@ -10,7 +11,7 @@
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\ReferralProgram::class;
+ protected $objectClass = ReferralProgram::class;
protected $objectName = 'referral-program';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/ReferralProgram/ReadCommand.php b/src/app/Console/Commands/Scalpel/ReferralProgram/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/ReferralProgram/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/ReferralProgram/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\ReferralProgram;
use App\Console\ObjectReadCommand;
+use App\ReferralProgram;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\ReferralProgram::class;
+ protected $objectClass = ReferralProgram::class;
protected $objectName = 'referral-program';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/ReferralProgram/UpdateCommand.php b/src/app/Console/Commands/Scalpel/ReferralProgram/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/ReferralProgram/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/ReferralProgram/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\ReferralProgram;
use App\Console\ObjectUpdateCommand;
+use App\ReferralProgram;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\ReferralProgram::class;
+ protected $objectClass = ReferralProgram::class;
protected $objectName = 'referral-program';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/SharedFolder/CreateCommand.php b/src/app/Console/Commands/Scalpel/SharedFolder/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/SharedFolder/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/SharedFolder/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\SharedFolder;
use App\Console\ObjectCreateCommand;
+use App\SharedFolder;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\SharedFolder::class;
+ protected $objectClass = SharedFolder::class;
protected $objectName = 'folder';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/SharedFolder/ReadCommand.php b/src/app/Console/Commands/Scalpel/SharedFolder/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/SharedFolder/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/SharedFolder/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\SharedFolder;
use App\Console\ObjectReadCommand;
+use App\SharedFolder;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\SharedFolder::class;
+ protected $objectClass = SharedFolder::class;
protected $objectName = 'folder';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/SharedFolder/UpdateCommand.php b/src/app/Console/Commands/Scalpel/SharedFolder/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/SharedFolder/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/SharedFolder/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\SharedFolder;
use App\Console\ObjectUpdateCommand;
+use App\SharedFolder;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\SharedFolder::class;
+ protected $objectClass = SharedFolder::class;
protected $objectName = 'folder';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/Sku/ReadCommand.php b/src/app/Console/Commands/Scalpel/Sku/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Sku/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Sku/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Sku;
use App\Console\ObjectReadCommand;
+use App\Sku;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Sku::class;
+ protected $objectClass = Sku::class;
protected $objectName = 'sku';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Scalpel/Sku/UpdateCommand.php b/src/app/Console/Commands/Scalpel/Sku/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/Sku/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/Sku/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Sku;
use App\Console\ObjectUpdateCommand;
+use App\Sku;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Sku::class;
+ protected $objectClass = Sku::class;
protected $objectName = 'sku';
- protected $objectTitle = null; // SKU title is not unique
+ protected $objectTitle; // SKU title is not unique
}
diff --git a/src/app/Console/Commands/Scalpel/TenantSetting/CreateCommand.php b/src/app/Console/Commands/Scalpel/TenantSetting/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/TenantSetting/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/TenantSetting/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\TenantSetting;
use App\Console\ObjectCreateCommand;
+use App\TenantSetting;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\TenantSetting::class;
+ protected $objectClass = TenantSetting::class;
protected $objectName = 'tenant-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/TenantSetting/ReadCommand.php b/src/app/Console/Commands/Scalpel/TenantSetting/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/TenantSetting/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/TenantSetting/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\TenantSetting;
use App\Console\ObjectReadCommand;
+use App\TenantSetting;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\TenantSetting::class;
+ protected $objectClass = TenantSetting::class;
protected $objectName = 'tenant-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/TenantSetting/UpdateCommand.php b/src/app/Console/Commands/Scalpel/TenantSetting/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/TenantSetting/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/TenantSetting/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\TenantSetting;
use App\Console\ObjectUpdateCommand;
+use App\TenantSetting;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\TenantSetting::class;
+ protected $objectClass = TenantSetting::class;
protected $objectName = 'tenant-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Transaction/ReadCommand.php b/src/app/Console/Commands/Scalpel/Transaction/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Transaction/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Transaction/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Transaction;
use App\Console\ObjectReadCommand;
+use App\Transaction;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Transaction::class;
+ protected $objectClass = Transaction::class;
protected $objectName = 'transaction';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/User/CreateCommand.php b/src/app/Console/Commands/Scalpel/User/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/User/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/User/CreateCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Scalpel\User;
use App\Console\ObjectCreateCommand;
+use App\User;
/**
* Create a user at the lowest level of control over the exact database entry.
@@ -22,7 +23,7 @@
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/User/ReadCommand.php b/src/app/Console/Commands/Scalpel/User/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/User/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/User/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\User;
use App\Console\ObjectReadCommand;
+use App\User;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/User/UpdateCommand.php b/src/app/Console/Commands/Scalpel/User/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/User/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/User/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\User;
use App\Console\ObjectUpdateCommand;
+use App\User;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/Scalpel/UserSetting/CreateCommand.php b/src/app/Console/Commands/Scalpel/UserSetting/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/UserSetting/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/UserSetting/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\UserSetting;
use App\Console\ObjectCreateCommand;
+use App\UserSetting;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\UserSetting::class;
+ protected $objectClass = UserSetting::class;
protected $objectName = 'user-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/UserSetting/ReadCommand.php b/src/app/Console/Commands/Scalpel/UserSetting/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/UserSetting/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/UserSetting/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\UserSetting;
use App\Console\ObjectReadCommand;
+use App\UserSetting;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\UserSetting::class;
+ protected $objectClass = UserSetting::class;
protected $objectName = 'user-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/UserSetting/UpdateCommand.php b/src/app/Console/Commands/Scalpel/UserSetting/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/UserSetting/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/UserSetting/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\UserSetting;
use App\Console\ObjectUpdateCommand;
+use App\UserSetting;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\UserSetting::class;
+ protected $objectClass = UserSetting::class;
protected $objectName = 'user-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/VatRate/CreateCommand.php b/src/app/Console/Commands/Scalpel/VatRate/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/VatRate/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/VatRate/CreateCommand.php
@@ -3,12 +3,13 @@
namespace App\Console\Commands\Scalpel\VatRate;
use App\Console\ObjectCreateCommand;
+use App\VatRate;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\VatRate::class;
+ protected $objectClass = VatRate::class;
protected $objectName = 'vat-rate';
}
diff --git a/src/app/Console/Commands/Scalpel/VatRate/ReadCommand.php b/src/app/Console/Commands/Scalpel/VatRate/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/VatRate/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/VatRate/ReadCommand.php
@@ -3,12 +3,13 @@
namespace App\Console\Commands\Scalpel\VatRate;
use App\Console\ObjectReadCommand;
+use App\VatRate;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\VatRate::class;
+ protected $objectClass = VatRate::class;
protected $objectName = 'vat-rate';
}
diff --git a/src/app/Console/Commands/Scalpel/VatRate/UpdateCommand.php b/src/app/Console/Commands/Scalpel/VatRate/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/VatRate/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/VatRate/UpdateCommand.php
@@ -3,12 +3,13 @@
namespace App\Console\Commands\Scalpel\VatRate;
use App\Console\ObjectUpdateCommand;
+use App\VatRate;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\VatRate::class;
+ protected $objectClass = VatRate::class;
protected $objectName = 'vat-rate';
}
diff --git a/src/app/Console/Commands/Scalpel/Wallet/ReadCommand.php b/src/app/Console/Commands/Scalpel/Wallet/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/Wallet/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/Wallet/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\Wallet;
use App\Console\ObjectReadCommand;
+use App\Wallet;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Wallet::class;
+ protected $objectClass = Wallet::class;
protected $objectName = 'wallet';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php b/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php
--- a/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php
+++ b/src/app/Console/Commands/Scalpel/Wallet/SettingsCommand.php
@@ -3,14 +3,15 @@
namespace App\Console\Commands\Scalpel\Wallet;
use App\Console\ObjectRelationListCommand;
+use App\Wallet;
class SettingsCommand extends ObjectRelationListCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\Wallet::class;
+ protected $objectClass = Wallet::class;
protected $objectName = 'wallet';
- protected $objectTitle = null;
+ protected $objectTitle;
protected $objectRelation = 'settings';
}
diff --git a/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php b/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php
--- a/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php
+++ b/src/app/Console/Commands/Scalpel/WalletSetting/CreateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\WalletSetting;
use App\Console\ObjectCreateCommand;
+use App\WalletSetting;
class CreateCommand extends ObjectCreateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\WalletSetting::class;
+ protected $objectClass = WalletSetting::class;
protected $objectName = 'wallet-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/WalletSetting/ReadCommand.php b/src/app/Console/Commands/Scalpel/WalletSetting/ReadCommand.php
--- a/src/app/Console/Commands/Scalpel/WalletSetting/ReadCommand.php
+++ b/src/app/Console/Commands/Scalpel/WalletSetting/ReadCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\WalletSetting;
use App\Console\ObjectReadCommand;
+use App\WalletSetting;
class ReadCommand extends ObjectReadCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\WalletSetting::class;
+ protected $objectClass = WalletSetting::class;
protected $objectName = 'wallet-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php b/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php
--- a/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php
+++ b/src/app/Console/Commands/Scalpel/WalletSetting/UpdateCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\Scalpel\WalletSetting;
use App\Console\ObjectUpdateCommand;
+use App\WalletSetting;
class UpdateCommand extends ObjectUpdateCommand
{
protected $hidden = true;
protected $commandPrefix = 'scalpel';
- protected $objectClass = \App\WalletSetting::class;
+ protected $objectClass = WalletSetting::class;
protected $objectName = 'wallet-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/SharedFolder/CreateCommand.php b/src/app/Console/Commands/SharedFolder/CreateCommand.php
--- a/src/app/Console/Commands/SharedFolder/CreateCommand.php
+++ b/src/app/Console/Commands/SharedFolder/CreateCommand.php
@@ -3,9 +3,9 @@
namespace App\Console\Commands\SharedFolder;
use App\Console\Command;
-use App\SharedFolder;
use App\Rules\SharedFolderName;
use App\Rules\SharedFolderType;
+use App\SharedFolder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -63,7 +63,7 @@
// Validate folder name and type
$rules = [
'name' => ['required', 'string', new SharedFolderName($owner, $domain->namespace)],
- 'type' => ['required', 'string', new SharedFolderType()]
+ 'type' => ['required', 'string', new SharedFolderType()],
];
$v = Validator::make(['name' => $name, 'type' => $type], $rules);
diff --git a/src/app/Console/Commands/SharedFolder/ListCommand.php b/src/app/Console/Commands/SharedFolder/ListCommand.php
--- a/src/app/Console/Commands/SharedFolder/ListCommand.php
+++ b/src/app/Console/Commands/SharedFolder/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\SharedFolder;
use App\Console\ObjectListCommand;
+use App\SharedFolder;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\SharedFolder::class;
+ protected $objectClass = SharedFolder::class;
protected $objectName = 'shared-folder';
protected $objectTitle = 'name';
}
diff --git a/src/app/Console/Commands/SharedFolderAliasesCommand.php b/src/app/Console/Commands/SharedFolderAliasesCommand.php
--- a/src/app/Console/Commands/SharedFolderAliasesCommand.php
+++ b/src/app/Console/Commands/SharedFolderAliasesCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\SharedFolderAlias;
class SharedFolderAliasesCommand extends ObjectListCommand
{
- protected $objectClass = \App\SharedFolderAlias::class;
+ protected $objectClass = SharedFolderAlias::class;
protected $objectName = 'shared-folder-alias';
protected $objectNamePlural = 'shared-folder-aliases';
protected $objectTitle = 'alias';
diff --git a/src/app/Console/Commands/Sku/ListCommand.php b/src/app/Console/Commands/Sku/ListCommand.php
--- a/src/app/Console/Commands/Sku/ListCommand.php
+++ b/src/app/Console/Commands/Sku/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Sku;
use App\Console\ObjectListCommand;
+use App\Sku;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Sku::class;
+ protected $objectClass = Sku::class;
protected $objectName = 'sku';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Sku/ListUsersCommand.php b/src/app/Console/Commands/Sku/ListUsersCommand.php
--- a/src/app/Console/Commands/Sku/ListUsersCommand.php
+++ b/src/app/Console/Commands/Sku/ListUsersCommand.php
@@ -3,6 +3,9 @@
namespace App\Console\Commands\Sku;
use App\Console\Command;
+use App\Entitlement;
+use App\Sku;
+use App\User;
class ListUsersCommand extends Command
{
@@ -32,23 +35,23 @@
{
parent::handle();
- $sku = $this->getObject(\App\Sku::class, $this->argument('sku'), 'title');
+ $sku = $this->getObject(Sku::class, $this->argument('sku'), 'title');
if (!$sku) {
$this->error("Unable to find the SKU.");
return 1;
}
- $fn = function ($entitlement) {
+ $fn = static function ($entitlement) {
$user_id = $entitlement->user_id;
- if ($entitlement->entitleable_type == \App\User::class) {
+ if ($entitlement->entitleable_type == User::class) {
$user_id = $entitlement->entitleable_id;
}
return $user_id;
};
- $users = \App\Entitlement::select('user_id', 'entitleable_id', 'entitleable_type')
+ $users = Entitlement::select('user_id', 'entitleable_id', 'entitleable_type')
->join('wallets', 'wallets.id', '=', 'wallet_id')
->where('sku_id', $sku->id)
->get()
@@ -56,7 +59,7 @@
->unique();
// TODO: This whereIn() might not scale
- \App\User::whereIn('id', $users)->orderBy('email')->get()
+ User::whereIn('id', $users)->orderBy('email')->get()
->pluck('email')
->each(function ($email, $key) {
$this->info($email);
diff --git a/src/app/Console/Commands/Status/Health.php b/src/app/Console/Commands/Status/Health.php
--- a/src/app/Console/Commands/Status/Health.php
+++ b/src/app/Console/Commands/Status/Health.php
@@ -2,9 +2,8 @@
namespace App\Console\Commands\Status;
-use Illuminate\Console\Command;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Redis;
+use App\Http\Controllers\API\AuthController;
+use App\Meet\Service;
use App\Providers\Payment\Mollie;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
@@ -12,9 +11,13 @@
use App\Support\Facades\OpenExchangeRates;
use App\Support\Facades\Roundcube;
use App\Support\Facades\Storage;
+use App\User;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Redis;
-//TODO stripe
-//TODO firebase
+// TODO stripe
+// TODO firebase
class Health extends Command
{
@@ -26,7 +29,7 @@
protected $signature = 'status:health
{--check=* : One of DB, Redis, IMAP, LDAP, Roundcube, Meet, DAV, Mollie, OpenExchangeRates, Storage, Auth}
{--user= : Test user (for Auth test)}
- {--password= : Password of test user}'; // phpcs:ignore
+ {--password= : Password of test user}';
/**
* The console command description.
@@ -102,8 +105,8 @@
private function checkAuth()
{
try {
- $user = \App\User::findByEmail($this->option('user'));
- $response = \App\Http\Controllers\API\AuthController::logonResponse($user, $this->option('password'));
+ $user = User::findByEmail($this->option('user'));
+ $response = AuthController::logonResponse($user, $this->option('password'));
return $response->getData()->status == 'success';
} catch (\Exception $exception) {
$this->line($exception);
@@ -150,10 +153,10 @@
$success = true;
foreach ($urls as $url) {
- $this->line("Checking $url");
+ $this->line("Checking {$url}");
try {
- $response = \App\Meet\Service::client($url)->get('ping');
+ $response = Service::client($url)->get('ping');
if (!$response->ok()) {
$success = false;
$this->line("Backend {$url} not available. Status: " . $response->status());
@@ -178,7 +181,7 @@
$steps = $this->option('check');
if (empty($steps)) {
$steps = [
- 'DB', 'Redis', 'Roundcube', 'Meet', 'DAV', 'Mollie', 'OpenExchangeRates'
+ 'DB', 'Redis', 'Roundcube', 'Meet', 'DAV', 'Mollie', 'OpenExchangeRates',
];
if (!empty($this->option('user'))) {
array_unshift($steps, 'Auth');
@@ -202,7 +205,7 @@
if ($this->{$func}()) {
$this->info("OK");
} else {
- $this->error("Error while checking: $step");
+ $this->error("Error while checking: {$step}");
$result = 1;
}
}
diff --git a/src/app/Console/Commands/StripeInfo.php b/src/app/Console/Commands/StripeInfo.php
--- a/src/app/Console/Commands/StripeInfo.php
+++ b/src/app/Console/Commands/StripeInfo.php
@@ -5,7 +5,6 @@
use App\Console\Command;
use App\Providers\PaymentProvider;
use App\User;
-use Stripe as StripeAPI;
class StripeInfo extends Command
{
@@ -67,8 +66,7 @@
}
// TODO: List user payments history
- } else {
- // TODO: Fetch some info/stats from Stripe
}
+ // TODO: Fetch some info/stats from Stripe
}
}
diff --git a/src/app/Console/Commands/Tenant/CreateCommand.php b/src/app/Console/Commands/Tenant/CreateCommand.php
--- a/src/app/Console/Commands/Tenant/CreateCommand.php
+++ b/src/app/Console/Commands/Tenant/CreateCommand.php
@@ -3,7 +3,13 @@
namespace App\Console\Commands\Tenant;
use App\Console\Command;
+use App\Domain;
use App\Http\Controllers\API\V4\UsersController;
+use App\Package;
+use App\Plan;
+use App\Sku;
+use App\Tenant;
+use App\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Queue;
@@ -32,12 +38,12 @@
{
$email = $this->argument('user');
- if ($user = \App\User::where('email', $email)->first()) {
+ if ($user = User::where('email', $email)->first()) {
$this->error("The user already exists.");
return 1;
}
- if ($domain = \App\Domain::where('namespace', $this->argument('domain'))->first()) {
+ if ($domain = Domain::where('namespace', $this->argument('domain'))->first()) {
$this->error("The domain already exists.");
return 1;
}
@@ -45,21 +51,21 @@
DB::beginTransaction();
// Create a tenant
- $tenant = \App\Tenant::create(['title' => $this->option('title')]);
+ $tenant = Tenant::create(['title' => $this->option('title')]);
// Clone plans, packages, skus for the tenant
- $sku_map = \App\Sku::withEnvTenantContext()->where('active', true)->get()
- ->mapWithKeys(function ($sku) use ($tenant) {
- $sku_new = \App\Sku::create([
- 'title' => $sku->title,
- 'name' => $sku->getTranslations('name'),
- 'description' => $sku->getTranslations('description'),
- 'cost' => $sku->cost,
- 'units_free' => $sku->units_free,
- 'period' => $sku->period,
- 'handler_class' => $sku->handler_class,
- 'active' => true,
- 'fee' => $sku->fee,
+ $sku_map = Sku::withEnvTenantContext()->where('active', true)->get()
+ ->mapWithKeys(static function ($sku) use ($tenant) {
+ $sku_new = Sku::create([
+ 'title' => $sku->title,
+ 'name' => $sku->getTranslations('name'),
+ 'description' => $sku->getTranslations('description'),
+ 'cost' => $sku->cost,
+ 'units_free' => $sku->units_free,
+ 'period' => $sku->period,
+ 'handler_class' => $sku->handler_class,
+ 'active' => true,
+ 'fee' => $sku->fee,
]);
$sku_new->tenant_id = $tenant->id;
@@ -69,18 +75,18 @@
})
->all();
- $plan_map = \App\Plan::withEnvTenantContext()->get()
- ->mapWithKeys(function ($plan) use ($tenant) {
- $plan_new = \App\Plan::create([
- 'title' => $plan->title,
- 'name' => $plan->getTranslations('name'),
- 'description' => $plan->getTranslations('description'),
- 'promo_from' => $plan->promo_from,
- 'promo_to' => $plan->promo_to,
- 'qty_min' => $plan->qty_min,
- 'qty_max' => $plan->qty_max,
- 'discount_qty' => $plan->discount_qty,
- 'discount_rate' => $plan->discount_rate,
+ $plan_map = Plan::withEnvTenantContext()->get()
+ ->mapWithKeys(static function ($plan) use ($tenant) {
+ $plan_new = Plan::create([
+ 'title' => $plan->title,
+ 'name' => $plan->getTranslations('name'),
+ 'description' => $plan->getTranslations('description'),
+ 'promo_from' => $plan->promo_from,
+ 'promo_to' => $plan->promo_to,
+ 'qty_min' => $plan->qty_min,
+ 'qty_max' => $plan->qty_max,
+ 'discount_qty' => $plan->discount_qty,
+ 'discount_rate' => $plan->discount_rate,
]);
$plan_new->tenant_id = $tenant->id;
@@ -90,13 +96,13 @@
})
->all();
- $package_map = \App\Package::withEnvTenantContext()->get()
- ->mapWithKeys(function ($package) use ($tenant) {
- $package_new = \App\Package::create([
- 'title' => $package->title,
- 'name' => $package->getTranslations('name'),
- 'description' => $package->getTranslations('description'),
- 'discount_rate' => $package->discount_rate,
+ $package_map = Package::withEnvTenantContext()->get()
+ ->mapWithKeys(static function ($package) use ($tenant) {
+ $package_new = Package::create([
+ 'title' => $package->title,
+ 'name' => $package->getTranslations('name'),
+ 'description' => $package->getTranslations('description'),
+ 'discount_rate' => $package->discount_rate,
]);
$package_new->tenant_id = $tenant->id;
@@ -107,28 +113,28 @@
->all();
DB::table('package_skus')->whereIn('package_id', array_keys($package_map))->get()
- ->each(function ($item) use ($package_map, $sku_map) {
+ ->each(static function ($item) use ($package_map, $sku_map) {
if (isset($sku_map[$item->sku_id])) {
DB::table('package_skus')->insert([
- 'qty' => $item->qty,
- 'cost' => $item->cost,
- 'sku_id' => $sku_map[$item->sku_id],
- 'package_id' => $package_map[$item->package_id],
+ 'qty' => $item->qty,
+ 'cost' => $item->cost,
+ 'sku_id' => $sku_map[$item->sku_id],
+ 'package_id' => $package_map[$item->package_id],
]);
}
});
DB::table('plan_packages')->whereIn('plan_id', array_keys($plan_map))->get()
- ->each(function ($item) use ($package_map, $plan_map) {
+ ->each(static function ($item) use ($package_map, $plan_map) {
if (isset($package_map[$item->package_id])) {
DB::table('plan_packages')->insert([
- 'qty' => $item->qty,
- 'qty_min' => $item->qty_min,
- 'qty_max' => $item->qty_max,
- 'discount_qty' => $item->discount_qty,
- 'discount_rate' => $item->discount_rate,
- 'plan_id' => $plan_map[$item->plan_id],
- 'package_id' => $package_map[$item->package_id],
+ 'qty' => $item->qty,
+ 'qty_min' => $item->qty_min,
+ 'qty_max' => $item->qty_max,
+ 'discount_qty' => $item->discount_qty,
+ 'discount_rate' => $item->discount_rate,
+ 'plan_id' => $plan_map[$item->plan_id],
+ 'package_id' => $package_map[$item->package_id],
]);
}
});
@@ -138,7 +144,7 @@
Queue::fake();
// Make sure the transaction wasn't aborted
- $tenant = \App\Tenant::find($tenant->id);
+ $tenant = Tenant::find($tenant->id);
if (!$tenant) {
$this->error("Failed to create a tenant.");
@@ -148,18 +154,18 @@
$this->info("Created tenant {$tenant->id}.");
// Set up the primary tenant domain
- $domain = \App\Domain::create(
+ $domain = Domain::create(
[
'namespace' => $this->argument('domain'),
- 'type' => \App\Domain::TYPE_PUBLIC,
+ 'type' => Domain::TYPE_PUBLIC,
]
);
$domain->tenant_id = $tenant->id;
- $domain->status = \App\Domain::STATUS_CONFIRMED | \App\Domain::STATUS_ACTIVE;
+ $domain->status = Domain::STATUS_CONFIRMED | Domain::STATUS_ACTIVE;
$domain->save();
$this->info("Created domain {$domain->id}.");
- $user = new \App\User();
+ $user = new User();
$user->email = $email;
$user->password = $this->option('password');
$user->role = 'reseller';
diff --git a/src/app/Console/Commands/Tenant/ListCommand.php b/src/app/Console/Commands/Tenant/ListCommand.php
--- a/src/app/Console/Commands/Tenant/ListCommand.php
+++ b/src/app/Console/Commands/Tenant/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Tenant;
use App\Console\ObjectListCommand;
+use App\Tenant;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Tenant::class;
+ protected $objectClass = Tenant::class;
protected $objectName = 'tenant';
protected $objectTitle = 'title';
}
diff --git a/src/app/Console/Commands/Tenant/ListSettingsCommand.php b/src/app/Console/Commands/Tenant/ListSettingsCommand.php
--- a/src/app/Console/Commands/Tenant/ListSettingsCommand.php
+++ b/src/app/Console/Commands/Tenant/ListSettingsCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Tenant;
use App\Console\Command;
+use App\Tenant;
class ListSettingsCommand extends Command
{
@@ -27,7 +28,7 @@
*/
public function handle()
{
- $tenant = $this->getObject(\App\Tenant::class, $this->argument('tenant'), 'title');
+ $tenant = $this->getObject(Tenant::class, $this->argument('tenant'), 'title');
if (!$tenant) {
$this->error("Unable to find the tenant.");
diff --git a/src/app/Console/Commands/TransactionsCommand.php b/src/app/Console/Commands/TransactionsCommand.php
--- a/src/app/Console/Commands/TransactionsCommand.php
+++ b/src/app/Console/Commands/TransactionsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\Transaction;
class TransactionsCommand extends ObjectListCommand
{
- protected $objectClass = \App\Transaction::class;
+ protected $objectClass = Transaction::class;
protected $objectName = 'transaction';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/User/AssignSkuCommand.php b/src/app/Console/Commands/User/AssignSkuCommand.php
--- a/src/app/Console/Commands/User/AssignSkuCommand.php
+++ b/src/app/Console/Commands/User/AssignSkuCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Sku;
class AssignSkuCommand extends Command
{
@@ -34,7 +35,7 @@
return 1;
}
- $sku = $this->getObject(\App\Sku::class, $this->argument('sku'), 'title');
+ $sku = $this->getObject(Sku::class, $this->argument('sku'), 'title');
if (!$sku) {
$this->error("Unable to find the SKU {$this->argument('sku')}.");
diff --git a/src/app/Console/Commands/User/CompanionAppsCommand.php b/src/app/Console/Commands/User/CompanionAppsCommand.php
--- a/src/app/Console/Commands/User/CompanionAppsCommand.php
+++ b/src/app/Console/Commands/User/CompanionAppsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class CompanionAppsCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'companionApps';
diff --git a/src/app/Console/Commands/User/ContactsCommand.php b/src/app/Console/Commands/User/ContactsCommand.php
--- a/src/app/Console/Commands/User/ContactsCommand.php
+++ b/src/app/Console/Commands/User/ContactsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class ContactsCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'contacts';
diff --git a/src/app/Console/Commands/User/CreateCommand.php b/src/app/Console/Commands/User/CreateCommand.php
--- a/src/app/Console/Commands/User/CreateCommand.php
+++ b/src/app/Console/Commands/User/CreateCommand.php
@@ -2,13 +2,19 @@
namespace App\Console\Commands\User;
+use App\Console\Command;
+use App\Group;
use App\Http\Controllers\API\V4\UsersController;
+use App\Package;
+use App\Resource;
use App\Rules\ExternalEmail;
+use App\SharedFolder;
use App\User;
+use App\Utils;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
-class CreateCommand extends \App\Console\Command
+class CreateCommand extends Command
{
/**
* The name and signature of the console command.
@@ -38,7 +44,7 @@
$email = $this->argument('email');
$packages = $this->option('package');
- $password = $this->option('password') ?: \App\Utils::generatePassphrase();
+ $password = $this->option('password') ?: Utils::generatePassphrase();
$role = $this->option('role');
$existingDeletedUser = null;
@@ -52,10 +58,10 @@
return 1;
}
- // TODO: Assigning user to an existing account
- // TODO: Making him an operator of the reseller wallet
+ // TODO: Assigning user to an existing account
+ // TODO: Making him an operator of the reseller wallet
} else {
- list($local, $domainName) = explode('@', $email, 2);
+ [$local, $domainName] = explode('@', $email, 2);
$domain = $this->getDomain($domainName);
@@ -72,7 +78,7 @@
$this->tenantId = $domain->tenant_id;
foreach ($packages as $package) {
- $userPackage = $this->getObject(\App\Package::class, $package, 'title', false);
+ $userPackage = $this->getObject(Package::class, $package, 'title', false);
if (!$userPackage) {
$this->error("Invalid package: {$package}");
return 1;
@@ -82,7 +88,7 @@
}
try {
- $user = new \App\User();
+ $user = new User();
$user->email = $email;
$user->password = $password;
$user->role = $role;
@@ -145,10 +151,10 @@
if (
User::emailExists($email, true)
|| User::aliasExists($email)
- || \App\Group::emailExists($email, true)
- || \App\Resource::emailExists($email, true)
- || \App\SharedFolder::emailExists($email, true)
- || \App\SharedFolder::aliasExists($email)
+ || Group::emailExists($email, true)
+ || Resource::emailExists($email, true)
+ || SharedFolder::emailExists($email, true)
+ || SharedFolder::aliasExists($email)
) {
return "Email address is already in use";
}
diff --git a/src/app/Console/Commands/User/DeleteCommand.php b/src/app/Console/Commands/User/DeleteCommand.php
--- a/src/app/Console/Commands/User/DeleteCommand.php
+++ b/src/app/Console/Commands/User/DeleteCommand.php
@@ -3,13 +3,14 @@
namespace App\Console\Commands\User;
use App\Console\ObjectDeleteCommand;
+use App\User;
class DeleteCommand extends ObjectDeleteCommand
{
protected $dangerous = false;
protected $hidden = false;
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
}
diff --git a/src/app/Console/Commands/User/DomainsCommand.php b/src/app/Console/Commands/User/DomainsCommand.php
--- a/src/app/Console/Commands/User/DomainsCommand.php
+++ b/src/app/Console/Commands/User/DomainsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class DomainsCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'domains';
diff --git a/src/app/Console/Commands/User/EntitlementsCommand.php b/src/app/Console/Commands/User/EntitlementsCommand.php
--- a/src/app/Console/Commands/User/EntitlementsCommand.php
+++ b/src/app/Console/Commands/User/EntitlementsCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Sku;
class EntitlementsCommand extends Command
{
@@ -40,12 +41,12 @@
if (!array_key_exists($entitlement->sku_id, $skus_counted)) {
$skus_counted[$entitlement->sku_id] = 1;
} else {
- $skus_counted[$entitlement->sku_id] += 1;
+ $skus_counted[$entitlement->sku_id]++;
}
}
foreach ($skus_counted as $id => $qty) {
- $sku = \App\Sku::find($id);
+ $sku = Sku::find($id);
$this->info("{$sku->title}: {$qty}");
}
}
diff --git a/src/app/Console/Commands/User/GreylistCommand.php b/src/app/Console/Commands/User/GreylistCommand.php
--- a/src/app/Console/Commands/User/GreylistCommand.php
+++ b/src/app/Console/Commands/User/GreylistCommand.php
@@ -3,6 +3,8 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Policy\Greylist\Connect;
+use Carbon\Carbon;
class GreylistCommand extends Command
{
@@ -31,7 +33,7 @@
$recipientAddress = $this->argument('user');
$recipientHash = hash('sha256', $recipientAddress);
- $lastConnect = \App\Policy\Greylist\Connect::where('recipient_hash', $recipientHash)
+ $lastConnect = Connect::where('recipient_hash', $recipientHash)
->orderBy('updated_at', 'desc')
->first();
@@ -39,11 +41,11 @@
$timestamp = $lastConnect->updated_at->copy();
$this->info("Going from timestamp (last connect) {$timestamp}");
} else {
- $timestamp = \Carbon\Carbon::now();
+ $timestamp = Carbon::now();
$this->info("Going from timestamp (now) {$timestamp}");
}
- \App\Policy\Greylist\Connect::where('recipient_hash', $recipientHash)
+ Connect::where('recipient_hash', $recipientHash)
->where('greylisting', true)
->whereDate('updated_at', '>=', $timestamp->copy()->subDays(7))
->orderBy('created_at')->each(
diff --git a/src/app/Console/Commands/User/GroupsCommand.php b/src/app/Console/Commands/User/GroupsCommand.php
--- a/src/app/Console/Commands/User/GroupsCommand.php
+++ b/src/app/Console/Commands/User/GroupsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class GroupsCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'groups';
diff --git a/src/app/Console/Commands/User/InfoCommand.php b/src/app/Console/Commands/User/InfoCommand.php
--- a/src/app/Console/Commands/User/InfoCommand.php
+++ b/src/app/Console/Commands/User/InfoCommand.php
@@ -2,7 +2,9 @@
namespace App\Console\Commands\User;
-class InfoCommand extends \App\Console\Command
+use App\Console\Command;
+
+class InfoCommand extends Command
{
/**
* The name and signature of the console command.
diff --git a/src/app/Console/Commands/User/ListCommand.php b/src/app/Console/Commands/User/ListCommand.php
--- a/src/app/Console/Commands/User/ListCommand.php
+++ b/src/app/Console/Commands/User/ListCommand.php
@@ -3,10 +3,12 @@
namespace App\Console\Commands\User;
use App\Console\ObjectListCommand;
+use App\Payment;
+use App\User;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
@@ -24,16 +26,16 @@
if (preg_match('/^(with|without)-payment/i', $filter, $matches)) {
$method = strtolower($matches[1]) == 'with' ? 'whereIn' : 'whereNotIn';
- return $query->whereIn('id', function ($query) use ($method) {
+ return $query->whereIn('id', static function ($query) use ($method) {
// all user IDs from the entitlements
$query->select('entitleable_id')->distinct()
->from('entitlements')
- ->where('entitleable_type', \App\User::class)
- ->{$method}('wallet_id', function ($query) {
+ ->where('entitleable_type', User::class)
+ ->{$method}('wallet_id', static function ($query) {
// wallets with a PAID payment
$query->select('wallet_id')->distinct()
->from('payments')
- ->where('status', \App\Payment::STATUS_PAID);
+ ->where('status', Payment::STATUS_PAID);
});
});
}
diff --git a/src/app/Console/Commands/User/RemoveSkuCommand.php b/src/app/Console/Commands/User/RemoveSkuCommand.php
--- a/src/app/Console/Commands/User/RemoveSkuCommand.php
+++ b/src/app/Console/Commands/User/RemoveSkuCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Sku;
use Illuminate\Support\Facades\DB;
class RemoveSkuCommand extends Command
@@ -35,7 +36,7 @@
return 1;
}
- $sku = $this->getObject(\App\Sku::class, $this->argument('sku'), 'title');
+ $sku = $this->getObject(Sku::class, $this->argument('sku'), 'title');
if (!$sku) {
$this->error("Unable to find the SKU {$this->argument('sku')}.");
diff --git a/src/app/Console/Commands/User/ResourcesCommand.php b/src/app/Console/Commands/User/ResourcesCommand.php
--- a/src/app/Console/Commands/User/ResourcesCommand.php
+++ b/src/app/Console/Commands/User/ResourcesCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class ResourcesCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'resources';
diff --git a/src/app/Console/Commands/User/ResyncCommand.php b/src/app/Console/Commands/User/ResyncCommand.php
--- a/src/app/Console/Commands/User/ResyncCommand.php
+++ b/src/app/Console/Commands/User/ResyncCommand.php
@@ -3,7 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Jobs\User\CreateJob;
+use App\Jobs\User\DeleteJob;
+use App\Jobs\User\ResyncJob;
use App\User;
+use Carbon\Carbon;
class ResyncCommand extends Command
{
@@ -59,11 +63,11 @@
if ($deletedUsers) {
$deletedUsers = $deletedUsers
- ->where(function ($query) {
+ ->where(static function ($query) {
$query->whereNull('role')
- ->orWhere('role', '!=', User::ROLE_SERVICE);
+ ->orWhere('role', '!=', User::ROLE_SERVICE);
})
- ->where(function ($query) use ($with_ldap) {
+ ->where(static function ($query) use ($with_ldap) {
$query = $query->where('status', '&', User::STATUS_IMAP_READY);
if ($with_ldap) {
$query->orWhere('status', '&', User::STATUS_LDAP_READY);
@@ -73,11 +77,11 @@
if ($createdUsers) {
$createdUsers = $createdUsers
- ->where(function ($query) {
+ ->where(static function ($query) {
$query->whereNull('role')
- ->orWhere('role', '!=', User::ROLE_SERVICE);
+ ->orWhere('role', '!=', User::ROLE_SERVICE);
})
- ->where(function ($query) use ($with_ldap) {
+ ->where(static function ($query) use ($with_ldap) {
$query = $query->whereNot('status', '&', User::STATUS_IMAP_READY)
->orWhereNot('status', '&', User::STATUS_ACTIVE);
if ($with_ldap) {
@@ -90,7 +94,7 @@
if (preg_match('/^([0-9]+)([mdy])$/i', $min_age, $matches)) {
$count = (int) $matches[1];
$period = strtolower($matches[2]);
- $date = \Carbon\Carbon::now();
+ $date = Carbon::now();
if ($period == 'y') {
$date->subYearsWithoutOverflow($count);
@@ -120,7 +124,7 @@
$createdUsers = $createdUsers->orderBy('id')->cursor();
foreach ($createdUsers as $user) {
if ($limit > 0 && $count > $limit) {
- $this->info("Reached limit of $limit");
+ $this->info("Reached limit of {$limit}");
break;
}
@@ -130,7 +134,7 @@
continue;
}
- \App\Jobs\User\CreateJob::dispatch($user->id);
+ CreateJob::dispatch($user->id);
$this->info("{$user->email}: pushed (create)");
}
}
@@ -140,7 +144,7 @@
$deletedUsers = $deletedUsers->orderBy('id')->cursor();
foreach ($deletedUsers as $user) {
if ($limit > 0 && $count > $limit) {
- $this->info("Reached limit of $limit");
+ $this->info("Reached limit of {$limit}");
break;
}
@@ -156,7 +160,7 @@
$user->update(['status' => $user->status ^ User::STATUS_DELETED]);
}
- \App\Jobs\User\DeleteJob::dispatch($user->id);
+ DeleteJob::dispatch($user->id);
$this->info("{$user->email}: pushed (delete)");
}
}
@@ -171,7 +175,7 @@
} else {
// We push the update only if a specific user is requested,
// We don't want to flood the database/backend with an update of all users
- \App\Jobs\User\ResyncJob::dispatch($req_user->id);
+ ResyncJob::dispatch($req_user->id);
$this->info("{$req_user->email}: pushed (resync)");
}
}
diff --git a/src/app/Console/Commands/User/SetDiscountCommand.php b/src/app/Console/Commands/User/SetDiscountCommand.php
--- a/src/app/Console/Commands/User/SetDiscountCommand.php
+++ b/src/app/Console/Commands/User/SetDiscountCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Discount;
class SetDiscountCommand extends Command
{
@@ -37,7 +38,7 @@
if ($this->argument('discount') === '0') {
$discount = null;
} else {
- $discount = $this->getObject(\App\Discount::class, $this->argument('discount'));
+ $discount = $this->getObject(Discount::class, $this->argument('discount'));
if (!$discount) {
$this->error("Discount not found.");
diff --git a/src/app/Console/Commands/User/SetRoleCommand.php b/src/app/Console/Commands/User/SetRoleCommand.php
--- a/src/app/Console/Commands/User/SetRoleCommand.php
+++ b/src/app/Console/Commands/User/SetRoleCommand.php
@@ -3,7 +3,6 @@
namespace App\Console\Commands\User;
use App\Console\Command;
-use App\User;
class SetRoleCommand extends Command
{
diff --git a/src/app/Console/Commands/User/SharedFoldersCommand.php b/src/app/Console/Commands/User/SharedFoldersCommand.php
--- a/src/app/Console/Commands/User/SharedFoldersCommand.php
+++ b/src/app/Console/Commands/User/SharedFoldersCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class SharedFoldersCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'sharedFolders';
diff --git a/src/app/Console/Commands/User/StatusCommand.php b/src/app/Console/Commands/User/StatusCommand.php
--- a/src/app/Console/Commands/User/StatusCommand.php
+++ b/src/app/Console/Commands/User/StatusCommand.php
@@ -3,7 +3,6 @@
namespace App\Console\Commands\User;
use App\Console\Command;
-use App\User;
class StatusCommand extends Command
{
diff --git a/src/app/Console/Commands/User/SuspendCommand.php b/src/app/Console/Commands/User/SuspendCommand.php
--- a/src/app/Console/Commands/User/SuspendCommand.php
+++ b/src/app/Console/Commands/User/SuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\EventLog;
class SuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$user->suspend();
- \App\EventLog::createFor($user, \App\EventLog::TYPE_SUSPENDED, $this->option('comment'));
+ EventLog::createFor($user, EventLog::TYPE_SUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/User/UnsuspendCommand.php b/src/app/Console/Commands/User/UnsuspendCommand.php
--- a/src/app/Console/Commands/User/UnsuspendCommand.php
+++ b/src/app/Console/Commands/User/UnsuspendCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\EventLog;
class UnsuspendCommand extends Command
{
@@ -36,6 +37,6 @@
$user->unsuspend();
- \App\EventLog::createFor($user, \App\EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
+ EventLog::createFor($user, EventLog::TYPE_UNSUSPENDED, $this->option('comment'));
}
}
diff --git a/src/app/Console/Commands/User/UsersCommand.php b/src/app/Console/Commands/User/UsersCommand.php
--- a/src/app/Console/Commands/User/UsersCommand.php
+++ b/src/app/Console/Commands/User/UsersCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class UsersCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'users';
diff --git a/src/app/Console/Commands/User/VerifyCommand.php b/src/app/Console/Commands/User/VerifyCommand.php
--- a/src/app/Console/Commands/User/VerifyCommand.php
+++ b/src/app/Console/Commands/User/VerifyCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Jobs\User\VerifyJob;
class VerifyCommand extends Command
{
@@ -34,7 +35,7 @@
return 1;
}
- \App\Jobs\User\VerifyJob::dispatchSync($user->id);
+ VerifyJob::dispatchSync($user->id);
// TODO: We should check the job result and print an error on failure
}
diff --git a/src/app/Console/Commands/User/WalletsCommand.php b/src/app/Console/Commands/User/WalletsCommand.php
--- a/src/app/Console/Commands/User/WalletsCommand.php
+++ b/src/app/Console/Commands/User/WalletsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\User;
use App\Console\ObjectRelationListCommand;
+use App\User;
class WalletsCommand extends ObjectRelationListCommand
{
- protected $objectClass = \App\User::class;
+ protected $objectClass = User::class;
protected $objectName = 'user';
protected $objectTitle = 'email';
protected $objectRelation = 'wallets';
diff --git a/src/app/Console/Commands/UserAliasesCommand.php b/src/app/Console/Commands/UserAliasesCommand.php
--- a/src/app/Console/Commands/UserAliasesCommand.php
+++ b/src/app/Console/Commands/UserAliasesCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\UserAlias;
class UserAliasesCommand extends ObjectListCommand
{
- protected $objectClass = \App\UserAlias::class;
+ protected $objectClass = UserAlias::class;
protected $objectName = 'user-alias';
protected $objectNamePlural = 'user-aliases';
protected $objectTitle = 'alias';
diff --git a/src/app/Console/Commands/UserSettingsCommand.php b/src/app/Console/Commands/UserSettingsCommand.php
--- a/src/app/Console/Commands/UserSettingsCommand.php
+++ b/src/app/Console/Commands/UserSettingsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\UserSetting;
class UserSettingsCommand extends ObjectListCommand
{
- protected $objectClass = \App\UserSetting::class;
+ protected $objectClass = UserSetting::class;
protected $objectName = 'user-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/VatRatesCommand.php b/src/app/Console/Commands/VatRatesCommand.php
--- a/src/app/Console/Commands/VatRatesCommand.php
+++ b/src/app/Console/Commands/VatRatesCommand.php
@@ -3,9 +3,10 @@
namespace App\Console\Commands;
use App\Console\ObjectListCommand;
+use App\VatRate;
class VatRatesCommand extends ObjectListCommand
{
- protected $objectClass = \App\VatRate::class;
+ protected $objectClass = VatRate::class;
protected $objectName = 'vat-rate';
}
diff --git a/src/app/Console/Commands/Wallet/BalancesCommand.php b/src/app/Console/Commands/Wallet/BalancesCommand.php
--- a/src/app/Console/Commands/Wallet/BalancesCommand.php
+++ b/src/app/Console/Commands/Wallet/BalancesCommand.php
@@ -46,7 +46,7 @@
->groupBy('wallet_id');
$wallets->addSelect('balances.summary')
- ->leftJoinSub($balances, 'balances', function ($join) {
+ ->leftJoinSub($balances, 'balances', static function ($join) {
$join->on('wallets.id', '=', 'balances.wallet_id');
})
->whereRaw(
diff --git a/src/app/Console/Commands/Wallet/ChargeCommand.php b/src/app/Console/Commands/Wallet/ChargeCommand.php
--- a/src/app/Console/Commands/Wallet/ChargeCommand.php
+++ b/src/app/Console/Commands/Wallet/ChargeCommand.php
@@ -3,6 +3,11 @@
namespace App\Console\Commands\Wallet;
use App\Console\Command;
+use App\Jobs\Wallet\ChargeJob;
+use App\Jobs\Wallet\CheckJob;
+use App\User;
+use App\Wallet;
+use Illuminate\Database\Query\JoinClause;
class ChargeCommand extends Command
{
@@ -44,19 +49,19 @@
$wallets = [$wallet];
} elseif ($this->option('topup')) {
// Find wallets that need to be topped up
- $wallets = \App\Wallet::select('wallets.id')
+ $wallets = Wallet::select('wallets.id')
->join('users', 'users.id', '=', 'wallets.user_id')
- ->join('wallet_settings', function (\Illuminate\Database\Query\JoinClause $join) {
+ ->join('wallet_settings', static function (JoinClause $join) {
$join->on('wallet_settings.wallet_id', '=', 'wallets.id')
->where('wallet_settings.key', '=', 'mandate_balance');
})
->whereNull('users.deleted_at')
->whereRaw('wallets.balance < (wallet_settings.value * 100)')
- ->whereNot('users.status', '&', \App\User::STATUS_DEGRADED | \App\User::STATUS_SUSPENDED)
+ ->whereNot('users.status', '&', User::STATUS_DEGRADED | User::STATUS_SUSPENDED)
->cursor();
} else {
// Get all wallets, excluding deleted accounts
- $wallets = \App\Wallet::select('wallets.id')
+ $wallets = Wallet::select('wallets.id')
->join('users', 'users.id', '=', 'wallets.user_id')
->whereNull('users.deleted_at')
->cursor();
@@ -68,9 +73,9 @@
} else {
if ($this->option('topup')) {
$this->info("Dispatching wallet charge for {$wallet->id}");
- \App\Jobs\Wallet\ChargeJob::dispatch($wallet->id);
+ ChargeJob::dispatch($wallet->id);
} else {
- \App\Jobs\Wallet\CheckJob::dispatch($wallet->id);
+ CheckJob::dispatch($wallet->id);
}
}
}
diff --git a/src/app/Console/Commands/Wallet/ExpectedCommand.php b/src/app/Console/Commands/Wallet/ExpectedCommand.php
--- a/src/app/Console/Commands/Wallet/ExpectedCommand.php
+++ b/src/app/Console/Commands/Wallet/ExpectedCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Wallet;
use App\Console\Command;
+use App\Wallet;
class ExpectedCommand extends Command
{
@@ -37,7 +38,7 @@
$wallets = $user->wallets;
} else {
- $wallets = \App\Wallet::select('wallets.*')
+ $wallets = Wallet::select('wallets.*')
->join('users', 'users.id', '=', 'wallets.user_id')
->withEnvTenantContext('users')
->whereNull('users.deleted_at');
diff --git a/src/app/Console/Commands/Wallet/ListCommand.php b/src/app/Console/Commands/Wallet/ListCommand.php
--- a/src/app/Console/Commands/Wallet/ListCommand.php
+++ b/src/app/Console/Commands/Wallet/ListCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Wallet;
use App\Console\ObjectListCommand;
+use App\Wallet;
class ListCommand extends ObjectListCommand
{
- protected $objectClass = \App\Wallet::class;
+ protected $objectClass = Wallet::class;
protected $objectName = 'wallet';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Wallet/MandateCommand.php b/src/app/Console/Commands/Wallet/MandateCommand.php
--- a/src/app/Console/Commands/Wallet/MandateCommand.php
+++ b/src/app/Console/Commands/Wallet/MandateCommand.php
@@ -60,7 +60,7 @@
$this->info(" status: {$status}");
$this->info(" amount: {$mandate['amount']} {$wallet->currency}");
$this->info(" min-balance: {$mandate['balance']} {$wallet->currency}");
- $this->info(" disabled: $disabled");
+ $this->info(" disabled: {$disabled}");
} else {
$this->info("Auto-payment: none");
}
diff --git a/src/app/Console/Commands/Wallet/SetDiscountCommand.php b/src/app/Console/Commands/Wallet/SetDiscountCommand.php
--- a/src/app/Console/Commands/Wallet/SetDiscountCommand.php
+++ b/src/app/Console/Commands/Wallet/SetDiscountCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Wallet;
use App\Console\Command;
+use App\Discount;
class SetDiscountCommand extends Command
{
@@ -39,7 +40,7 @@
if ($this->argument('discount') === '0') {
$wallet->discount()->dissociate();
} else {
- $discount = $this->getObject(\App\Discount::class, $this->argument('discount'));
+ $discount = $this->getObject(Discount::class, $this->argument('discount'));
if (!$discount) {
$this->error("Discount not found.");
diff --git a/src/app/Console/Commands/Wallet/SettingsCommand.php b/src/app/Console/Commands/Wallet/SettingsCommand.php
--- a/src/app/Console/Commands/Wallet/SettingsCommand.php
+++ b/src/app/Console/Commands/Wallet/SettingsCommand.php
@@ -3,10 +3,11 @@
namespace App\Console\Commands\Wallet;
use App\Console\ObjectListCommand;
+use App\WalletSetting;
class SettingsCommand extends ObjectListCommand
{
- protected $objectClass = \App\WalletSetting::class;
+ protected $objectClass = WalletSetting::class;
protected $objectName = 'wallet-setting';
- protected $objectTitle = null;
+ protected $objectTitle;
}
diff --git a/src/app/Console/Commands/Wallet/TransactionsCommand.php b/src/app/Console/Commands/Wallet/TransactionsCommand.php
--- a/src/app/Console/Commands/Wallet/TransactionsCommand.php
+++ b/src/app/Console/Commands/Wallet/TransactionsCommand.php
@@ -3,6 +3,7 @@
namespace App\Console\Commands\Wallet;
use App\Console\Command;
+use App\Transaction;
class TransactionsCommand extends Command
{
@@ -54,7 +55,7 @@
);
if ($withDetail) {
- $elements = \App\Transaction::where('transaction_id', $transaction->id)
+ $elements = Transaction::where('transaction_id', $transaction->id)
->orderBy('created_at')->get();
foreach ($elements as $element) {
diff --git a/src/app/Console/Commands/Wallet/TrialEndCommand.php b/src/app/Console/Commands/Wallet/TrialEndCommand.php
--- a/src/app/Console/Commands/Wallet/TrialEndCommand.php
+++ b/src/app/Console/Commands/Wallet/TrialEndCommand.php
@@ -3,6 +3,9 @@
namespace App\Console\Commands\Wallet;
use App\Console\Command;
+use App\Jobs\Mail\TrialEndJob;
+use App\User;
+use App\Wallet;
class TrialEndCommand extends Command
{
@@ -28,25 +31,25 @@
public function handle()
{
// Get all wallets...
- $wallets = \App\Wallet::select('wallets.*')
+ $wallets = Wallet::select('wallets.*')
->join('users', 'users.id', '=', 'wallets.user_id')
// exclude deleted accounts
->whereNull('users.deleted_at')
// exclude "inactive" accounts
- ->where('users.status', '&', \App\User::STATUS_IMAP_READY)
+ ->where('users.status', '&', User::STATUS_IMAP_READY)
// consider only these created 1 to 2 months ago
->where('users.created_at', '>', \now()->subMonthsNoOverflow(2))
->where('users.created_at', '<=', \now()->subMonthsNoOverflow(1))
// skip wallets with the notification already sent
- ->whereNotExists(function ($query) {
+ ->whereNotExists(static function ($query) {
$query->from('wallet_settings')
->where('wallet_settings.key', 'trial_end_notice')
->whereColumn('wallet_settings.wallet_id', 'wallets.id');
})
// skip users that aren't account owners
- ->whereExists(function ($query) {
+ ->whereExists(static function ($query) {
$query->from('entitlements')
- ->where('entitlements.entitleable_type', \App\User::class)
+ ->where('entitlements.entitleable_type', User::class)
->whereColumn('entitlements.entitleable_id', 'wallets.user_id')
->whereColumn('entitlements.wallet_id', 'wallets.id');
})
@@ -60,7 +63,7 @@
}
// Send the email asynchronously
- \App\Jobs\Mail\TrialEndJob::dispatch($wallet->owner);
+ TrialEndJob::dispatch($wallet->owner);
// Store the timestamp
$wallet->setSetting('trial_end_notice', (string) \now());
diff --git a/src/app/Console/Development/TemplateRender.php b/src/app/Console/Development/TemplateRender.php
--- a/src/app/Console/Development/TemplateRender.php
+++ b/src/app/Console/Development/TemplateRender.php
@@ -38,12 +38,12 @@
foreach (glob(app_path() . '/Documents/*.php') as $file) {
$file = basename($file, '.php');
- $this->info("Documents/$file");
+ $this->info("Documents/{$file}");
}
foreach (glob(app_path() . '/Mail/*.php') as $file) {
$file = basename($file, '.php');
- $this->info("Mail/$file");
+ $this->info("Mail/{$file}");
}
return 1;
diff --git a/src/app/Console/Kernel.php b/src/app/Console/Kernel.php
--- a/src/app/Console/Kernel.php
+++ b/src/app/Console/Kernel.php
@@ -27,7 +27,7 @@
$schedule->command('fs:expunge')->hourly();
// This cleans up IMAP ACL for deleted users/etc.
- //$schedule->command('imap:cleanup')->dailyAt('03:00');
+ // $schedule->command('imap:cleanup')->dailyAt('03:00');
// This notifies users about an end of the trial period
$schedule->command('wallet:trial-end')->dailyAt('07:00');
diff --git a/src/app/Console/ObjectCreateCommand.php b/src/app/Console/ObjectCreateCommand.php
--- a/src/app/Console/ObjectCreateCommand.php
+++ b/src/app/Console/ObjectCreateCommand.php
@@ -2,6 +2,8 @@
namespace App\Console;
+use App\Traits\BelongsToTenantTrait;
+
/**
* This abstract class provides a means to treat objects in our model using CRUD.
*/
@@ -37,7 +39,7 @@
if (
$this->commandPrefix == 'scalpel'
- && in_array(\App\Traits\BelongsToTenantTrait::class, class_uses($this->objectClass))
+ && in_array(BelongsToTenantTrait::class, class_uses($this->objectClass))
) {
$properties[] = 'tenant_id';
}
diff --git a/src/app/Console/ObjectDeleteCommand.php b/src/app/Console/ObjectDeleteCommand.php
--- a/src/app/Console/ObjectDeleteCommand.php
+++ b/src/app/Console/ObjectDeleteCommand.php
@@ -2,6 +2,8 @@
namespace App\Console;
+use App\Utils;
+
/**
* This abstract class provides a means to treat objects in our model using CRUD.
*/
@@ -17,7 +19,7 @@
$this->objectName
);
- if (\App\Utils::isSoftDeletable($this->objectClass)) {
+ if (Utils::isSoftDeletable($this->objectClass)) {
$this->signature .= " {--with-deleted : Consider deleted {$this->objectName}s}";
}
diff --git a/src/app/Console/ObjectListCommand.php b/src/app/Console/ObjectListCommand.php
--- a/src/app/Console/ObjectListCommand.php
+++ b/src/app/Console/ObjectListCommand.php
@@ -2,6 +2,10 @@
namespace App\Console;
+use App\Traits\BelongsToTenantTrait;
+use App\Utils;
+use Carbon\Carbon;
+
/**
* This abstract class provides a means to treat objects in our model using CRUD, with the exception that
* this particular abstract class lists objects.
@@ -20,11 +24,11 @@
$this->signature .= "{$this->objectName}s";
}
- if (in_array(\App\Traits\BelongsToTenantTrait::class, class_uses($this->objectClass))) {
+ if (in_array(BelongsToTenantTrait::class, class_uses($this->objectClass))) {
$this->signature .= " {--tenant= : Limit results to the specified tenant}";
}
- if (\App\Utils::isSoftDeletable($this->objectClass)) {
+ if (Utils::isSoftDeletable($this->objectClass)) {
$this->signature .= " {--with-deleted : Include deleted {$this->objectName}s}";
}
@@ -42,14 +46,14 @@
public function handle()
{
// @phpstan-ignore-next-line
- if (\App\Utils::isSoftDeletable($this->objectClass) && $this->option('with-deleted')) {
+ if (Utils::isSoftDeletable($this->objectClass) && $this->option('with-deleted')) {
$objects = $this->objectClass::withTrashed();
} else {
$objects = new $this->objectClass();
}
// @phpstan-ignore-next-line
- if ($this->hasOption('tenant') && ($tenant = intval($this->option('tenant')))) {
+ if ($this->hasOption('tenant') && ($tenant = (int) $this->option('tenant'))) {
$this->tenantId = $tenant;
$objects = $this->applyTenant($objects);
}
@@ -100,7 +104,7 @@
$operator = strtolower($matches[1]) == 'min' ? '<=' : '>=';
$count = (int) $matches[2];
$period = strtolower($matches[3]);
- $date = \Carbon\Carbon::now();
+ $date = Carbon::now();
if ($period == 'y') {
$date->subYearsWithoutOverflow($count);
diff --git a/src/app/Console/ObjectRelationListCommand.php b/src/app/Console/ObjectRelationListCommand.php
--- a/src/app/Console/ObjectRelationListCommand.php
+++ b/src/app/Console/ObjectRelationListCommand.php
@@ -2,6 +2,10 @@
namespace App\Console;
+use App\Utils;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Collection;
+use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Str;
@@ -54,7 +58,7 @@
$this->objectRelationClass = "App\\" . rtrim(ucfirst($this->objectRelation), 's');
}
- if (\App\Utils::isSoftDeletable($this->objectRelationClass)) {
+ if (Utils::isSoftDeletable($this->objectRelationClass)) {
$this->signature .= " {--with-deleted : Include deleted objects}";
}
@@ -95,11 +99,11 @@
// Convert query builder into a collection
if (
- ($result instanceof \Illuminate\Database\Eloquent\Relations\Relation)
- || ($result instanceof \Illuminate\Database\Eloquent\Builder)
+ ($result instanceof Relation)
+ || ($result instanceof Builder)
) {
// @phpstan-ignore-next-line
- if (\App\Utils::isSoftDeletable($this->objectRelationClass) && $this->option('with-deleted')) {
+ if (Utils::isSoftDeletable($this->objectRelationClass) && $this->option('with-deleted')) {
$result->withoutGlobalScope(SoftDeletingScope::class);
}
@@ -108,7 +112,7 @@
// Print the result
if (
- ($result instanceof \Illuminate\Database\Eloquent\Collection)
+ ($result instanceof Collection)
|| is_array($result)
) {
foreach ($result as $entry) {
diff --git a/src/app/Console/ObjectUpdateCommand.php b/src/app/Console/ObjectUpdateCommand.php
--- a/src/app/Console/ObjectUpdateCommand.php
+++ b/src/app/Console/ObjectUpdateCommand.php
@@ -56,7 +56,7 @@
if (preg_match_all('/@property\s+([^$\s]+)\s+\$([a-z_]+)/', $reflector->getDocComment(), $matches)) {
foreach ($matches[1] as $key => $type) {
$type = preg_replace('/[\?]/', '', $type);
- if (preg_match('/^(int|string|float|bool|\\Carbon\\Carbon)$/', $type)) {
+ if (preg_match('/^(int|string|float|bool|\Carbon\Carbon)$/', $type)) {
$list[] = $matches[2][$key];
}
}
diff --git a/src/app/Contact.php b/src/app/Contact.php
--- a/src/app/Contact.php
+++ b/src/app/Contact.php
@@ -7,10 +7,10 @@
/**
* The eloquent definition of a Contact (in the global addressbook).
*
- * @property int $id The contact identifier
- * @property string $email The contact email address
- * @property string $name The contact (display) name
- * @property int $user_id The contact owner
+ * @property int $id The contact identifier
+ * @property string $email The contact email address
+ * @property string $name The contact (display) name
+ * @property int $user_id The contact owner
*/
class Contact extends Model
{
diff --git a/src/app/DataMigrator/Account.php b/src/app/DataMigrator/Account.php
--- a/src/app/DataMigrator/Account.php
+++ b/src/app/DataMigrator/Account.php
@@ -27,7 +27,7 @@
/** @var string Full account location URI (w/o parameters) */
public $uri;
- /** @var string Username for proxy auth */
+ /** @var ?string Username for proxy auth */
public $loginas;
/** @var array Additional parameters from the input */
@@ -42,7 +42,6 @@
/** @var ?User User object */
protected $user;
-
/**
* Object constructor
*
diff --git a/src/app/DataMigrator/Driver/DAV.php b/src/app/DataMigrator/Driver/DAV.php
--- a/src/app/DataMigrator/Driver/DAV.php
+++ b/src/app/DataMigrator/Driver/DAV.php
@@ -3,14 +3,14 @@
namespace App\DataMigrator\Driver;
use App\Backends\DAV as DAVClient;
-use App\Backends\DAV\Opaque as DAVOpaque;
use App\Backends\DAV\Folder as DAVFolder;
+use App\Backends\DAV\Opaque as DAVOpaque;
use App\Backends\DAV\Search as DAVSearch;
use App\Backends\DAV\ShareResource as DAVShareResource;
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
-use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ExporterInterface;
+use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
@@ -95,7 +95,6 @@
case Engine::TYPE_TASK:
$object->contentType = 'text/calendar; charset=utf-8';
break;
-
case Engine::TYPE_CONTACT:
$object->contentType = 'text/vcard; charset=utf-8';
break;
@@ -258,7 +257,7 @@
$result = $this->client->search(
$location,
$search,
- function ($item) use (&$set, $dav_type, $folder, $existing, $callback) {
+ static function ($item) use (&$set, $dav_type, $folder, $existing, $callback) {
// Skip an item that exists and did not change
$exists = null;
if (!empty($existing[$item->uid])) {
@@ -342,7 +341,7 @@
$items = $this->client->search(
$location,
$search,
- function ($item) use ($dav_type) {
+ static function ($item) use ($dav_type) {
// Slim down the result to properties we might need
$object = [
'href' => $item->href,
diff --git a/src/app/DataMigrator/Driver/EWS.php b/src/app/DataMigrator/Driver/EWS.php
--- a/src/app/DataMigrator/Driver/EWS.php
+++ b/src/app/DataMigrator/Driver/EWS.php
@@ -5,8 +5,8 @@
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
use App\DataMigrator\Interface\ExporterInterface;
-use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Folder;
+use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
use App\DataMigrator\Queue;
@@ -97,7 +97,6 @@
/** @var Engine Data migrator engine */
protected $engine;
-
/**
* Object constructor
*/
@@ -155,11 +154,11 @@
/**
* Autodiscover the server and authenticate the user
*/
- protected function authenticateWithPassword(string $server, string $user, string $password, string $loginas = null)
+ protected function authenticateWithPassword(string $server, string $user, string $password, ?string $loginas = null)
{
// Note: Since 2023-01-01 EWS at Office365 requires OAuth2, no way back to basic auth.
- \Log::debug("[EWS] Using basic authentication on $server...");
+ \Log::debug("[EWS] Using basic authentication on {$server}...");
$options = [];
@@ -180,7 +179,7 @@
*/
protected function authenticateWithToken(string $server, string $user, string $token, $expires_at = null)
{
- \Log::debug("[EWS] Using token authentication on $server...");
+ \Log::debug("[EWS] Using token authentication on {$server}...");
$options = ['impersonation' => $user];
@@ -208,7 +207,7 @@
// See https://github.com/Garethp/php-ews/issues/236#issuecomment-1292521527
// To register OAuth2 app goto https://entra.microsoft.com > Applications > App registrations
- \Log::debug("[EWS] Fetching OAuth2 token from $server...");
+ \Log::debug("[EWS] Fetching OAuth2 token from {$server}...");
$scope = 'https://outlook.office365.com/.default';
$token_uri = "https://login.microsoftonline.com/{$tenant_id}/oauth2/v2.0/token";
@@ -292,7 +291,7 @@
// FIXME: Is there a better way to distinguish user folders from system ones?
if (
in_array($fullname, $this->folder_exceptions)
- || strpos($fullname, 'OwaFV15.1All') === 0
+ || str_starts_with($fullname, 'OwaFV15.1All')
) {
continue;
}
@@ -344,7 +343,7 @@
$existingIndex = [];
array_walk(
$existing,
- function (&$item, $idx) use (&$existingIndex) {
+ static function (&$item, $idx) use (&$existingIndex) {
if (!empty($item['x-ms-id'])) {
[$id, $changeKey] = explode('!', $item['x-ms-id']);
$item['changeKey'] = $changeKey;
@@ -367,7 +366,7 @@
'FieldURI' => [
['FieldURI' => 'item:ItemClass'],
// ['FieldURI' => 'item:Size'],
- ['FieldURI' => 'message:InternetMessageId'], //For mail only?
+ ['FieldURI' => 'message:InternetMessageId'], // For mail only?
],
],
],
@@ -420,7 +419,7 @@
if (count($set->items)) {
$callback($set);
}
- \Log::debug("[EWS] Processed $itemCount items");
+ \Log::debug("[EWS] Processed {$itemCount} items");
// TODO: Delete items that do not exist anymore?
}
@@ -470,7 +469,7 @@
$idx = $existingIndex[$id['Id']];
if ($existing[$idx]['changeKey'] == $id['ChangeKey']) {
- \Log::debug("[EWS] Skipping over already existing message $idx with class {$item->getItemClass()}...");
+ \Log::debug("[EWS] Skipping over already existing message {$idx} with class {$item->getItemClass()}...");
return null;
}
@@ -480,14 +479,14 @@
try {
$msgid = $item->getInternetMessageId();
} catch (\Exception $e) {
- //Ignore
+ // Ignore
}
if (isset($existingIndex[$msgid])) {
// If the messageid already exists, we assume it's the same email.
// Flag/size changes are ignored for now.
// Otherwise we should set uid/size/flags on exists, so the IMAP implementation can pick it up.
\Log::debug(
- "[EWS] Skipping over already existing message $msgid with class {$item->getItemClass()}..."
+ "[EWS] Skipping over already existing message {$msgid} with class {$item->getItemClass()}..."
);
return null;
}
diff --git a/src/app/DataMigrator/Driver/EWS/Appointment.php b/src/app/DataMigrator/Driver/EWS/Appointment.php
--- a/src/app/DataMigrator/Driver/EWS/Appointment.php
+++ b/src/app/DataMigrator/Driver/EWS/Appointment.php
@@ -2,7 +2,6 @@
namespace App\DataMigrator\Driver\EWS;
-use garethp\ews\API;
use garethp\ews\API\Type;
/**
@@ -12,8 +11,7 @@
{
public const FOLDER_TYPE = 'IPF.Appointment';
// public const TYPE = 'IPM.Appointment';
- public const FILE_EXT = 'ics';
-
+ public const FILE_EXT = 'ics';
/**
* Get GetItem request parameters
diff --git a/src/app/DataMigrator/Driver/EWS/Contact.php b/src/app/DataMigrator/Driver/EWS/Contact.php
--- a/src/app/DataMigrator/Driver/EWS/Contact.php
+++ b/src/app/DataMigrator/Driver/EWS/Contact.php
@@ -11,7 +11,7 @@
{
public const FOLDER_TYPE = 'IPF.Contact';
// public const TYPE = 'IPM.Contact';
- public const FILE_EXT = 'vcf';
+ public const FILE_EXT = 'vcf';
/**
* Get GetItem request parameters
@@ -73,7 +73,7 @@
}
foreach ($emailEntries->Entry as $email) {
- $emails[] = 'EMAIL;TYPE=internet:' . strval($email);
+ $emails[] = 'EMAIL;TYPE=internet:' . (string) $email;
}
if ($emails) {
diff --git a/src/app/DataMigrator/Driver/EWS/DistList.php b/src/app/DataMigrator/Driver/EWS/DistList.php
--- a/src/app/DataMigrator/Driver/EWS/DistList.php
+++ b/src/app/DataMigrator/Driver/EWS/DistList.php
@@ -11,7 +11,7 @@
{
public const FOLDER_TYPE = 'IPF.Contact';
// public const TYPE = 'IPM.DistList';
- public const FILE_EXT = 'vcf';
+ public const FILE_EXT = 'vcf';
/**
* Get GetItem request parameters
@@ -44,7 +44,7 @@
$vcard = "BEGIN:VCARD\r\nVERSION:4.0\r\nPRODID:Kolab EWS Data Migrator\r\n";
foreach ($data as $key => $prop) {
- $vcard .= $this->formatProp($key, $prop[0], isset($prop[1]) ? $prop[1] : []);
+ $vcard .= $this->formatProp($key, $prop[0], $prop[1] ?? []);
}
// Process list members
diff --git a/src/app/DataMigrator/Driver/EWS/Email.php b/src/app/DataMigrator/Driver/EWS/Email.php
--- a/src/app/DataMigrator/Driver/EWS/Email.php
+++ b/src/app/DataMigrator/Driver/EWS/Email.php
@@ -11,8 +11,7 @@
{
public const FOLDER_TYPE = 'IPF.Note';
// public const TYPE = 'IPM.Email';
- public const FILE_EXT = 'mime';
-
+ public const FILE_EXT = 'mime';
/**
* Get GetItem request parameters
diff --git a/src/app/DataMigrator/Driver/EWS/Item.php b/src/app/DataMigrator/Driver/EWS/Item.php
--- a/src/app/DataMigrator/Driver/EWS/Item.php
+++ b/src/app/DataMigrator/Driver/EWS/Item.php
@@ -6,9 +6,9 @@
use App\DataMigrator\Engine;
use App\DataMigrator\Interface\Folder as FolderInterface;
use App\DataMigrator\Interface\Item as ItemInterface;
-use App\DataMigrator\Interface\ItemSet as ItemSetInterface;
-use garethp\ews\API;
use garethp\ews\API\Type;
+use Sabre\VObject\Component\VCalendar;
+use Sabre\VObject\Property\Text;
/**
* Abstraction for object handlers
@@ -27,7 +27,6 @@
/** @var string Current item UID */
protected $uid;
-
/**
* Object constructor
*/
@@ -78,9 +77,8 @@
{
if ($itemClass = self::lookupClassHandler($item->class)) {
return new $itemClass($driver, $item->folder);
- } else {
- \Log::warning("Encountered unhandled item class {$item->class} ");
}
+ \Log::warning("Encountered unhandled item class {$item->class} ");
}
/**
@@ -150,7 +148,7 @@
['FieldURI' => 'item:LastModifiedTime'],
],
],
- ]
+ ],
];
return $request;
@@ -163,11 +161,11 @@
{
$request = [
'AttachmentIds' => [
- $attachment->getAttachmentId()->toXmlObject()
+ $attachment->getAttachmentId()->toXmlObject(),
],
'AttachmentShape' => [
'IncludeMimeContent' => true,
- ]
+ ],
];
return $this->driver->api->getClient()->GetAttachment($request);
@@ -207,8 +205,8 @@
*/
protected function formatProp($name, $value, array $params = []): string
{
- $cal = new \Sabre\VObject\Component\VCalendar();
- $prop = new \Sabre\VObject\Property\Text($cal, $name, $value, $params);
+ $cal = new VCalendar();
+ $prop = new Text($cal, $name, $value, $params);
$value = $prop->serialize();
diff --git a/src/app/DataMigrator/Driver/EWS/Note.php b/src/app/DataMigrator/Driver/EWS/Note.php
--- a/src/app/DataMigrator/Driver/EWS/Note.php
+++ b/src/app/DataMigrator/Driver/EWS/Note.php
@@ -13,7 +13,7 @@
// public const TYPE = 'IPM.Note';
// public const TYPE = 'IPM.Note.SMIME';
// public const TYPE = 'IPM.Note.SMIME.MultipartSigned';
- public const FILE_EXT = 'eml';
+ public const FILE_EXT = 'eml';
/**
* Get GetItem request parameters
@@ -43,7 +43,7 @@
$flags[] = 'SEEN';
}
- //low/normal/high are exist
+ // low/normal/high are exist
if (strtolower($item->getImportance()) == "high") {
$flags[] = 'FLAGGED';
}
diff --git a/src/app/DataMigrator/Driver/EWS/ScheduleMeeting.php b/src/app/DataMigrator/Driver/EWS/ScheduleMeeting.php
--- a/src/app/DataMigrator/Driver/EWS/ScheduleMeeting.php
+++ b/src/app/DataMigrator/Driver/EWS/ScheduleMeeting.php
@@ -12,7 +12,7 @@
public const FOLDER_TYPE = 'IPF.Note';
// public const TYPE = 'IPM.Schedule.Meeting.Request';
// public const TYPE = 'IPM.Schedule.Meeting.Canceled';
- public const FILE_EXT = 'eml';
+ public const FILE_EXT = 'eml';
/**
* Get GetItem request parameters
diff --git a/src/app/DataMigrator/Driver/EWS/Task.php b/src/app/DataMigrator/Driver/EWS/Task.php
--- a/src/app/DataMigrator/Driver/EWS/Task.php
+++ b/src/app/DataMigrator/Driver/EWS/Task.php
@@ -11,7 +11,7 @@
{
public const FOLDER_TYPE = 'IPF.Task';
// public const TYPE = 'IPM.Task';
- public const FILE_EXT = 'ics';
+ public const FILE_EXT = 'ics';
/**
* Get GetItem request parameters
@@ -43,10 +43,10 @@
'UID' => [$this->getUID($item)],
'DTSTAMP' => [$this->formatDate($item->getLastModifiedTime()), ['VALUE' => 'DATE-TIME']],
'CREATED' => [$this->formatDate($item->getDateTimeCreated()), ['VALUE' => 'DATE-TIME']],
- 'SEQUENCE' => [intval($item->getChangeCount())],
+ 'SEQUENCE' => [(int) $item->getChangeCount()],
'SUMMARY' => [$item->getSubject()],
'DESCRIPTION' => [(string) $item->getBody()],
- 'PERCENT-COMPLETE' => [intval($item->getPercentComplete())],
+ 'PERCENT-COMPLETE' => [(int) $item->getPercentComplete()],
'X-MS-ID' => [$this->itemId],
];
@@ -104,7 +104,7 @@
$ical = "BEGIN:VCALENDAR\r\nMETHOD:PUBLISH\r\nVERSION:2.0\r\nPRODID:Kolab EWS Data Migrator\r\nBEGIN:VTODO\r\n";
foreach ($data as $key => $prop) {
- $ical .= $this->formatProp($key, $prop[0], isset($prop[1]) ? $prop[1] : []);
+ $ical .= $this->formatProp($key, $prop[0], $prop[1] ?? []);
}
// Attachments
@@ -220,7 +220,7 @@
$rrule = array_filter($rrule);
$rrule = trim(array_reduce(
array_keys($rrule),
- function ($carry, $key) use ($rrule) {
+ static function ($carry, $key) use ($rrule) {
return $carry . ';' . $key . '=' . $rrule[$key];
}
), ';');
@@ -277,7 +277,7 @@
$days = explode(' ', $days);
$days = array_map(
- function ($day) use ($days_map, $index_map, $index) {
+ static function ($day) use ($days_map, $index_map, $index) {
return ($index ? $index_map[$index] : '') . $days_map[$day];
},
$days
@@ -296,7 +296,7 @@
$months = explode(' ', $months);
$months = array_map(
- function ($month) use ($months_map) {
+ static function ($month) use ($months_map) {
return array_search($month, $months_map) + 1;
},
$months
diff --git a/src/app/DataMigrator/Driver/IMAP.php b/src/app/DataMigrator/Driver/IMAP.php
--- a/src/app/DataMigrator/Driver/IMAP.php
+++ b/src/app/DataMigrator/Driver/IMAP.php
@@ -4,8 +4,8 @@
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
-use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ExporterInterface;
+use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
@@ -31,7 +31,6 @@
/** @var Engine Data migrator engine */
protected $engine;
-
/**
* Object constructor
*/
@@ -390,7 +389,7 @@
{
$this->initIMAP();
- $mailbox = self::toUTF7($folder->targetname ? $folder->targetname : $folder->fullname);
+ $mailbox = self::toUTF7($folder->targetname ?: $folder->fullname);
// TODO: We should probably first use SEARCH/SORT to skip messages marked as \Deleted
// TODO: fetchHeaders() fetches too many headers, we should slim-down, here we need
@@ -489,7 +488,7 @@
// cert validation, or make it optional via Account URI parameters
'verify_peer' => \config('services.imap.verify_peer'),
'verify_peer_name' => \config('services.imap.verify_peer'),
- 'verify_host' => \config('services.imap.verify_host')
+ 'verify_host' => \config('services.imap.verify_host'),
],
],
],
diff --git a/src/app/DataMigrator/Driver/Kolab.php b/src/app/DataMigrator/Driver/Kolab.php
--- a/src/app/DataMigrator/Driver/Kolab.php
+++ b/src/app/DataMigrator/Driver/Kolab.php
@@ -2,12 +2,12 @@
namespace App\DataMigrator\Driver;
+use App\Auth\Utils;
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
-use App\DataMigrator\Interface\ItemSet;
use App\User;
/**
@@ -30,7 +30,7 @@
protected const IMAP_TYPES = [
Engine::TYPE_MAIL,
Engine::TYPE_CONFIGURATION,
- Engine::TYPE_FILE
+ Engine::TYPE_FILE,
];
/** @var DAV DAV importer/exporter engine */
@@ -58,9 +58,9 @@
// the Authorize-As header, it is used only for cummunication with Murder backends.
// We use a one-time token instead. It's valid for 6 hours, assume it's enough time
// to migrate an account.
- $account->password = \App\Auth\Utils::tokenCreate((string) $user->id, 6 * 60 * 60);
+ $account->password = Utils::tokenCreate((string) $user->id, 6 * 60 * 60);
$account->username = $account->loginas;
- unset($account->loginas);
+ $account->loginas = null;
}
// Setup DAV connection
diff --git a/src/app/DataMigrator/Driver/Kolab/Files.php b/src/app/DataMigrator/Driver/Kolab/Files.php
--- a/src/app/DataMigrator/Driver/Kolab/Files.php
+++ b/src/app/DataMigrator/Driver/Kolab/Files.php
@@ -170,7 +170,7 @@
DB::beginTransaction();
if ($item->existing) {
- /** @var FsItem $file */
+ /** @var FsItem $file */
$file = $item->existing;
$file->updated_at = $item->data['mtime'];
$file->timestamps = false;
diff --git a/src/app/DataMigrator/Driver/Kolab/Tags.php b/src/app/DataMigrator/Driver/Kolab/Tags.php
--- a/src/app/DataMigrator/Driver/Kolab/Tags.php
+++ b/src/app/DataMigrator/Driver/Kolab/Tags.php
@@ -14,7 +14,6 @@
private const METADATA_ROOT = 'INBOX';
private const METADATA_TAGS_KEY = '/private/vendor/kolab/tags/v1';
-
/**
* Get all tag properties, resolve tag members
*
@@ -290,7 +289,7 @@
*/
public static function saveKolab4Tags($imap, array $tags): void
{
- $metadata = json_encode($tags, JSON_INVALID_UTF8_IGNORE | JSON_UNESCAPED_UNICODE);
+ $metadata = json_encode($tags, \JSON_INVALID_UTF8_IGNORE | \JSON_UNESCAPED_UNICODE);
if (!$imap->setMetadata(self::METADATA_ROOT, [self::METADATA_TAGS_KEY => $metadata])) {
throw new \Exception("Failed to store tags in IMAP. Error: {$imap->error}");
diff --git a/src/app/DataMigrator/Driver/Takeout.php b/src/app/DataMigrator/Driver/Takeout.php
--- a/src/app/DataMigrator/Driver/Takeout.php
+++ b/src/app/DataMigrator/Driver/Takeout.php
@@ -5,10 +5,9 @@
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
use App\DataMigrator\Interface\ExporterInterface;
-use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Folder;
+use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
-use App\DataMigrator\Interface\ItemSet;
/**
* Data migration from Google Takeout archive file
@@ -24,7 +23,6 @@
/** @var string Local folder with folders/files (extracted from the Takeout archive) */
protected $location;
-
/**
* Object constructor
*/
@@ -170,10 +168,10 @@
$pos = 0;
$start = null;
- $add_vevent_block = function ($start_pos, $end_pos) use (&$event, &$events) {
+ $add_vevent_block = static function ($start_pos, $end_pos) use (&$event, &$events) {
// Get the UID which will be the array key
if (preg_match('/\nUID:(.[^\r\n]+(\r\n[\s\t][^\r\n]+)*)/', $event, $matches)) {
- $uid = str_replace(["\r\n ", "\r\n "], '', $matches[1]);
+ $uid = str_replace(["\r\n ", "\r\n "], '', $matches[1]);
// Remember position in the stream, we don't want to copy the whole content into memory
$chunk = $start_pos . ':' . $end_pos;
$events[$uid] = isset($events[$uid]) ? array_merge($events[$uid], [$chunk]) : [$chunk];
@@ -214,7 +212,7 @@
$event = '';
foreach ($chunks as $pos) {
[$start, $end] = explode(':', $pos);
- $event .= stream_get_contents($fp, intval($end) - intval($start), intval($start));
+ $event .= stream_get_contents($fp, (int) $end - (int) $start, (int) $start);
}
$this->eventItemHandler($folder, $head . $event . "END:VCALENDAR\r\n", $existing, $callback);
diff --git a/src/app/DataMigrator/Driver/Test.php b/src/app/DataMigrator/Driver/Test.php
--- a/src/app/DataMigrator/Driver/Test.php
+++ b/src/app/DataMigrator/Driver/Test.php
@@ -4,8 +4,8 @@
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
-use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ExporterInterface;
+use App\DataMigrator\Interface\Folder;
use App\DataMigrator\Interface\ImporterInterface;
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
@@ -25,7 +25,6 @@
/** @var Engine Data migrator engine */
protected $engine;
-
/**
* Object constructor
*/
@@ -47,9 +46,7 @@
/**
* Check user credentials.
*/
- public function authenticate(): void
- {
- }
+ public function authenticate(): void {}
/**
* Create an item in a folder.
diff --git a/src/app/DataMigrator/Engine.php b/src/app/DataMigrator/Engine.php
--- a/src/app/DataMigrator/Engine.php
+++ b/src/app/DataMigrator/Engine.php
@@ -9,6 +9,7 @@
use App\DataMigrator\Interface\Item;
use App\DataMigrator\Interface\ItemSet;
use Illuminate\Support\Str;
+use Symfony\Component\Console\Output\ConsoleOutput;
/**
* Data migration engine
@@ -45,7 +46,6 @@
/** @var array Data migration options */
protected $options = [];
-
/**
* Execute migration for the specified user
*/
@@ -56,7 +56,7 @@
$this->options = $options;
// Create a unique identifier for the migration request
- $queue_id = md5(strval($source) . strval($destination) . ($options['type'] ?? ''));
+ $queue_id = md5((string) $source . (string) $destination . ($options['type'] ?? ''));
// TODO: When running in 'sync' mode we shouldn't create a queue at all
@@ -97,7 +97,7 @@
$location = storage_path('export/') . $source->email;
if (!file_exists($location)) {
- mkdir($location, 0740, true);
+ mkdir($location, 0o740, true);
}
$types = empty($options['type']) ? [] : preg_split('/\s*,\s*/', strtolower($options['type']));
@@ -128,7 +128,7 @@
// Apply name replacements
$folder->targetname = $folder->fullname;
foreach ($folderMapping as $key => $value) {
- //TODO we should have a syntax for exact or prefix matching.
+ // TODO we should have a syntax for exact or prefix matching.
// There are at least two usecases:
// * Match a specific folder exactly
// * Match a parent folder in a hierarchy: "Posteingang/Foo" => "INBOX/Foo"
@@ -203,7 +203,7 @@
}
$count++;
} else {
- $rate = (double)$itemCount / max((time() - $startTime), 1);
+ $rate = (float) $itemCount / max(time() - $startTime, 1);
$this->progress(sprintf(" Item Progress [%d] %f items/s", $itemCount, $rate));
if ($item_or_set instanceof ItemSet) {
$this->processItemSet($item_or_set);
@@ -216,7 +216,7 @@
);
$this->progressComplete();
- $this->debug("Migrated $itemCount items");
+ $this->debug("Migrated {$itemCount} items");
if ($count) {
$this->queue->bumpJobsStarted($count);
}
@@ -292,10 +292,10 @@
public function debug($line)
{
if (!empty($this->options['stdout'])) {
- $output = new \Symfony\Component\Console\Output\ConsoleOutput();
- $output->writeln("$line");
+ $output = new ConsoleOutput();
+ $output->writeln("{$line}");
} else {
- \Log::debug("[DataMigrator] $line");
+ \Log::debug("[DataMigrator] {$line}");
}
}
@@ -307,8 +307,8 @@
public function progress($line)
{
if (!empty($this->options['stdout'])) {
- $output = new \Symfony\Component\Console\Output\ConsoleOutput();
- $output->write("\r$line");
+ $output = new ConsoleOutput();
+ $output->write("\r{$line}");
}
}
@@ -318,7 +318,7 @@
public function progressComplete()
{
if (!empty($this->options['stdout'])) {
- $output = new \Symfony\Component\Console\Output\ConsoleOutput();
+ $output = new ConsoleOutput();
$output->writeln("");
}
}
@@ -400,33 +400,27 @@
case 'ews':
$driver = new Driver\EWS($account, $this);
break;
-
case 'dav':
case 'davs':
$driver = new Driver\DAV($account, $this);
break;
-
case 'imap':
case 'imaps':
case 'tls':
case 'ssl':
$driver = new Driver\IMAP($account, $this);
break;
-
case 'kolab':
case 'kolab3':
case 'kolab4':
$driver = new Driver\Kolab($account, $this);
break;
-
case 'takeout':
$driver = new Driver\Takeout($account, $this);
break;
-
case 'test':
$driver = new Driver\Test($account, $this);
break;
-
default:
throw new \Exception("Failed to init driver for '{$account->scheme}'");
}
diff --git a/src/app/DataMigrator/Interface/Folder.php b/src/app/DataMigrator/Interface/Folder.php
--- a/src/app/DataMigrator/Interface/Folder.php
+++ b/src/app/DataMigrator/Interface/Folder.php
@@ -48,11 +48,10 @@
/** @var array Extra (temporary, cache) data */
public $data = [];
-
/**
* Create Folder instance from an array
*/
- public static function fromArray(array $data = []): Folder
+ public static function fromArray(array $data = []): self
{
$obj = new self();
@@ -74,7 +73,7 @@
// TODO: What if parent folder not yet exists?
if (!file_exists($location)) {
- mkdir($location, 0740, true);
+ mkdir($location, 0o740, true);
}
$location .= '/' . $filename;
diff --git a/src/app/DataMigrator/Interface/Item.php b/src/app/DataMigrator/Interface/Item.php
--- a/src/app/DataMigrator/Interface/Item.php
+++ b/src/app/DataMigrator/Interface/Item.php
@@ -19,6 +19,7 @@
/**
* Identifier/Location of the item if exists in the destination folder.
* And/or some metadata on the existing item. This information is driver specific.
+ *
* @TODO: Unify this to be always an array (or object) for easier cross-driver interop.
*
* @var string|array|null
@@ -34,11 +35,10 @@
/** @var array Extra data to migrate (like email flags, internaldate, etc.) */
public $data = [];
-
/**
* Create Item object from an array
*/
- public static function fromArray(array $data = []): Item
+ public static function fromArray(array $data = []): self
{
$obj = new self();
diff --git a/src/app/DataMigrator/Interface/ItemSet.php b/src/app/DataMigrator/Interface/ItemSet.php
--- a/src/app/DataMigrator/Interface/ItemSet.php
+++ b/src/app/DataMigrator/Interface/ItemSet.php
@@ -13,7 +13,7 @@
/**
* Create an ItemSet instance
*/
- public static function set(array $items = []): ItemSet
+ public static function set(array $items = []): self
{
$obj = new self();
$obj->items = $items;
diff --git a/src/app/DataMigrator/Jobs/FolderJob.php b/src/app/DataMigrator/Jobs/FolderJob.php
--- a/src/app/DataMigrator/Jobs/FolderJob.php
+++ b/src/app/DataMigrator/Jobs/FolderJob.php
@@ -8,8 +8,8 @@
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
class FolderJob implements ShouldQueue
{
@@ -27,13 +27,10 @@
/** @var Folder Job data */
protected $folder;
-
/**
* Create a new job instance.
*
* @param Folder $folder Folder to process
- *
- * @return void
*/
public function __construct(Folder $folder)
{
@@ -42,8 +39,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -53,10 +48,6 @@
/**
* The job failed to process.
- *
- * @param \Exception $exception
- *
- * @return void
*/
public function failed(\Exception $exception)
{
diff --git a/src/app/DataMigrator/Jobs/ItemJob.php b/src/app/DataMigrator/Jobs/ItemJob.php
--- a/src/app/DataMigrator/Jobs/ItemJob.php
+++ b/src/app/DataMigrator/Jobs/ItemJob.php
@@ -8,8 +8,8 @@
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
class ItemJob implements ShouldQueue
{
@@ -27,13 +27,10 @@
/** @var Item Job data */
protected $item;
-
/**
* Create a new job instance.
*
* @param Item $item Item to process
- *
- * @return void
*/
public function __construct(Item $item)
{
@@ -42,8 +39,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -53,10 +48,6 @@
/**
* The job failed to process.
- *
- * @param \Exception $exception
- *
- * @return void
*/
public function failed(\Exception $exception)
{
diff --git a/src/app/DataMigrator/Jobs/ItemSetJob.php b/src/app/DataMigrator/Jobs/ItemSetJob.php
--- a/src/app/DataMigrator/Jobs/ItemSetJob.php
+++ b/src/app/DataMigrator/Jobs/ItemSetJob.php
@@ -8,8 +8,8 @@
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
-use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
+use Illuminate\Queue\SerializesModels;
class ItemSetJob implements ShouldQueue
{
@@ -27,13 +27,10 @@
/** @var ItemSet Job data */
protected $set;
-
/**
* Create a new job instance.
*
* @param ItemSet $set Set of Items to process
- *
- * @return void
*/
public function __construct(ItemSet $set)
{
@@ -42,8 +39,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -53,10 +48,6 @@
/**
* The job failed to process.
- *
- * @param \Exception $exception
- *
- * @return void
*/
public function failed(\Exception $exception)
{
diff --git a/src/app/DataMigrator/Queue.php b/src/app/DataMigrator/Queue.php
--- a/src/app/DataMigrator/Queue.php
+++ b/src/app/DataMigrator/Queue.php
@@ -2,7 +2,6 @@
namespace App\DataMigrator;
-use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
@@ -53,11 +52,10 @@
'data' => '', // must not be []
];
-
/**
* Fast and race-condition free method of bumping the jobs_started value
*/
- public function bumpJobsStarted(int $num = null)
+ public function bumpJobsStarted(?int $num = null)
{
DB::update(
"update data_migrator_queues set jobs_started = jobs_started + ? where id = ?",
@@ -68,7 +66,7 @@
/**
* Fast and race-condition free method of bumping the jobs_finished value
*/
- public function bumpJobsFinished(int $num = null)
+ public function bumpJobsFinished(?int $num = null)
{
DB::update(
"update data_migrator_queues set jobs_finished = jobs_finished + ? where id = ?",
diff --git a/src/app/Delegation.php b/src/app/Delegation.php
--- a/src/app/Delegation.php
+++ b/src/app/Delegation.php
@@ -3,15 +3,16 @@
namespace App;
use App\Traits\StatusPropertyTrait;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* Definition of Delegation (user to user relation).
*
- * @property int $delegatee_id
- * @property ?array $options
- * @property int $status
- * @property int $user_id
+ * @property int $delegatee_id
+ * @property ?array $options
+ * @property int $status
+ * @property int $user_id
*/
class Delegation extends Pivot
{
@@ -50,11 +51,10 @@
/** @var bool Indicates if the model should be timestamped. */
public $timestamps = false;
-
/**
* The delegator user
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function user()
{
@@ -64,7 +64,7 @@
/**
* The delegatee user
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function delegatee()
{
diff --git a/src/app/Discount.php b/src/app/Discount.php
--- a/src/app/Discount.php
+++ b/src/app/Discount.php
@@ -5,6 +5,7 @@
use App\Traits\BelongsToTenantTrait;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
/**
@@ -32,7 +33,6 @@
/** @var array<int, string> Translatable properties */
public $translatable = ['description'];
-
/**
* Discount value mutator
*
@@ -58,7 +58,7 @@
/**
* List of wallets with this discount assigned.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Wallet, $this>
+ * @return HasMany<Wallet, $this>
*/
public function wallets()
{
diff --git a/src/app/Documents/Receipt.php b/src/app/Documents/Receipt.php
--- a/src/app/Documents/Receipt.php
+++ b/src/app/Documents/Receipt.php
@@ -4,13 +4,16 @@
use App\Payment;
use App\User;
+use App\Utils;
+use App\VatRate;
use App\Wallet;
use Barryvdh\DomPDF\Facade\Pdf;
use Carbon\Carbon;
+use Illuminate\View\View;
class Receipt
{
- /** @var \App\Wallet The wallet */
+ /** @var Wallet The wallet */
protected $wallet;
/** @var int Transactions date year */
@@ -22,15 +25,12 @@
/** @var bool Enable fake data mode */
protected static $fakeMode = false;
-
/**
* Document constructor.
*
- * @param \App\Wallet $wallet A wallet containing transactions
- * @param int $year A year to list transactions from
- * @param int $month A month to list transactions from
- *
- * @return void
+ * @param Wallet $wallet A wallet containing transactions
+ * @param int $year A year to list transactions from
+ * @param int $month A month to list transactions from
*/
public function __construct(Wallet $wallet, int $year, int $month)
{
@@ -49,7 +49,7 @@
public static function fakeRender(string $type = 'html'): string
{
$wallet = new Wallet(['currency' => 'CHF']);
- $wallet->id = \App\Utils::uuidStr();
+ $wallet->id = Utils::uuidStr();
$wallet->owner = new User(['id' => 123456789]);
$receipt = new self($wallet, (int) date('Y'), (int) date('n'));
@@ -58,7 +58,8 @@
if ($type == 'pdf') {
return $receipt->pdfOutput();
- } elseif ($type !== 'html') {
+ }
+ if ($type !== 'html') {
throw new \Exception("Unsupported output format");
}
@@ -114,7 +115,7 @@
/**
* Build the document
*
- * @return \Illuminate\View\View The template object
+ * @return View The template object
*/
protected function build()
{
@@ -122,7 +123,7 @@
$start = Carbon::create($this->year, $this->month, 1, 0, 0, 0);
$end = $start->copy()->endOfMonth();
- $month = \trans('documents.month' . intval($this->month));
+ $month = \trans('documents.month' . (int) $this->month);
$title = \trans('documents.receipt-title', ['year' => $this->year, 'month' => $month]);
$company = $this->companyData();
@@ -152,8 +153,8 @@
],
]);
- $items = $items->map(function ($payment) {
- $payment->vatRate = new \App\VatRate();
+ $items = $items->map(static function ($payment) {
+ $payment->vatRate = new VatRate();
$payment->vatRate->rate = 7.7;
$payment->credit_amount = $payment->amount + round($payment->amount * $payment->vatRate->rate / 100);
return $payment;
@@ -205,16 +206,16 @@
// Load the template
$view = view('documents.receipt')
->with([
- 'site' => $appName,
- 'title' => $title,
- 'company' => $company,
- 'customer' => $customer,
- 'items' => $items,
- 'subTotal' => $this->wallet->money($total),
- 'total' => $this->wallet->money($total + $totalVat),
- 'totalVat' => $this->wallet->money($totalVat),
- 'vatRate' => preg_replace('/(\.00|0|\.)$/', '', sprintf('%.2F', $vatRate)),
- 'vat' => $vatRate > 0,
+ 'site' => $appName,
+ 'title' => $title,
+ 'company' => $company,
+ 'customer' => $customer,
+ 'items' => $items,
+ 'subTotal' => $this->wallet->money($total),
+ 'total' => $this->wallet->money($total + $totalVat),
+ 'totalVat' => $this->wallet->money($totalVat),
+ 'vatRate' => preg_replace('/(\.00|0|\.)$/', '', sprintf('%.2F', $vatRate)),
+ 'vat' => $vatRate > 0,
]);
return $view;
@@ -264,12 +265,12 @@
. sprintf('<a href="mailto:%s">%s</a>', $contact, $contact);
}
- if ($logo && strpos($logo, '/') === false) {
- $logo = "/themes/$theme/images/$logo";
+ if ($logo && !str_contains($logo, '/')) {
+ $logo = "/themes/{$theme}/images/{$logo}";
}
return [
- 'logo' => $logo ? "<img src=\"$logo\" width=300>" : '',
+ 'logo' => $logo ? "<img src=\"{$logo}\" width=300>" : '',
'header' => $header,
'footer' => $footer,
];
diff --git a/src/app/Domain.php b/src/app/Domain.php
--- a/src/app/Domain.php
+++ b/src/app/Domain.php
@@ -10,6 +10,7 @@
use App\Traits\UuidIntKeyTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
/**
@@ -31,39 +32,39 @@
use UuidIntKeyTrait;
// we've simply never heard of this domain
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// it's been activated
- public const STATUS_ACTIVE = 1 << 1;
+ public const STATUS_ACTIVE = 1 << 1;
// domain has been suspended.
- public const STATUS_SUSPENDED = 1 << 2;
+ public const STATUS_SUSPENDED = 1 << 2;
// domain has been deleted
- public const STATUS_DELETED = 1 << 3;
+ public const STATUS_DELETED = 1 << 3;
// ownership of the domain has been confirmed
- public const STATUS_CONFIRMED = 1 << 4;
+ public const STATUS_CONFIRMED = 1 << 4;
// domain has been verified that it exists in DNS
- public const STATUS_VERIFIED = 1 << 5;
+ public const STATUS_VERIFIED = 1 << 5;
// domain has been created in LDAP
public const STATUS_LDAP_READY = 1 << 6;
// open for public registration
- public const TYPE_PUBLIC = 1 << 0;
+ public const TYPE_PUBLIC = 1 << 0;
// zone hosted with us
- public const TYPE_HOSTED = 1 << 1;
+ public const TYPE_HOSTED = 1 << 1;
// zone registered externally
- public const TYPE_EXTERNAL = 1 << 2;
+ public const TYPE_EXTERNAL = 1 << 2;
public const HASH_CODE = 1;
public const HASH_TEXT = 2;
public const HASH_CNAME = 3;
/** @var int The allowed states for this object used in StatusPropertyTrait */
- private int $allowed_states = self::STATUS_NEW |
- self::STATUS_ACTIVE |
- self::STATUS_SUSPENDED |
- self::STATUS_DELETED |
- self::STATUS_CONFIRMED |
- self::STATUS_VERIFIED |
- self::STATUS_LDAP_READY;
+ private int $allowed_states = self::STATUS_NEW
+ | self::STATUS_ACTIVE
+ | self::STATUS_SUSPENDED
+ | self::STATUS_DELETED
+ | self::STATUS_CONFIRMED
+ | self::STATUS_VERIFIED
+ | self::STATUS_LDAP_READY;
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
@@ -80,10 +81,10 @@
/**
* Assign a package to a domain. The domain should not belong to any existing entitlements.
*
- * @param \App\Package $package The package to assign.
- * @param \App\User $user The wallet owner.
+ * @param Package $package the package to assign
+ * @param User $user the wallet owner
*
- * @return \App\Domain Self
+ * @return Domain Self
*/
public function assignPackage($package, $user)
{
@@ -108,14 +109,12 @@
public static function getPublicDomains(): array
{
return self::withEnvTenantContext()
- ->where('type', '&', Domain::TYPE_PUBLIC)
+ ->where('type', '&', self::TYPE_PUBLIC)
->pluck('namespace')->all();
}
/**
* Returns whether this domain is confirmed the ownership of.
- *
- * @return bool
*/
public function isConfirmed(): bool
{
@@ -124,8 +123,6 @@
/**
* Returns whether this domain is registered with us.
- *
- * @return bool
*/
public function isExternal(): bool
{
@@ -134,8 +131,6 @@
/**
* Returns whether this domain is hosted with us.
- *
- * @return bool
*/
public function isHosted(): bool
{
@@ -144,8 +139,6 @@
/**
* Returns whether this domain is public.
- *
- * @return bool
*/
public function isPublic(): bool
{
@@ -155,8 +148,6 @@
/**
* Returns whether this (external) domain has been verified
* to exist in DNS.
- *
- * @return bool
*/
public function isVerified(): bool
{
@@ -214,6 +205,7 @@
* in the domain's DNS (that matches the verification hash).
*
* @return bool True if verification was successful, false otherwise
+ *
* @throws \Exception Throws exception on DNS or DB errors
*/
public function confirm(): bool
@@ -226,7 +218,7 @@
$confirmed = false;
// Get DNS records and find a matching TXT entry
- $records = \dns_get_record($this->namespace, DNS_TXT);
+ $records = \dns_get_record($this->namespace, \DNS_TXT);
if ($records === false) {
throw new \Exception("Failed to get DNS record for {$this->namespace}");
@@ -245,7 +237,7 @@
// i.e.: kolab-verify IN CNAME <hash>.domain.tld.
if (!$confirmed) {
$cname = $this->hash(self::HASH_CODE) . '.' . $this->namespace;
- $records = \dns_get_record('kolab-verify.' . $this->namespace, DNS_CNAME);
+ $records = \dns_get_record('kolab-verify.' . $this->namespace, \DNS_CNAME);
if ($records === false) {
throw new \Exception("Failed to get DNS record for {$this->namespace}");
@@ -260,7 +252,7 @@
}
if ($confirmed) {
- $this->status |= Domain::STATUS_CONFIRMED;
+ $this->status |= self::STATUS_CONFIRMED;
$this->save();
}
@@ -284,7 +276,7 @@
$hash = \md5('hkccp-verify-' . $this->namespace);
- return $mod === self::HASH_TEXT ? "$cname=$hash" : $hash;
+ return $mod === self::HASH_TEXT ? "{$cname}={$hash}" : $hash;
}
/**
@@ -328,7 +320,7 @@
* List the users of a domain, so long as the domain is not a public registration domain.
* Note: It returns only users with a mailbox.
*
- * @return \Illuminate\Support\Collection<User> A collection of users
+ * @return Collection<User> A collection of users
*/
public function users()
{
@@ -350,7 +342,7 @@
}
return User::select()
- ->whereExists(function ($query) use ($wallet, $mailboxSKU) {
+ ->whereExists(static function ($query) use ($wallet, $mailboxSKU) {
$query->select(DB::raw(1))
->from('entitlements')
->whereColumn('entitleable_id', 'users.id')
@@ -365,6 +357,7 @@
* Verify if a domain exists in DNS
*
* @return bool True if registered, False otherwise
+ *
* @throws \Exception Throws exception on DNS or DB errors
*/
public function verify(): bool
@@ -373,7 +366,7 @@
return true;
}
- $records = \dns_get_record($this->namespace, DNS_ANY);
+ $records = \dns_get_record($this->namespace, \DNS_ANY);
if ($records === false) {
throw new \Exception("Failed to get DNS record for {$this->namespace}");
@@ -382,7 +375,7 @@
// It may happen that result contains other domains depending on the host DNS setup
// that's why in_array() and not just !empty()
if (in_array($this->namespace, array_column($records, 'host'))) {
- $this->status |= Domain::STATUS_VERIFIED;
+ $this->status |= self::STATUS_VERIFIED;
$this->save();
return true;
diff --git a/src/app/DomainSetting.php b/src/app/DomainSetting.php
--- a/src/app/DomainSetting.php
+++ b/src/app/DomainSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Domain.
@@ -20,7 +21,7 @@
/**
* The domain to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Domain, $this>
+ * @return BelongsTo<Domain, $this>
*/
public function domain()
{
diff --git a/src/app/Entitlement.php b/src/app/Entitlement.php
--- a/src/app/Entitlement.php
+++ b/src/app/Entitlement.php
@@ -4,6 +4,7 @@
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
@@ -11,18 +12,18 @@
*
* Owned by a {@link \App\User}, billed to a {@link \App\Wallet}.
*
- * @property int $cost
- * @property ?string $description
- * @property ?object $entitleable The entitled object (receiver of the entitlement).
- * @property int $entitleable_id
- * @property string $entitleable_type
- * @property int $fee
- * @property string $id
- * @property \App\User $owner The owner of this entitlement (subject).
- * @property \App\Sku $sku The SKU to which this entitlement applies.
- * @property string $sku_id
- * @property \App\Wallet $wallet The wallet to which this entitlement is charged.
- * @property string $wallet_id
+ * @property int $cost
+ * @property ?string $description
+ * @property ?object $entitleable The entitled object (receiver of the entitlement).
+ * @property int $entitleable_id
+ * @property string $entitleable_type
+ * @property int $fee
+ * @property string $id
+ * @property User $owner The owner of this entitlement (subject).
+ * @property Sku $sku The SKU to which this entitlement applies.
+ * @property string $sku_id
+ * @property Wallet $wallet The wallet to which this entitlement is charged.
+ * @property string $wallet_id
*/
class Entitlement extends Model
{
@@ -43,15 +44,15 @@
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
'cost' => 'integer',
- 'fee' => 'integer'
+ 'fee' => 'integer',
];
/**
* Create a transaction record for this entitlement.
*
- * @param string $type The type of transaction ('created', 'billed', 'deleted'), but use the
- * \App\Transaction constants.
- * @param int $amount The amount involved in cents
+ * @param string $type the type of transaction ('created', 'billed', 'deleted'), but use the
+ * \App\Transaction constants
+ * @param int $amount The amount involved in cents
*
* @return string The transaction ID
*/
@@ -60,9 +61,9 @@
$transaction = Transaction::create(
[
'object_id' => $this->id,
- 'object_type' => Entitlement::class,
+ 'object_type' => self::class,
'type' => $type,
- 'amount' => $amount
+ 'amount' => $amount,
]
);
@@ -110,7 +111,7 @@
/**
* The SKU concerned.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Sku, $this>
+ * @return BelongsTo<Sku, $this>
*/
public function sku()
{
@@ -120,7 +121,7 @@
/**
* The wallet this entitlement is being billed to
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Wallet, $this>
+ * @return BelongsTo<Wallet, $this>
*/
public function wallet()
{
diff --git a/src/app/Enums/Queue.php b/src/app/Enums/Queue.php
--- a/src/app/Enums/Queue.php
+++ b/src/app/Enums/Queue.php
@@ -17,6 +17,6 @@
*/
public static function values(): array
{
- return array_map(fn ($case) => $case->value, self::cases());
+ return array_map(static fn ($case) => $case->value, self::cases());
}
}
diff --git a/src/app/EventLog.php b/src/app/EventLog.php
--- a/src/app/EventLog.php
+++ b/src/app/EventLog.php
@@ -56,7 +56,6 @@
/** @var bool Indicates if the model should be timestamped. */
public $timestamps = false;
-
/**
* Create an eventlog object for a specified object.
*
@@ -64,17 +63,15 @@
* @param int $type Event type (use one of EventLog::TYPE_* consts)
* @param ?string $comment Event description
* @param ?array $data Extra information
- *
- * @return EventLog
*/
- public static function createFor($object, int $type, string $comment = null, array $data = null): EventLog
+ public static function createFor($object, int $type, ?string $comment = null, ?array $data = null): self
{
$event = self::create([
- 'object_id' => $object->id,
- 'object_type' => get_class($object),
- 'type' => $type,
- 'comment' => $comment,
- 'data' => $data,
+ 'object_id' => $object->id,
+ 'object_type' => $object::class,
+ 'type' => $type,
+ 'comment' => $comment,
+ 'data' => $data,
]);
return $event;
diff --git a/src/app/Exceptions/Handler.php b/src/app/Exceptions/Handler.php
--- a/src/app/Exceptions/Handler.php
+++ b/src/app/Exceptions/Handler.php
@@ -4,14 +4,17 @@
use Illuminate\Auth\AuthenticationException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
+use Laravel\Passport\Exceptions\OAuthServerException;
+use Symfony\Component\HttpFoundation\Response;
class Handler extends ExceptionHandler
{
/** @var array<int, class-string<\Throwable>> A list of the exception types that are not reported */
protected $dontReport = [
- \Laravel\Passport\Exceptions\OAuthServerException::class,
- \League\OAuth2\Server\Exception\OAuthServerException::class
+ OAuthServerException::class,
+ \League\OAuth2\Server\Exception\OAuthServerException::class,
];
/** @var array<int, string> A list of the inputs that are never flashed for validation exceptions */
@@ -21,13 +24,12 @@
'password_confirmation',
];
-
/**
* Register the exception handling callbacks for the application.
*/
public function register(): void
{
- $this->reportable(function (\Throwable $e) {
+ $this->reportable(static function (\Throwable $e) {
// Rollback uncommitted transactions
while (DB::transactionLevel() > 0) {
DB::rollBack();
@@ -38,10 +40,9 @@
/**
* Convert an authentication exception into a response.
*
- * @param \Illuminate\Http\Request $request
- * @param \Illuminate\Auth\AuthenticationException $exception
+ * @param Request $request
*
- * @return \Symfony\Component\HttpFoundation\Response
+ * @return Response
*/
protected function unauthenticated($request, AuthenticationException $exception)
{
diff --git a/src/app/Fs/Chunk.php b/src/app/Fs/Chunk.php
--- a/src/app/Fs/Chunk.php
+++ b/src/app/Fs/Chunk.php
@@ -3,16 +3,17 @@
namespace App\Fs;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* The eloquent definition of a file chunk.
*
- * @property int $id Chunk identifier
- * @property string $chunk_id Chunk long identifier (storage file name)
- * @property string $item_id Item identifier
- * @property int $sequence Chunk sequence number
- * @property int $size Chunk size
+ * @property int $id Chunk identifier
+ * @property string $chunk_id Chunk long identifier (storage file name)
+ * @property string $item_id Item identifier
+ * @property int $sequence Chunk sequence number
+ * @property int $size Chunk size
*/
class Chunk extends Model
{
@@ -24,11 +25,10 @@
/** @var string Database table name */
protected $table = 'fs_chunks';
-
/**
* The item (file) the chunk belongs to.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Item, $this>
+ * @return BelongsTo<Item, $this>
*/
public function item()
{
diff --git a/src/app/Fs/Item.php b/src/app/Fs/Item.php
--- a/src/app/Fs/Item.php
+++ b/src/app/Fs/Item.php
@@ -2,20 +2,21 @@
namespace App\Fs;
-use App\User;
use App\Traits\BelongsToUserTrait;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* The eloquent definition of a filesystem item.
*
- * @property string $id Item identifier
- * @property int $type Item type
- * @property string $path Item path (readonly)
- * @property int $user_id Item owner
+ * @property string $id Item identifier
+ * @property int $type Item type
+ * @property string $path Item path (readonly)
+ * @property int $user_id Item owner
*/
class Item extends Model
{
@@ -23,7 +24,7 @@
use SoftDeletes;
use UuidStrKeyTrait;
- public const TYPE_FILE = 1;
+ public const TYPE_FILE = 1;
public const TYPE_COLLECTION = 2;
public const TYPE_INCOMPLETE = 4;
@@ -39,11 +40,10 @@
/** @var string Database table name */
protected $table = 'fs_items';
-
/**
* Content chunks of this item (file).
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Chunk, $this>
+ * @return HasMany<Chunk, $this>
*/
public function chunks()
{
@@ -52,8 +52,6 @@
/**
* Getter for the file path (without the filename) in the storage.
- *
- * @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function path(): Attribute
{
@@ -73,7 +71,7 @@
/**
* Any (additional) properties of this item.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Property, $this>
+ * @return HasMany<Property, $this>
*/
public function properties()
{
@@ -107,7 +105,7 @@
$props = array_fill_keys($keys, null);
$this->properties()->whereIn('key', $keys)->get()
- ->each(function ($prop) use (&$props) {
+ ->each(static function ($prop) use (&$props) {
$props[$prop->key] = $prop->value;
});
@@ -138,7 +136,7 @@
/**
* Create or update multiple properties in one fell swoop.
*
- * @param array $data An associative array of key value pairs.
+ * @param array $data an associative array of key value pairs
*/
public function setProperties(array $data = []): void
{
@@ -171,7 +169,7 @@
/**
* All relations for this item
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Relation, $this>
+ * @return HasMany<Relation, $this>
*/
public function relations()
{
@@ -183,11 +181,11 @@
*
* Used to retrieve all items in a collection.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Item, $this>
+ * @return BelongsToMany<Item, $this>
*/
public function children()
{
- return $this->belongsToMany(Item::class, 'fs_relations', 'item_id', 'related_id');
+ return $this->belongsToMany(self::class, 'fs_relations', 'item_id', 'related_id');
}
/**
@@ -195,10 +193,10 @@
*
* Used to retrieve all collections of an item.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Item, $this>
+ * @return BelongsToMany<Item, $this>
*/
public function parents()
{
- return $this->belongsToMany(Item::class, 'fs_relations', 'related_id', 'item_id');
+ return $this->belongsToMany(self::class, 'fs_relations', 'related_id', 'item_id');
}
}
diff --git a/src/app/Fs/Property.php b/src/app/Fs/Property.php
--- a/src/app/Fs/Property.php
+++ b/src/app/Fs/Property.php
@@ -3,14 +3,15 @@
namespace App\Fs;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of properties for a filesystem item.
*
- * @property int $id Property identifier
- * @property int $item_id Item identifier
- * @property string $key Attribute name
- * @property string $value Attrbute value
+ * @property int $id Property identifier
+ * @property int $item_id Item identifier
+ * @property string $key Attribute name
+ * @property string $value Attrbute value
*/
class Property extends Model
{
@@ -20,11 +21,10 @@
/** @var string Database table name */
protected $table = 'fs_properties';
-
/**
* The item to which this property belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Item, $this>
+ * @return BelongsTo<Item, $this>
*/
public function item()
{
diff --git a/src/app/Group.php b/src/app/Group.php
--- a/src/app/Group.php
+++ b/src/app/Group.php
@@ -3,8 +3,8 @@
namespace App;
use App\Traits\BelongsToTenantTrait;
-use App\Traits\EntitleableTrait;
use App\Traits\EmailPropertyTrait;
+use App\Traits\EntitleableTrait;
use App\Traits\GroupConfigTrait;
use App\Traits\SettingsTrait;
use App\Traits\StatusPropertyTrait;
@@ -26,30 +26,30 @@
{
use BelongsToTenantTrait;
use EntitleableTrait;
- use EmailPropertyTrait;
use GroupConfigTrait;
use SettingsTrait;
use SoftDeletes;
use StatusPropertyTrait;
use UuidIntKeyTrait;
+ use EmailPropertyTrait; // must be after UuidIntKeyTrait
// we've simply never heard of this group
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// group has been activated
- public const STATUS_ACTIVE = 1 << 1;
+ public const STATUS_ACTIVE = 1 << 1;
// group has been suspended.
- public const STATUS_SUSPENDED = 1 << 2;
+ public const STATUS_SUSPENDED = 1 << 2;
// group has been deleted
- public const STATUS_DELETED = 1 << 3;
+ public const STATUS_DELETED = 1 << 3;
// group has been created in LDAP
public const STATUS_LDAP_READY = 1 << 4;
/** @var int The allowed states for this object used in StatusPropertyTrait */
- private int $allowed_states = self::STATUS_NEW |
- self::STATUS_ACTIVE |
- self::STATUS_SUSPENDED |
- self::STATUS_DELETED |
- self::STATUS_LDAP_READY;
+ private int $allowed_states = self::STATUS_NEW
+ | self::STATUS_ACTIVE
+ | self::STATUS_SUSPENDED
+ | self::STATUS_DELETED
+ | self::STATUS_LDAP_READY;
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
@@ -66,7 +66,6 @@
'status',
];
-
/**
* Group members propert accessor. Converts internal comma-separated list into an array
*
diff --git a/src/app/GroupSetting.php b/src/app/GroupSetting.php
--- a/src/app/GroupSetting.php
+++ b/src/app/GroupSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Group.
@@ -20,7 +21,7 @@
/**
* The group to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Group, $this>
+ * @return BelongsTo<Group, $this>
*/
public function group()
{
@@ -32,6 +33,6 @@
*/
public function isBackendSetting(): bool
{
- return (\config('app.with_ldap') && $this->key == 'sender_policy');
+ return \config('app.with_ldap') && $this->key == 'sender_policy';
}
}
diff --git a/src/app/Handlers/Activesync.php b/src/app/Handlers/Activesync.php
--- a/src/app/Handlers/Activesync.php
+++ b/src/app/Handlers/Activesync.php
@@ -3,16 +3,18 @@
namespace App\Handlers;
use App\Entitlement;
+use App\Jobs\User\UpdateJob;
use App\Sku;
+use App\User;
-class Activesync extends \App\Handlers\Base
+class Activesync extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
@@ -21,7 +23,7 @@
public static function entitlementCreated(Entitlement $entitlement): void
{
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
@@ -31,7 +33,7 @@
public static function entitlementDeleted(Entitlement $entitlement): void
{
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
diff --git a/src/app/Handlers/Auth2F.php b/src/app/Handlers/Auth2F.php
--- a/src/app/Handlers/Auth2F.php
+++ b/src/app/Handlers/Auth2F.php
@@ -2,17 +2,20 @@
namespace App\Handlers;
+use App\Auth\SecondFactor;
use App\Entitlement;
+use App\Jobs\User\UpdateJob;
use App\Sku;
+use App\User;
-class Auth2F extends \App\Handlers\Base
+class Auth2F extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
@@ -21,7 +24,7 @@
public static function entitlementCreated(Entitlement $entitlement): void
{
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
@@ -33,11 +36,11 @@
// Remove all configured 2FA methods from Roundcube database
if ($entitlement->entitleable && !$entitlement->entitleable->trashed()) {
// TODO: This should be an async job
- $sf = new \App\Auth\SecondFactor($entitlement->entitleable);
+ $sf = new SecondFactor($entitlement->entitleable);
$sf->removeFactors();
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
}
diff --git a/src/app/Handlers/Beta.php b/src/app/Handlers/Beta.php
--- a/src/app/Handlers/Beta.php
+++ b/src/app/Handlers/Beta.php
@@ -3,15 +3,16 @@
namespace App\Handlers;
use App\Entitlement;
+use App\User;
-class Beta extends \App\Handlers\Base
+class Beta extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
diff --git a/src/app/Handlers/Domain.php b/src/app/Handlers/Domain.php
--- a/src/app/Handlers/Domain.php
+++ b/src/app/Handlers/Domain.php
@@ -2,7 +2,7 @@
namespace App\Handlers;
-class Domain extends \App\Handlers\Base
+class Domain extends Base
{
/**
* The entitleable class for this handler.
diff --git a/src/app/Handlers/DomainHosting.php b/src/app/Handlers/DomainHosting.php
--- a/src/app/Handlers/DomainHosting.php
+++ b/src/app/Handlers/DomainHosting.php
@@ -2,20 +2,23 @@
namespace App\Handlers;
-class DomainHosting extends \App\Handlers\Base
+use App\Domain;
+use App\Sku;
+
+class DomainHosting extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\Domain::class;
+ return Domain::class;
}
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/DomainRegistration.php b/src/app/Handlers/DomainRegistration.php
--- a/src/app/Handlers/DomainRegistration.php
+++ b/src/app/Handlers/DomainRegistration.php
@@ -2,13 +2,15 @@
namespace App\Handlers;
-class DomainRegistration extends \App\Handlers\Base
+use App\Domain;
+
+class DomainRegistration extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\Domain::class;
+ return Domain::class;
}
}
diff --git a/src/app/Handlers/DomainRelay.php b/src/app/Handlers/DomainRelay.php
--- a/src/app/Handlers/DomainRelay.php
+++ b/src/app/Handlers/DomainRelay.php
@@ -2,13 +2,15 @@
namespace App\Handlers;
-class DomainRelay extends \App\Handlers\Base
+use App\Domain;
+
+class DomainRelay extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\Domain::class;
+ return Domain::class;
}
}
diff --git a/src/app/Handlers/Group.php b/src/app/Handlers/Group.php
--- a/src/app/Handlers/Group.php
+++ b/src/app/Handlers/Group.php
@@ -2,7 +2,9 @@
namespace App\Handlers;
-class Group extends \App\Handlers\Base
+use App\Sku;
+
+class Group extends Base
{
/**
* The entitleable class for this handler.
@@ -15,7 +17,7 @@
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/GroupRoom.php b/src/app/Handlers/GroupRoom.php
--- a/src/app/Handlers/GroupRoom.php
+++ b/src/app/Handlers/GroupRoom.php
@@ -2,6 +2,9 @@
namespace App\Handlers;
+use App\Meet\Room;
+use App\Sku;
+
class GroupRoom extends Base
{
/**
@@ -9,13 +12,13 @@
*/
public static function entitleableClass(): string
{
- return \App\Meet\Room::class;
+ return Room::class;
}
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/Groupware.php b/src/app/Handlers/Groupware.php
--- a/src/app/Handlers/Groupware.php
+++ b/src/app/Handlers/Groupware.php
@@ -3,15 +3,17 @@
namespace App\Handlers;
use App\Entitlement;
+use App\Jobs\User\UpdateJob;
+use App\User;
-class Groupware extends \App\Handlers\Base
+class Groupware extends Base
{
/**
* The entitleable class for this handler.
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
@@ -20,7 +22,7 @@
public static function entitlementCreated(Entitlement $entitlement): void
{
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
@@ -30,7 +32,7 @@
public static function entitlementDeleted(Entitlement $entitlement): void
{
if (\config('app.with_ldap')) {
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
}
diff --git a/src/app/Handlers/Mailbox.php b/src/app/Handlers/Mailbox.php
--- a/src/app/Handlers/Mailbox.php
+++ b/src/app/Handlers/Mailbox.php
@@ -2,19 +2,17 @@
namespace App\Handlers;
-use App\Entitlement;
use App\Sku;
+use App\User;
-class Mailbox extends \App\Handlers\Base
+class Mailbox extends Base
{
/**
* The entitleable class for this handler.
- *
- * @return string
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
diff --git a/src/app/Handlers/Resource.php b/src/app/Handlers/Resource.php
--- a/src/app/Handlers/Resource.php
+++ b/src/app/Handlers/Resource.php
@@ -2,7 +2,9 @@
namespace App\Handlers;
-class Resource extends \App\Handlers\Base
+use App\Sku;
+
+class Resource extends Base
{
/**
* The entitleable class for this handler.
@@ -15,7 +17,7 @@
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/Room.php b/src/app/Handlers/Room.php
--- a/src/app/Handlers/Room.php
+++ b/src/app/Handlers/Room.php
@@ -2,6 +2,8 @@
namespace App\Handlers;
+use App\Sku;
+
class Room extends Base
{
/**
@@ -15,7 +17,7 @@
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/SharedFolder.php b/src/app/Handlers/SharedFolder.php
--- a/src/app/Handlers/SharedFolder.php
+++ b/src/app/Handlers/SharedFolder.php
@@ -2,7 +2,9 @@
namespace App\Handlers;
-class SharedFolder extends \App\Handlers\Base
+use App\Sku;
+
+class SharedFolder extends Base
{
/**
* The entitleable class for this handler.
@@ -15,7 +17,7 @@
/**
* SKU handler metadata.
*/
- public static function metadata(\App\Sku $sku): array
+ public static function metadata(Sku $sku): array
{
$data = parent::metadata($sku);
diff --git a/src/app/Handlers/Storage.php b/src/app/Handlers/Storage.php
--- a/src/app/Handlers/Storage.php
+++ b/src/app/Handlers/Storage.php
@@ -3,9 +3,11 @@
namespace App\Handlers;
use App\Entitlement;
+use App\Jobs\User\UpdateJob;
use App\Sku;
+use App\User;
-class Storage extends \App\Handlers\Base
+class Storage extends Base
{
public const MAX_ITEMS = 100;
public const ITEM_UNIT = 'GB';
@@ -15,7 +17,7 @@
*/
public static function entitleableClass(): string
{
- return \App\User::class;
+ return User::class;
}
/**
@@ -24,7 +26,7 @@
public static function entitlementCreated(Entitlement $entitlement): void
{
// Update the user IMAP mailbox quota
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
/**
@@ -33,7 +35,7 @@
public static function entitlementDeleted(Entitlement $entitlement): void
{
// Update the user IMAP mailbox quota
- \App\Jobs\User\UpdateJob::dispatch($entitlement->entitleable_id);
+ UpdateJob::dispatch($entitlement->entitleable_id);
}
/**
@@ -46,9 +48,9 @@
$data['readonly'] = true; // only the checkbox will be disabled, not range
$data['enabled'] = true;
$data['range'] = [
- 'min' => $sku->units_free,
- 'max' => self::MAX_ITEMS,
- 'unit' => self::ITEM_UNIT,
+ 'min' => $sku->units_free,
+ 'max' => self::MAX_ITEMS,
+ 'unit' => self::ITEM_UNIT,
];
return $data;
diff --git a/src/app/Http/Controllers/API/AuthController.php b/src/app/Http/Controllers/API/AuthController.php
--- a/src/app/Http/Controllers/API/AuthController.php
+++ b/src/app/Http/Controllers/API/AuthController.php
@@ -5,21 +5,25 @@
use App\Auth\PassportClient;
use App\Http\Controllers\Controller;
use App\User;
+use App\Utils;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Validator;
-use Laravel\Passport\TokenRepository;
use Laravel\Passport\RefreshTokenRepository;
+use Laravel\Passport\TokenRepository;
use League\OAuth2\Server\AuthorizationServer;
-use Psr\Http\Message\ServerRequestInterface;
+use League\OAuth2\Server\Exception\OAuthServerException;
use Nyholm\Psr7\Response as Psr7Response;
+use Psr\Http\Message\ServerRequestInterface;
+use Symfony\Component\HttpFoundation\Response;
class AuthController extends Controller
{
/**
* Get the authenticated User
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function info()
{
@@ -38,11 +42,11 @@
* Helper method for other controllers with user auto-logon
* functionality
*
- * @param \App\User $user User model object
+ * @param User $user User model object
* @param string $password Plain text password
* @param string|null $secondFactor Second factor code if available
*/
- public static function logonResponse(User $user, string $password, string $secondFactor = null)
+ public static function logonResponse(User $user, string $password, ?string $secondFactor = null)
{
$proxyRequest = Request::create('/oauth/token', 'POST', [
'username' => $user->email,
@@ -51,7 +55,7 @@
'client_id' => \config('auth.proxy.client_id'),
'client_secret' => \config('auth.proxy.client_secret'),
'scope' => 'api',
- 'secondfactor' => $secondFactor
+ 'secondfactor' => $secondFactor,
]);
$proxyRequest->headers->set('X-Client-IP', request()->ip());
@@ -63,9 +67,9 @@
/**
* Get an oauth token via given credentials.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function login(Request $request)
{
@@ -81,14 +85,14 @@
return response()->json(['status' => 'error', 'errors' => $v->errors()], 422);
}
- $user = \App\User::where('email', $request->email)->first();
+ $user = User::where('email', $request->email)->first();
if (!$user) {
\Log::debug("[Auth] User not found on login: {$request->email}");
return response()->json(['status' => 'error', 'message' => self::trans('auth.failed')], 401);
}
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
\Log::debug("[Auth] Login with service account not allowed: {$request->email}");
return response()->json(['status' => 'error', 'message' => self::trans('auth.failed')], 401);
}
@@ -105,11 +109,11 @@
*
* The implementation is based on Laravel\Passport\Http\Controllers\AuthorizationController
*
- * @param ServerRequestInterface $psrRequest PSR request
- * @param \Illuminate\Http\Request $request The API request
- * @param AuthorizationServer $server Authorization server
+ * @param ServerRequestInterface $psrRequest PSR request
+ * @param Request $request The API request
+ * @param AuthorizationServer $server Authorization server
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function oauthApprove(ServerRequestInterface $psrRequest, Request $request, AuthorizationServer $server)
{
@@ -152,7 +156,7 @@
// we would have to store these records in SQL table. It would become handy especially
// if we give users possibility to register external OAuth apps.
Cache::put($cacheKey, 1, now()->addDays(14));
- } catch (\League\OAuth2\Server\Exception\OAuthServerException $e) {
+ } catch (OAuthServerException $e) {
// Note: We don't want 401 or 400 codes here, use 422 which is used in our API
$code = $e->getHttpStatusCode();
$response = $e->getPayload();
@@ -187,15 +191,15 @@
}
return response()->json([
- 'status' => 'success',
- 'redirectUrl' => $response->getHeader('Location')[0],
+ 'status' => 'success',
+ 'redirectUrl' => $response->getHeader('Location')[0],
]);
}
/**
* Get the authenticated User information (using access token claims)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function oauthUserInfo()
{
@@ -210,7 +214,7 @@
$response['email'] = $user->email;
$response['email_verified'] = $user->isActive();
// At least synapse depends on a "settings" structure being available
- $response['settings'] = [ 'name' => $user->name() ];
+ $response['settings'] = ['name' => $user->name()];
}
// TODO: Other claims (https://openid.net/specs/openid-connect-core-1_0.html#StandardClaims)
@@ -225,7 +229,7 @@
/**
* Get the user (geo) location
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function location()
{
@@ -233,7 +237,7 @@
$response = [
'ipAddress' => $ip,
- 'countryCode' => \App\Utils::countryForIP($ip, ''),
+ 'countryCode' => Utils::countryForIP($ip, ''),
];
return response()->json($response);
@@ -242,7 +246,7 @@
/**
* Log the user out (Invalidate the token)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function logout()
{
@@ -257,15 +261,15 @@
$refreshTokenRepository->revokeRefreshTokensByAccessTokenId($tokenId);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('auth.logoutsuccess')
+ 'status' => 'success',
+ 'message' => self::trans('auth.logoutsuccess'),
]);
}
/**
* Refresh a token.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function refresh(Request $request)
{
@@ -275,10 +279,10 @@
/**
* Refresh the token and respond with it.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param ?\App\User $user The user being authenticated
+ * @param Request $request the API request
+ * @param ?User $user The user being authenticated
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
protected static function refreshAndRespond(Request $request, $user = null)
{
@@ -297,10 +301,10 @@
/**
* Get the token array structure.
*
- * @param \Symfony\Component\HttpFoundation\Response $tokenResponse The response containing the token.
- * @param ?\App\User $user The user being authenticated
+ * @param Response $tokenResponse the response containing the token
+ * @param ?User $user The user being authenticated
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
protected static function respondWithToken($tokenResponse, $user = null)
{
@@ -312,7 +316,7 @@
return response()->json(['status' => 'error', 'errors' => $errors], 422);
}
- \Log::warning("Failed to request a token: " . strval($tokenResponse));
+ \Log::warning("Failed to request a token: " . (string) $tokenResponse);
return response()->json(['status' => 'error', 'message' => self::trans('auth.failed')], 401);
}
diff --git a/src/app/Http/Controllers/API/PasswordPolicyController.php b/src/app/Http/Controllers/API/PasswordPolicyController.php
--- a/src/app/Http/Controllers/API/PasswordPolicyController.php
+++ b/src/app/Http/Controllers/API/PasswordPolicyController.php
@@ -4,6 +4,8 @@
use App\Http\Controllers\Controller;
use App\Rules\Password;
+use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class PasswordPolicyController extends Controller
@@ -12,9 +14,7 @@
* Fetch the password policy for the current user account.
* The result includes all supported policy rules.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index(Request $request)
{
@@ -31,24 +31,22 @@
];
return response()->json([
- 'list' => array_values($rules),
- 'count' => count($rules),
- 'config' => $config,
+ 'list' => array_values($rules),
+ 'count' => count($rules),
+ 'config' => $config,
]);
}
/**
* Validate the password regarding the defined policies.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function check(Request $request)
{
$userId = $request->input('user');
- $user = !empty($userId) ? \App\User::find($userId) : null;
+ $user = !empty($userId) ? User::find($userId) : null;
// Get the policy
$policy = new Password($user ? $user->walletOwner() : null, $user);
@@ -58,15 +56,15 @@
$passed = array_filter(
$status,
- function ($rule) {
+ static function ($rule) {
return !empty($rule['status']);
}
);
return response()->json([
- 'status' => count($passed) == count($status) ? 'success' : 'error',
- 'list' => array_values($status),
- 'count' => count($status),
+ 'status' => count($passed) == count($status) ? 'success' : 'error',
+ 'list' => array_values($status),
+ 'count' => count($status),
]);
}
}
diff --git a/src/app/Http/Controllers/API/PasswordResetController.php b/src/app/Http/Controllers/API/PasswordResetController.php
--- a/src/app/Http/Controllers/API/PasswordResetController.php
+++ b/src/app/Http/Controllers/API/PasswordResetController.php
@@ -7,6 +7,7 @@
use App\Rules\Password;
use App\User;
use App\VerificationCode;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
@@ -21,9 +22,9 @@
*
* Verifies user email, sends verification email message.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function init(Request $request)
{
@@ -67,9 +68,9 @@
/**
* Validation of the verification code.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function verify(Request $request)
{
@@ -104,18 +105,18 @@
$request->code = $code;
return response()->json([
- 'status' => 'success',
- // we need user's ID for e.g. password policy checks
- 'userId' => $code->user_id,
+ 'status' => 'success',
+ // we need user's ID for e.g. password policy checks
+ 'userId' => $code->user_id,
]);
}
/**
* Password change
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function reset(Request $request)
{
@@ -149,9 +150,9 @@
/**
* Create a verification code for the current user.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function codeCreate(Request $request)
{
@@ -168,10 +169,10 @@
$this->guard()->user()->verificationcodes()->save($code);
return response()->json([
- 'status' => 'success',
- 'code' => $code->code,
- 'short_code' => $code->short_code,
- 'expires_at' => $code->expires_at->toDateTimeString(),
+ 'status' => 'success',
+ 'code' => $code->code,
+ 'short_code' => $code->short_code,
+ 'expires_at' => $code->expires_at->toDateTimeString(),
]);
}
@@ -180,7 +181,7 @@
*
* @param string $id Code identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function codeDelete($id)
{
@@ -204,8 +205,8 @@
$code->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.password-reset-code-delete-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.password-reset-code-delete-success'),
]);
}
}
diff --git a/src/app/Http/Controllers/API/SignupController.php b/src/app/Http/Controllers/API/SignupController.php
--- a/src/app/Http/Controllers/API/SignupController.php
+++ b/src/app/Http/Controllers/API/SignupController.php
@@ -2,10 +2,12 @@
namespace App\Http\Controllers\API;
-use App\Http\Controllers\Controller;
-use App\Jobs\Mail\SignupVerificationJob;
use App\Discount;
use App\Domain;
+use App\Group;
+use App\Http\Controllers\Controller;
+use App\Jobs\Mail\SignupVerificationJob;
+use App\Payment;
use App\Plan;
use App\Providers\PaymentProvider;
use App\ReferralCode;
@@ -22,6 +24,7 @@
use App\User;
use App\Utils;
use App\VatRate;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -35,9 +38,9 @@
/**
* Returns plans definitions for signup.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function plans(Request $request)
{
@@ -46,9 +49,9 @@
$plans = Plan::withEnvTenantContext()->where('hidden', false)
->orderBy('months')->orderByDesc('title')
->get()
- ->map(function ($plan) {
+ ->map(static function ($plan) {
$button = self::trans("app.planbutton-{$plan->title}");
- if (strpos($button, 'app.planbutton') !== false) {
+ if (str_contains($button, 'app.planbutton')) {
$button = self::trans('app.planbutton', ['plan' => $plan->name]);
}
@@ -69,9 +72,9 @@
/**
* Returns list of public domains for signup.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function domains(Request $request)
{
@@ -84,9 +87,9 @@
* Verifies user name and email/phone, sends verification email/sms message.
* Returns the verification code.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function init(Request $request)
{
@@ -115,12 +118,12 @@
// Generate the verification code
$code = SignupCode::create([
- 'email' => $plan->mode == Plan::MODE_TOKEN ? $request->token : $request->email,
- 'first_name' => $request->first_name,
- 'last_name' => $request->last_name,
- 'plan' => $plan->title,
- 'voucher' => $request->voucher,
- 'referral' => $request->referral,
+ 'email' => $plan->mode == Plan::MODE_TOKEN ? $request->token : $request->email,
+ 'first_name' => $request->first_name,
+ 'last_name' => $request->last_name,
+ 'plan' => $plan->title,
+ 'voucher' => $request->voucher,
+ 'referral' => $request->referral,
]);
$response = [
@@ -147,7 +150,7 @@
*
* @param string $id Signup invitation identifier
*
- * @return \Illuminate\Http\JsonResponse|void
+ * @return JsonResponse|void
*/
public function invitation($id)
{
@@ -165,10 +168,10 @@
/**
* Validation of the verification code.
*
- * @param \Illuminate\Http\Request $request HTTP request
- * @param bool $update Update the signup code record
+ * @param Request $request HTTP request
+ * @param bool $update Update the signup code record
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function verify(Request $request, $update = true)
{
@@ -216,21 +219,21 @@
// Return user name and email/phone/voucher from the codes database,
// domains list for selection and "plan type" flag
return response()->json([
- 'status' => 'success',
- 'email' => $code->email,
- 'first_name' => $code->first_name,
- 'last_name' => $code->last_name,
- 'voucher' => $code->voucher,
- 'is_domain' => $plan->hasDomain(),
+ 'status' => 'success',
+ 'email' => $code->email,
+ 'first_name' => $code->first_name,
+ 'last_name' => $code->last_name,
+ 'voucher' => $code->voucher,
+ 'is_domain' => $plan->hasDomain(),
]);
}
/**
* Validates the input to the final signup request.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function signupValidate(Request $request)
{
@@ -344,9 +347,9 @@
/**
* Finishes the signup process by creating the user account.
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function signup(Request $request)
{
@@ -376,16 +379,16 @@
// Create domain record
if ($is_domain && !Domain::withTrashed()->where('namespace', $domain_name)->exists()) {
$domain = Domain::create([
- 'namespace' => $domain_name,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'namespace' => $domain_name,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
}
// Create user record
$user = User::create([
- 'email' => $login . '@' . $domain_name,
- 'password' => $request->password,
- 'status' => $user_status,
+ 'email' => $login . '@' . $domain_name,
+ 'password' => $request->password,
+ 'status' => $user_status,
]);
if ($request->discount) {
@@ -455,11 +458,11 @@
* Collects some content to display to the user before redirect to a checkout page.
* Optionally creates a recurrent payment mandate for specified user/plan.
*/
- protected function mandateForPlan(Plan $plan, Discount $discount = null, User $user = null): array
+ protected function mandateForPlan(Plan $plan, ?Discount $discount = null, ?User $user = null): array
{
$result = [];
- $min = \App\Payment::MIN_AMOUNT;
+ $min = Payment::MIN_AMOUNT;
$planCost = $cost = $plan->cost();
$disc = 0;
@@ -534,9 +537,9 @@
// TODO: app.vat.mode
$vat = (int) round($planCost * $rate->rate / 100);
$content = self::trans('app.vat-incl', [
- 'rate' => Utils::percent($rate->rate),
- 'cost' => Utils::money($planCost - $vat, $currency),
- 'vat' => Utils::money($vat, $currency),
+ 'rate' => Utils::percent($rate->rate),
+ 'cost' => Utils::money($planCost - $vat, $currency),
+ 'vat' => Utils::money($vat, $currency),
]);
$summary .= '<tr class="vat-summary"><td colspan="2">*' . $content . '</td></tr>';
@@ -559,7 +562,7 @@
/**
* Returns plan for the signup process
*
- * @param \Illuminate\Http\Request $request HTTP request
+ * @param Request $request HTTP request
*
* @returns \App\Plan Plan object selected for current signup process
*/
@@ -631,7 +634,7 @@
// Check if user with specified login already exists
$email = $login . '@' . $namespace;
- if (User::emailExists($email) || User::aliasExists($email) || \App\Group::emailExists($email)) {
+ if (User::emailExists($email) || User::aliasExists($email) || Group::emailExists($email)) {
return ['login' => self::trans('validation.loginexists')];
}
diff --git a/src/app/Http/Controllers/API/V4/Admin/DiscountsController.php b/src/app/Http/Controllers/API/V4/Admin/DiscountsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/DiscountsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/DiscountsController.php
@@ -4,6 +4,8 @@
use App\Discount;
use App\Http\Controllers\Controller;
+use App\User;
+use Illuminate\Http\JsonResponse;
class DiscountsController extends Controller
{
@@ -12,11 +14,11 @@
*
* @param int $id User identifier
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function userDiscounts($id)
{
- $user = \App\User::find($id);
+ $user = User::find($id);
if (!$this->checkTenant($user)) {
return $this->errorResponse(404);
@@ -26,7 +28,7 @@
->where('active', true)
->orderBy('discount')
->get()
- ->map(function ($discount) {
+ ->map(static function ($discount) {
$label = $discount->discount . '% - ' . $discount->description;
if ($discount->code) {
@@ -43,9 +45,9 @@
});
return response()->json([
- 'status' => 'success',
- 'list' => $discounts,
- 'count' => count($discounts),
+ 'status' => 'success',
+ 'list' => $discounts,
+ 'count' => count($discounts),
]);
}
}
diff --git a/src/app/Http/Controllers/API/V4/Admin/DomainsController.php b/src/app/Http/Controllers/API/V4/Admin/DomainsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/DomainsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/DomainsController.php
@@ -5,6 +5,7 @@
use App\Domain;
use App\EventLog;
use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
@@ -15,7 +16,7 @@
*
* @param string $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function destroy($id)
{
@@ -25,7 +26,7 @@
/**
* Search for domains
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -71,9 +72,7 @@
/**
* Create a domain.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function store(Request $request)
{
@@ -83,10 +82,10 @@
/**
* Suspend the domain
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Domain identifier
+ * @param Request $request the API request
+ * @param string $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function suspend(Request $request, $id)
{
@@ -107,18 +106,18 @@
EventLog::createFor($domain, EventLog::TYPE_SUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.domain-suspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.domain-suspend-success'),
]);
}
/**
* Un-Suspend the domain
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Domain identifier
+ * @param Request $request the API request
+ * @param string $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function unsuspend(Request $request, $id)
{
@@ -139,8 +138,8 @@
EventLog::createFor($domain, EventLog::TYPE_UNSUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.domain-unsuspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.domain-unsuspend-success'),
]);
}
}
diff --git a/src/app/Http/Controllers/API/V4/Admin/EventLogController.php b/src/app/Http/Controllers/API/V4/Admin/EventLogController.php
--- a/src/app/Http/Controllers/API/V4/Admin/EventLogController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/EventLogController.php
@@ -4,6 +4,7 @@
use App\EventLog;
use App\Http\Controllers\Controller;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class EventLogController extends Controller
@@ -11,11 +12,11 @@
/**
* Listing of eventlog entries.
*
- * @param \Illuminate\Http\Request $request HTTP Request
- * @param string $object_type Object type
- * @param string $object_id Object id
+ * @param Request $request HTTP Request
+ * @param string $object_type Object type
+ * @param string $object_id Object id
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index(Request $request, string $object_type, string $object_id)
{
@@ -31,7 +32,7 @@
return $this->errorResponse(404);
}
- $page = intval($request->input('page')) ?: 1;
+ $page = (int) ($request->input('page')) ?: 1;
$pageSize = 20;
$hasMore = false;
@@ -47,7 +48,7 @@
$hasMore = true;
}
- $result = $result->map(function ($event) {
+ $result = $result->map(static function ($event) {
return [
'id' => $event->id,
'comment' => $event->comment,
diff --git a/src/app/Http/Controllers/API/V4/Admin/GroupsController.php b/src/app/Http/Controllers/API/V4/Admin/GroupsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/GroupsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/GroupsController.php
@@ -5,6 +5,7 @@
use App\EventLog;
use App\Group;
use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
@@ -13,7 +14,7 @@
/**
* Search for groups
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -50,9 +51,9 @@
/**
* Create a new group.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -62,10 +63,10 @@
/**
* Suspend a group
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Group identifier
+ * @param Request $request the API request
+ * @param string $id Group identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function suspend(Request $request, $id)
{
@@ -86,18 +87,18 @@
EventLog::createFor($group, EventLog::TYPE_SUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.distlist-suspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.distlist-suspend-success'),
]);
}
/**
* Un-Suspend a group
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Group identifier
+ * @param Request $request the API request
+ * @param string $id Group identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function unsuspend(Request $request, $id)
{
@@ -118,8 +119,8 @@
EventLog::createFor($group, EventLog::TYPE_UNSUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.distlist-unsuspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.distlist-unsuspend-success'),
]);
}
}
diff --git a/src/app/Http/Controllers/API/V4/Admin/ResourcesController.php b/src/app/Http/Controllers/API/V4/Admin/ResourcesController.php
--- a/src/app/Http/Controllers/API/V4/Admin/ResourcesController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/ResourcesController.php
@@ -4,6 +4,7 @@
use App\Resource;
use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ResourcesController extends \App\Http\Controllers\API\V4\ResourcesController
@@ -11,7 +12,7 @@
/**
* Search for resources
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -48,9 +49,9 @@
/**
* Create a new resource.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
diff --git a/src/app/Http/Controllers/API/V4/Admin/SharedFoldersController.php b/src/app/Http/Controllers/API/V4/Admin/SharedFoldersController.php
--- a/src/app/Http/Controllers/API/V4/Admin/SharedFoldersController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/SharedFoldersController.php
@@ -4,6 +4,7 @@
use App\SharedFolder;
use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class SharedFoldersController extends \App\Http\Controllers\API\V4\SharedFoldersController
@@ -11,7 +12,7 @@
/**
* Search for shared folders
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -48,9 +49,9 @@
/**
* Create a new shared folder.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
diff --git a/src/app/Http/Controllers/API/V4/Admin/SkusController.php b/src/app/Http/Controllers/API/V4/Admin/SkusController.php
--- a/src/app/Http/Controllers/API/V4/Admin/SkusController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/SkusController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Admin;
-class SkusController extends \App\Http\Controllers\API\V4\SkusController
-{
-}
+class SkusController extends \App\Http\Controllers\API\V4\SkusController {}
diff --git a/src/app/Http/Controllers/API/V4/Admin/StatsController.php b/src/app/Http/Controllers/API/V4/Admin/StatsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/StatsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/StatsController.php
@@ -2,13 +2,15 @@
namespace App\Http\Controllers\API\V4\Admin;
+use App\Http\Controllers\Controller;
use App\Payment;
-use App\User;
+use App\Utils;
use Carbon\Carbon;
-use Illuminate\Http\Request;
+use Illuminate\Database\Query\Builder;
+use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\DB;
-class StatsController extends \App\Http\Controllers\Controller
+class StatsController extends Controller
{
public const COLOR_GREEN = '#48d368'; // '#28a745'
public const COLOR_GREEN_DARK = '#19692c';
@@ -35,7 +37,7 @@
*
* @param string $chart Name of the chart
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function chart($chart)
{
@@ -67,7 +69,7 @@
->whereNull('users.deleted_at')
->groupBy('discounts.discount');
- $addTenantScope = function ($builder, $tenantId) {
+ $addTenantScope = static function ($builder, $tenantId) {
return $builder->where('users.tenant_id', $tenantId);
};
@@ -80,7 +82,7 @@
// $labels = [10, 25, 30, 100];
// $discounts = [100, 120, 30, 50];
- $labels = array_map(function ($item) {
+ $labels = array_map(static function ($item) {
return $item . '%';
}, $labels);
@@ -118,7 +120,7 @@
->whereIn('type', [Payment::TYPE_ONEOFF, Payment::TYPE_RECURRING])
->groupByRaw('period, wallets.currency');
- $addTenantScope = function ($builder, $tenantId) {
+ $addTenantScope = static function ($builder, $tenantId) {
$where = sprintf(
'`wallets`.`user_id` IN (select `id` from `users` where `tenant_id` = %d)',
$tenantId
@@ -132,10 +134,10 @@
$this->applyTenantScope($query, $addTenantScope)
->get()
- ->each(function ($record) use (&$payments, $currency) {
+ ->each(static function ($record) use (&$payments, $currency) {
$amount = $record->amount;
if ($record->currency != $currency) {
- $amount = intval(round($amount * \App\Utils::exchangeRate($record->currency, $currency)));
+ $amount = (int) round($amount * Utils::exchangeRate($record->currency, $currency));
}
if (isset($payments[$record->period])) {
@@ -168,17 +170,17 @@
'datasets' => [
[
// 'name' => 'Payments',
- 'values' => $payments
- ]
+ 'values' => $payments,
+ ],
],
'yMarkers' => [
[
'label' => sprintf('average = %.2F', $avg),
'value' => $avg,
- 'options' => [ 'labelPos' => 'left' ] // default: 'right'
- ]
- ]
- ]
+ 'options' => ['labelPos' => 'left'], // default: 'right'
+ ],
+ ],
+ ],
];
}
@@ -187,7 +189,7 @@
*/
protected function chartPayers(): array
{
- list($labels, $stats) = $this->getCollectedStats(self::TYPE_PAYERS, 54, fn($v) => intval($v));
+ [$labels, $stats] = $this->getCollectedStats(self::TYPE_PAYERS, 54, static fn ($v) => (int) $v);
// See https://frappe.io/charts/docs for format/options description
@@ -208,10 +210,10 @@
'datasets' => [
[
// 'name' => 'Existing',
- 'values' => $stats
- ]
- ]
- ]
+ 'values' => $stats,
+ ],
+ ],
+ ],
];
}
@@ -272,22 +274,22 @@
[
'name' => self::trans('app.chart-created'),
'chartType' => 'bar',
- 'values' => $created
+ 'values' => $created,
],
[
'name' => self::trans('app.chart-deleted'),
'chartType' => 'line',
- 'values' => $deleted
- ]
+ 'values' => $deleted,
+ ],
],
'yMarkers' => [
[
'label' => sprintf('%s = %.1f', self::trans('app.chart-average'), $avg),
'value' => collect($created)->avg(),
- 'options' => [ 'labelPos' => 'left' ] // default: 'right'
- ]
- ]
- ]
+ 'options' => ['labelPos' => 'left'], // default: 'right'
+ ],
+ ],
+ ],
];
}
@@ -361,10 +363,10 @@
'datasets' => [
[
// 'name' => 'Existing',
- 'values' => $all
- ]
- ]
- ]
+ 'values' => $all,
+ ],
+ ],
+ ],
];
}
@@ -384,7 +386,7 @@
->havingRaw("count(discount_id) > 0")
->orderByRaw('1');
- $addTenantScope = function ($builder, $tenantId) {
+ $addTenantScope = static function ($builder, $tenantId) {
return $builder->where('users.tenant_id', $tenantId);
};
@@ -414,7 +416,7 @@
self::COLOR_GREEN_DARK,
self::COLOR_ORANGE,
self::COLOR_RED,
- self::COLOR_RED_DARK
+ self::COLOR_RED_DARK,
],
'maxSlices' => 8,
'tooltipOptions' => [], // does not work without it (https://github.com/frappe/charts/issues/314)
@@ -422,20 +424,20 @@
'labels' => $labels,
'datasets' => [
[
- 'values' => $data
- ]
- ]
- ]
+ 'values' => $data,
+ ],
+ ],
+ ],
];
}
/**
* Add tenant scope to the queries when needed
*
- * @param \Illuminate\Database\Query\Builder $query The query
- * @param callable $addQuery Additional tenant-scope query-modifier
+ * @param Builder $query The query
+ * @param callable $addQuery Additional tenant-scope query-modifier
*
- * @return \Illuminate\Database\Query\Builder
+ * @return Builder
*/
protected function applyTenantScope($query, $addQuery = null)
{
@@ -497,7 +499,7 @@
// Get the query result and sum up per-tenant stats
$result = [];
$this->applyTenantScope($stats)->get()
- ->each(function ($item) use (&$result) {
+ ->each(static function ($item) use (&$result) {
$result[$item->period] = ($result[$item->period] ?? 0) + $item->cnt;
});
diff --git a/src/app/Http/Controllers/API/V4/Admin/UsersController.php b/src/app/Http/Controllers/API/V4/Admin/UsersController.php
--- a/src/app/Http/Controllers/API/V4/Admin/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/UsersController.php
@@ -3,10 +3,20 @@
namespace App\Http\Controllers\API\V4\Admin;
use App\Domain;
+use App\Entitlement;
use App\EventLog;
+use App\Group;
+use App\Payment;
+use App\Resource;
+use App\SharedFolder;
+use App\SharedFolderAlias;
use App\Sku;
use App\User;
+use App\UserAlias;
+use App\UserSetting;
use App\Wallet;
+use App\WalletSetting;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
@@ -17,7 +27,7 @@
*
* @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function destroy($id)
{
@@ -27,7 +37,7 @@
/**
* Searching of user accounts.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -49,10 +59,10 @@
if ($result->isEmpty()) {
// Search by an alias
- $user_ids = \App\UserAlias::where('alias', $search)->get()->pluck('user_id');
+ $user_ids = UserAlias::where('alias', $search)->get()->pluck('user_id');
// Search by an external email
- $ext_user_ids = \App\UserSetting::where('key', 'external_email')
+ $ext_user_ids = UserSetting::where('key', 'external_email')
->where('value', $search)
->get()
->pluck('user_id');
@@ -60,13 +70,13 @@
$user_ids = $user_ids->merge($ext_user_ids)->unique();
// Search by an email of a group, resource, shared folder, etc.
- if ($group = \App\Group::withTrashed()->where('email', $search)->first()) {
+ if ($group = Group::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$group->wallet()->user_id])->unique();
- } elseif ($resource = \App\Resource::withTrashed()->where('email', $search)->first()) {
+ } elseif ($resource = Resource::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$resource->wallet()->user_id])->unique();
- } elseif ($folder = \App\SharedFolder::withTrashed()->where('email', $search)->first()) {
+ } elseif ($folder = SharedFolder::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$folder->wallet()->user_id])->unique();
- } elseif ($alias = \App\SharedFolderAlias::where('alias', $search)->first()) {
+ } elseif ($alias = SharedFolderAlias::where('alias', $search)->first()) {
$user_ids = $user_ids->merge([$alias->sharedFolder->wallet()->user_id])->unique();
}
@@ -84,7 +94,7 @@
if ($user) {
$result->push($user);
}
- } elseif (strpos($search, '.') !== false) {
+ } elseif (str_contains($search, '.')) {
// Search by domain
$domain = Domain::withTrashed()->where('namespace', $search)
->first();
@@ -96,10 +106,10 @@
}
// A mollie customer ID
} elseif (substr($search, 0, 4) == 'cst_') {
- $setting = \App\WalletSetting::where(
+ $setting = WalletSetting::where(
[
'key' => 'mollie_id',
- 'value' => $search
+ 'value' => $search,
]
)->first();
@@ -112,7 +122,7 @@
}
// A mollie transaction ID
} elseif (substr($search, 0, 3) == 'tr_') {
- $payment = \App\Payment::find($search);
+ $payment = Payment::find($search);
if ($payment) {
if ($owner = $payment->wallet->owner()->withTrashed()->first()) {
@@ -148,10 +158,10 @@
/**
* Reset 2-Factor Authentication for the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function reset2FA(Request $request, $id)
{
@@ -174,18 +184,18 @@
$entitlement->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-reset-2fa-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-reset-2fa-success'),
]);
}
/**
* Reset Geo-Lockin for the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function resetGeoLock(Request $request, $id)
{
@@ -202,18 +212,18 @@
$user->setConfig(['limit_geo' => []]);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-reset-geo-lock-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-reset-geo-lock-success'),
]);
}
/**
* Resync the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function resync(Request $request, $id)
{
@@ -232,20 +242,19 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-resync-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-resync-success'),
]);
}
-
/**
* Set/Add a SKU for the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
- * @param string $sku SKU title
+ * @param Request $request the API request
+ * @param string $id User identifier
+ * @param string $sku SKU title
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function setSku(Request $request, $id, $sku)
{
@@ -276,26 +285,26 @@
$user->assignSku($sku);
- /** @var \App\Entitlement $entitlement */
+ /** @var Entitlement $entitlement */
$entitlement = $user->entitlements()->where('sku_id', $sku->id)->first();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-set-sku-success'),
- 'sku' => [
- 'cost' => $entitlement->cost,
- 'name' => $sku->name,
- 'id' => $sku->id,
- ]
+ 'status' => 'success',
+ 'message' => self::trans('app.user-set-sku-success'),
+ 'sku' => [
+ 'cost' => $entitlement->cost,
+ 'name' => $sku->name,
+ 'id' => $sku->id,
+ ],
]);
}
/**
* Create a new user record.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -305,10 +314,10 @@
/**
* Suspend the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function suspend(Request $request, $id)
{
@@ -333,18 +342,18 @@
EventLog::createFor($user, EventLog::TYPE_SUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-suspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-suspend-success'),
]);
}
/**
* Un-Suspend the user
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function unsuspend(Request $request, $id)
{
@@ -369,18 +378,18 @@
EventLog::createFor($user, EventLog::TYPE_UNSUSPENDED, $request->comment);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-unsuspend-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-unsuspend-success'),
]);
}
/**
* Update user data.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -417,8 +426,8 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-update-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-update-success'),
]);
}
@@ -427,7 +436,7 @@
*
* Useful for testing proxy settings and making sure the X-Forwarded-For Header is picked up.
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function inspectRequest(Request $request)
{
@@ -435,7 +444,7 @@
'ip' => $request->ip(),
'clientIps' => $request->getClientIps(),
'isFromTrustedProxy' => $request->isFromTrustedProxy(),
- 'headers' => $request->headers->all()
+ 'headers' => $request->headers->all(),
]);
}
}
diff --git a/src/app/Http/Controllers/API/V4/Admin/WalletsController.php b/src/app/Http/Controllers/API/V4/Admin/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/Admin/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/Admin/WalletsController.php
@@ -5,8 +5,8 @@
use App\Discount;
use App\Http\Controllers\API\V4\PaymentsController;
use App\Providers\PaymentProvider;
-use App\Transaction;
use App\Wallet;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -18,7 +18,7 @@
*
* @param string $id A wallet identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function show($id)
{
@@ -52,10 +52,10 @@
/**
* Award/penalize a wallet.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Wallet identifier
+ * @param Request $request the API request
+ * @param string $id Wallet identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function oneOff(Request $request, $id)
{
@@ -99,7 +99,7 @@
$response = [
'status' => 'success',
'message' => self::trans("app.wallet-{$method}-success"),
- 'balance' => $wallet->balance
+ 'balance' => $wallet->balance,
];
return response()->json($response);
@@ -108,10 +108,10 @@
/**
* Update wallet data.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Wallet identifier
+ * @param Request $request the API request
+ * @param string $id Wallet identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
diff --git a/src/app/Http/Controllers/API/V4/AuthAttemptsController.php b/src/app/Http/Controllers/API/V4/AuthAttemptsController.php
--- a/src/app/Http/Controllers/API/V4/AuthAttemptsController.php
+++ b/src/app/Http/Controllers/API/V4/AuthAttemptsController.php
@@ -4,7 +4,8 @@
use App\AuthAttempt;
use App\Http\Controllers\Controller;
-use Illuminate\Support\Facades\Cache;
+use App\Utils;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class AuthAttemptsController extends Controller
@@ -14,7 +15,7 @@
*
* @param string $id Id of AuthAttempt attempt
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function confirm($id)
{
@@ -38,7 +39,7 @@
*
* @param string $id Id of AuthAttempt attempt
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function deny($id)
{
@@ -62,7 +63,7 @@
*
* @param string $id Id of AuthAttempt attempt
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function details($id)
{
@@ -79,8 +80,8 @@
return response()->json([
'status' => 'success',
'username' => $user->email,
- 'country' => \App\Utils::countryForIP($authAttempt->ip),
- 'entry' => $authAttempt->toArray()
+ 'country' => Utils::countryForIP($authAttempt->ip),
+ 'entry' => $authAttempt->toArray(),
]);
}
@@ -89,17 +90,17 @@
*
* All authAttempt attempts from the current user
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index(Request $request)
{
$user = $this->guard()->user();
$pageSize = 10;
- $page = intval($request->input('page')) ?: 1;
+ $page = (int) ($request->input('page')) ?: 1;
$hasMore = false;
- $result = \App\AuthAttempt::where('user_id', $user->id)
+ $result = AuthAttempt::where('user_id', $user->id)
->orderBy('updated_at', 'desc')
->limit($pageSize + 1)
->offset($pageSize * ($page - 1))
@@ -110,7 +111,7 @@
$hasMore = true;
}
- $result = $result->map(function ($authAttempt) {
+ $result = $result->map(static function ($authAttempt) {
return $authAttempt->toArray();
});
diff --git a/src/app/Http/Controllers/API/V4/CompanionAppsController.php b/src/app/Http/Controllers/API/V4/CompanionAppsController.php
--- a/src/app/Http/Controllers/API/V4/CompanionAppsController.php
+++ b/src/app/Http/Controllers/API/V4/CompanionAppsController.php
@@ -2,15 +2,16 @@
namespace App\Http\Controllers\API\V4;
+use App\CompanionApp;
use App\Http\Controllers\ResourceController;
use App\Utils;
-use App\Tenant;
-use Laravel\Passport\Passport;
-use Laravel\Passport\ClientRepository;
+use BaconQrCode;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
-use BaconQrCode;
+use Laravel\Passport\ClientRepository;
+use Laravel\Passport\Passport;
class CompanionAppsController extends ResourceController
{
@@ -19,11 +20,11 @@
*
* @param string $id Companion app identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function destroy($id)
{
- $companion = \App\CompanionApp::find($id);
+ $companion = CompanionApp::find($id);
if (!$companion) {
return $this->errorResponse(404);
}
@@ -51,9 +52,7 @@
/**
* Create a companion app.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function store(Request $request)
{
@@ -70,25 +69,25 @@
return response()->json(['status' => 'error', 'errors' => $v->errors()], 422);
}
- $app = \App\CompanionApp::create([
+ $app = CompanionApp::create([
'name' => $request->name,
- 'user_id' => $user->id,
+ 'user_id' => $user->id,
]);
return response()->json([
'status' => 'success',
'message' => self::trans('app.companion-create-success'),
- 'id' => $app->id
+ 'id' => $app->id,
]);
}
/**
- * Register a companion app.
- *
- * @param \Illuminate\Http\Request $request The API request.
- *
- * @return \Illuminate\Http\JsonResponse The response
- */
+ * Register a companion app.
+ *
+ * @param Request $request the API request
+ *
+ * @return JsonResponse The response
+ */
public function register(Request $request)
{
$user = $this->guard()->user();
@@ -114,7 +113,7 @@
\Log::info("Registering app. Notification token: {$notificationToken} Device id: {$deviceId} Name: {$name}");
- $app = \App\CompanionApp::find($companionId);
+ $app = CompanionApp::find($companionId);
if (!$app) {
return $this->errorResponse(404);
}
@@ -145,7 +144,7 @@
$renderer_style = new BaconQrCode\Renderer\RendererStyle\RendererStyle(300, 1);
$renderer_image = new BaconQrCode\Renderer\Image\SvgImageBackEnd();
$renderer = new BaconQrCode\Renderer\ImageRenderer($renderer_style, $renderer_image);
- $writer = new BaconQrCode\Writer($renderer);
+ $writer = new BaconQrCode\Writer($renderer);
return 'data:image/svg+xml;base64,' . base64_encode($writer->writeString($data));
}
@@ -153,17 +152,17 @@
/**
* List devices.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
$user = $this->guard()->user();
$search = trim(request()->input('search'));
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$pageSize = 20;
$hasMore = false;
- $result = \App\CompanionApp::where('user_id', $user->id);
+ $result = CompanionApp::where('user_id', $user->id);
$result = $result->orderBy('created_at')
->limit($pageSize + 1)
@@ -177,9 +176,9 @@
// Process the result
$result = $result->map(
- function ($device) {
+ static function ($device) {
return array_merge($device->toArray(), [
- 'isReady' => $device->isPaired()
+ 'isReady' => $device->isPaired(),
]);
}
);
@@ -198,11 +197,11 @@
*
* @param string $id CompanionApp identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
- $result = \App\CompanionApp::find($id);
+ $result = CompanionApp::find($id);
if (!$result) {
return $this->errorResponse(404);
}
@@ -214,19 +213,19 @@
return response()->json(array_merge($result->toArray(), [
'statusInfo' => [
- 'isReady' => $result->isPaired()
- ]
+ 'isReady' => $result->isPaired(),
+ ],
]));
}
/**
* Retrieve the pairing information encoded into a qrcode image.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function pairing($id)
{
- $result = \App\CompanionApp::find($id);
+ $result = CompanionApp::find($id);
if (!$result) {
return $this->errorResponse(404);
}
@@ -247,7 +246,7 @@
'personal_access_client' => 0,
'password_client' => 1,
'revoked' => false,
- 'allowed_scopes' => ["mfa", "fs"]
+ 'allowed_scopes' => ["mfa", "fs"],
]);
$client->save();
diff --git a/src/app/Http/Controllers/API/V4/ConfigController.php b/src/app/Http/Controllers/API/V4/ConfigController.php
--- a/src/app/Http/Controllers/API/V4/ConfigController.php
+++ b/src/app/Http/Controllers/API/V4/ConfigController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\Controller;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ConfigController extends Controller
@@ -10,7 +11,7 @@
/**
* Get the per-user webmail configuration.
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function webmail(Request $request)
{
diff --git a/src/app/Http/Controllers/API/V4/DomainsController.php b/src/app/Http/Controllers/API/V4/DomainsController.php
--- a/src/app/Http/Controllers/API/V4/DomainsController.php
+++ b/src/app/Http/Controllers/API/V4/DomainsController.php
@@ -4,7 +4,10 @@
use App\Domain;
use App\Http\Controllers\RelationController;
+use App\Jobs\Domain\CreateJob;
+use App\Package;
use App\Rules\UserEmailDomain;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -26,13 +29,12 @@
/** @var array Resource relation method arguments */
protected $relationArgs = [true, false];
-
/**
* Confirm ownership of the specified domain (via DNS check).
*
* @param int $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse|void
+ * @return JsonResponse|void
*/
public function confirm($id)
{
@@ -48,15 +50,15 @@
if (!$domain->confirm()) {
return response()->json([
- 'status' => 'error',
- 'message' => self::trans('app.domain-confirm-error'),
+ 'status' => 'error',
+ 'message' => self::trans('app.domain-confirm-error'),
]);
}
return response()->json([
- 'status' => 'success',
- 'statusInfo' => self::statusInfo($domain),
- 'message' => self::trans('app.domain-confirm-success'),
+ 'status' => 'success',
+ 'statusInfo' => self::statusInfo($domain),
+ 'message' => self::trans('app.domain-confirm-success'),
]);
}
@@ -65,7 +67,7 @@
*
* @param string $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function destroy($id)
{
@@ -88,17 +90,15 @@
$domain->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.domain-delete-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.domain-delete-success'),
]);
}
/**
* Create a domain.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function store(Request $request)
{
@@ -113,7 +113,7 @@
$v = Validator::make(
$request->all(),
[
- 'namespace' => ['required', 'string', new UserEmailDomain()]
+ 'namespace' => ['required', 'string', new UserEmailDomain()],
]
);
@@ -137,7 +137,7 @@
if (
empty($request->package)
- || !($package = \App\Package::withObjectTenantContext($owner)->find($request->package))
+ || !($package = Package::withObjectTenantContext($owner)->find($request->package))
) {
$errors = ['package' => self::trans('validation.packagerequired')];
return response()->json(['status' => 'error', 'errors' => $errors], 422);
@@ -157,8 +157,8 @@
// Create the domain
$domain = Domain::create([
- 'namespace' => $namespace,
- 'type' => \App\Domain::TYPE_EXTERNAL,
+ 'namespace' => $namespace,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
$domain->assignPackage($package, $owner);
@@ -166,8 +166,8 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.domain-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.domain-create-success'),
]);
}
@@ -176,7 +176,7 @@
*
* @param string $id Domain identifier
*
- * @return \Illuminate\Http\JsonResponse|void
+ * @return JsonResponse|void
*/
public function show($id)
{
@@ -223,7 +223,7 @@
// copy MX entries from an existing domain
if ($master = \config('dns.copyfrom')) {
// TODO: cache this lookup
- foreach ((array) dns_get_record($master, DNS_MX) as $entry) {
+ foreach ((array) dns_get_record($master, \DNS_MX) as $entry) {
$entries[] = sprintf(
"@\t%s\t%s\tMX\t%d %s.",
\config('dns.ttl', $entry['ttl']),
@@ -233,7 +233,7 @@
);
}
} elseif ($static = \config('dns.static')) {
- $entries[] = strtr($static, array('\n' => "\n", '%s' => $namespace));
+ $entries[] = strtr($static, ['\n' => "\n", '%s' => $namespace]);
}
// display SPF settings
@@ -277,7 +277,7 @@
/**
* Domain status (extended) information.
*
- * @param \App\Domain $domain Domain object
+ * @param Domain $domain Domain object
*
* @return array Status information
*/
@@ -298,8 +298,8 @@
/**
* Execute (synchronously) specified step in a domain setup process.
*
- * @param \App\Domain $domain Domain object
- * @param string $step Step identifier (as in self::statusInfo())
+ * @param Domain $domain Domain object
+ * @param string $step Step identifier (as in self::statusInfo())
*
* @return bool|null True if the execution succeeded, False if not, Null when
* the job has been sent to the worker (result unknown)
@@ -310,14 +310,12 @@
switch ($step) {
case 'domain-ldap-ready':
// Use worker to do the job
- \App\Jobs\Domain\CreateJob::dispatch($domain->id);
+ CreateJob::dispatch($domain->id);
return null;
-
case 'domain-verified':
// Domain existence not verified
$domain->verify();
return $domain->isVerified();
-
case 'domain-confirmed':
// Domain ownership confirmation
$domain->confirm();
diff --git a/src/app/Http/Controllers/API/V4/FsController.php b/src/app/Http/Controllers/API/V4/FsController.php
--- a/src/app/Http/Controllers/API/V4/FsController.php
+++ b/src/app/Http/Controllers/API/V4/FsController.php
@@ -7,12 +7,14 @@
use App\Http\Controllers\RelationController;
use App\Rules\FileName;
use App\Support\Facades\Storage;
-use App\User;
use App\Utils;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
+use Symfony\Component\HttpFoundation\StreamedResponse;
class FsController extends RelationController
{
@@ -29,13 +31,12 @@
/** @var string Resource model name */
protected $model = Item::class;
-
/**
* Delete a file.
*
* @param string $id File identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function destroy($id)
{
@@ -55,17 +56,17 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => $message ?? self::trans('app.file-delete-success'),
+ 'status' => 'success',
+ 'message' => $message ?? self::trans('app.file-delete-success'),
]);
}
/**
* Fetch content of a file.
*
- * @param string $id The download (not file) identifier.
+ * @param string $id the download (not file) identifier
*
- * @return \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\StreamedResponse
+ * @return Response|StreamedResponse
*/
public function download($id)
{
@@ -87,9 +88,9 @@
/**
* Fetch the permissions for the specific file.
*
- * @param string $fileId The file identifier.
+ * @param string $fileId the file identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function getPermissions($fileId)
{
@@ -101,7 +102,7 @@
}
$result = $file->properties()->whereLike('key', 'share-%')->get()->map(
- fn($prop) => self::permissionToClient($prop->key, $prop->value)
+ static fn ($prop) => self::permissionToClient($prop->key, $prop->value)
);
$result = [
@@ -115,9 +116,9 @@
/**
* Add permission for the specific file.
*
- * @param string $fileId The file identifier.
+ * @param string $fileId the file identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function createPermission($fileId)
{
@@ -130,8 +131,8 @@
// Validate/format input
$v = Validator::make(request()->all(), [
- 'user' => 'email|required',
- 'permissions' => 'string|required',
+ 'user' => 'email|required',
+ 'permissions' => 'string|required',
]);
$errors = $v->fails() ? $v->errors()->toArray() : [];
@@ -156,29 +157,29 @@
}
// Create the property (with a unique id)
- while ($shareId = 'share-' . \App\Utils::uuidStr()) {
+ while ($shareId = 'share-' . Utils::uuidStr()) {
if (!Property::where('key', $shareId)->exists()) {
break;
}
}
- $file->setProperty($shareId, "$user:$acl");
+ $file->setProperty($shareId, "{$user}:{$acl}");
- $result = self::permissionToClient($shareId, "$user:$acl");
+ $result = self::permissionToClient($shareId, "{$user}:{$acl}");
return response()->json($result + [
- 'status' => 'success',
- 'message' => self::trans('app.file-permissions-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.file-permissions-create-success'),
]);
}
/**
* Delete file permission.
*
- * @param string $fileId The file identifier.
- * @param string $id The file permission identifier.
+ * @param string $fileId the file identifier
+ * @param string $id the file permission identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function deletePermission($fileId, $id)
{
@@ -198,19 +199,19 @@
$property->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.file-permissions-delete-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.file-permissions-delete-success'),
]);
}
/**
* Update file permission.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $fileId The file identifier.
- * @param string $id The file permission identifier.
+ * @param Request $request the API request
+ * @param string $fileId the file identifier
+ * @param string $id the file permission identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function updatePermission(Request $request, $fileId, $id)
{
@@ -229,8 +230,8 @@
// Validate/format input
$v = Validator::make($request->all(), [
- 'user' => 'email|required',
- 'permissions' => 'string|required',
+ 'user' => 'email|required',
+ 'permissions' => 'string|required',
]);
$errors = $v->fails() ? $v->errors()->toArray() : [];
@@ -243,7 +244,7 @@
$user = \strtolower($request->input('user'));
- if (empty($errors['user']) && strpos($property->value, "$user:") !== 0) {
+ if (empty($errors['user']) && !str_starts_with($property->value, "{$user}:")) {
if ($file->properties()->whereLike('key', 'share-%')->whereLike('value', "{$user}:%")->exists()) {
$errors['user'] = self::trans('validation.file-perm-exists');
}
@@ -253,26 +254,26 @@
return response()->json(['status' => 'error', 'errors' => $errors], 422);
}
- $property->value = "$user:$acl";
+ $property->value = "{$user}:{$acl}";
$property->save();
$result = self::permissionToClient($property->key, $property->value);
return response()->json($result + [
- 'status' => 'success',
- 'message' => self::trans('app.file-permissions-update-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.file-permissions-update-success'),
]);
}
/**
* Listing of files (and folders).
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
$search = trim(request()->input('search'));
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$parent = request()->input('parent');
$type = request()->input('type');
$pageSize = 100;
@@ -340,9 +341,9 @@
/**
* Fetch the specific file metadata or content.
*
- * @param string $id The file identifier.
+ * @param string $id the file identifier
*
- * @return \Illuminate\Http\JsonResponse|\Symfony\Component\HttpFoundation\StreamedResponse
+ * @return JsonResponse|StreamedResponse
*/
public function show($id)
{
@@ -378,9 +379,9 @@
/**
* Create a new file.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -460,10 +461,10 @@
/**
* Update a file.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id File identifier
+ * @param Request $request the API request
+ * @param string $id File identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -559,10 +560,10 @@
/**
* Upload a file content.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Upload (not file) identifier
+ * @param Request $request the API request
+ * @param string $id Upload (not file) identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function upload(Request $request, $id)
{
@@ -591,9 +592,9 @@
/**
* Create a new collection.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
protected function createCollection(Request $request)
{
@@ -643,9 +644,9 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'id' => $item->id,
- 'message' => self::trans('app.collection-create-success'),
+ 'status' => 'success',
+ 'id' => $item->id,
+ 'message' => self::trans('app.collection-create-success'),
]);
}
@@ -660,7 +661,7 @@
if ($request->has('deduplicate-property')) {
// query for item by deduplicate-value
$item = $user->fsItems()->select('fs_items.*')
- ->join('fs_properties', function ($join) use ($request) {
+ ->join('fs_properties', static function ($join) use ($request) {
$join->on('fs_items.id', '=', 'fs_properties.item_id')
->where('fs_properties.key', $request->input('deduplicate-property'));
})
@@ -688,9 +689,9 @@
*/
protected static function permissionToClient(string $id, string $value): array
{
- list($user, $acl) = explode(':', $value);
+ [$user, $acl] = explode(':', $value);
- $perms = strpos($acl, self::WRITE) !== false ? 'read-write' : 'read-only';
+ $perms = str_contains($acl, self::WRITE) ? 'read-write' : 'read-only';
return [
'id' => $id,
@@ -727,7 +728,7 @@
* @param string $fileId File or file permission identifier
* @param ?string $permission Required access rights
*
- * @return \App\Fs\Item|int File object or error code
+ * @return Item|int File object or error code
*/
protected function inputItem($fileId, $permission)
{
@@ -742,9 +743,9 @@
return 404;
}
- list($acl_user, $acl) = explode(':', $property->value);
+ [$acl_user, $acl] = explode(':', $property->value);
- if (!$permission || $acl_user != $user->email || strpos($acl, $permission) === false) {
+ if (!$permission || $acl_user != $user->email || !str_contains($acl, $permission)) {
return 403;
}
@@ -761,7 +762,7 @@
return 403;
}
- if ($file->type & Item::TYPE_FILE && $file->type & Item::TYPE_INCOMPLETE) {
+ if ($file->type & Item::TYPE_FILE && $file->type & Item::TYPE_INCOMPLETE) {
return 404;
}
diff --git a/src/app/Http/Controllers/API/V4/GroupsController.php b/src/app/Http/Controllers/API/V4/GroupsController.php
--- a/src/app/Http/Controllers/API/V4/GroupsController.php
+++ b/src/app/Http/Controllers/API/V4/GroupsController.php
@@ -2,11 +2,15 @@
namespace App\Http\Controllers\API\V4;
-use App\Http\Controllers\RelationController;
use App\Domain;
use App\Group;
+use App\Http\Controllers\RelationController;
+use App\Jobs\Group\CreateJob;
+use App\Rules\ExternalEmail;
use App\Rules\GroupName;
+use App\Rules\UserEmailLocal;
use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -25,11 +29,10 @@
/** @var array Common object properties in the API response */
protected $objectProps = ['email', 'name'];
-
/**
* Group status (extended) information
*
- * @param \App\Group $group Group object
+ * @param Group $group Group object
*
* @return array Status information
*/
@@ -47,9 +50,9 @@
/**
* Create a new group record.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -68,10 +71,10 @@
];
// Validate group address
- if ($error = GroupsController::validateGroupEmail($email, $owner)) {
+ if ($error = self::validateGroupEmail($email, $owner)) {
$errors['email'] = $error;
} else {
- list(, $domainName) = explode('@', $email);
+ [, $domainName] = explode('@', $email);
$rules['name'] = ['required', 'string', new GroupName($owner, $domainName)];
}
@@ -88,7 +91,7 @@
} else {
foreach ($members as $i => $member) {
if (is_string($member) && !empty($member)) {
- if ($error = GroupsController::validateMemberEmail($member, $owner)) {
+ if ($error = self::validateMemberEmail($member, $owner)) {
$errors['members'][$i] = $error;
} elseif (\strtolower($member) === \strtolower($email)) {
$errors['members'][$i] = self::trans('validation.memberislist');
@@ -117,18 +120,18 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.distlist-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.distlist-create-success'),
]);
}
/**
* Update a group.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Group identifier
+ * @param Request $request the API request
+ * @param string $id Group identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -151,7 +154,7 @@
// Validate the group name
if ($name !== null && $name != $group->name) {
- list(, $domainName) = explode('@', $group->email);
+ [, $domainName] = explode('@', $group->email);
$rules = ['name' => ['required', 'string', new GroupName($owner, $domainName)]];
$v = Validator::make($request->all(), $rules);
@@ -169,7 +172,7 @@
} else {
foreach ((array) $members as $i => $member) {
if (is_string($member) && !empty($member)) {
- if ($error = GroupsController::validateMemberEmail($member, $owner)) {
+ if ($error = self::validateMemberEmail($member, $owner)) {
$errors['members'][$i] = $error;
} elseif (\strtolower($member) === $group->email) {
$errors['members'][$i] = self::trans('validation.memberislist');
@@ -190,16 +193,16 @@
$group->save();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.distlist-update-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.distlist-update-success'),
]);
}
/**
* Execute (synchronously) specified step in a group setup process.
*
- * @param \App\Group $group Group object
- * @param string $step Step identifier (as in self::statusInfo())
+ * @param Group $group Group object
+ * @param string $step Step identifier (as in self::statusInfo())
*
* @return bool|null True if the execution succeeded, False if not, Null when
* the job has been sent to the worker (result unknown)
@@ -207,14 +210,14 @@
public static function execProcessStep(Group $group, string $step): ?bool
{
try {
- if (strpos($step, 'domain-') === 0) {
+ if (str_starts_with($step, 'domain-')) {
return DomainsController::execProcessStep($group->domain(), $step);
}
switch ($step) {
case 'distlist-ldap-ready':
// Group not in LDAP, create it
- \App\Jobs\Group\CreateJob::dispatch($group->id);
+ CreateJob::dispatch($group->id);
return null;
}
} catch (\Exception $e) {
@@ -227,24 +230,24 @@
/**
* Validate an email address for use as a group email
*
- * @param string $email Email address
- * @param \App\User $user The group owner
+ * @param string $email Email address
+ * @param User $user The group owner
*
* @return ?string Error message on validation error
*/
- public static function validateGroupEmail($email, \App\User $user): ?string
+ public static function validateGroupEmail($email, User $user): ?string
{
if (empty($email)) {
return self::trans('validation.required', ['attribute' => 'email']);
}
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return self::trans('validation.entryinvalid', ['attribute' => 'email']);
}
- list($login, $domain) = explode('@', \strtolower($email));
+ [$login, $domain] = explode('@', \strtolower($email));
- if (strlen($login) === 0 || strlen($domain) === 0) {
+ if ($login === '' || $domain === '') {
return self::trans('validation.entryinvalid', ['attribute' => 'email']);
}
@@ -265,7 +268,7 @@
// Validate login part alone
$v = Validator::make(
['email' => $login],
- ['email' => [new \App\Rules\UserEmailLocal(true)]]
+ ['email' => [new UserEmailLocal(true)]]
);
if ($v->fails()) {
@@ -292,16 +295,16 @@
/**
* Validate an email address for use as a group member
*
- * @param string $email Email address
- * @param \App\User $user The group owner
+ * @param string $email Email address
+ * @param User $user The group owner
*
* @return ?string Error message on validation error
*/
- public static function validateMemberEmail($email, \App\User $user): ?string
+ public static function validateMemberEmail($email, User $user): ?string
{
$v = Validator::make(
['email' => $email],
- ['email' => [new \App\Rules\ExternalEmail()]]
+ ['email' => [new ExternalEmail()]]
);
if ($v->fails()) {
@@ -310,7 +313,7 @@
// A local domain user must exist
if (!User::where('email', \strtolower($email))->first()) {
- list($login, $domain) = explode('@', \strtolower($email));
+ [$login, $domain] = explode('@', \strtolower($email));
$domain = Domain::where('namespace', $domain)->first();
diff --git a/src/app/Http/Controllers/API/V4/HealthController.php b/src/app/Http/Controllers/API/V4/HealthController.php
--- a/src/app/Http/Controllers/API/V4/HealthController.php
+++ b/src/app/Http/Controllers/API/V4/HealthController.php
@@ -3,13 +3,14 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\Controller;
+use Illuminate\Http\JsonResponse;
class HealthController extends Controller
{
/**
* Liveness probe
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function liveness()
{
@@ -21,7 +22,7 @@
/**
* Readiness probe
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function readiness()
{
diff --git a/src/app/Http/Controllers/API/V4/LicenseController.php b/src/app/Http/Controllers/API/V4/LicenseController.php
--- a/src/app/Http/Controllers/API/V4/LicenseController.php
+++ b/src/app/Http/Controllers/API/V4/LicenseController.php
@@ -4,7 +4,7 @@
use App\Http\Controllers\Controller;
use App\License;
-use Carbon\Carbon;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -15,7 +15,7 @@
*
* @param string $type License type
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function license(Request $request, string $type)
{
@@ -49,11 +49,11 @@
}
// Slim down the result set
- $licenses = $licenses->map(function ($license) {
- return [
- 'key' => $license->key,
- 'type' => $license->type,
- ];
+ $licenses = $licenses->map(static function ($license) {
+ return [
+ 'key' => $license->key,
+ 'type' => $license->type,
+ ];
});
return response()->json([
diff --git a/src/app/Http/Controllers/API/V4/MeetController.php b/src/app/Http/Controllers/API/V4/MeetController.php
--- a/src/app/Http/Controllers/API/V4/MeetController.php
+++ b/src/app/Http/Controllers/API/V4/MeetController.php
@@ -4,7 +4,9 @@
use App\Http\Controllers\Controller;
use App\Meet\Room;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
class MeetController extends Controller
@@ -15,7 +17,7 @@
*
* @param string $id Room identifier (name)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function joinRoom($id)
{
@@ -144,9 +146,9 @@
/**
* Webhook as triggered from the Meet server
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function webhook(Request $request)
{
@@ -172,7 +174,6 @@
}
break;
-
case 'joinRequestAccepted':
case 'joinRequestDenied':
$room = Room::where('session_id', $sessionId)->first();
diff --git a/src/app/Http/Controllers/API/V4/MetricsController.php b/src/app/Http/Controllers/API/V4/MetricsController.php
--- a/src/app/Http/Controllers/API/V4/MetricsController.php
+++ b/src/app/Http/Controllers/API/V4/MetricsController.php
@@ -4,9 +4,12 @@
use App\Http\Controllers\Controller;
use App\Payment;
+use App\Transaction;
use App\User;
use App\Wallet;
-use App\Transaction;
+use Carbon\Carbon;
+use Illuminate\Database\Query\JoinClause;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
use Laravel\Horizon\Contracts\JobRepository;
use Laravel\Horizon\Contracts\MetricsRepository;
@@ -18,9 +21,8 @@
{
if ($tenantId = \config('app.tenant_id')) {
return $query->where('users.tenant_id', $tenantId);
- } else {
- return $query->whereNull('users.tenant_id');
}
+ return $query->whereNull('users.tenant_id');
}
/**
@@ -43,10 +45,10 @@
// Count all non-degraded and non-deleted users with any successful payment
$count = DB::table('users')
- ->joinSub($wallets, 'wallets', function ($join) {
+ ->joinSub($wallets, 'wallets', static function ($join) {
$join->on('users.id', '=', 'wallets.user_id');
})
- ->joinSub($transactions, 'transactions', function ($join) {
+ ->joinSub($transactions, 'transactions', static function ($join) {
$join->on('wallets.id', '=', 'transactions.wallet_id');
})
->whereNull('users.deleted_at')
@@ -63,7 +65,7 @@
{
$count = Wallet::select('wallets.id')
->join('users', 'users.id', '=', 'wallets.user_id')
- ->join('wallet_settings', function (\Illuminate\Database\Query\JoinClause $join) {
+ ->join('wallet_settings', static function (JoinClause $join) {
$join->on('wallet_settings.wallet_id', '=', 'wallets.id')
->where('wallet_settings.key', '=', 'mandate_balance');
})
@@ -79,37 +81,35 @@
{
$recentJobs = app(JobRepository::class)->countRecent();
$recentFailedJobs = app(JobRepository::class)->countRecentlyFailed();
- $jobsPerMinute = intval(app(MetricsRepository::class)->jobsProcessedPerMinute());
+ $jobsPerMinute = (int) app(MetricsRepository::class)->jobsProcessedPerMinute();
$text = <<<EOF
- # HELP kolab_horizon_recent_jobs Number of jobs in past 7 days
- # TYPE kolab_horizon_recent_jobs gauge
- kolab_horizon_recent_jobs{instance="$appDomain", tenant="$tenantId"} $recentJobs
- # HELP kolab_horizon_recent_failed_jobs Number of jobs failed in past 7 days
- # TYPE kolab_horizon_recent_failed_jobs gauge
- kolab_horizon_recent_failed_jobs{instance="$appDomain", tenant="$tenantId"} $recentFailedJobs
- # HELP kolab_horizon_jobs_per_minute Number of jobs processed per minute
- # TYPE kolab_horizon_jobs_per_minute gauge
- kolab_horizon_jobs_per_minute{instance="$appDomain", tenant="$tenantId"} $jobsPerMinute
-
- EOF;
-
- // phpcs:disable
+ # HELP kolab_horizon_recent_jobs Number of jobs in past 7 days
+ # TYPE kolab_horizon_recent_jobs gauge
+ kolab_horizon_recent_jobs{instance="{$appDomain}", tenant="{$tenantId}"} {$recentJobs}
+ # HELP kolab_horizon_recent_failed_jobs Number of jobs failed in past 7 days
+ # TYPE kolab_horizon_recent_failed_jobs gauge
+ kolab_horizon_recent_failed_jobs{instance="{$appDomain}", tenant="{$tenantId}"} {$recentFailedJobs}
+ # HELP kolab_horizon_jobs_per_minute Number of jobs processed per minute
+ # TYPE kolab_horizon_jobs_per_minute gauge
+ kolab_horizon_jobs_per_minute{instance="{$appDomain}", tenant="{$tenantId}"} {$jobsPerMinute}
+
+ EOF;
+
foreach (app(WorkloadRepository::class)->get() as $workloadMetrics) {
$queueName = $workloadMetrics['name'] ?? 'unknown';
$queueSize = $workloadMetrics['length'] ?? 0;
$queueWaitTime = $workloadMetrics['wait'] ?? 0;
$text .= <<<EOF
- # HELP kolab_horizon_queue_size Number of jobs in queue
- # TYPE kolab_horizon_queue_size gauge
- kolab_horizon_queue_size{instance="$appDomain", tenant="$tenantId", queue="$queueName"} $queueSize
- # HELP kolab_horizon_queue_wait_seconds Time until queue is empty
- # TYPE kolab_horizon_queue_wait_seconds gauge
- kolab_horizon_queue_wait_seconds{instance="$appDomain", tenant="$tenantId", queue="$queueName"} $queueWaitTime
-
- EOF;
+ # HELP kolab_horizon_queue_size Number of jobs in queue
+ # TYPE kolab_horizon_queue_size gauge
+ kolab_horizon_queue_size{instance="{$appDomain}", tenant="{$tenantId}", queue="{$queueName}"} {$queueSize}
+ # HELP kolab_horizon_queue_wait_seconds Time until queue is empty
+ # TYPE kolab_horizon_queue_wait_seconds gauge
+ kolab_horizon_queue_wait_seconds{instance="{$appDomain}", tenant="{$tenantId}", queue="{$queueName}"} {$queueWaitTime}
+
+ EOF;
}
- // phpcs:enable
return $text;
}
@@ -117,7 +117,7 @@
/**
* Expose kolab metrics
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function metrics()
{
@@ -130,7 +130,7 @@
$numberOfPayers = Payment::where('status', Payment::STATUS_PAID)
->distinct()->count('wallet_id');
$numberOfActivePayers = Payment::where('status', Payment::STATUS_PAID)
- ->where('created_at', '>', \Carbon\Carbon::now()->subMonths(1))
+ ->where('created_at', '>', Carbon::now()->subMonths(1))
->distinct()->count('wallet_id');
$numberOfBilledTransactions = Transaction::where('type', Transaction::ENTITLEMENT_BILLED)->count();
@@ -149,16 +149,16 @@
$numberOfWalletsWithBalanceBelowManadate = $this->numberOfWalletsWithBalanceBelowManadate();
// Should be ~0 (otherwise a cleanup job failed)
$numberOfDeletedUserWithMissingCleanup = User::onlyTrashed()
- ->where('deleted_at', '<', \Carbon\Carbon::now()->subDays(1))
- ->where(function ($query) use ($with_ldap) {
+ ->where('deleted_at', '<', Carbon::now()->subDays(1))
+ ->where(static function ($query) use ($with_ldap) {
$query = $query->where('status', '&', User::STATUS_IMAP_READY);
if ($with_ldap) {
$query->orWhere('status', '&', User::STATUS_LDAP_READY);
}
})->count();
- $numberOfUserWithFailedInit = User::where('created_at', '<', \Carbon\Carbon::now()->subDays(1));
- $numberOfUserWithFailedInit->where(function ($query) use ($with_ldap) {
+ $numberOfUserWithFailedInit = User::where('created_at', '<', Carbon::now()->subDays(1));
+ $numberOfUserWithFailedInit->where(static function ($query) use ($with_ldap) {
$query = $query->whereNot('status', '&', User::STATUS_IMAP_READY)
->orWhereNot('status', '&', User::STATUS_ACTIVE);
if ($with_ldap) {
@@ -175,47 +175,45 @@
$numberOfPaidPayments = Payment::where('status', Payment::STATUS_PAID)->count();
$numberOfFailedPayments = Payment::where('status', Payment::STATUS_FAILED)->count();
- // phpcs:disable
$text = <<<EOF
- # HELP kolab_users_count Number of users with a certain state
- # TYPE kolab_users_count gauge
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="existing"} $numberOfUsers
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="active"} $numberOfActiveUsers
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="trashed"} $numberOfDeletedUsers
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="suspended"} $numberOfSuspendedUsers
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="restricted"} $numberOfRestrictedUsers
- kolab_users_count{instance="$appDomain", tenant="$tenantId", state="degraded"} $numberOfDegradedUsers
- # HELP kolab_users_paying_count Number of paying users
- # TYPE kolab_users_paying_count gauge
- kolab_users_paying_count{instance="$appDomain", tenant="$tenantId"} $numberOfPayingUsers
- # HELP kolab_wallets_balance_below_mandate_amount_count Number of wallets requiring topup
- # TYPE kolab_wallets_balance_below_mandate_amount_count gauge
- kolab_wallets_balance_below_mandate_amount{instance="$appDomain", tenant="$tenantId"} $numberOfWalletsWithBalanceBelowManadate
- # HELP kolab_users_deleted_with_missing_cleanup Number of users that are still imap/ldap ready
- # TYPE kolab_users_deleted_with_missing_cleanup gauge
- kolab_users_deleted_with_missing_cleanup{instance="$appDomain", tenant="$tenantId"} $numberOfDeletedUserWithMissingCleanup
- # HELP kolab_users_failed_init Number of users that are still imap/ldap ready
- # TYPE kolab_users_failed_init gauge
- kolab_users_failed_init{instance="$appDomain", tenant="$tenantId"} $numberOfUserWithFailedInit
- # HELP kolab_transactions_count Number of transactions
- # TYPE kolab_transactions_count gauge
- kolab_transactions_count{instance="$appDomain", tenant="$tenantId", type="billed"} $numberOfBilledTransactions
- kolab_transactions_count{instance="$appDomain", tenant="$tenantId", type="refund"} $numberOfRefundTransactions
- kolab_transactions_count{instance="$appDomain", tenant="$tenantId", type="chargeback"} $numberOfChargebackTransactions
- # HELP kolab_payments_paid_count Number of paid payments
- # TYPE kolab_payments_paid_count gauge
- kolab_payments_count{instance="$appDomain", tenant="$tenantId", status="paid"} $numberOfPaidPayments
- kolab_payments_count{instance="$appDomain", tenant="$tenantId", status="failed"} $numberOfFailedPayments
- # HELP kolab_payers_count Number of distinct wallets with payments
- # TYPE kolab_payers_count gauge
- kolab_payers_count{instance="$appDomain", tenant="$tenantId"} $numberOfPayers
- # HELP kolab_payers_active_count Number of distinct wallets with payments in past month
- # TYPE kolab_payers_active_count gauge
- kolab_payers_active_count{instance="$appDomain", tenant="$tenantId"} $numberOfActivePayers
- $horizon
- \n
- EOF;
- // phpcs:enable
+ # HELP kolab_users_count Number of users with a certain state
+ # TYPE kolab_users_count gauge
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="existing"} {$numberOfUsers}
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="active"} {$numberOfActiveUsers}
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="trashed"} {$numberOfDeletedUsers}
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="suspended"} {$numberOfSuspendedUsers}
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="restricted"} {$numberOfRestrictedUsers}
+ kolab_users_count{instance="{$appDomain}", tenant="{$tenantId}", state="degraded"} {$numberOfDegradedUsers}
+ # HELP kolab_users_paying_count Number of paying users
+ # TYPE kolab_users_paying_count gauge
+ kolab_users_paying_count{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfPayingUsers}
+ # HELP kolab_wallets_balance_below_mandate_amount_count Number of wallets requiring topup
+ # TYPE kolab_wallets_balance_below_mandate_amount_count gauge
+ kolab_wallets_balance_below_mandate_amount{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfWalletsWithBalanceBelowManadate}
+ # HELP kolab_users_deleted_with_missing_cleanup Number of users that are still imap/ldap ready
+ # TYPE kolab_users_deleted_with_missing_cleanup gauge
+ kolab_users_deleted_with_missing_cleanup{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfDeletedUserWithMissingCleanup}
+ # HELP kolab_users_failed_init Number of users that are still imap/ldap ready
+ # TYPE kolab_users_failed_init gauge
+ kolab_users_failed_init{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfUserWithFailedInit}
+ # HELP kolab_transactions_count Number of transactions
+ # TYPE kolab_transactions_count gauge
+ kolab_transactions_count{instance="{$appDomain}", tenant="{$tenantId}", type="billed"} {$numberOfBilledTransactions}
+ kolab_transactions_count{instance="{$appDomain}", tenant="{$tenantId}", type="refund"} {$numberOfRefundTransactions}
+ kolab_transactions_count{instance="{$appDomain}", tenant="{$tenantId}", type="chargeback"} {$numberOfChargebackTransactions}
+ # HELP kolab_payments_paid_count Number of paid payments
+ # TYPE kolab_payments_paid_count gauge
+ kolab_payments_count{instance="{$appDomain}", tenant="{$tenantId}", status="paid"} {$numberOfPaidPayments}
+ kolab_payments_count{instance="{$appDomain}", tenant="{$tenantId}", status="failed"} {$numberOfFailedPayments}
+ # HELP kolab_payers_count Number of distinct wallets with payments
+ # TYPE kolab_payers_count gauge
+ kolab_payers_count{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfPayers}
+ # HELP kolab_payers_active_count Number of distinct wallets with payments in past month
+ # TYPE kolab_payers_active_count gauge
+ kolab_payers_active_count{instance="{$appDomain}", tenant="{$tenantId}"} {$numberOfActivePayers}
+ {$horizon}
+ \n
+ EOF;
return response(
$text,
diff --git a/src/app/Http/Controllers/API/V4/NGINXController.php b/src/app/Http/Controllers/API/V4/NGINXController.php
--- a/src/app/Http/Controllers/API/V4/NGINXController.php
+++ b/src/app/Http/Controllers/API/V4/NGINXController.php
@@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
class NGINXController extends Controller
{
@@ -14,9 +15,9 @@
* @param string $login The login name
* @param string $password The password
*
- * @return \App\User The user
+ * @return User The user
*
- * @throws \Exception If the authorization fails.
+ * @throws \Exception if the authorization fails
*/
private function authorizeRequestCredentialsOnly($login, $password)
{
@@ -40,13 +41,13 @@
/**
* Authorize with the provided credentials.
*
- * @param string $login The login name
+ * @param string $login The login name
* @param string $password The password
* @param string $clientIP The client ip
*
- * @return \App\User The user
+ * @return User The user
*
- * @throws \Exception If the authorization fails.
+ * @throws \Exception if the authorization fails
*/
private function authorizeRequest($login, $password, $clientIP)
{
@@ -79,7 +80,7 @@
/**
* Convert domain.tld\username into username@domain for activesync
*
- * @param string $username The original username.
+ * @param string $username the original username
*
* @return string The username in canonical form
*/
@@ -100,25 +101,25 @@
/**
* Authentication request from the ngx_http_auth_request_module
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function httpauth(Request $request)
{
- /**
- Php-Auth-Pw: simple123
- Php-Auth-User: john@kolab.org
- Sec-Fetch-Dest: document
- Sec-Fetch-Mode: navigate
- Sec-Fetch-Site: cross-site
- Sec-Gpc: 1
- Upgrade-Insecure-Requests: 1
- User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
- X-Forwarded-For: 31.10.153.58
- X-Forwarded-Proto: https
- X-Original-Uri: /iRony/
- X-Real-Ip: 31.10.153.58
+ /*
+ * Php-Auth-Pw: simple123
+ * Php-Auth-User: john@kolab.org
+ * Sec-Fetch-Dest: document
+ * Sec-Fetch-Mode: navigate
+ * Sec-Fetch-Site: cross-site
+ * Sec-Gpc: 1
+ * Upgrade-Insecure-Requests: 1
+ * User-Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0
+ * X-Forwarded-For: 31.10.153.58
+ * X-Forwarded-Proto: https
+ * X-Original-Uri: /iRony/
+ * X-Real-Ip: 31.10.153.58
*/
$username = $this->normalizeUsername($request->headers->get('Php-Auth-User', ''));
@@ -149,9 +150,9 @@
/**
* Authentication request from the cyrus sasl
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function cyrussasl(Request $request)
{
@@ -169,17 +170,17 @@
$password = $array[2];
if (!empty($realm)) {
- $username = "$username@$realm";
+ $username = "{$username}@{$realm}";
}
try {
$this->authorizeRequestCredentialsOnly($username, $password);
} catch (\Exception $e) {
- \Log::debug("Authentication attempt failed for $username: {$e->getMessage()}");
+ \Log::debug("Authentication attempt failed for {$username}: {$e->getMessage()}");
return response('', 403);
}
- \Log::debug("Authentication attempt succeeded for $username");
+ \Log::debug("Authentication attempt succeeded for {$username}");
return response('');
}
@@ -189,13 +190,13 @@
* @todo: Separate IMAP(+STARTTLS) from IMAPS, same for SMTP/submission. =>
* I suppose that's not necessary given that we have the information avialable in the headers?
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function authenticate(Request $request)
{
- /**
+ /*
* Auth-Login-Attempt: 1
* Auth-Method: plain
* Auth-Pass: simple123
@@ -237,13 +238,13 @@
/**
* Authentication request for roundcube imap.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function authenticateRoundcube(Request $request)
{
- /**
+ /*
* Auth-Login-Attempt: 1
* Auth-Method: plain
* Auth-Pass: simple123
@@ -283,11 +284,11 @@
/**
* Create an imap authentication response.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param bool $prefGuam Whether or not Guam is enabled.
- * @param string $password The password to include in the response.
+ * @param Request $request the API request
+ * @param bool $prefGuam whether or not Guam is enabled
+ * @param string $password the password to include in the response
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
private function authenticateIMAP(Request $request, $prefGuam, $password)
{
@@ -302,7 +303,7 @@
"Auth-Status" => "OK",
"Auth-Server" => gethostbyname(\config('services.imap.host')),
"Auth-Port" => $port,
- "Auth-Pass" => $password
+ "Auth-Pass" => $password,
]
);
@@ -312,10 +313,10 @@
/**
* Create an smtp authentication response.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $password The password to include in the response.
+ * @param Request $request the API request
+ * @param string $password the password to include in the response
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
private function authenticateSMTP(Request $request, $password)
{
@@ -324,7 +325,7 @@
"Auth-Status" => "OK",
"Auth-Server" => gethostbyname(\config('services.smtp.host')),
"Auth-Port" => \config('services.smtp.port'),
- "Auth-Pass" => $password
+ "Auth-Pass" => $password,
]
);
@@ -334,10 +335,10 @@
/**
* Create a failed-authentication response.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $reason The reason for the failure.
+ * @param Request $request the API request
+ * @param string $reason the reason for the failure
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
private function byebye(Request $request, $reason = null)
{
@@ -346,7 +347,7 @@
$response = response('')->withHeaders(
[
"Auth-Status" => "authentication failure",
- "Auth-Wait" => 3
+ "Auth-Wait" => 3,
]
);
diff --git a/src/app/Http/Controllers/API/V4/PackagesController.php b/src/app/Http/Controllers/API/V4/PackagesController.php
--- a/src/app/Http/Controllers/API/V4/PackagesController.php
+++ b/src/app/Http/Controllers/API/V4/PackagesController.php
@@ -2,16 +2,16 @@
namespace App\Http\Controllers\API\V4;
-use App\Package;
use App\Http\Controllers\ResourceController;
-use Illuminate\Http\Request;
+use App\Package;
+use Illuminate\Http\JsonResponse;
class PackagesController extends ResourceController
{
/**
* Display a listing of packages.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
diff --git a/src/app/Http/Controllers/API/V4/PaymentsController.php b/src/app/Http/Controllers/API/V4/PaymentsController.php
--- a/src/app/Http/Controllers/API/V4/PaymentsController.php
+++ b/src/app/Http/Controllers/API/V4/PaymentsController.php
@@ -3,11 +3,15 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\Controller;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
use App\Providers\PaymentProvider;
use App\Tenant;
+use App\Utils;
use App\Wallet;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\Validator;
class PaymentsController extends Controller
@@ -15,7 +19,7 @@
/**
* Get the auto-payment mandate info.
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function mandate()
{
@@ -32,9 +36,9 @@
/**
* Create a new auto-payment mandate.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function mandateCreate(Request $request)
{
@@ -49,8 +53,8 @@
}
$wallet->setSettings([
- 'mandate_amount' => $request->amount,
- 'mandate_balance' => $request->balance,
+ 'mandate_amount' => $request->amount,
+ 'mandate_balance' => $request->balance,
]);
$mandate = [
@@ -82,7 +86,7 @@
/**
* Revoke the auto-payment mandate.
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function mandateDelete()
{
@@ -98,17 +102,17 @@
$wallet->setSetting('mandate_disabled', null);
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.mandate-delete-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.mandate-delete-success'),
]);
}
/**
* Update a new auto-payment mandate.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function mandateUpdate(Request $request)
{
@@ -123,16 +127,16 @@
}
$wallet->setSettings([
- 'mandate_amount' => $request->amount,
- 'mandate_balance' => $request->balance,
- // Re-enable the mandate to give it a chance to charge again
- // after it has been disabled (e.g. because the mandate amount was too small)
- 'mandate_disabled' => null,
+ 'mandate_amount' => $request->amount,
+ 'mandate_balance' => $request->balance,
+ // Re-enable the mandate to give it a chance to charge again
+ // after it has been disabled (e.g. because the mandate amount was too small)
+ 'mandate_disabled' => null,
]);
// Trigger auto-payment if the balance is below the threshold
if ($wallet->balance < round($request->balance * 100)) {
- \App\Jobs\Wallet\ChargeJob::dispatch($wallet->id);
+ ChargeJob::dispatch($wallet->id);
}
$result = self::walletMandate($wallet);
@@ -145,9 +149,9 @@
/**
* Reset the auto-payment mandate, create a new payment for it.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function mandateReset(Request $request)
{
@@ -163,7 +167,7 @@
. ' ' . self::trans('app.mandate-description-suffix'),
'methodId' => $request->methodId ?: PaymentProvider::METHOD_CREDITCARD,
- 'redirectUrl' => \App\Utils::serviceUrl('/payment/status', $user->tenant_id),
+ 'redirectUrl' => Utils::serviceUrl('/payment/status', $user->tenant_id),
];
$provider = PaymentProvider::factory($wallet);
@@ -178,8 +182,8 @@
/**
* Validate an auto-payment mandate request.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param \App\Wallet $wallet The wallet
+ * @param Request $request the API request
+ * @param Wallet $wallet The wallet
*
* @return array|null List of errors on error or Null on success
*/
@@ -222,7 +226,7 @@
/**
* Get status of the last payment.
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function paymentStatus()
{
@@ -244,20 +248,20 @@
}
return response()->json([
- 'id' => $payment->id,
- 'status' => $payment->status,
- 'type' => $payment->type,
- 'statusMessage' => self::trans($label),
- 'description' => $payment->description,
+ 'id' => $payment->id,
+ 'status' => $payment->status,
+ 'type' => $payment->type,
+ 'statusMessage' => self::trans($label),
+ 'description' => $payment->description,
]);
}
/**
* Create a new payment.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -310,9 +314,7 @@
/**
* Delete a pending payment.
*
- * @param \Illuminate\Http\Request $request The API request.
- *
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
// TODO currently unused
// public function cancel(Request $request)
@@ -346,7 +348,7 @@
*
* @param string $provider Provider name
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function webhook($provider)
{
@@ -362,7 +364,7 @@
/**
* Returns auto-payment mandate info for the specified wallet
*
- * @param \App\Wallet $wallet A wallet object
+ * @param Wallet $wallet A wallet object
*
* @return array A mandate metadata
*/
@@ -396,9 +398,9 @@
/**
* List supported payment methods.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function paymentMethods(Request $request)
{
@@ -417,9 +419,9 @@
/**
* Check for pending payments.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function hasPayments(Request $request)
{
@@ -431,24 +433,24 @@
$exists = Payment::where('wallet_id', $wallet->id)
->where('type', Payment::TYPE_ONEOFF)
->whereIn('status', [
- Payment::STATUS_OPEN,
- Payment::STATUS_PENDING,
- Payment::STATUS_AUTHORIZED
+ Payment::STATUS_OPEN,
+ Payment::STATUS_PENDING,
+ Payment::STATUS_AUTHORIZED,
])
->exists();
return response()->json([
'status' => 'success',
- 'hasPending' => $exists
+ 'hasPending' => $exists,
]);
}
/**
* List pending payments.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function payments(Request $request)
{
@@ -458,14 +460,14 @@
$wallet = $user->wallets()->first();
$pageSize = 10;
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$hasMore = false;
$result = Payment::where('wallet_id', $wallet->id)
->where('type', Payment::TYPE_ONEOFF)
->whereIn('status', [
- Payment::STATUS_OPEN,
- Payment::STATUS_PENDING,
- Payment::STATUS_AUTHORIZED
+ Payment::STATUS_OPEN,
+ Payment::STATUS_PENDING,
+ Payment::STATUS_AUTHORIZED,
])
->orderBy('created_at', 'desc')
->limit($pageSize + 1)
@@ -477,7 +479,7 @@
$hasMore = true;
}
- $result = $result->map(function ($item) use ($wallet) {
+ $result = $result->map(static function ($item) use ($wallet) {
$provider = PaymentProvider::factory($item->provider);
$payment = $provider->getPayment($item->id);
$entry = [
@@ -490,7 +492,7 @@
// note: $item->currency/$item->currency_amount might be different
'status' => $item->status,
'isCancelable' => $payment['isCancelable'],
- 'checkoutUrl' => $payment['checkoutUrl']
+ 'checkoutUrl' => $payment['checkoutUrl'],
];
return $entry;
diff --git a/src/app/Http/Controllers/API/V4/PolicyController.php b/src/app/Http/Controllers/API/V4/PolicyController.php
--- a/src/app/Http/Controllers/API/V4/PolicyController.php
+++ b/src/app/Http/Controllers/API/V4/PolicyController.php
@@ -8,14 +8,16 @@
use App\Policy\RateLimit;
use App\Policy\SmtpAccess;
use App\Policy\SPF;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
+use Illuminate\Http\Response;
class PolicyController extends Controller
{
/**
* Take a greylist policy request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function greylist()
{
@@ -27,9 +29,9 @@
/**
* SMTP Content Filter
*
- * @param Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function mailfilter(Request $request)
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/DiscountsController.php b/src/app/Http/Controllers/API/V4/Reseller/DiscountsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/DiscountsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/DiscountsController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Reseller;
-class DiscountsController extends \App\Http\Controllers\API\V4\Admin\DiscountsController
-{
-}
+class DiscountsController extends \App\Http\Controllers\API\V4\Admin\DiscountsController {}
diff --git a/src/app/Http/Controllers/API/V4/Reseller/DomainsController.php b/src/app/Http/Controllers/API/V4/Reseller/DomainsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/DomainsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/DomainsController.php
@@ -4,13 +4,14 @@
use App\Domain;
use App\User;
+use Illuminate\Http\JsonResponse;
class DomainsController extends \App\Http\Controllers\API\V4\Admin\DomainsController
{
/**
* Search for domains
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/EventLogController.php b/src/app/Http/Controllers/API/V4/Reseller/EventLogController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/EventLogController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/EventLogController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Reseller;
-class EventLogController extends \App\Http\Controllers\API\V4\Admin\EventLogController
-{
-}
+class EventLogController extends \App\Http\Controllers\API\V4\Admin\EventLogController {}
diff --git a/src/app/Http/Controllers/API/V4/Reseller/GroupsController.php b/src/app/Http/Controllers/API/V4/Reseller/GroupsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/GroupsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/GroupsController.php
@@ -4,13 +4,14 @@
use App\Group;
use App\User;
+use Illuminate\Http\JsonResponse;
class GroupsController extends \App\Http\Controllers\API\V4\Admin\GroupsController
{
/**
* Search for groups
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php b/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/InvitationsController.php
@@ -4,6 +4,7 @@
use App\Http\Controllers\Controller;
use App\SignupInvitation;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
@@ -12,7 +13,7 @@
/**
* Show the form for creating a new resource.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function create()
{
@@ -24,7 +25,7 @@
*
* @param int $id Invitation identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function destroy($id)
{
@@ -37,8 +38,8 @@
$invitation->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.signup-invitation-delete-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.signup-invitation-delete-success'),
]);
}
@@ -47,7 +48,7 @@
*
* @param int $id Invitation identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function edit($id)
{
@@ -57,13 +58,13 @@
/**
* Display a listing of the resource.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
$pageSize = 10;
$search = request()->input('search');
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$hasMore = false;
$result = SignupInvitation::withSubjectTenantContext()
@@ -91,11 +92,11 @@
});
return response()->json([
- 'status' => 'success',
- 'list' => $result,
- 'count' => count($result),
- 'hasMore' => $hasMore,
- 'page' => $page,
+ 'status' => 'success',
+ 'list' => $result,
+ 'count' => count($result),
+ 'hasMore' => $hasMore,
+ 'page' => $page,
]);
}
@@ -104,7 +105,7 @@
*
* @param int $id Invitation identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function resend($id)
{
@@ -121,18 +122,16 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.signup-invitation-resend-success'),
- 'invitation' => $this->invitationToArray($invitation),
+ 'status' => 'success',
+ 'message' => self::trans('app.signup-invitation-resend-success'),
+ 'invitation' => $this->invitationToArray($invitation),
]);
}
/**
* Store a newly created resource in storage.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function store(Request $request)
{
@@ -207,9 +206,9 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => \trans_choice('app.signup-invitations-created', $count, ['count' => $count]),
- 'count' => $count,
+ 'status' => 'success',
+ 'message' => \trans_choice('app.signup-invitations-created', $count, ['count' => $count]),
+ 'count' => $count,
]);
}
@@ -218,7 +217,7 @@
*
* @param int $id Invitation identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
@@ -228,10 +227,9 @@
/**
* Update the specified resource in storage.
*
- * @param \Illuminate\Http\Request $request
- * @param int $id
+ * @param int $id
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function update(Request $request, $id)
{
@@ -241,9 +239,7 @@
/**
* Convert an invitation object to an array for output
*
- * @param \App\SignupInvitation $invitation The signup invitation object
- *
- * @return array
+ * @param SignupInvitation $invitation The signup invitation object
*/
protected static function invitationToArray(SignupInvitation $invitation): array
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/PaymentsController.php b/src/app/Http/Controllers/API/V4/Reseller/PaymentsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/PaymentsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/PaymentsController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Reseller;
-class PaymentsController extends \App\Http\Controllers\API\V4\PaymentsController
-{
-}
+class PaymentsController extends \App\Http\Controllers\API\V4\PaymentsController {}
diff --git a/src/app/Http/Controllers/API/V4/Reseller/ResourcesController.php b/src/app/Http/Controllers/API/V4/Reseller/ResourcesController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/ResourcesController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/ResourcesController.php
@@ -4,13 +4,14 @@
use App\Resource;
use App\User;
+use Illuminate\Http\JsonResponse;
class ResourcesController extends \App\Http\Controllers\API\V4\Admin\ResourcesController
{
/**
* Search for resources
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/SharedFoldersController.php b/src/app/Http/Controllers/API/V4/Reseller/SharedFoldersController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/SharedFoldersController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/SharedFoldersController.php
@@ -4,13 +4,14 @@
use App\SharedFolder;
use App\User;
+use Illuminate\Http\JsonResponse;
class SharedFoldersController extends \App\Http\Controllers\API\V4\Admin\SharedFoldersController
{
/**
* Search for shared folders
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/SkusController.php b/src/app/Http/Controllers/API/V4/Reseller/SkusController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/SkusController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/SkusController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Reseller;
-class SkusController extends \App\Http\Controllers\API\V4\SkusController
-{
-}
+class SkusController extends \App\Http\Controllers\API\V4\SkusController {}
diff --git a/src/app/Http/Controllers/API/V4/Reseller/StatsController.php b/src/app/Http/Controllers/API/V4/Reseller/StatsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/StatsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/StatsController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers\API\V4\Reseller;
+use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Auth;
class StatsController extends \App\Http\Controllers\API\V4\Admin\StatsController
@@ -19,10 +20,10 @@
/**
* Add tenant scope to the queries when needed
*
- * @param \Illuminate\Database\Query\Builder $query The query
- * @param callable $addQuery Additional tenant-scope query-modifier
+ * @param Builder $query The query
+ * @param callable $addQuery Additional tenant-scope query-modifier
*
- * @return \Illuminate\Database\Query\Builder
+ * @return Builder
*/
protected function applyTenantScope($query, $addQuery = null)
{
diff --git a/src/app/Http/Controllers/API/V4/Reseller/UsersController.php b/src/app/Http/Controllers/API/V4/Reseller/UsersController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/UsersController.php
@@ -4,16 +4,20 @@
use App\Domain;
use App\Group;
+use App\Resource;
+use App\SharedFolder;
+use App\SharedFolderAlias;
use App\User;
use App\UserAlias;
use App\UserSetting;
+use Illuminate\Http\JsonResponse;
class UsersController extends \App\Http\Controllers\API\V4\Admin\UsersController
{
/**
* Searching of user accounts.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -53,11 +57,11 @@
// Search by an email of a group, resource, shared folder, etc.
if ($group = Group::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$group->wallet()->user_id])->unique();
- } elseif ($resource = \App\Resource::withTrashed()->where('email', $search)->first()) {
+ } elseif ($resource = Resource::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$resource->wallet()->user_id])->unique();
- } elseif ($folder = \App\SharedFolder::withTrashed()->where('email', $search)->first()) {
+ } elseif ($folder = SharedFolder::withTrashed()->where('email', $search)->first()) {
$user_ids = $user_ids->merge([$folder->wallet()->user_id])->unique();
- } elseif ($alias = \App\SharedFolderAlias::where('alias', $search)->first()) {
+ } elseif ($alias = SharedFolderAlias::where('alias', $search)->first()) {
$user_ids = $user_ids->merge([$alias->sharedFolder->wallet()->user_id])->unique();
}
diff --git a/src/app/Http/Controllers/API/V4/Reseller/WalletsController.php b/src/app/Http/Controllers/API/V4/Reseller/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/Reseller/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/Reseller/WalletsController.php
@@ -2,6 +2,4 @@
namespace App\Http\Controllers\API\V4\Reseller;
-class WalletsController extends \App\Http\Controllers\API\V4\Admin\WalletsController
-{
-}
+class WalletsController extends \App\Http\Controllers\API\V4\Admin\WalletsController {}
diff --git a/src/app/Http/Controllers/API/V4/ResourcesController.php b/src/app/Http/Controllers/API/V4/ResourcesController.php
--- a/src/app/Http/Controllers/API/V4/ResourcesController.php
+++ b/src/app/Http/Controllers/API/V4/ResourcesController.php
@@ -3,8 +3,10 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\RelationController;
+use App\Jobs\Resource\CreateJob;
use App\Resource;
use App\Rules\ResourceName;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -23,11 +25,10 @@
/** @var array Common object properties in the API response */
protected $objectProps = ['email', 'name'];
-
/**
* Resource status (extended) information
*
- * @param \App\Resource $resource Resource object
+ * @param Resource $resource Resource object
*
* @return array Status information
*/
@@ -46,9 +47,9 @@
/**
* Create a new resource record.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -82,18 +83,18 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.resource-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.resource-create-success'),
]);
}
/**
* Update a resource.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Resource identifier
+ * @param Request $request the API request
+ * @param string $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -137,16 +138,16 @@
$resource->save();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.resource-update-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.resource-update-success'),
]);
}
/**
* Execute (synchronously) specified step in a resource setup process.
*
- * @param \App\Resource $resource Resource object
- * @param string $step Step identifier (as in self::statusInfo())
+ * @param Resource $resource Resource object
+ * @param string $step Step identifier (as in self::statusInfo())
*
* @return bool|null True if the execution succeeded, False if not, Null when
* the job has been sent to the worker (result unknown)
@@ -154,7 +155,7 @@
public static function execProcessStep(Resource $resource, string $step): ?bool
{
try {
- if (strpos($step, 'domain-') === 0) {
+ if (str_starts_with($step, 'domain-')) {
return DomainsController::execProcessStep($resource->domain(), $step);
}
@@ -162,7 +163,7 @@
case 'resource-ldap-ready':
case 'resource-imap-ready':
// Use worker to do the job, frontend might not have the IMAP admin credentials
- \App\Jobs\Resource\CreateJob::dispatch($resource->id);
+ CreateJob::dispatch($resource->id);
return null;
}
} catch (\Exception $e) {
diff --git a/src/app/Http/Controllers/API/V4/RoomsController.php b/src/app/Http/Controllers/API/V4/RoomsController.php
--- a/src/app/Http/Controllers/API/V4/RoomsController.php
+++ b/src/app/Http/Controllers/API/V4/RoomsController.php
@@ -2,9 +2,11 @@
namespace App\Http\Controllers\API\V4;
+use App\Entitlement;
use App\Http\Controllers\RelationController;
use App\Meet\Room;
use App\Permission;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -23,13 +25,12 @@
/** @var array Common object properties in the API response */
protected $objectProps = ['name', 'description'];
-
/**
* Delete a room
*
* @param string $id Room identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function destroy($id)
{
@@ -41,25 +42,25 @@
$room->delete();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans("app.room-delete-success"),
+ 'status' => 'success',
+ 'message' => self::trans("app.room-delete-success"),
]);
}
/**
* Listing of rooms that belong to the authenticated user.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
$user = $this->guard()->user();
- $shared = Room::whereIn('id', function ($query) use ($user) {
- $query->select('permissible_id')
- ->from('permissions')
- ->where('permissible_type', Room::class)
- ->where('user', $user->email);
+ $shared = Room::whereIn('id', static function ($query) use ($user) {
+ $query->select('permissible_id')
+ ->from('permissions')
+ ->where('permissible_type', Room::class)
+ ->where('user', $user->email);
});
// Create a "private" room for the user
@@ -89,7 +90,7 @@
*
* @param int|string $id Room identifier (or name)
*
- * @return \Illuminate\Http\JsonResponse|void
+ * @return JsonResponse|void
*/
public function setConfig($id)
{
@@ -112,17 +113,17 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => self::trans("app.room-setconfig-success"),
+ 'status' => 'success',
+ 'message' => self::trans("app.room-setconfig-success"),
]);
}
/**
* Display information of a room specified by $id.
*
- * @param string $id The room to show information for.
+ * @param string $id the room to show information for
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
@@ -145,7 +146,7 @@
unset($response['config']['acl']);
}
- $response['skus'] = \App\Entitlement::objectEntitlementsSummary($room);
+ $response['skus'] = Entitlement::objectEntitlementsSummary($room);
$response['wallet'] = $wallet->toArray();
if ($wallet->discount) {
@@ -167,7 +168,7 @@
*
* @param int $id Room identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function skus($id)
{
@@ -182,9 +183,9 @@
/**
* Create a new room.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -199,7 +200,7 @@
$v = Validator::make(
$request->all(),
[
- 'description' => 'nullable|string|max:191'
+ 'description' => 'nullable|string|max:191',
]
);
@@ -210,7 +211,7 @@
DB::beginTransaction();
$room = Room::create([
- 'description' => $request->input('description'),
+ 'description' => $request->input('description'),
]);
if (!empty($request->skus)) {
@@ -222,18 +223,18 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans("app.room-create-success"),
+ 'status' => 'success',
+ 'message' => self::trans("app.room-create-success"),
]);
}
/**
* Update a room.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Room identifier
+ * @param Request $request the API request
+ * @param string $id Room identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -246,7 +247,7 @@
$v = Validator::make(
request()->all(),
[
- 'description' => 'nullable|string|max:191'
+ 'description' => 'nullable|string|max:191',
]
);
@@ -268,20 +269,20 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans("app.room-update-success"),
+ 'status' => 'success',
+ 'message' => self::trans("app.room-update-success"),
]);
}
/**
* Get the input room object, check permissions.
*
- * @param int|string $id Room identifier (or name)
- * @param ?int $rights Required access rights
- * @param ?\App\Permission $permission Room permission reference if the user has permissions
- * to the room and is not the owner
+ * @param int|string $id Room identifier (or name)
+ * @param ?int $rights Required access rights
+ * @param ?Permission $permission Room permission reference if the user has permissions
+ * to the room and is not the owner
*
- * @return \App\Meet\Room|int File object or error code
+ * @return Room|int File object or error code
*/
protected function inputRoom($id, $rights = 0, &$permission = null): int|Room
{
diff --git a/src/app/Http/Controllers/API/V4/SearchController.php b/src/app/Http/Controllers/API/V4/SearchController.php
--- a/src/app/Http/Controllers/API/V4/SearchController.php
+++ b/src/app/Http/Controllers/API/V4/SearchController.php
@@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\User;
use App\UserSetting;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@@ -19,15 +20,15 @@
/**
* Search request for user's contacts
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function searchContacts(Request $request)
{
$user = $this->guard()->user();
$search = trim(request()->input('search'));
- $limit = intval(request()->input('limit'));
+ $limit = (int) request()->input('limit');
if ($limit <= 0) {
$limit = 15;
@@ -45,7 +46,7 @@
$query = $owner->contacts();
if (strlen($search)) {
- $query->Where(function ($query) use ($search) {
+ $query->Where(static function ($query) use ($search) {
$query->whereLike('name', "%{$search}%")
->orWhereLike('email', "%{$search}%");
});
@@ -53,7 +54,7 @@
// Execute the query
$result = $query->orderBy('email')->limit($limit)->get()
- ->map(function ($contact) {
+ ->map(static function ($contact) {
return [
'email' => $contact->email,
'name' => $contact->name,
@@ -69,16 +70,16 @@
/**
* Search request for user's email addresses
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function searchSelf(Request $request)
{
$user = $this->guard()->user();
$search = trim(request()->input('search'));
$with_aliases = !empty(request()->input('alias'));
- $limit = intval(request()->input('limit'));
+ $limit = (int) request()->input('limit');
if ($limit <= 0) {
$limit = 15;
@@ -114,16 +115,16 @@
/**
* Search request for addresses of all users (in an account)
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function searchUser(Request $request)
{
$user = $this->guard()->user();
$search = trim(request()->input('search'));
$with_aliases = !empty(request()->input('alias'));
- $limit = intval(request()->input('limit'));
+ $limit = (int) request()->input('limit');
if ($limit <= 0) {
$limit = 15;
@@ -151,12 +152,12 @@
->whereIn('user_id', $allUsers);
if (strlen($search)) {
- $query->where(function ($query) use ($foundUserIds, $search) {
+ $query->where(static function ($query) use ($foundUserIds, $search) {
$query->whereLike('email', "%{$search}%")
->orWhereIn('id', $foundUserIds);
});
- $aliases->where(function ($query) use ($foundUserIds, $search) {
+ $aliases->where(static function ($query) use ($foundUserIds, $search) {
$query->whereLike('alias', "%{$search}%")
->orWhereIn('user_id', $foundUserIds);
});
@@ -187,21 +188,21 @@
$settings = UserSetting::whereIn('key', ['first_name', 'last_name'])
->whereIn('user_id', $result->pluck('id'))
->get()
- ->mapWithKeys(function ($item) {
+ ->mapWithKeys(static function ($item) {
return [($item->user_id . ':' . $item->key) => $item->value];
})
->all();
// "Format" the result, include user names
- $result = $result->map(function ($record) use ($settings) {
- return [
- 'email' => $record->email,
- 'name' => trim(
- ($settings["{$record->id}:first_name"] ?? '')
- . ' '
- . ($settings["{$record->id}:last_name"] ?? '')
- ),
- ];
+ $result = $result->map(static function ($record) use ($settings) {
+ return [
+ 'email' => $record->email,
+ 'name' => trim(
+ ($settings["{$record->id}:first_name"] ?? '')
+ . ' '
+ . ($settings["{$record->id}:last_name"] ?? '')
+ ),
+ ];
})
->sortBy(['name', 'email'])
->values();
diff --git a/src/app/Http/Controllers/API/V4/SharedFoldersController.php b/src/app/Http/Controllers/API/V4/SharedFoldersController.php
--- a/src/app/Http/Controllers/API/V4/SharedFoldersController.php
+++ b/src/app/Http/Controllers/API/V4/SharedFoldersController.php
@@ -3,9 +3,12 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\RelationController;
-use App\SharedFolder;
+use App\Jobs\SharedFolder\CreateJob;
use App\Rules\SharedFolderName;
use App\Rules\SharedFolderType;
+use App\SharedFolder;
+use App\User;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -25,11 +28,10 @@
/** @var array Common object properties in the API response */
protected $objectProps = ['email', 'name', 'type'];
-
/**
* SharedFolder status (extended) information
*
- * @param \App\SharedFolder $folder SharedFolder object
+ * @param SharedFolder $folder SharedFolder object
*
* @return array Status information
*/
@@ -48,9 +50,9 @@
/**
* Create a new shared folder record.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -83,18 +85,18 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.shared-folder-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.shared-folder-create-success'),
]);
}
/**
* Update a shared folder.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Shared folder identifier
+ * @param Request $request the API request
+ * @param string $id Shared folder identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -133,16 +135,16 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.shared-folder-update-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.shared-folder-update-success'),
]);
}
/**
* Execute (synchronously) specified step in a shared folder setup process.
*
- * @param \App\SharedFolder $folder Shared folder object
- * @param string $step Step identifier (as in self::statusInfo())
+ * @param SharedFolder $folder Shared folder object
+ * @param string $step Step identifier (as in self::statusInfo())
*
* @return bool|null True if the execution succeeded, False if not, Null when
* the job has been sent to the worker (result unknown)
@@ -150,7 +152,7 @@
public static function execProcessStep(SharedFolder $folder, string $step): ?bool
{
try {
- if (strpos($step, 'domain-') === 0) {
+ if (str_starts_with($step, 'domain-')) {
return DomainsController::execProcessStep($folder->domain(), $step);
}
@@ -158,7 +160,7 @@
case 'shared-folder-ldap-ready':
case 'shared-folder-imap-ready':
// Use worker to do the job, frontend might not have the IMAP admin credentials
- \App\Jobs\SharedFolder\CreateJob::dispatch($folder->id);
+ CreateJob::dispatch($folder->id);
return null;
}
} catch (\Exception $e) {
@@ -171,11 +173,11 @@
/**
* Validate shared folder input
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param \App\SharedFolder|null $folder Shared folder
- * @param \App\User|null $owner Account owner
+ * @param Request $request the API request
+ * @param SharedFolder|null $folder Shared folder
+ * @param User|null $owner Account owner
*
- * @return \Illuminate\Http\JsonResponse|null The error response on error
+ * @return JsonResponse|null The error response on error
*/
protected function validateFolderRequest(Request $request, $folder, $owner)
{
@@ -247,14 +249,14 @@
/**
* Email address validation for use as a shared folder alias.
*
- * @param string $alias Email address
- * @param \App\User $owner The account owner
- * @param string $folderName Folder name
- * @param string $domain Folder domain
+ * @param string $alias Email address
+ * @param User $owner The account owner
+ * @param string $folderName Folder name
+ * @param string $domain Folder domain
*
* @return ?string Error message on validation error
*/
- public static function validateAlias(string $alias, \App\User $owner, string $folderName, string $domain): ?string
+ public static function validateAlias(string $alias, User $owner, string $folderName, string $domain): ?string
{
$lmtp_alias = "shared+shared/{$folderName}@{$domain}";
diff --git a/src/app/Http/Controllers/API/V4/SkusController.php b/src/app/Http/Controllers/API/V4/SkusController.php
--- a/src/app/Http/Controllers/API/V4/SkusController.php
+++ b/src/app/Http/Controllers/API/V4/SkusController.php
@@ -2,18 +2,20 @@
namespace App\Http\Controllers\API\V4;
+use App\Entitlement;
+use App\Handlers\Mailbox;
use App\Http\Controllers\ResourceController;
use App\Sku;
-use Illuminate\Http\Request;
+use App\Wallet;
+use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;
-use Illuminate\Support\Str;
class SkusController extends ResourceController
{
/**
* Get a list of active SKUs.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -25,7 +27,7 @@
->transform(function ($sku) {
return $this->skuElement($sku);
})
- ->filter(function ($sku) use ($type) {
+ ->filter(static function ($sku) use ($type) {
return $sku && (!$type || $sku['type'] === $type);
})
->sortByDesc('prio')
@@ -35,7 +37,7 @@
$wallet = $this->guard()->user()->wallet();
// Figure out the cost for a new object of the specified type
- $response = $response->map(function ($sku) use ($wallet) {
+ $response = $response->map(static function ($sku) use ($wallet) {
$sku['nextCost'] = $sku['cost'];
if ($sku['cost'] && $sku['units_free']) {
$count = $wallet->entitlements()->where('sku_id', $sku['id'])->count();
@@ -57,7 +59,7 @@
*
* @param object $object Entitleable object
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public static function objectSkus($object)
{
@@ -91,8 +93,8 @@
}
}
- usort($response, function ($a, $b) {
- return ($b['prio'] <=> $a['prio']);
+ usort($response, static function ($a, $b) {
+ return $b['prio'] <=> $a['prio'];
});
return response()->json($response);
@@ -107,7 +109,7 @@
public static function objectEntitlements($object, &$response = []): void
{
// Object's entitlements information
- $response['skus'] = \App\Entitlement::objectEntitlementsSummary($object);
+ $response['skus'] = Entitlement::objectEntitlementsSummary($object);
// Some basic information about the object's wallet
$wallet = $object->wallet();
@@ -121,9 +123,9 @@
/**
* Update object entitlements.
*
- * @param object $object The object for update
- * @param array $rSkus List of SKU IDs requested for the object in the form [id=>qty]
- * @param ?\App\Wallet $wallet The target wallet
+ * @param object $object The object for update
+ * @param array $rSkus List of SKU IDs requested for the object in the form [id=>qty]
+ * @param ?Wallet $wallet The target wallet
*/
public static function updateEntitlements($object, $rSkus, $wallet = null): void
{
@@ -137,14 +139,14 @@
// available SKUs, [id => obj]
$skus = Sku::withObjectTenantContext($object)->get()->mapWithKeys(
- function ($sku) {
+ static function ($sku) {
return [$sku->id => $sku];
}
);
// existing object SKUs, [id => total]
$eSkus = $object->entitlements()->groupBy('sku_id')->selectRaw('count(*) as total, sku_id')->get()->mapWithKeys(
- function ($e) {
+ static function ($e) {
return [$e->sku_id => $e->total];
}
)->all();
@@ -158,7 +160,7 @@
continue;
}
- if ($sku->handler_class == \App\Handlers\Mailbox::class) {
+ if ($sku->handler_class == Mailbox::class) {
if ($r != 1) {
throw new \Exception("Invalid quantity of mailboxes");
}
@@ -166,10 +168,10 @@
if ($e > $r) {
// remove those entitled more than existing
- $object->removeSku($sku, ($e - $r));
+ $object->removeSku($sku, $e - $r);
} elseif ($e < $r) {
// add those requested more than entitled
- $object->assignSku($sku, ($r - $e), $wallet);
+ $object->assignSku($sku, $r - $e, $wallet);
}
}
}
@@ -178,7 +180,7 @@
* Convert SKU information to metadata used by UI to
* display the form control
*
- * @param \App\Sku $sku SKU object
+ * @param Sku $sku SKU object
*
* @return array|null Metadata
*/
diff --git a/src/app/Http/Controllers/API/V4/SupportController.php b/src/app/Http/Controllers/API/V4/SupportController.php
--- a/src/app/Http/Controllers/API/V4/SupportController.php
+++ b/src/app/Http/Controllers/API/V4/SupportController.php
@@ -3,6 +3,7 @@
namespace App\Http\Controllers\API\V4;
use App\Http\Controllers\Controller;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Validator;
@@ -12,9 +13,7 @@
/**
* Submit contact request form.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function request(Request $request)
{
@@ -51,7 +50,7 @@
$params['body'],
);
- Mail::raw($content, function ($message) use ($params, $to) {
+ Mail::raw($content, static function ($message) use ($params, $to) {
// Remove the global reply-to addressee
$message->getHeaders()->remove('Reply-To');
@@ -62,8 +61,8 @@
});
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.support-request-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.support-request-success'),
]);
}
}
diff --git a/src/app/Http/Controllers/API/V4/User/DelegationTrait.php b/src/app/Http/Controllers/API/V4/User/DelegationTrait.php
--- a/src/app/Http/Controllers/API/V4/User/DelegationTrait.php
+++ b/src/app/Http/Controllers/API/V4/User/DelegationTrait.php
@@ -4,7 +4,7 @@
use App\Delegation;
use App\User;
-use Illuminate\Http\Request;
+use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Validator;
trait DelegationTrait
@@ -14,7 +14,7 @@
*
* @param string $id The user to get delegatees for
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function delegations($id)
{
@@ -30,7 +30,7 @@
}
$result = $user->delegatees()->orderBy('email')->get()
- ->map(function (User $user) {
+ ->map(static function (User $user) {
return [
'email' => $user->email,
'options' => $user->delegation->options ?? [],
@@ -51,7 +51,7 @@
*
* @param string $id The user to get delegators for
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function delegators($id)
{
@@ -67,7 +67,7 @@
}
$delegators = $user->delegators()->orderBy('email')->get()
- ->map(function (User $user) {
+ ->map(static function (User $user) {
return [
'email' => $user->email,
'aliases' => $user->aliases()->pluck('alias'),
@@ -88,7 +88,7 @@
* @param string $id User identifier
* @param string $email Delegatee's email address
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function deleteDelegation($id, $email)
{
@@ -118,8 +118,8 @@
$delegation->delete();
return response()->json([
- 'status' => 'success',
- 'message' => \trans('app.delegation-delete-success'),
+ 'status' => 'success',
+ 'message' => \trans('app.delegation-delete-success'),
]);
}
@@ -128,7 +128,7 @@
*
* @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function createDelegation($id)
{
diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -2,15 +2,25 @@
namespace App\Http\Controllers\API\V4;
+use App\Domain;
+use App\Entitlement;
+use App\Group;
use App\Http\Controllers\API\V4\User\DelegationTrait;
use App\Http\Controllers\RelationController;
-use App\Domain;
+use App\Jobs\User\CreateJob;
use App\License;
+use App\Package;
use App\Plan;
+use App\Providers\PaymentProvider;
+use App\Resource;
use App\Rules\Password;
use App\Rules\UserEmailLocal;
+use App\SharedFolder;
use App\Sku;
use App\User;
+use App\VerificationCode;
+use Carbon\Carbon;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Validator;
@@ -36,7 +46,7 @@
* On user create it is filled with a user or group object to force-delete
* before the creation of a new user record is possible.
*
- * @var \App\User|\App\Group|null
+ * @var User|Group|null
*/
protected $deleteBeforeCreate;
@@ -49,7 +59,7 @@
/** @var array Common object properties in the API response */
protected $objectProps = ['email'];
- /** @var ?\App\VerificationCode Password reset code to activate on user create/update */
+ /** @var ?VerificationCode Password reset code to activate on user create/update */
protected $passCode;
/**
@@ -57,20 +67,20 @@
*
* The user-entitlements billed to the current user wallet(s)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
$user = $this->guard()->user();
$search = trim(request()->input('search'));
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$pageSize = 20;
$hasMore = false;
$result = $user->users();
// Search by user email, alias or name
- if (strlen($search) > 0) {
+ if ($search !== '') {
// thanks to cloning we skip some extra queries in $user->users()
$allUsers1 = clone $result;
$allUsers2 = clone $result;
@@ -119,7 +129,7 @@
* @param string $id The account to get licenses for
* @param string $type License type
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function licenses(string $id, string $type)
{
@@ -157,11 +167,11 @@
}
// Slim down the result set
- $licenses = $licenses->map(function ($license) {
- return [
- 'key' => $license->key,
- 'type' => $license->type,
- ];
+ $licenses = $licenses->map(static function ($license) {
+ return [
+ 'key' => $license->key,
+ 'type' => $license->type,
+ ];
});
return response()->json([
@@ -174,9 +184,9 @@
/**
* Display information on the user account specified by $id.
*
- * @param string $id The account to show information for.
+ * @param string $id the account to show information for
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
@@ -192,12 +202,12 @@
$response = $this->userResponse($user);
- $response['skus'] = \App\Entitlement::objectEntitlementsSummary($user);
+ $response['skus'] = Entitlement::objectEntitlementsSummary($user);
$response['config'] = $user->getConfig();
$response['aliases'] = $user->aliases()->pluck('alias')->all();
$code = $user->verificationcodes()->where('active', true)
- ->where('expires_at', '>', \Carbon\Carbon::now())
+ ->where('expires_at', '>', Carbon::now())
->first();
if ($code) {
@@ -210,7 +220,7 @@
/**
* User status (extended) information
*
- * @param \App\User $user User object
+ * @param User $user User object
*
* @return array Status information
*/
@@ -265,9 +275,9 @@
/**
* Create a new user record.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -286,7 +296,7 @@
if (
empty($request->package)
- || !($package = \App\Package::withObjectTenantContext($owner)->find($request->package))
+ || !($package = Package::withObjectTenantContext($owner)->find($request->package))
) {
$errors = ['package' => self::trans('validation.packagerequired')];
return response()->json(['status' => 'error', 'errors' => $errors], 422);
@@ -306,9 +316,9 @@
// Create user record
$user = User::create([
- 'email' => $request->email,
- 'password' => $request->password,
- 'status' => $owner->isRestricted() ? User::STATUS_RESTRICTED : 0,
+ 'email' => $request->email,
+ 'password' => $request->password,
+ 'status' => $owner->isRestricted() ? User::STATUS_RESTRICTED : 0,
]);
$this->activatePassCode($user);
@@ -326,18 +336,18 @@
DB::commit();
return response()->json([
- 'status' => 'success',
- 'message' => self::trans('app.user-create-success'),
+ 'status' => 'success',
+ 'message' => self::trans('app.user-create-success'),
]);
}
/**
* Update user data.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id User identifier
+ * @param Request $request the API request
+ * @param string $id User identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
@@ -398,7 +408,7 @@
/**
* Create a response data array for specified user.
*
- * @param \App\User $user User object
+ * @param User $user User object
*
* @return array Response data
*/
@@ -421,7 +431,7 @@
$response['statusInfo'] = self::statusInfo($user);
// Add more info to the wallet object output
- $map_func = function ($wallet) use ($user) {
+ $map_func = static function ($wallet) use ($user) {
$result = $wallet->toArray();
if ($wallet->discount) {
@@ -433,7 +443,7 @@
$result['user_email'] = $wallet->owner->email;
}
- $provider = \App\Providers\PaymentProvider::factory($wallet);
+ $provider = PaymentProvider::factory($wallet);
$result['provider'] = $provider->name();
return $result;
@@ -450,7 +460,7 @@
/**
* Prepare user statuses for the UI
*
- * @param \App\User $user User object
+ * @param User $user User object
*
* @return array Statuses array
*/
@@ -466,11 +476,11 @@
/**
* Validate user input
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param \App\User|null $user User identifier
- * @param array $settings User settings (from the request)
+ * @param Request $request the API request
+ * @param User|null $user User identifier
+ * @param array $settings User settings (from the request)
*
- * @return \Illuminate\Http\JsonResponse|null The error response on error
+ * @return JsonResponse|null The error response on error
*/
protected function validateUserRequest(Request $request, $user, &$settings = [])
{
@@ -577,8 +587,8 @@
/**
* Execute (synchronously) specified step in a user setup process.
*
- * @param \App\User $user User object
- * @param string $step Step identifier (as in self::statusInfo())
+ * @param User $user User object
+ * @param string $step Step identifier (as in self::statusInfo())
*
* @return bool|null True if the execution succeeded, False if not, Null when
* the job has been sent to the worker (result unknown)
@@ -586,7 +596,7 @@
public static function execProcessStep(User $user, string $step): ?bool
{
try {
- if (strpos($step, 'domain-') === 0) {
+ if (str_starts_with($step, 'domain-')) {
return DomainsController::execProcessStep($user->domain(), $step);
}
@@ -594,7 +604,7 @@
case 'user-ldap-ready':
case 'user-imap-ready':
// Use worker to do the job, frontend might not have the IMAP admin credentials
- \App\Jobs\User\CreateJob::dispatch($user->id);
+ CreateJob::dispatch($user->id);
return null;
}
} catch (\Exception $e) {
@@ -607,24 +617,24 @@
/**
* Email address validation for use as a user mailbox (login).
*
- * @param string $email Email address
- * @param \App\User $user The account owner
- * @param mixed $deleted Filled with an instance of a deleted model object
- * with the specified email address, if exists
+ * @param string $email Email address
+ * @param User $user The account owner
+ * @param mixed $deleted Filled with an instance of a deleted model object
+ * with the specified email address, if exists
*
* @return ?string Error message on validation error
*/
- public static function validateEmail(string $email, \App\User $user, &$deleted = null): ?string
+ public static function validateEmail(string $email, User $user, &$deleted = null): ?string
{
$deleted = null;
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return self::trans('validation.entryinvalid', ['attribute' => 'email']);
}
- list($login, $domain) = explode('@', Str::lower($email));
+ [$login, $domain] = explode('@', Str::lower($email));
- if (strlen($login) === 0 || strlen($domain) === 0) {
+ if ($login === '' || $domain === '') {
return self::trans('validation.entryinvalid', ['attribute' => 'email']);
}
@@ -653,9 +663,9 @@
// Check if a user/group/resource/shared folder with specified address already exists
if (
($existing = User::emailExists($email, true))
- || ($existing = \App\Group::emailExists($email, true))
- || ($existing = \App\Resource::emailExists($email, true))
- || ($existing = \App\SharedFolder::emailExists($email, true))
+ || ($existing = Group::emailExists($email, true))
+ || ($existing = Resource::emailExists($email, true))
+ || ($existing = SharedFolder::emailExists($email, true))
) {
// If this is a deleted user/group/resource/folder in the same custom domain
// we'll force delete it before creating the target user
@@ -667,7 +677,7 @@
}
// Check if an alias with specified address already exists.
- if (User::aliasExists($email) || \App\SharedFolder::aliasExists($email)) {
+ if (User::aliasExists($email) || SharedFolder::aliasExists($email)) {
return self::trans('validation.entryexists', ['attribute' => 'email']);
}
@@ -677,20 +687,20 @@
/**
* Email address validation for use as an alias.
*
- * @param string $email Email address
- * @param \App\User $user The account owner
+ * @param string $email Email address
+ * @param User $user The account owner
*
* @return ?string Error message on validation error
*/
- public static function validateAlias(string $email, \App\User $user): ?string
+ public static function validateAlias(string $email, User $user): ?string
{
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return self::trans('validation.entryinvalid', ['attribute' => 'alias']);
}
- list($login, $domain) = explode('@', Str::lower($email));
+ [$login, $domain] = explode('@', Str::lower($email));
- if (strlen($login) === 0 || strlen($domain) === 0) {
+ if ($login === '' || $domain === '') {
return self::trans('validation.entryinvalid', ['attribute' => 'alias']);
}
@@ -726,15 +736,15 @@
// Check if a group/resource/shared folder with specified address already exists
if (
- \App\Group::emailExists($email)
- || \App\Resource::emailExists($email)
- || \App\SharedFolder::emailExists($email)
+ Group::emailExists($email)
+ || Resource::emailExists($email)
+ || SharedFolder::emailExists($email)
) {
return self::trans('validation.entryexists', ['attribute' => 'alias']);
}
// Check if an alias with specified address already exists
- if (User::aliasExists($email) || \App\SharedFolder::aliasExists($email)) {
+ if (User::aliasExists($email) || SharedFolder::aliasExists($email)) {
// Allow assigning the same alias to a user in the same group account,
// but only for non-public domains
if ($domain->isPublic()) {
@@ -748,7 +758,7 @@
/**
* Activate password reset code (if set), and assign it to a user.
*
- * @param \App\User $user The user
+ * @param User $user The user
*/
protected function activatePassCode(User $user): void
{
diff --git a/src/app/Http/Controllers/API/V4/VPNController.php b/src/app/Http/Controllers/API/V4/VPNController.php
--- a/src/app/Http/Controllers/API/V4/VPNController.php
+++ b/src/app/Http/Controllers/API/V4/VPNController.php
@@ -4,6 +4,7 @@
use App\Http\Controllers\Controller;
use Carbon\Carbon;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Lcobucci\JWT\Encoding\ChainedFormatter;
use Lcobucci\JWT\Encoding\JoseEncoder;
@@ -16,9 +17,9 @@
/**
* Token request from the vpn module
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function token(Request $request)
{
diff --git a/src/app/Http/Controllers/API/V4/WalletsController.php b/src/app/Http/Controllers/API/V4/WalletsController.php
--- a/src/app/Http/Controllers/API/V4/WalletsController.php
+++ b/src/app/Http/Controllers/API/V4/WalletsController.php
@@ -2,16 +2,18 @@
namespace App\Http\Controllers\API\V4;
+use App\Documents\Receipt;
+use App\Http\Controllers\ResourceController;
use App\Payment;
+use App\Providers\PaymentProvider;
use App\ReferralCode;
use App\ReferralProgram;
use App\Transaction;
use App\Wallet;
-use App\Http\Controllers\ResourceController;
-use App\Providers\PaymentProvider;
use Carbon\Carbon;
use Illuminate\Database\Query\JoinClause;
-use Illuminate\Http\Request;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Http\Response;
use Illuminate\Support\Facades\DB;
/**
@@ -24,7 +26,7 @@
*
* @param string $id A wallet identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function show($id)
{
@@ -55,7 +57,7 @@
* @param string $id Wallet identifier
* @param string $receipt Receipt identifier (YYYY-MM)
*
- * @return \Illuminate\Http\Response
+ * @return Response
*/
public function receiptDownload($id, $receipt)
{
@@ -70,7 +72,7 @@
abort(403);
}
- list ($year, $month) = explode('-', $receipt);
+ [$year, $month] = explode('-', $receipt);
if (empty($year) || empty($month) || $year < 2000 || $month < 1 || $month > 12) {
abort(404);
@@ -82,19 +84,19 @@
$params = [
'id' => sprintf('%04d-%02d', $year, $month),
- 'site' => \config('app.name')
+ 'site' => \config('app.name'),
];
$filename = self::trans('documents.receipt-filename', $params) . '.pdf';
- $receipt = new \App\Documents\Receipt($wallet, (int) $year, (int) $month);
+ $receipt = new Receipt($wallet, (int) $year, (int) $month);
$content = $receipt->pdfOutput();
return response($content)
->withHeaders([
'Content-Type' => 'application/pdf',
- 'Content-Disposition' => 'attachment; filename="' . $filename . '"',
+ 'Content-Disposition' => 'attachment; filename="' . $filename . '"',
'Content-Length' => strlen($content),
]);
}
@@ -104,7 +106,7 @@
*
* @param string $id Wallet identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function receipts($id)
{
@@ -120,7 +122,7 @@
}
$pageSize = 10;
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$hasMore = false;
$result = $wallet->payments()
@@ -140,21 +142,21 @@
}
// @phpstan-ignore argument.unresolvableType
- $result = $result->map(function ($item) use ($wallet) {
+ $result = $result->map(static function ($item) use ($wallet) {
$entry = [
'period' => $item->ident, // @phpstan-ignore-line
'amount' => $item->total, // @phpstan-ignore-line
- 'currency' => $wallet->currency
+ 'currency' => $wallet->currency,
];
return $entry;
});
return response()->json([
- 'status' => 'success',
- 'list' => $result,
- 'count' => count($result),
- 'hasMore' => $hasMore,
- 'page' => $page,
+ 'status' => 'success',
+ 'list' => $result,
+ 'count' => count($result),
+ 'hasMore' => $hasMore,
+ 'page' => $page,
]);
}
@@ -163,7 +165,7 @@
*
* @param string $id Wallet identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function referralPrograms($id)
{
@@ -183,12 +185,12 @@
$result = ReferralProgram::withObjectTenantContext($wallet->owner)
->where('active', true)
- ->leftJoinSub($codes, 'codes', function (JoinClause $join) {
+ ->leftJoinSub($codes, 'codes', static function (JoinClause $join) {
$join->on('referral_programs.id', '=', 'codes.program_id');
})
->select('id', 'name', 'description', 'tenant_id', 'codes.code', 'codes.refcount')
->get()
- ->map(function ($program) use ($wallet) {
+ ->map(static function ($program) use ($wallet) {
if (empty($program->code)) {
// Register/Generate a code for the user if it does not exist yet
$code = $program->codes()->create(['user_id' => $wallet->user_id]);
@@ -212,11 +214,11 @@
});
return response()->json([
- 'status' => 'success',
- 'list' => $result,
- 'count' => count($result),
- 'hasMore' => false,
- 'page' => 1,
+ 'status' => 'success',
+ 'list' => $result,
+ 'count' => count($result),
+ 'hasMore' => false,
+ 'page' => 1,
]);
}
@@ -225,7 +227,7 @@
*
* @param string $id Wallet identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function transactions($id)
{
@@ -241,7 +243,7 @@
}
$pageSize = 10;
- $page = intval(request()->input('page')) ?: 1;
+ $page = (int) (request()->input('page')) ?: 1;
$hasMore = false;
$isAdmin = $this instanceof Admin\WalletsController;
@@ -249,7 +251,7 @@
// Get sub-transactions for the specified transaction ID, first
// check access rights to the transaction's wallet
- /** @var ?\App\Transaction $transaction */
+ /** @var ?Transaction $transaction */
$transaction = $wallet->transactions()->where('id', $transaction)->first();
if (!$transaction) {
@@ -276,7 +278,7 @@
}
}
- $result = $result->map(function ($item) use ($isAdmin, $wallet) {
+ $result = $result->map(static function ($item) use ($isAdmin, $wallet) {
$entry = [
'id' => $item->id,
'createdAt' => $item->created_at->format('Y-m-d H:i'),
@@ -295,18 +297,18 @@
});
return response()->json([
- 'status' => 'success',
- 'list' => $result,
- 'count' => count($result),
- 'hasMore' => $hasMore,
- 'page' => $page,
+ 'status' => 'success',
+ 'list' => $result,
+ 'count' => count($result),
+ 'hasMore' => $hasMore,
+ 'page' => $page,
]);
}
/**
* Returns human readable notice about the wallet state.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*/
protected function getWalletNotice(Wallet $wallet): ?string
{
diff --git a/src/app/Http/Controllers/ContentController.php b/src/app/Http/Controllers/ContentController.php
--- a/src/app/Http/Controllers/ContentController.php
+++ b/src/app/Http/Controllers/ContentController.php
@@ -2,6 +2,10 @@
namespace App\Http\Controllers;
+use App\Utils;
+use Illuminate\Http\JsonResponse;
+use Illuminate\View\View;
+
class ContentController extends Controller
{
/**
@@ -9,7 +13,7 @@
*
* @param string $page Page template identifier
*
- * @return \Illuminate\View\View
+ * @return View
*/
public function pageContent(string $page)
{
@@ -27,7 +31,7 @@
abort(404);
}
- return view($view)->with('env', \App\Utils::uiEnv());
+ return view($view)->with('env', Utils::uiEnv());
}
/**
@@ -35,7 +39,7 @@
*
* @param string $page Page path
*
- * @return \Illuminate\Http\JsonResponse JSON response
+ * @return JsonResponse JSON response
*/
public function faqContent(string $page)
{
@@ -51,8 +55,8 @@
if (file_exists($theme_file)) {
$theme = json_decode(file_get_contents($theme_file), true);
- if (json_last_error() != JSON_ERROR_NONE) {
- \Log::error("Failed to parse $theme_file: " . json_last_error_msg());
+ if (json_last_error() != \JSON_ERROR_NONE) {
+ \Log::error("Failed to parse {$theme_file}: " . json_last_error_msg());
} elseif (!empty($theme['faq']) && !empty($theme['faq'][$page])) {
$faq = $theme['faq'][$page];
}
@@ -88,8 +92,6 @@
/**
* Get menu definition from the theme
- *
- * @return array
*/
public static function menu(): array
{
@@ -100,8 +102,8 @@
if (file_exists($theme_file)) {
$theme = json_decode(file_get_contents($theme_file), true);
- if (json_last_error() != JSON_ERROR_NONE) {
- \Log::error("Failed to parse $theme_file: " . json_last_error_msg());
+ if (json_last_error() != \JSON_ERROR_NONE) {
+ \Log::error("Failed to parse {$theme_file}: " . json_last_error_msg());
} elseif (!empty($theme['menu'])) {
$menu = $theme['menu'];
}
@@ -110,9 +112,9 @@
// TODO: These 2-3 lines could become a utility function somewhere
$req_domain = preg_replace('/:[0-9]+$/', '', request()->getHttpHost());
$sys_domain = \config('app.domain');
- $isAdmin = $req_domain == "admin.$sys_domain";
+ $isAdmin = $req_domain == "admin.{$sys_domain}";
- $filter = function ($item) use ($isAdmin) {
+ $filter = static function ($item) use ($isAdmin) {
if ($isAdmin && empty($item['admin'])) {
return false;
}
diff --git a/src/app/Http/Controllers/Controller.php b/src/app/Http/Controllers/Controller.php
--- a/src/app/Http/Controllers/Controller.php
+++ b/src/app/Http/Controllers/Controller.php
@@ -2,10 +2,12 @@
namespace App\Http\Controllers;
+use Illuminate\Contracts\Auth\Guard;
+use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
-use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
-use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
+use Illuminate\Http\JsonResponse;
+use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Auth;
class Controller extends BaseController
@@ -14,7 +16,6 @@
use DispatchesJobs;
use ValidatesRequests;
-
/**
* Common error response builder for API (JSON) responses
*
@@ -22,7 +23,7 @@
* @param string $message Error message
* @param array $data Additional response data
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public static function errorResponse(int $code, string $message = '', array $data = [])
{
@@ -43,7 +44,7 @@
];
if (!empty($data)) {
- $response = $response + $data;
+ $response += $data;
}
return response()->json($response, $code);
@@ -73,7 +74,7 @@
/**
* Get the guard to be used during authentication.
*
- * @return \Illuminate\Contracts\Auth\Guard
+ * @return Guard
*/
protected function guard()
{
diff --git a/src/app/Http/Controllers/RelationController.php b/src/app/Http/Controllers/RelationController.php
--- a/src/app/Http/Controllers/RelationController.php
+++ b/src/app/Http/Controllers/RelationController.php
@@ -2,6 +2,8 @@
namespace App\Http\Controllers;
+use Carbon\Carbon;
+use Illuminate\Http\JsonResponse;
use Illuminate\Support\Str;
class RelationController extends ResourceController
@@ -26,7 +28,7 @@
*
* @param string $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function destroy($id)
{
@@ -43,8 +45,8 @@
$resource->delete();
return response()->json([
- 'status' => 'success',
- 'message' => \trans("app.{$this->label}-delete-success"),
+ 'status' => 'success',
+ 'message' => \trans("app.{$this->label}-delete-success"),
]);
}
@@ -53,7 +55,7 @@
*
* The resource entitlements billed to the current user wallet(s)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -97,10 +99,10 @@
{
$state = [];
- $reflect = new \ReflectionClass(get_class($resource));
+ $reflect = new \ReflectionClass($resource::class);
foreach (array_keys($reflect->getConstants()) as $const) {
- if (strpos($const, 'STATUS_') === 0 && $const != 'STATUS_NEW') {
+ if (str_starts_with($const, 'STATUS_') && $const != 'STATUS_NEW') {
$method = Str::camel('is_' . strtolower(substr($const, 7)));
$state[$method] = $resource->{$method}();
}
@@ -199,15 +201,15 @@
}
$all = count($process);
- $checked = count(array_filter($process, function ($v) {
- return $v['state'];
+ $checked = count(array_filter($process, static function ($v) {
+ return $v['state'];
}));
$state = $all === $checked ? 'done' : 'running';
// After 180 seconds assume the process is in failed state,
// this should unlock the Refresh button in the UI
- if ($all !== $checked && $object->created_at->diffInSeconds(\Carbon\Carbon::now()) > 180) {
+ if ($all !== $checked && $object->created_at->diffInSeconds(Carbon::now()) > 180) {
$state = 'failed';
}
@@ -277,7 +279,7 @@
*
* @param int $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse|void
+ * @return JsonResponse|void
*/
public function setConfig($id)
{
@@ -304,17 +306,17 @@
}
return response()->json([
- 'status' => 'success',
- 'message' => \trans("app.{$this->label}-setconfig-success"),
+ 'status' => 'success',
+ 'message' => \trans("app.{$this->label}-setconfig-success"),
]);
}
/**
* Display information of a resource specified by $id.
*
- * @param string $id The resource to show information for.
+ * @param string $id the resource to show information for
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
@@ -356,7 +358,7 @@
*
* @param int $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function skus($id)
{
@@ -378,7 +380,7 @@
*
* @param int $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function status($id)
{
diff --git a/src/app/Http/Controllers/ResourceController.php b/src/app/Http/Controllers/ResourceController.php
--- a/src/app/Http/Controllers/ResourceController.php
+++ b/src/app/Http/Controllers/ResourceController.php
@@ -2,6 +2,7 @@
namespace App\Http\Controllers;
+use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ResourceController extends Controller
@@ -9,7 +10,7 @@
/**
* Show the form for creating a new resource.
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function create()
{
@@ -21,7 +22,7 @@
*
* @param string $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function destroy($id)
{
@@ -33,7 +34,7 @@
*
* @param string $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function edit($id)
{
@@ -45,7 +46,7 @@
*
* The resource entitlements billed to the current user wallet(s)
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function index()
{
@@ -55,9 +56,9 @@
/**
* Display information of a resource specified by $id.
*
- * @param string $id The resource to show information for.
+ * @param string $id the resource to show information for
*
- * @return \Illuminate\Http\JsonResponse
+ * @return JsonResponse
*/
public function show($id)
{
@@ -67,9 +68,9 @@
/**
* Create a new resource.
*
- * @param \Illuminate\Http\Request $request The API request.
+ * @param Request $request the API request
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function store(Request $request)
{
@@ -79,10 +80,10 @@
/**
* Update a resource.
*
- * @param \Illuminate\Http\Request $request The API request.
- * @param string $id Resource identifier
+ * @param Request $request the API request
+ * @param string $id Resource identifier
*
- * @return \Illuminate\Http\JsonResponse The response
+ * @return JsonResponse The response
*/
public function update(Request $request, $id)
{
diff --git a/src/app/Http/Controllers/WebsocketController.php b/src/app/Http/Controllers/WebsocketController.php
--- a/src/app/Http/Controllers/WebsocketController.php
+++ b/src/app/Http/Controllers/WebsocketController.php
@@ -2,8 +2,6 @@
namespace App\Http\Controllers;
-use Illuminate\Http\Request;
-
class WebsocketController extends Controller
{
public function message($websocket, $data)
diff --git a/src/app/Http/Controllers/WellKnownController.php b/src/app/Http/Controllers/WellKnownController.php
--- a/src/app/Http/Controllers/WellKnownController.php
+++ b/src/app/Http/Controllers/WellKnownController.php
@@ -2,14 +2,14 @@
namespace App\Http\Controllers;
-use App\Http\Controllers\Controller;
+use Illuminate\Http\Response;
class WellKnownController extends Controller
{
/**
* Return the mtaSts policy
*
- * @return \Illuminate\Http\Response The response
+ * @return Response The response
*/
public function mtaSts()
{
@@ -18,11 +18,11 @@
if (!$policy) {
$domain = \config('app.domain');
$policy = <<<EOF
- version: STSv1
- mode: enforce
- mx: $domain
- max_age: 604800
- EOF;
+ version: STSv1
+ mode: enforce
+ mx: {$domain}
+ max_age: 604800
+ EOF;
}
return response($policy, 200)->header('Content-Type', 'text/plain');
diff --git a/src/app/Http/Kernel.php b/src/app/Http/Kernel.php
--- a/src/app/Http/Kernel.php
+++ b/src/app/Http/Kernel.php
@@ -2,7 +2,31 @@
namespace App\Http;
+use App\Http\Middleware\AllowedHosts;
+use App\Http\Middleware\Authenticate;
+use App\Http\Middleware\AuthenticateAdmin;
+use App\Http\Middleware\AuthenticateReseller;
+use App\Http\Middleware\ContentSecurityPolicy;
+use App\Http\Middleware\DevelConfig;
+use App\Http\Middleware\Locale;
+use App\Http\Middleware\PreventRequestsDuringMaintenance;
+use App\Http\Middleware\RedirectIfAuthenticated;
+use App\Http\Middleware\RequestLogger;
+use App\Http\Middleware\TrimStrings;
+use App\Http\Middleware\TrustProxies;
+use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
+use Illuminate\Auth\Middleware\Authorize;
+use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
+use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull;
+use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
+use Illuminate\Http\Middleware\SetCacheHeaders;
+use Illuminate\Http\Response;
+use Illuminate\Routing\Middleware\SubstituteBindings;
+use Illuminate\Routing\Middleware\ThrottleRequests;
+use Illuminate\Routing\Middleware\ValidateSignature;
+use Laravel\Passport\Http\Middleware\CheckForAnyScope;
+use Laravel\Passport\Http\Middleware\CheckScopes;
class Kernel extends HttpKernel
{
@@ -15,15 +39,15 @@
*/
protected $middleware = [
// \App\Http\Middleware\TrustHosts::class,
- \App\Http\Middleware\RequestLogger::class,
- \App\Http\Middleware\TrustProxies::class,
- \App\Http\Middleware\PreventRequestsDuringMaintenance::class,
- \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
- \App\Http\Middleware\TrimStrings::class,
- \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
- \App\Http\Middleware\DevelConfig::class,
- \App\Http\Middleware\Locale::class,
- \App\Http\Middleware\ContentSecurityPolicy::class,
+ RequestLogger::class,
+ TrustProxies::class,
+ PreventRequestsDuringMaintenance::class,
+ ValidatePostSize::class,
+ TrimStrings::class,
+ ConvertEmptyStringsToNull::class,
+ DevelConfig::class,
+ Locale::class,
+ ContentSecurityPolicy::class,
// FIXME: CORS handling added here, I didn't find a nice way
// to add this only to the API routes
// \App\Http\Middleware\Cors::class,
@@ -47,7 +71,7 @@
'api' => [
// 'throttle:api',
- \Illuminate\Routing\Middleware\SubstituteBindings::class,
+ SubstituteBindings::class,
],
];
@@ -59,19 +83,19 @@
* @var array<string, class-string|string>
*/
protected $middlewareAliases = [
- 'admin' => \App\Http\Middleware\AuthenticateAdmin::class,
- 'auth' => \App\Http\Middleware\Authenticate::class,
- 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
- 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
- 'can' => \Illuminate\Auth\Middleware\Authorize::class,
- 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
- 'reseller' => \App\Http\Middleware\AuthenticateReseller::class,
- 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
- 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
- 'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
- 'scopes' => \Laravel\Passport\Http\Middleware\CheckScopes::class,
- 'scope' => \Laravel\Passport\Http\Middleware\CheckForAnyScope::class,
- 'allowedHosts' => \App\Http\Middleware\AllowedHosts::class,
+ 'admin' => AuthenticateAdmin::class,
+ 'auth' => Authenticate::class,
+ 'auth.basic' => AuthenticateWithBasicAuth::class,
+ 'cache.headers' => SetCacheHeaders::class,
+ 'can' => Authorize::class,
+ 'guest' => RedirectIfAuthenticated::class,
+ 'reseller' => AuthenticateReseller::class,
+ 'signed' => ValidateSignature::class,
+ 'throttle' => ThrottleRequests::class,
+ 'verified' => EnsureEmailIsVerified::class,
+ 'scopes' => CheckScopes::class,
+ 'scope' => CheckForAnyScope::class,
+ 'allowedHosts' => AllowedHosts::class,
];
/**
@@ -79,7 +103,7 @@
*
* @param \Illuminate\Http\Request $request HTTP Request object
*
- * @return \Illuminate\Http\Response
+ * @return Response
*/
public function handle($request)
{
diff --git a/src/app/Http/Middleware/AllowedHosts.php b/src/app/Http/Middleware/AllowedHosts.php
--- a/src/app/Http/Middleware/AllowedHosts.php
+++ b/src/app/Http/Middleware/AllowedHosts.php
@@ -2,19 +2,18 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
class AllowedHosts
{
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
*
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
$allowedDomains = \config('app.services_allowed_domains');
if (!in_array(request()->getHost(), $allowedDomains)) {
diff --git a/src/app/Http/Middleware/Authenticate.php b/src/app/Http/Middleware/Authenticate.php
--- a/src/app/Http/Middleware/Authenticate.php
+++ b/src/app/Http/Middleware/Authenticate.php
@@ -3,15 +3,14 @@
namespace App\Http\Middleware;
use Illuminate\Auth\Middleware\Authenticate as Middleware;
+use Illuminate\Http\Request;
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
- * @param \Illuminate\Http\Request $request
- *
- * @return string|null
+ * @param Request $request
*/
protected function redirectTo($request): ?string
{
diff --git a/src/app/Http/Middleware/AuthenticateAdmin.php b/src/app/Http/Middleware/AuthenticateAdmin.php
--- a/src/app/Http/Middleware/AuthenticateAdmin.php
+++ b/src/app/Http/Middleware/AuthenticateAdmin.php
@@ -2,18 +2,18 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
class AuthenticateAdmin
{
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
+ *
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
$user = auth()->user();
diff --git a/src/app/Http/Middleware/AuthenticateReseller.php b/src/app/Http/Middleware/AuthenticateReseller.php
--- a/src/app/Http/Middleware/AuthenticateReseller.php
+++ b/src/app/Http/Middleware/AuthenticateReseller.php
@@ -2,18 +2,18 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
class AuthenticateReseller
{
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
+ *
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
$user = auth()->user();
diff --git a/src/app/Http/Middleware/ContentSecurityPolicy.php b/src/app/Http/Middleware/ContentSecurityPolicy.php
--- a/src/app/Http/Middleware/ContentSecurityPolicy.php
+++ b/src/app/Http/Middleware/ContentSecurityPolicy.php
@@ -2,26 +2,25 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
class ContentSecurityPolicy
{
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
*
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
$headers = [
'csp' => 'Content-Security-Policy',
'xfo' => 'X-Frame-Options',
];
- //Exclude horizon routes, per https://github.com/laravel/horizon/issues/576
+ // Exclude horizon routes, per https://github.com/laravel/horizon/issues/576
if ($request->is('horizon*')) {
$headers = [];
}
diff --git a/src/app/Http/Middleware/Cors.php b/src/app/Http/Middleware/Cors.php
--- a/src/app/Http/Middleware/Cors.php
+++ b/src/app/Http/Middleware/Cors.php
@@ -2,19 +2,18 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
class Cors
{
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
*
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
// TODO: Now we allow all, but we should be allowing only meet.domain.tld
diff --git a/src/app/Http/Middleware/DevelConfig.php b/src/app/Http/Middleware/DevelConfig.php
--- a/src/app/Http/Middleware/DevelConfig.php
+++ b/src/app/Http/Middleware/DevelConfig.php
@@ -2,7 +2,7 @@
namespace App\Http\Middleware;
-use Closure;
+use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
class DevelConfig
@@ -10,12 +10,11 @@
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
+ * @param Request $request
*
* @return mixed
*/
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
// Only in testing/local environment...
if (\App::environment('local')) {
diff --git a/src/app/Http/Middleware/EncryptCookies.php b/src/app/Http/Middleware/EncryptCookies.php
--- a/src/app/Http/Middleware/EncryptCookies.php
+++ b/src/app/Http/Middleware/EncryptCookies.php
@@ -12,6 +12,5 @@
* @var array<int, string>
*/
protected $except = [
- //
];
}
diff --git a/src/app/Http/Middleware/Locale.php b/src/app/Http/Middleware/Locale.php
--- a/src/app/Http/Middleware/Locale.php
+++ b/src/app/Http/Middleware/Locale.php
@@ -2,7 +2,7 @@
namespace App\Http\Middleware;
-use Closure;
+use App\Http\Controllers\ContentController;
use Illuminate\Http\Request;
class Locale
@@ -10,15 +10,12 @@
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- *
* @return mixed
*/
- public function handle(Request $request, Closure $next)
+ public function handle(Request $request, \Closure $next)
{
$langDir = resource_path('lang');
- $enabledLanguages = \App\Http\Controllers\ContentController::locales();
+ $enabledLanguages = ContentController::locales();
$lang = null;
// setLocale() will modify the app.locale config entry, so any subsequent
@@ -30,7 +27,7 @@
if (
($cookie = $request->cookie('language'))
&& in_array($cookie, $enabledLanguages)
- && ($cookie == $default || file_exists("$langDir/$cookie"))
+ && ($cookie == $default || file_exists("{$langDir}/{$cookie}"))
) {
$lang = $cookie;
}
@@ -38,7 +35,7 @@
// If there's no cookie select try the browser languages
if (!$lang) {
$preferences = array_map(
- function ($lang) {
+ static function ($lang) {
return preg_replace('/[^a-z].*$/', '', strtolower($lang));
},
$request->getLanguages()
@@ -48,7 +45,7 @@
if (
!empty($pref)
&& in_array($pref, $enabledLanguages)
- && ($pref == $default || file_exists("$langDir/$pref"))
+ && ($pref == $default || file_exists("{$langDir}/{$pref}"))
) {
$lang = $pref;
break;
diff --git a/src/app/Http/Middleware/PreventRequestsDuringMaintenance.php b/src/app/Http/Middleware/PreventRequestsDuringMaintenance.php
--- a/src/app/Http/Middleware/PreventRequestsDuringMaintenance.php
+++ b/src/app/Http/Middleware/PreventRequestsDuringMaintenance.php
@@ -12,6 +12,5 @@
* @var array<int, string>
*/
protected $except = [
- //
];
}
diff --git a/src/app/Http/Middleware/RedirectIfAuthenticated.php b/src/app/Http/Middleware/RedirectIfAuthenticated.php
--- a/src/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/src/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -2,7 +2,6 @@
namespace App\Http\Middleware;
-use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
@@ -11,13 +10,11 @@
/**
* Handle an incoming request.
*
- * @param \Illuminate\Http\Request $request
- * @param \Closure $next
- * @param string|null ...$guards
+ * @param string|null ...$guards
*
* @return mixed
*/
- public function handle(Request $request, Closure $next, ...$guards)
+ public function handle(Request $request, \Closure $next, ...$guards)
{
$guards = empty($guards) ? [null] : $guards;
diff --git a/src/app/Http/Middleware/RequestLogger.php b/src/app/Http/Middleware/RequestLogger.php
--- a/src/app/Http/Middleware/RequestLogger.php
+++ b/src/app/Http/Middleware/RequestLogger.php
@@ -2,13 +2,11 @@
namespace App\Http\Middleware;
-use Closure;
-
class RequestLogger
{
private static $start;
- public function handle($request, Closure $next)
+ public function handle($request, \Closure $next)
{
// FIXME: This is not really a request start, but we can't
// use LARAVEL_START constant when working with swoole
diff --git a/src/app/Http/Middleware/TrustProxies.php b/src/app/Http/Middleware/TrustProxies.php
--- a/src/app/Http/Middleware/TrustProxies.php
+++ b/src/app/Http/Middleware/TrustProxies.php
@@ -12,9 +12,9 @@
*
* @var int
*/
- protected $headers = Request::HEADER_X_FORWARDED_FOR |
- Request::HEADER_X_FORWARDED_HOST |
- Request::HEADER_X_FORWARDED_PORT |
- Request::HEADER_X_FORWARDED_PROTO |
- Request::HEADER_X_FORWARDED_AWS_ELB;
+ protected $headers = Request::HEADER_X_FORWARDED_FOR
+ | Request::HEADER_X_FORWARDED_HOST
+ | Request::HEADER_X_FORWARDED_PORT
+ | Request::HEADER_X_FORWARDED_PROTO
+ | Request::HEADER_X_FORWARDED_AWS_ELB;
}
diff --git a/src/app/Http/Middleware/VerifyCsrfToken.php b/src/app/Http/Middleware/VerifyCsrfToken.php
--- a/src/app/Http/Middleware/VerifyCsrfToken.php
+++ b/src/app/Http/Middleware/VerifyCsrfToken.php
@@ -12,6 +12,5 @@
* @var array<int, string>
*/
protected $except = [
- //
];
}
diff --git a/src/app/IP4Net.php b/src/app/IP4Net.php
--- a/src/app/IP4Net.php
+++ b/src/app/IP4Net.php
@@ -30,7 +30,7 @@
'country',
'serial',
'created_at',
- 'updated_at'
+ 'updated_at',
];
/**
@@ -57,28 +57,24 @@
/**
* net_number accessor. Internally we store IP addresses
* in a numeric form, outside they are human-readable.
- *
- * @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function netNumber(): Attribute
{
return Attribute::make(
- get: fn ($ip) => inet_ntop($ip),
- set: fn ($ip) => inet_pton($ip),
+ get: static fn ($ip) => inet_ntop($ip),
+ set: static fn ($ip) => inet_pton($ip),
);
}
/**
* net_broadcast accessor. Internally we store IP addresses
* in a numeric form, outside they are human-readable.
- *
- * @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function netBroadcast(): Attribute
{
return Attribute::make(
- get: fn ($ip) => inet_ntop($ip),
- set: fn ($ip) => inet_pton($ip),
+ get: static fn ($ip) => inet_ntop($ip),
+ set: static fn ($ip) => inet_pton($ip),
);
}
}
diff --git a/src/app/Jobs/CommonJob.php b/src/app/Jobs/CommonJob.php
--- a/src/app/Jobs/CommonJob.php
+++ b/src/app/Jobs/CommonJob.php
@@ -22,8 +22,6 @@
/**
* Execute the job.
- *
- * @return void
*/
abstract public function handle();
diff --git a/src/app/Jobs/Domain/CreateJob.php b/src/app/Jobs/Domain/CreateJob.php
--- a/src/app/Jobs/Domain/CreateJob.php
+++ b/src/app/Jobs/Domain/CreateJob.php
@@ -2,14 +2,14 @@
namespace App\Jobs\Domain;
+use App\Domain;
use App\Jobs\DomainJob;
+use App\Support\Facades\LDAP;
class CreateJob extends DomainJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -20,12 +20,12 @@
}
if (\config('app.with_ldap') && !$domain->isLdapReady()) {
- \App\Support\Facades\LDAP::createDomain($domain);
+ LDAP::createDomain($domain);
- $domain->status |= \App\Domain::STATUS_LDAP_READY;
+ $domain->status |= Domain::STATUS_LDAP_READY;
$domain->save();
}
- \App\Jobs\Domain\VerifyJob::dispatch($domain->id);
+ VerifyJob::dispatch($domain->id);
}
}
diff --git a/src/app/Jobs/Domain/DeleteJob.php b/src/app/Jobs/Domain/DeleteJob.php
--- a/src/app/Jobs/Domain/DeleteJob.php
+++ b/src/app/Jobs/Domain/DeleteJob.php
@@ -2,14 +2,14 @@
namespace App\Jobs\Domain;
+use App\Domain;
use App\Jobs\DomainJob;
+use App\Support\Facades\LDAP;
class DeleteJob extends DomainJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -31,12 +31,12 @@
}
if (\config('app.with_ldap') && $domain->isLdapReady()) {
- \App\Support\Facades\LDAP::deleteDomain($domain);
+ LDAP::deleteDomain($domain);
- $domain->status ^= \App\Domain::STATUS_LDAP_READY;
+ $domain->status ^= Domain::STATUS_LDAP_READY;
}
- $domain->status |= \App\Domain::STATUS_DELETED;
+ $domain->status |= Domain::STATUS_DELETED;
$domain->save();
}
}
diff --git a/src/app/Jobs/Domain/UpdateJob.php b/src/app/Jobs/Domain/UpdateJob.php
--- a/src/app/Jobs/Domain/UpdateJob.php
+++ b/src/app/Jobs/Domain/UpdateJob.php
@@ -3,13 +3,12 @@
namespace App\Jobs\Domain;
use App\Jobs\DomainJob;
+use App\Support\Facades\LDAP;
class UpdateJob extends DomainJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -24,6 +23,6 @@
return;
}
- \App\Support\Facades\LDAP::updateDomain($domain);
+ LDAP::updateDomain($domain);
}
}
diff --git a/src/app/Jobs/Domain/VerifyJob.php b/src/app/Jobs/Domain/VerifyJob.php
--- a/src/app/Jobs/Domain/VerifyJob.php
+++ b/src/app/Jobs/Domain/VerifyJob.php
@@ -8,8 +8,6 @@
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
diff --git a/src/app/Jobs/DomainJob.php b/src/app/Jobs/DomainJob.php
--- a/src/app/Jobs/DomainJob.php
+++ b/src/app/Jobs/DomainJob.php
@@ -31,9 +31,7 @@
/**
* Create a new job instance.
*
- * @param int $domainId The ID for the domain to create.
- *
- * @return void
+ * @param int $domainId the ID for the domain to create
*/
public function __construct(int $domainId)
{
diff --git a/src/app/Jobs/Group/CreateJob.php b/src/app/Jobs/Group/CreateJob.php
--- a/src/app/Jobs/Group/CreateJob.php
+++ b/src/app/Jobs/Group/CreateJob.php
@@ -2,14 +2,14 @@
namespace App\Jobs\Group;
+use App\Group;
use App\Jobs\GroupJob;
+use App\Support\Facades\LDAP;
class CreateJob extends GroupJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -20,12 +20,12 @@
}
if (\config('app.with_ldap') && !$group->isLdapReady()) {
- \App\Support\Facades\LDAP::createGroup($group);
+ LDAP::createGroup($group);
- $group->status |= \App\Group::STATUS_LDAP_READY;
+ $group->status |= Group::STATUS_LDAP_READY;
}
- $group->status |= \App\Group::STATUS_ACTIVE;
+ $group->status |= Group::STATUS_ACTIVE;
$group->save();
}
}
diff --git a/src/app/Jobs/Group/DeleteJob.php b/src/app/Jobs/Group/DeleteJob.php
--- a/src/app/Jobs/Group/DeleteJob.php
+++ b/src/app/Jobs/Group/DeleteJob.php
@@ -2,14 +2,14 @@
namespace App\Jobs\Group;
+use App\Group;
use App\Jobs\GroupJob;
+use App\Support\Facades\LDAP;
class DeleteJob extends GroupJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -31,20 +31,20 @@
}
if (\config('app.with_ldap') && $group->isLdapReady()) {
- \App\Support\Facades\LDAP::deleteGroup($group);
+ LDAP::deleteGroup($group);
- $group->status ^= \App\Group::STATUS_LDAP_READY;
+ $group->status ^= Group::STATUS_LDAP_READY;
}
-/*
- if (\config('app.with_imap') && $group->isImapReady()) {
- if (!\App\Support\Facades\IMAP::deleteGroup($group)) {
- throw new \Exception("Failed to delete group {$this->groupId} from IMAP.");
- }
-
- $group->status ^= \App\Group::STATUS_IMAP_READY;
- }
-*/
- $group->status |= \App\Group::STATUS_DELETED;
+ /*
+ if (\config('app.with_imap') && $group->isImapReady()) {
+ if (!\App\Support\Facades\IMAP::deleteGroup($group)) {
+ throw new \Exception("Failed to delete group {$this->groupId} from IMAP.");
+ }
+
+ $group->status ^= \App\Group::STATUS_IMAP_READY;
+ }
+ */
+ $group->status |= Group::STATUS_DELETED;
$group->save();
}
}
diff --git a/src/app/Jobs/Group/UpdateJob.php b/src/app/Jobs/Group/UpdateJob.php
--- a/src/app/Jobs/Group/UpdateJob.php
+++ b/src/app/Jobs/Group/UpdateJob.php
@@ -2,15 +2,13 @@
namespace App\Jobs\Group;
-use App\Support\Facades\LDAP;
use App\Jobs\GroupJob;
+use App\Support\Facades\LDAP;
class UpdateJob extends GroupJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
diff --git a/src/app/Jobs/GroupJob.php b/src/app/Jobs/GroupJob.php
--- a/src/app/Jobs/GroupJob.php
+++ b/src/app/Jobs/GroupJob.php
@@ -31,9 +31,7 @@
/**
* Create a new job instance.
*
- * @param int $groupId The ID for the group to create.
- *
- * @return void
+ * @param int $groupId the ID for the group to create
*/
public function __construct(int $groupId)
{
diff --git a/src/app/Jobs/IMAP/AclCleanupJob.php b/src/app/Jobs/IMAP/AclCleanupJob.php
--- a/src/app/Jobs/IMAP/AclCleanupJob.php
+++ b/src/app/Jobs/IMAP/AclCleanupJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\IMAP;
use App\Jobs\CommonJob;
+use App\Support\Facades\IMAP;
/**
* Remove ACL for a specified user/group anywhere in IMAP
@@ -33,14 +34,11 @@
/** @var int The number of tries for this Job. */
public $tries = 3;
-
/**
* Create a new job instance.
*
* @param string $ident ACL identifier
* @param string $domain ACL domain
- *
- * @return void
*/
public function __construct(string $ident, string $domain = '')
{
@@ -51,12 +49,10 @@
/**
* Execute the job.
*
- * @return void
- *
* @throws \Exception
*/
public function handle()
{
- \App\Support\Facades\IMAP::aclCleanup($this->ident, $this->domain);
+ IMAP::aclCleanup($this->ident, $this->domain);
}
}
diff --git a/src/app/Jobs/Mail/PasswordResetJob.php b/src/app/Jobs/Mail/PasswordResetJob.php
--- a/src/app/Jobs/Mail/PasswordResetJob.php
+++ b/src/app/Jobs/Mail/PasswordResetJob.php
@@ -2,21 +2,20 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\PasswordReset;
use App\VerificationCode;
-class PasswordResetJob extends \App\Jobs\MailJob
+class PasswordResetJob extends MailJob
{
- /** @var \App\VerificationCode Verification code object */
+ /** @var VerificationCode Verification code object */
protected $code;
-
/**
* Create a new job instance.
*
- * @param \App\VerificationCode $code Verification code object
- *
- * @return void
+ * @param VerificationCode $code Verification code object
*/
public function __construct(VerificationCode $code)
{
@@ -25,14 +24,12 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
$email = $this->code->user->getSetting('external_email');
- \App\Mail\Helper::sendMail(
+ Helper::sendMail(
new PasswordReset($this->code),
$this->code->user->tenant_id,
['to' => $email]
diff --git a/src/app/Jobs/Mail/PasswordRetentionJob.php b/src/app/Jobs/Mail/PasswordRetentionJob.php
--- a/src/app/Jobs/Mail/PasswordRetentionJob.php
+++ b/src/app/Jobs/Mail/PasswordRetentionJob.php
@@ -2,26 +2,26 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\PasswordExpirationReminder;
+use App\User;
-class PasswordRetentionJob extends \App\Jobs\MailJob
+class PasswordRetentionJob extends MailJob
{
/** @var string Password expiration date */
protected $expiresOn;
- /** @var \App\User User object */
+ /** @var User User object */
protected $user;
-
/**
* Create a new job instance.
*
- * @param \App\User $user User object
- * @param string $expiresOn Password expiration date
- *
- * @return void
+ * @param User $user User object
+ * @param string $expiresOn Password expiration date
*/
- public function __construct(\App\User $user, string $expiresOn)
+ public function __construct(User $user, string $expiresOn)
{
$this->user = $user;
$this->expiresOn = $expiresOn;
@@ -29,8 +29,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -42,7 +40,7 @@
// TODO: Should we check if the password didn't update since
// the job has been created?
- \App\Mail\Helper::sendMail(
+ Helper::sendMail(
new PasswordExpirationReminder($this->user, $this->expiresOn),
$this->user->tenant_id,
['to' => $this->user->email]
diff --git a/src/app/Jobs/Mail/PaymentJob.php b/src/app/Jobs/Mail/PaymentJob.php
--- a/src/app/Jobs/Mail/PaymentJob.php
+++ b/src/app/Jobs/Mail/PaymentJob.php
@@ -2,27 +2,28 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
+use App\Mail\PaymentFailure;
+use App\Mail\PaymentSuccess;
use App\Payment;
use App\User;
-class PaymentJob extends \App\Jobs\MailJob
+class PaymentJob extends MailJob
{
- /** @var \App\Payment A payment object */
+ /** @var Payment A payment object */
protected $payment;
- /** @var ?\App\User A wallet controller */
+ /** @var ?User A wallet controller */
protected $controller;
-
/**
* Create a new job instance.
*
- * @param \App\Payment $payment A payment object
- * @param \App\User $controller A wallet controller
- *
- * @return void
+ * @param Payment $payment A payment object
+ * @param User $controller A wallet controller
*/
- public function __construct(Payment $payment, User $controller = null)
+ public function __construct(Payment $payment, ?User $controller = null)
{
$this->payment = $payment;
$this->controller = $controller;
@@ -30,8 +31,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -46,19 +45,19 @@
}
if ($this->payment->status == Payment::STATUS_PAID) {
- $mail = new \App\Mail\PaymentSuccess($this->payment, $this->controller);
+ $mail = new PaymentSuccess($this->payment, $this->controller);
$label = "Success";
} elseif (
$this->payment->status == Payment::STATUS_EXPIRED
|| $this->payment->status == Payment::STATUS_FAILED
) {
- $mail = new \App\Mail\PaymentFailure($this->payment, $this->controller);
+ $mail = new PaymentFailure($this->payment, $this->controller);
$label = "Failure";
} else {
return;
}
- list($to, $cc) = \App\Mail\Helper::userEmails($this->controller);
+ [$to, $cc] = Helper::userEmails($this->controller);
if (!empty($to) || !empty($cc)) {
$params = [
@@ -67,7 +66,7 @@
'add' => " for {$wallet->id}",
];
- \App\Mail\Helper::sendMail($mail, $this->controller->tenant_id, $params);
+ Helper::sendMail($mail, $this->controller->tenant_id, $params);
}
/*
diff --git a/src/app/Jobs/Mail/PaymentMandateDisabledJob.php b/src/app/Jobs/Mail/PaymentMandateDisabledJob.php
--- a/src/app/Jobs/Mail/PaymentMandateDisabledJob.php
+++ b/src/app/Jobs/Mail/PaymentMandateDisabledJob.php
@@ -2,28 +2,27 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\PaymentMandateDisabled;
use App\User;
use App\Wallet;
-class PaymentMandateDisabledJob extends \App\Jobs\MailJob
+class PaymentMandateDisabledJob extends MailJob
{
- /** @var \App\Wallet A wallet object */
+ /** @var Wallet A wallet object */
protected $wallet;
- /** @var ?\App\User A wallet controller */
+ /** @var ?User A wallet controller */
protected $controller;
-
/**
* Create a new job instance.
*
- * @param \App\Wallet $wallet A wallet object
- * @param \App\User $controller An email recipient (wallet controller)
- *
- * @return void
+ * @param Wallet $wallet A wallet object
+ * @param User $controller An email recipient (wallet controller)
*/
- public function __construct(Wallet $wallet, User $controller = null)
+ public function __construct(Wallet $wallet, ?User $controller = null)
{
$this->wallet = $wallet;
$this->controller = $controller;
@@ -31,8 +30,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -46,7 +43,7 @@
$mail = new PaymentMandateDisabled($this->wallet, $this->controller);
- list($to, $cc) = \App\Mail\Helper::userEmails($this->controller);
+ [$to, $cc] = Helper::userEmails($this->controller);
if (!empty($to) || !empty($cc)) {
$params = [
@@ -55,7 +52,7 @@
'add' => " for {$this->wallet->id}",
];
- \App\Mail\Helper::sendMail($mail, $this->controller->tenant_id, $params);
+ Helper::sendMail($mail, $this->controller->tenant_id, $params);
}
/*
diff --git a/src/app/Jobs/Mail/SignupInvitationJob.php b/src/app/Jobs/Mail/SignupInvitationJob.php
--- a/src/app/Jobs/Mail/SignupInvitationJob.php
+++ b/src/app/Jobs/Mail/SignupInvitationJob.php
@@ -2,21 +2,20 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\SignupInvitation as SignupInvitationMail;
use App\SignupInvitation;
-class SignupInvitationJob extends \App\Jobs\MailJob
+class SignupInvitationJob extends MailJob
{
/** @var SignupInvitation Signup invitation object */
protected $invitation;
-
/**
* Create a new job instance.
*
* @param SignupInvitation $invitation Invitation object
- *
- * @return void
*/
public function __construct(SignupInvitation $invitation)
{
@@ -25,12 +24,10 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
- \App\Mail\Helper::sendMail(
+ Helper::sendMail(
new SignupInvitationMail($this->invitation),
$this->invitation->tenant_id,
['to' => $this->invitation->email]
@@ -43,10 +40,6 @@
/**
* The job failed to process.
- *
- * @param \Exception $exception
- *
- * @return void
*/
public function failed(\Exception $exception)
{
diff --git a/src/app/Jobs/Mail/SignupVerificationJob.php b/src/app/Jobs/Mail/SignupVerificationJob.php
--- a/src/app/Jobs/Mail/SignupVerificationJob.php
+++ b/src/app/Jobs/Mail/SignupVerificationJob.php
@@ -2,21 +2,20 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\SignupVerification;
use App\SignupCode;
-class SignupVerificationJob extends \App\Jobs\MailJob
+class SignupVerificationJob extends MailJob
{
/** @var SignupCode Signup verification code object */
protected $code;
-
/**
* Create a new job instance.
*
* @param SignupCode $code Verification code object
- *
- * @return void
*/
public function __construct(SignupCode $code)
{
@@ -25,12 +24,10 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
- \App\Mail\Helper::sendMail(
+ Helper::sendMail(
new SignupVerification($this->code),
$this->code->tenant_id,
['to' => $this->code->email]
diff --git a/src/app/Jobs/Mail/TrialEndJob.php b/src/app/Jobs/Mail/TrialEndJob.php
--- a/src/app/Jobs/Mail/TrialEndJob.php
+++ b/src/app/Jobs/Mail/TrialEndJob.php
@@ -2,21 +2,20 @@
namespace App\Jobs\Mail;
+use App\Jobs\MailJob;
+use App\Mail\Helper;
use App\Mail\TrialEnd;
use App\User;
-class TrialEndJob extends \App\Jobs\MailJob
+class TrialEndJob extends MailJob
{
- /** @var \App\User The account owner */
+ /** @var User The account owner */
protected $account;
-
/**
* Create a new job instance.
*
- * @param \App\User $account The account owner
- *
- * @return void
+ * @param User $account The account owner
*/
public function __construct(User $account)
{
@@ -25,14 +24,12 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
// Skip accounts that aren't ready for mail delivery
if ($this->account->isLdapReady() && $this->account->isImapReady()) {
- \App\Mail\Helper::sendMail(
+ Helper::sendMail(
new TrialEnd($this->account),
$this->account->tenant_id,
['to' => $this->account->email]
diff --git a/src/app/Jobs/MailJob.php b/src/app/Jobs/MailJob.php
--- a/src/app/Jobs/MailJob.php
+++ b/src/app/Jobs/MailJob.php
@@ -2,6 +2,7 @@
namespace App\Jobs;
+use App\Enums\Queue;
use Illuminate\Queue\SerializesModels;
/**
@@ -18,8 +19,7 @@
public $deleteWhenMissingModels = true;
/** @var string|null The name of the queue the job should be sent to. */
- public $queue = \App\Enums\Queue::Mail->value;
-
+ public $queue = Queue::Mail->value;
/**
* Number of seconds to wait before retrying the job.
diff --git a/src/app/Jobs/PGP/KeyCreateJob.php b/src/app/Jobs/PGP/KeyCreateJob.php
--- a/src/app/Jobs/PGP/KeyCreateJob.php
+++ b/src/app/Jobs/PGP/KeyCreateJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\PGP;
use App\Jobs\UserJob;
+use App\Support\Facades\PGP;
/**
* Create a GPG keypair for a user (or alias).
@@ -19,10 +20,8 @@
/**
* Create a new job instance.
*
- * @param int $userId User identifier.
+ * @param int $userId user identifier
* @param string $userEmail User email address for the key
- *
- * @return void
*/
public function __construct(int $userId, string $userEmail)
{
@@ -33,8 +32,6 @@
/**
* Execute the job.
*
- * @return void
- *
* @throws \Exception
*/
public function handle()
@@ -64,6 +61,6 @@
return;
}
- \App\Support\Facades\PGP::keypairCreate($user, $this->userEmail);
+ PGP::keypairCreate($user, $this->userEmail);
}
}
diff --git a/src/app/Jobs/PGP/KeyDeleteJob.php b/src/app/Jobs/PGP/KeyDeleteJob.php
--- a/src/app/Jobs/PGP/KeyDeleteJob.php
+++ b/src/app/Jobs/PGP/KeyDeleteJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\PGP;
use App\Jobs\UserJob;
+use App\Support\Facades\PGP;
/**
* Delete a GPG keypair for a user (or alias) from the DNS and Enigma storage.
@@ -12,10 +13,8 @@
/**
* Create a new job instance.
*
- * @param int $userId User identifier.
+ * @param int $userId user identifier
* @param string $userEmail User email address of the key
- *
- * @return void
*/
public function __construct(int $userId, string $userEmail)
{
@@ -26,8 +25,6 @@
/**
* Execute the job.
*
- * @return void
- *
* @throws \Exception
*/
public function handle()
@@ -38,6 +35,6 @@
return;
}
- \App\Support\Facades\PGP::keyDelete($user, $this->userEmail);
+ PGP::keyDelete($user, $this->userEmail);
}
}
diff --git a/src/app/Jobs/Resource/CreateJob.php b/src/app/Jobs/Resource/CreateJob.php
--- a/src/app/Jobs/Resource/CreateJob.php
+++ b/src/app/Jobs/Resource/CreateJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\Resource;
use App\Jobs\ResourceJob;
+use App\Resource;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,8 +11,6 @@
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -55,7 +54,7 @@
if ($withLdap && !$resource->isLdapReady()) {
LDAP::createResource($resource);
- $resource->status |= \App\Resource::STATUS_LDAP_READY;
+ $resource->status |= Resource::STATUS_LDAP_READY;
$resource->save();
}
@@ -73,10 +72,10 @@
}
}
- $resource->status |= \App\Resource::STATUS_IMAP_READY;
+ $resource->status |= Resource::STATUS_IMAP_READY;
}
- $resource->status |= \App\Resource::STATUS_ACTIVE;
+ $resource->status |= Resource::STATUS_ACTIVE;
$resource->save();
}
}
diff --git a/src/app/Jobs/Resource/DeleteJob.php b/src/app/Jobs/Resource/DeleteJob.php
--- a/src/app/Jobs/Resource/DeleteJob.php
+++ b/src/app/Jobs/Resource/DeleteJob.php
@@ -3,13 +3,14 @@
namespace App\Jobs\Resource;
use App\Jobs\ResourceJob;
+use App\Resource;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
class DeleteJob extends ResourceJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -31,23 +32,23 @@
}
if (\config('app.with_ldap') && $resource->isLdapReady()) {
- \App\Support\Facades\LDAP::deleteResource($resource);
+ LDAP::deleteResource($resource);
- $resource->status ^= \App\Resource::STATUS_LDAP_READY;
+ $resource->status ^= Resource::STATUS_LDAP_READY;
$resource->save();
}
if ($resource->isImapReady()) {
if (\config('app.with_imap')) {
- if (!\App\Support\Facades\IMAP::deleteResource($resource)) {
+ if (!IMAP::deleteResource($resource)) {
throw new \Exception("Failed to delete mailbox for resource {$this->resourceId}.");
}
}
- $resource->status ^= \App\Resource::STATUS_IMAP_READY;
+ $resource->status ^= Resource::STATUS_IMAP_READY;
}
- $resource->status |= \App\Resource::STATUS_DELETED;
+ $resource->status |= Resource::STATUS_DELETED;
$resource->save();
}
}
diff --git a/src/app/Jobs/Resource/UpdateJob.php b/src/app/Jobs/Resource/UpdateJob.php
--- a/src/app/Jobs/Resource/UpdateJob.php
+++ b/src/app/Jobs/Resource/UpdateJob.php
@@ -3,13 +3,13 @@
namespace App\Jobs\Resource;
use App\Jobs\ResourceJob;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
class UpdateJob extends ResourceJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -26,11 +26,11 @@
}
if (\config('app.with_ldap') && $resource->isLdapReady()) {
- \App\Support\Facades\LDAP::updateResource($resource);
+ LDAP::updateResource($resource);
}
if (\config('app.with_imap') && $resource->isImapReady()) {
- if (!\App\Support\Facades\IMAP::updateResource($resource, $this->properties)) {
+ if (!IMAP::updateResource($resource, $this->properties)) {
throw new \Exception("Failed to update mailbox for resource {$this->resourceId}.");
}
}
diff --git a/src/app/Jobs/Resource/VerifyJob.php b/src/app/Jobs/Resource/VerifyJob.php
--- a/src/app/Jobs/Resource/VerifyJob.php
+++ b/src/app/Jobs/Resource/VerifyJob.php
@@ -3,13 +3,13 @@
namespace App\Jobs\Resource;
use App\Jobs\ResourceJob;
+use App\Resource;
+use App\Support\Facades\IMAP;
class VerifyJob extends ResourceJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -26,9 +26,9 @@
$folder = $resource->getSetting('folder');
- if ($folder && \App\Support\Facades\IMAP::verifySharedFolder($folder)) {
- $resource->status |= \App\Resource::STATUS_IMAP_READY;
- $resource->status |= \App\Resource::STATUS_ACTIVE;
+ if ($folder && IMAP::verifySharedFolder($folder)) {
+ $resource->status |= Resource::STATUS_IMAP_READY;
+ $resource->status |= Resource::STATUS_ACTIVE;
$resource->save();
}
}
diff --git a/src/app/Jobs/ResourceJob.php b/src/app/Jobs/ResourceJob.php
--- a/src/app/Jobs/ResourceJob.php
+++ b/src/app/Jobs/ResourceJob.php
@@ -2,9 +2,11 @@
namespace App\Jobs;
+use App\Resource;
+
/**
* The abstract \App\Jobs\ResourceJob implements the logic needed for all dispatchable Jobs related to
- * \App\Resource objects.
+ * Resource objects.
*
* ```php
* $job = new \App\Jobs\Resource\CreateJob($resourceId);
@@ -21,15 +23,15 @@
protected $properties = [];
/**
- * The ID for the \App\Resource. This is the shortest globally unique identifier and saves Redis space
- * compared to a serialized version of the complete \App\Resource object.
+ * The ID for the Resource. This is the shortest globally unique identifier and saves Redis space
+ * compared to a serialized version of the complete Resource object.
*
* @var int
*/
protected $resourceId;
/**
- * The \App\Resource email property, for legibility in the queue management.
+ * The Resource email property, for legibility in the queue management.
*
* @var string
*/
@@ -38,10 +40,8 @@
/**
* Create a new job instance.
*
- * @param int $resourceId The ID for the resource to process.
+ * @param int $resourceId the ID for the resource to process
* @param array $properties Old values of the resource properties on update
- *
- * @return void
*/
public function __construct(int $resourceId, array $properties = [])
{
@@ -56,20 +56,20 @@
}
/**
- * Get the \App\Resource entry associated with this job.
+ * Get the Resource entry associated with this job.
*
- * @return \App\Resource|null
+ * @return Resource|null
*
* @throws \Exception
*/
protected function getResource()
{
- $resource = \App\Resource::withTrashed()->find($this->resourceId);
+ $resource = Resource::withTrashed()->find($this->resourceId);
if (!$resource) {
// The record might not exist yet in case of a db replication environment
// This will release the job and delay another attempt for 5 seconds
- if ($this instanceof Resource\CreateJob) {
+ if ($this instanceof \App\Jobs\Resource\CreateJob) {
$this->release(5);
return null;
}
diff --git a/src/app/Jobs/SharedFolder/CreateJob.php b/src/app/Jobs/SharedFolder/CreateJob.php
--- a/src/app/Jobs/SharedFolder/CreateJob.php
+++ b/src/app/Jobs/SharedFolder/CreateJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\SharedFolder;
use App\Jobs\SharedFolderJob;
+use App\SharedFolder;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,8 +11,6 @@
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -55,7 +54,7 @@
if ($withLdap && !$folder->isLdapReady()) {
LDAP::createSharedFolder($folder);
- $folder->status |= \App\SharedFolder::STATUS_LDAP_READY;
+ $folder->status |= SharedFolder::STATUS_LDAP_READY;
$folder->save();
}
@@ -73,10 +72,10 @@
}
}
- $folder->status |= \App\SharedFolder::STATUS_IMAP_READY;
+ $folder->status |= SharedFolder::STATUS_IMAP_READY;
}
- $folder->status |= \App\SharedFolder::STATUS_ACTIVE;
+ $folder->status |= SharedFolder::STATUS_ACTIVE;
$folder->save();
}
}
diff --git a/src/app/Jobs/SharedFolder/DeleteJob.php b/src/app/Jobs/SharedFolder/DeleteJob.php
--- a/src/app/Jobs/SharedFolder/DeleteJob.php
+++ b/src/app/Jobs/SharedFolder/DeleteJob.php
@@ -3,13 +3,14 @@
namespace App\Jobs\SharedFolder;
use App\Jobs\SharedFolderJob;
+use App\SharedFolder;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
class DeleteJob extends SharedFolderJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -31,24 +32,24 @@
}
if (\config('app.with_ldap') && $folder->isLdapReady()) {
- \App\Support\Facades\LDAP::deleteSharedFolder($folder);
+ LDAP::deleteSharedFolder($folder);
- $folder->status ^= \App\SharedFolder::STATUS_LDAP_READY;
+ $folder->status ^= SharedFolder::STATUS_LDAP_READY;
// Already save in case of exception below
$folder->save();
}
if ($folder->isImapReady()) {
if (\config('app.with_imap')) {
- if (!\App\Support\Facades\IMAP::deleteSharedFolder($folder)) {
+ if (!IMAP::deleteSharedFolder($folder)) {
throw new \Exception("Failed to delete mailbox for shared folder {$this->folderId}.");
}
}
- $folder->status ^= \App\SharedFolder::STATUS_IMAP_READY;
+ $folder->status ^= SharedFolder::STATUS_IMAP_READY;
}
- $folder->status |= \App\SharedFolder::STATUS_DELETED;
+ $folder->status |= SharedFolder::STATUS_DELETED;
$folder->save();
}
}
diff --git a/src/app/Jobs/SharedFolder/UpdateJob.php b/src/app/Jobs/SharedFolder/UpdateJob.php
--- a/src/app/Jobs/SharedFolder/UpdateJob.php
+++ b/src/app/Jobs/SharedFolder/UpdateJob.php
@@ -3,13 +3,13 @@
namespace App\Jobs\SharedFolder;
use App\Jobs\SharedFolderJob;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
class UpdateJob extends SharedFolderJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -26,11 +26,11 @@
}
if (\config('app.with_ldap') && $folder->isLdapReady()) {
- \App\Support\Facades\LDAP::updateSharedFolder($folder);
+ LDAP::updateSharedFolder($folder);
}
if (\config('app.with_imap') && $folder->isImapReady()) {
- if (!\App\Support\Facades\IMAP::updateSharedFolder($folder, $this->properties)) {
+ if (!IMAP::updateSharedFolder($folder, $this->properties)) {
throw new \Exception("Failed to update mailbox for shared folder {$this->folderId}.");
}
}
diff --git a/src/app/Jobs/SharedFolder/VerifyJob.php b/src/app/Jobs/SharedFolder/VerifyJob.php
--- a/src/app/Jobs/SharedFolder/VerifyJob.php
+++ b/src/app/Jobs/SharedFolder/VerifyJob.php
@@ -3,13 +3,13 @@
namespace App\Jobs\SharedFolder;
use App\Jobs\SharedFolderJob;
+use App\SharedFolder;
+use App\Support\Facades\IMAP;
class VerifyJob extends SharedFolderJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -26,9 +26,9 @@
$folderName = $folder->getSetting('folder');
- if (\App\Support\Facades\IMAP::verifySharedFolder($folderName)) {
- $folder->status |= \App\SharedFolder::STATUS_IMAP_READY;
- $folder->status |= \App\SharedFolder::STATUS_ACTIVE;
+ if (IMAP::verifySharedFolder($folderName)) {
+ $folder->status |= SharedFolder::STATUS_IMAP_READY;
+ $folder->status |= SharedFolder::STATUS_ACTIVE;
$folder->save();
}
}
diff --git a/src/app/Jobs/SharedFolderJob.php b/src/app/Jobs/SharedFolderJob.php
--- a/src/app/Jobs/SharedFolderJob.php
+++ b/src/app/Jobs/SharedFolderJob.php
@@ -39,8 +39,6 @@
*
* @param int $folderId The ID for the shared folder to process
* @param array $properties Old values of the shared folder properties on update (key -> value)
- *
- * @return void
*/
public function __construct(int $folderId, array $properties = [])
{
diff --git a/src/app/Jobs/User/CreateJob.php b/src/app/Jobs/User/CreateJob.php
--- a/src/app/Jobs/User/CreateJob.php
+++ b/src/app/Jobs/User/CreateJob.php
@@ -2,10 +2,13 @@
namespace App\Jobs\User;
+use App\EventLog;
use App\Jobs\UserJob;
+use App\Plan;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
+use App\User;
/**
* Create the \App\User in LDAP.
@@ -24,8 +27,6 @@
/**
* Execute the job.
*
- * @return void
- *
* @throws \Exception
*/
public function handle()
@@ -85,16 +86,16 @@
if ($code == 2) {
$msg = "Abuse check detected suspected spammer";
\Log::info("{$msg}: {$this->userId} {$user->email}");
- \App\EventLog::createFor($user, \App\EventLog::TYPE_SUSPENDED, $msg);
+ EventLog::createFor($user, EventLog::TYPE_SUSPENDED, $msg);
- $user->status |= \App\User::STATUS_SUSPENDED;
+ $user->status |= User::STATUS_SUSPENDED;
}
}
if ($withLdap && !$user->isLdapReady()) {
LDAP::createUser($user);
- $user->status |= \App\User::STATUS_LDAP_READY;
+ $user->status |= User::STATUS_LDAP_READY;
$user->save();
}
@@ -110,7 +111,7 @@
}
}
- $user->status |= \App\User::STATUS_IMAP_READY;
+ $user->status |= User::STATUS_IMAP_READY;
}
// FIXME: Should we ignore exceptions on this operation or introduce DAV_READY status?
@@ -120,9 +121,9 @@
if (
!($wallet = $user->wallet())
|| !($plan = $user->wallet()->plan())
- || $plan->mode != \App\Plan::MODE_MANDATE
+ || $plan->mode != Plan::MODE_MANDATE
) {
- $user->status |= \App\User::STATUS_ACTIVE;
+ $user->status |= User::STATUS_ACTIVE;
}
$user->save();
diff --git a/src/app/Jobs/User/Delegation/CreateJob.php b/src/app/Jobs/User/Delegation/CreateJob.php
--- a/src/app/Jobs/User/Delegation/CreateJob.php
+++ b/src/app/Jobs/User/Delegation/CreateJob.php
@@ -10,14 +10,13 @@
class CreateJob extends UserJob
{
- /** @var int $delegationId Delegation identifier */
+ /** @var int Delegation identifier */
protected $delegationId;
-
/**
* Create a new job instance.
*
- * @param int $delegationId The ID for the delegation to create.
+ * @param int $delegationId the ID for the delegation to create
*/
public function __construct(int $delegationId)
{
@@ -34,7 +33,6 @@
/**
* Execute the job.
*
- * @return void
* @throws \Exception
*/
public function handle()
diff --git a/src/app/Jobs/User/Delegation/DeleteJob.php b/src/app/Jobs/User/Delegation/DeleteJob.php
--- a/src/app/Jobs/User/Delegation/DeleteJob.php
+++ b/src/app/Jobs/User/Delegation/DeleteJob.php
@@ -17,12 +17,11 @@
/** @var string Delegatee's email address */
protected $delegateeEmail;
-
/**
* Create a new job instance.
*
- * @param string $delegatorEmail Delegator's email address.
- * @param string $delegateeEmail Delegatee's email address.
+ * @param string $delegatorEmail delegator's email address
+ * @param string $delegateeEmail delegatee's email address
*/
public function __construct(string $delegatorEmail, string $delegateeEmail)
{
@@ -33,8 +32,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
diff --git a/src/app/Jobs/User/DeleteJob.php b/src/app/Jobs/User/DeleteJob.php
--- a/src/app/Jobs/User/DeleteJob.php
+++ b/src/app/Jobs/User/DeleteJob.php
@@ -3,13 +3,15 @@
namespace App\Jobs\User;
use App\Jobs\UserJob;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
+use App\Support\Facades\Roundcube;
+use App\User;
class DeleteJob extends UserJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -38,27 +40,27 @@
}
if (\config('app.with_ldap') && $user->isLdapReady()) {
- \App\Support\Facades\LDAP::deleteUser($user);
+ LDAP::deleteUser($user);
- $user->status ^= \App\User::STATUS_LDAP_READY;
+ $user->status ^= User::STATUS_LDAP_READY;
$user->save();
}
if ($user->isImapReady()) {
if (\config('app.with_imap')) {
- if (!\App\Support\Facades\IMAP::deleteUser($user)) {
+ if (!IMAP::deleteUser($user)) {
throw new \Exception("Failed to delete mailbox for user {$this->userId}.");
}
}
- $user->status ^= \App\User::STATUS_IMAP_READY;
+ $user->status ^= User::STATUS_IMAP_READY;
}
if (\config('database.connections.roundcube')) {
- \App\Support\Facades\Roundcube::deleteUser($user->email);
+ Roundcube::deleteUser($user->email);
}
- $user->status |= \App\User::STATUS_DELETED;
+ $user->status |= User::STATUS_DELETED;
$user->save();
}
}
diff --git a/src/app/Jobs/User/ResyncJob.php b/src/app/Jobs/User/ResyncJob.php
--- a/src/app/Jobs/User/ResyncJob.php
+++ b/src/app/Jobs/User/ResyncJob.php
@@ -3,6 +3,7 @@
namespace App\Jobs\User;
use App\Domain;
+use App\Jobs\Domain\CreateJob;
use App\Jobs\UserJob;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -12,8 +13,6 @@
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -32,7 +31,7 @@
$withLdap = \config('app.with_ldap');
- $userJob = \App\Jobs\User\UpdateJob::class;
+ $userJob = UpdateJob::class;
// Make sure the LDAP entry exists, fix that
if ($withLdap && $user->isLdapReady()) {
@@ -42,7 +41,7 @@
$domain->status &= ~Domain::STATUS_LDAP_READY;
$domain->save();
- \App\Jobs\Domain\CreateJob::dispatchSync($domain->id);
+ CreateJob::dispatchSync($domain->id);
}
if (!LDAP::getUser($user->email)) {
diff --git a/src/app/Jobs/User/UpdateJob.php b/src/app/Jobs/User/UpdateJob.php
--- a/src/app/Jobs/User/UpdateJob.php
+++ b/src/app/Jobs/User/UpdateJob.php
@@ -3,6 +3,8 @@
namespace App\Jobs\User;
use App\Jobs\UserJob;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
use Illuminate\Contracts\Queue\ShouldBeUniqueUntilProcessing;
class UpdateJob extends UserJob implements ShouldBeUniqueUntilProcessing
@@ -15,8 +17,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -39,11 +39,11 @@
}
if (\config('app.with_ldap') && $user->isLdapReady()) {
- \App\Support\Facades\LDAP::updateUser($user);
+ LDAP::updateUser($user);
}
if (\config('app.with_imap') && $user->isImapReady()) {
- if (!\App\Support\Facades\IMAP::updateUser($user)) {
+ if (!IMAP::updateUser($user)) {
throw new \Exception("Failed to update mailbox for user {$this->userId}.");
}
}
diff --git a/src/app/Jobs/User/VerifyJob.php b/src/app/Jobs/User/VerifyJob.php
--- a/src/app/Jobs/User/VerifyJob.php
+++ b/src/app/Jobs/User/VerifyJob.php
@@ -3,13 +3,13 @@
namespace App\Jobs\User;
use App\Jobs\UserJob;
+use App\Support\Facades\IMAP;
+use App\User;
class VerifyJob extends UserJob
{
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
@@ -37,9 +37,9 @@
return;
}
- if (\App\Support\Facades\IMAP::verifyAccount($user->email)) {
- $user->status |= \App\User::STATUS_IMAP_READY;
- $user->status |= \App\User::STATUS_ACTIVE;
+ if (IMAP::verifyAccount($user->email)) {
+ $user->status |= User::STATUS_IMAP_READY;
+ $user->status |= User::STATUS_ACTIVE;
$user->save();
}
}
diff --git a/src/app/Jobs/UserJob.php b/src/app/Jobs/UserJob.php
--- a/src/app/Jobs/UserJob.php
+++ b/src/app/Jobs/UserJob.php
@@ -2,6 +2,8 @@
namespace App\Jobs;
+use App\User;
+
/**
* The abstract \App\Jobs\UserJob implements the logic needed for all dispatchable Jobs related to
* \App\User objects.
@@ -34,9 +36,7 @@
/**
* Create a new job instance.
*
- * @param int $userId The ID for the user to create.
- *
- * @return void
+ * @param int $userId the ID for the user to create
*/
public function __construct(int $userId)
{
@@ -52,13 +52,13 @@
/**
* Get the \App\User entry associated with this job.
*
- * @return \App\User|null
+ * @return User|null
*
* @throws \Exception
*/
protected function getUser()
{
- $user = \App\User::withTrashed()->find($this->userId);
+ $user = User::withTrashed()->find($this->userId);
if (!$user) {
// The record might not exist yet in case of a db replication environment
diff --git a/src/app/Jobs/Wallet/ChargeJob.php b/src/app/Jobs/Wallet/ChargeJob.php
--- a/src/app/Jobs/Wallet/ChargeJob.php
+++ b/src/app/Jobs/Wallet/ChargeJob.php
@@ -2,6 +2,7 @@
namespace App\Jobs\Wallet;
+use App\Enums\Queue;
use App\Jobs\CommonJob;
use App\Wallet;
@@ -11,7 +12,7 @@
public $tries = 5;
/** @var string|null The name of the queue the job should be sent to. */
- public $queue = \App\Enums\Queue::Background->value;
+ public $queue = Queue::Background->value;
/** @var string A wallet identifier */
protected $walletId;
@@ -19,9 +20,7 @@
/**
* Create a new job instance.
*
- * @param string $walletId The wallet that has been charged.
- *
- * @return void
+ * @param string $walletId the wallet that has been charged
*/
public function __construct(string $walletId)
{
@@ -30,8 +29,6 @@
/**
* Execute the job.
- *
- * @return void
*/
public function handle()
{
diff --git a/src/app/Jobs/Wallet/CheckJob.php b/src/app/Jobs/Wallet/CheckJob.php
--- a/src/app/Jobs/Wallet/CheckJob.php
+++ b/src/app/Jobs/Wallet/CheckJob.php
@@ -2,7 +2,13 @@
namespace App\Jobs\Wallet;
+use App\Enums\Queue;
use App\Jobs\CommonJob;
+use App\Mail\DegradedAccountReminder;
+use App\Mail\Helper;
+use App\Mail\NegativeBalance;
+use App\Mail\NegativeBalanceDegraded;
+use App\Mail\NegativeBalanceReminderDegrade;
use App\Wallet;
use Carbon\Carbon;
@@ -17,7 +23,7 @@
public $tries = 5;
/** @var string|null The name of the queue the job should be sent to. */
- public $queue = \App\Enums\Queue::Background->value;
+ public $queue = Queue::Background->value;
/** @var ?Wallet A wallet object */
protected $wallet;
@@ -25,13 +31,10 @@
/** @var string A wallet identifier */
protected $walletId;
-
/**
* Create a new job instance.
*
- * @param string $walletId The wallet that has been charged.
- *
- * @return void
+ * @param string $walletId the wallet that has been charged
*/
public function __construct(string $walletId)
{
@@ -109,10 +112,10 @@
}
if (!$this->wallet->owner->isSuspended()) {
- $this->sendMail(\App\Mail\NegativeBalance::class, false);
+ $this->sendMail(NegativeBalance::class, false);
}
- $now = \Carbon\Carbon::now()->toDateTimeString();
+ $now = Carbon::now()->toDateTimeString();
$this->wallet->setSetting('balance_warning_initial', $now);
}
@@ -130,10 +133,10 @@
}
if (!$this->wallet->owner->isSuspended()) {
- $this->sendMail(\App\Mail\NegativeBalanceReminderDegrade::class, true);
+ $this->sendMail(NegativeBalanceReminderDegrade::class, true);
}
- $now = \Carbon\Carbon::now()->toDateTimeString();
+ $now = Carbon::now()->toDateTimeString();
$this->wallet->setSetting('balance_warning_reminder', $now);
}
@@ -161,7 +164,7 @@
);
if (!$this->wallet->owner->isSuspended()) {
- $this->sendMail(\App\Mail\NegativeBalanceDegraded::class, true);
+ $this->sendMail(NegativeBalanceDegraded::class, true);
}
}
@@ -179,7 +182,7 @@
return;
}
- $now = \Carbon\Carbon::now();
+ $now = Carbon::now();
$last = $this->wallet->getSetting('degraded_last_reminder');
if ($last) {
@@ -190,7 +193,7 @@
return;
}
- $this->sendMail(\App\Mail\DegradedAccountReminder::class, false);
+ $this->sendMail(DegradedAccountReminder::class, false);
}
$this->wallet->setSetting('degraded_last_reminder', $now->toDateTimeString());
@@ -199,8 +202,8 @@
/**
* Send the email
*
- * @param string $class Mailable class name
- * @param bool $with_external Use users's external email
+ * @param string $class Mailable class name
+ * @param bool $with_external Use users's external email
*/
protected function sendMail($class, $with_external = false): void
{
@@ -208,7 +211,7 @@
$mail = new $class($this->wallet, $this->wallet->owner);
- list($to, $cc) = \App\Mail\Helper::userEmails($this->wallet->owner, $with_external);
+ [$to, $cc] = Helper::userEmails($this->wallet->owner, $with_external);
if (!empty($to) || !empty($cc)) {
$params = [
@@ -217,7 +220,7 @@
'add' => " for {$this->wallet->id}",
];
- \App\Mail\Helper::sendMail($mail, $this->wallet->owner->tenant_id, $params);
+ Helper::sendMail($mail, $this->wallet->owner->tenant_id, $params);
}
}
diff --git a/src/app/Listeners/SqlDebug.php b/src/app/Listeners/SqlDebug.php
--- a/src/app/Listeners/SqlDebug.php
+++ b/src/app/Listeners/SqlDebug.php
@@ -25,7 +25,7 @@
QueryExecuted::class => 'handle',
TransactionBeginning::class => 'handle',
TransactionCommitted::class => 'handle',
- TransactionRolledBack::class => 'handle'
+ TransactionRolledBack::class => 'handle',
];
}
@@ -36,7 +36,7 @@
*/
public function handle(object $event): void
{
- switch (get_class($event)) {
+ switch ($event::class) {
case TransactionBeginning::class:
$query = 'begin';
break;
@@ -65,12 +65,14 @@
{
$ipv = preg_match('/ip([46])nets/', $sql, $m) ? $m[1] : null;
- $serialized = array_map(function ($entry) use ($ipv) {
+ $serialized = array_map(static function ($entry) use ($ipv) {
if ($entry instanceof \DateTime) {
return $entry->format('Y-m-d h:i:s');
- } elseif (is_bool($entry)) {
+ }
+ if (is_bool($entry)) {
return $entry ? 'true' : 'false';
- } elseif ($ipv && is_string($entry) && strlen($entry) == ($ipv == 6 ? 16 : 4)) {
+ }
+ if ($ipv && is_string($entry) && strlen($entry) == ($ipv == 6 ? 16 : 4)) {
// binary IP address? use HEX representation
return '0x' . bin2hex($entry);
}
diff --git a/src/app/Mail/DegradedAccountReminder.php b/src/app/Mail/DegradedAccountReminder.php
--- a/src/app/Mail/DegradedAccountReminder.php
+++ b/src/app/Mail/DegradedAccountReminder.php
@@ -9,17 +9,14 @@
class DegradedAccountReminder extends Mailable
{
- /** @var \App\Wallet A wallet with a negative balance */
+ /** @var Wallet A wallet with a negative balance */
protected $wallet;
-
/**
* Create a new message instance.
*
- * @param \App\Wallet $wallet A wallet
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Wallet $wallet A wallet
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Wallet $wallet, User $user)
{
@@ -47,10 +44,10 @@
->text('emails.plain.degraded_account_reminder')
->subject(\trans('mail.degradedaccountreminder-subject', $vars))
->with([
- 'vars' => $vars,
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
- 'dashboardUrl' => Utils::serviceUrl('/dashboard', $this->user->tenant_id),
+ 'vars' => $vars,
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'dashboardUrl' => Utils::serviceUrl('/dashboard', $this->user->tenant_id),
]);
return $this;
diff --git a/src/app/Mail/Helper.php b/src/app/Mail/Helper.php
--- a/src/app/Mail/Helper.php
+++ b/src/app/Mail/Helper.php
@@ -4,6 +4,8 @@
use App\EventLog;
use App\Tenant;
+use App\User;
+use Illuminate\Container\Container;
use Illuminate\Support\Facades\Mail;
class Helper
@@ -22,7 +24,7 @@
if ($type == 'text') {
$mail->build(); // @phpstan-ignore-line
- $mailer = \Illuminate\Container\Container::getInstance()->make('mailer');
+ $mailer = Container::getInstance()->make('mailer');
return $mailer->render(['text' => $mail->textView], $mail->buildViewData());
}
@@ -46,7 +48,7 @@
*/
public static function sendMail(Mailable $mail, $tenantId = null, array $params = []): void
{
- $class = class_basename(get_class($mail));
+ $class = class_basename($mail::class);
$recipients = [];
// For now we do not support addresses + names, only addresses
@@ -102,12 +104,12 @@
/**
* Return user's email addresses, separately for use in To and Cc.
*
- * @param \App\User $user The user
- * @param bool $external Include users's external email
+ * @param User $user The user
+ * @param bool $external Include users's external email
*
- * @return array To address as the first element, Cc address(es) as the second.
+ * @return array to address as the first element, Cc address(es) as the second
*/
- public static function userEmails(\App\User $user, bool $external = false): array
+ public static function userEmails(User $user, bool $external = false): array
{
$active = $user->isLdapReady() && $user->isImapReady();
diff --git a/src/app/Mail/Mailable.php b/src/app/Mail/Mailable.php
--- a/src/app/Mail/Mailable.php
+++ b/src/app/Mail/Mailable.php
@@ -3,6 +3,7 @@
namespace App\Mail;
use App\Tenant;
+use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable as IMailable;
use Illuminate\Queue\SerializesModels;
@@ -12,16 +13,15 @@
use Queueable;
use SerializesModels;
- /** @var ?\App\User User context */
+ /** @var ?User User context */
protected $user;
-
/**
* Returns the user object of an email main recipient.
*
- * @return ?\App\User User object if set
+ * @return ?User User object if set
*/
- public function getUser(): ?\App\User
+ public function getUser(): ?User
{
return $this->user;
}
diff --git a/src/app/Mail/NegativeBalance.php b/src/app/Mail/NegativeBalance.php
--- a/src/app/Mail/NegativeBalance.php
+++ b/src/app/Mail/NegativeBalance.php
@@ -9,17 +9,14 @@
class NegativeBalance extends Mailable
{
- /** @var \App\Wallet A wallet with a negative balance */
+ /** @var Wallet A wallet with a negative balance */
protected $wallet;
-
/**
* Create a new message instance.
*
- * @param \App\Wallet $wallet A wallet
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Wallet $wallet A wallet
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Wallet $wallet, User $user)
{
@@ -47,9 +44,9 @@
->text('emails.plain.negative_balance')
->subject(\trans('mail.negativebalance-subject', $vars))
->with([
- 'vars' => $vars,
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'vars' => $vars,
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
]);
return $this;
diff --git a/src/app/Mail/NegativeBalanceDegraded.php b/src/app/Mail/NegativeBalanceDegraded.php
--- a/src/app/Mail/NegativeBalanceDegraded.php
+++ b/src/app/Mail/NegativeBalanceDegraded.php
@@ -12,14 +12,11 @@
/** @var Wallet A wallet with a negative balance */
protected $wallet;
-
/**
* Create a new message instance.
*
* @param Wallet $wallet A wallet
* @param User $user A wallet controller to whom the email is being sent
- *
- * @return void
*/
public function __construct(Wallet $wallet, User $user)
{
@@ -47,9 +44,9 @@
->text('emails.plain.negative_balance_degraded')
->subject(\trans('mail.negativebalancedegraded-subject', $vars))
->with([
- 'vars' => $vars,
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'vars' => $vars,
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
]);
return $this;
diff --git a/src/app/Mail/NegativeBalanceReminderDegrade.php b/src/app/Mail/NegativeBalanceReminderDegrade.php
--- a/src/app/Mail/NegativeBalanceReminderDegrade.php
+++ b/src/app/Mail/NegativeBalanceReminderDegrade.php
@@ -10,17 +10,14 @@
class NegativeBalanceReminderDegrade extends Mailable
{
- /** @var \App\Wallet A wallet with a negative balance */
+ /** @var Wallet A wallet with a negative balance */
protected $wallet;
-
/**
* Create a new message instance.
*
- * @param \App\Wallet $wallet A wallet
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Wallet $wallet A wallet
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Wallet $wallet, User $user)
{
@@ -50,9 +47,9 @@
->text('emails.plain.negative_balance_reminder_degrade')
->subject(\trans('mail.negativebalancereminderdegrade-subject', $vars))
->with([
- 'vars' => $vars,
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'vars' => $vars,
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
]);
return $this;
diff --git a/src/app/Mail/PasswordExpirationReminder.php b/src/app/Mail/PasswordExpirationReminder.php
--- a/src/app/Mail/PasswordExpirationReminder.php
+++ b/src/app/Mail/PasswordExpirationReminder.php
@@ -11,14 +11,11 @@
/** @var string Password expiration date */
protected $expiresOn;
-
/**
* Create a new message instance.
*
- * @param \App\User $user A user object
- * @param string $expiresOn Password expiration date (Y-m-d)
- *
- * @return void
+ * @param User $user A user object
+ * @param string $expiresOn Password expiration date (Y-m-d)
*/
public function __construct(User $user, string $expiresOn)
{
@@ -47,8 +44,8 @@
->text('emails.plain.password_expiration_reminder')
->subject(\trans('mail.passwordexpiration-subject', $vars))
->with([
- 'vars' => $vars,
- 'link' => sprintf('<a href="%s">%s</a>', $href, $href)
+ 'vars' => $vars,
+ 'link' => sprintf('<a href="%s">%s</a>', $href, $href),
]);
return $this;
@@ -64,7 +61,7 @@
public static function fakeRender(string $type = 'html'): string
{
$user = new User([
- 'email' => 'test@' . \config('app.domain'),
+ 'email' => 'test@' . \config('app.domain'),
]);
$mail = new self($user, now()->copy()->addDays(14)->toDateString());
diff --git a/src/app/Mail/PasswordReset.php b/src/app/Mail/PasswordReset.php
--- a/src/app/Mail/PasswordReset.php
+++ b/src/app/Mail/PasswordReset.php
@@ -10,16 +10,13 @@
class PasswordReset extends Mailable
{
- /** @var \App\VerificationCode A verification code object */
+ /** @var VerificationCode A verification code object */
protected $code;
-
/**
* Create a new message instance.
*
- * @param \App\VerificationCode $code A verification code object
- *
- * @return void
+ * @param VerificationCode $code A verification code object
*/
public function __construct(VerificationCode $code)
{
@@ -51,10 +48,10 @@
->text('emails.plain.password_reset')
->subject(\trans('mail.passwordreset-subject', $vars))
->with([
- 'vars' => $vars,
- 'link' => sprintf('<a href="%s">%s</a>', $href, $href),
- 'code' => $this->code->code,
- 'short_code' => $this->code->short_code,
+ 'vars' => $vars,
+ 'link' => sprintf('<a href="%s">%s</a>', $href, $href),
+ 'code' => $this->code->code,
+ 'short_code' => $this->code->short_code,
]);
return $this;
@@ -70,13 +67,13 @@
public static function fakeRender(string $type = 'html'): string
{
$code = new VerificationCode([
- 'code' => Str::random(VerificationCode::CODE_LENGTH),
- 'short_code' => VerificationCode::generateShortCode(),
+ 'code' => Str::random(VerificationCode::CODE_LENGTH),
+ 'short_code' => VerificationCode::generateShortCode(),
]);
// @phpstan-ignore-next-line
$code->user = new User([
- 'email' => 'test@' . \config('app.domain'),
+ 'email' => 'test@' . \config('app.domain'),
]);
$mail = new self($code);
diff --git a/src/app/Mail/PaymentFailure.php b/src/app/Mail/PaymentFailure.php
--- a/src/app/Mail/PaymentFailure.php
+++ b/src/app/Mail/PaymentFailure.php
@@ -6,20 +6,18 @@
use App\Tenant;
use App\User;
use App\Utils;
+use App\Wallet;
class PaymentFailure extends Mailable
{
- /** @var \App\Payment A payment operation */
+ /** @var Payment A payment operation */
protected $payment;
-
/**
* Create a new message instance.
*
- * @param \App\Payment $payment A payment operation
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Payment $payment A payment operation
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Payment $payment, User $user)
{
@@ -47,9 +45,9 @@
->text('emails.plain.payment_failure')
->subject(\trans('mail.paymentfailure-subject', $vars))
->with([
- 'vars' => $vars,
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'vars' => $vars,
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
]);
return $this;
@@ -65,11 +63,11 @@
public static function fakeRender(string $type = 'mail'): string
{
$user = new User([
- 'email' => 'test@' . \config('app.domain'),
+ 'email' => 'test@' . \config('app.domain'),
]);
$payment = new Payment();
- $payment->wallet = new \App\Wallet();
+ $payment->wallet = new Wallet();
$payment->wallet->owner = $user;
$mail = new self($payment, $user);
diff --git a/src/app/Mail/PaymentMandateDisabled.php b/src/app/Mail/PaymentMandateDisabled.php
--- a/src/app/Mail/PaymentMandateDisabled.php
+++ b/src/app/Mail/PaymentMandateDisabled.php
@@ -9,17 +9,14 @@
class PaymentMandateDisabled extends Mailable
{
- /** @var \App\Wallet A wallet for which the mandate has been disabled */
+ /** @var Wallet A wallet for which the mandate has been disabled */
protected $wallet;
-
/**
* Create a new message instance.
*
- * @param \App\Wallet $wallet A wallet that has been charged
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Wallet $wallet A wallet that has been charged
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Wallet $wallet, User $user)
{
@@ -47,9 +44,9 @@
->text('emails.plain.payment_mandate_disabled')
->subject(\trans('mail.paymentmandatedisabled-subject', $vars))
->with([
- 'vars' => $vars,
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'vars' => $vars,
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
]);
return $this;
@@ -66,7 +63,7 @@
{
$wallet = new Wallet();
$user = new User([
- 'email' => 'test@' . \config('app.domain'),
+ 'email' => 'test@' . \config('app.domain'),
]);
$wallet->owner = $user;
diff --git a/src/app/Mail/PaymentSuccess.php b/src/app/Mail/PaymentSuccess.php
--- a/src/app/Mail/PaymentSuccess.php
+++ b/src/app/Mail/PaymentSuccess.php
@@ -6,20 +6,18 @@
use App\Tenant;
use App\User;
use App\Utils;
+use App\Wallet;
class PaymentSuccess extends Mailable
{
- /** @var \App\Payment A payment operation */
+ /** @var Payment A payment operation */
protected $payment;
-
/**
* Create a new message instance.
*
- * @param \App\Payment $payment A payment operation
- * @param \App\User $user A wallet controller to whom the email is being sent
- *
- * @return void
+ * @param Payment $payment A payment operation
+ * @param User $user A wallet controller to whom the email is being sent
*/
public function __construct(Payment $payment, User $user)
{
@@ -47,9 +45,9 @@
->text('emails.plain.payment_success')
->subject(\trans('mail.paymentsuccess-subject', $vars))
->with([
- 'vars' => $vars,
- 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'vars' => $vars,
+ 'walletUrl' => Utils::serviceUrl('/wallet', $this->user->tenant_id),
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
]);
return $this;
@@ -65,11 +63,11 @@
public static function fakeRender(string $type = 'html'): string
{
$user = new User([
- 'email' => 'test@' . \config('app.domain'),
+ 'email' => 'test@' . \config('app.domain'),
]);
$payment = new Payment();
- $payment->wallet = new \App\Wallet();
+ $payment->wallet = new Wallet();
$payment->wallet->owner = $user;
$mail = new self($payment, $user);
diff --git a/src/app/Mail/SignupInvitation.php b/src/app/Mail/SignupInvitation.php
--- a/src/app/Mail/SignupInvitation.php
+++ b/src/app/Mail/SignupInvitation.php
@@ -5,20 +5,16 @@
use App\SignupInvitation as SI;
use App\Tenant;
use App\Utils;
-use Illuminate\Support\Str;
class SignupInvitation extends Mailable
{
- /** @var \App\SignupInvitation A signup invitation object */
+ /** @var SI A signup invitation object */
protected $invitation;
-
/**
* Create a new message instance.
*
- * @param \App\SignupInvitation $invitation A signup invitation object
- *
- * @return void
+ * @param SI $invitation A signup invitation object
*/
public function __construct(SI $invitation)
{
@@ -44,8 +40,8 @@
->text('emails.plain.signup_invitation')
->subject(\trans('mail.signupinvitation-subject', $vars))
->with([
- 'vars' => $vars,
- 'href' => $href,
+ 'vars' => $vars,
+ 'href' => $href,
]);
return $this;
@@ -61,7 +57,7 @@
public static function fakeRender(string $type = 'html'): string
{
$invitation = new SI([
- 'email' => 'test@external.org',
+ 'email' => 'test@external.org',
]);
$invitation->id = Utils::uuidStr();
diff --git a/src/app/Mail/SignupVerification.php b/src/app/Mail/SignupVerification.php
--- a/src/app/Mail/SignupVerification.php
+++ b/src/app/Mail/SignupVerification.php
@@ -12,13 +12,10 @@
/** @var SignupCode A signup verification code object */
protected $code;
-
/**
* Create a new message instance.
*
* @param SignupCode $code A signup verification code object
- *
- * @return void
*/
public function __construct(SignupCode $code)
{
@@ -53,10 +50,10 @@
->text('emails.plain.signup_verification')
->subject(\trans('mail.signupverification-subject', $vars))
->with([
- 'vars' => $vars,
- 'href' => $href,
- 'code' => $this->code->code,
- 'short_code' => $this->code->short_code,
+ 'vars' => $vars,
+ 'href' => $href,
+ 'code' => $this->code->code,
+ 'short_code' => $this->code->short_code,
]);
return $this;
@@ -72,11 +69,11 @@
public static function fakeRender(string $type = 'html'): string
{
$code = new SignupCode([
- 'code' => Str::random(SignupCode::CODE_LENGTH),
- 'short_code' => SignupCode::generateShortCode(),
- 'email' => 'test@' . \config('app.domain'),
- 'first_name' => 'Firstname',
- 'last_name' => 'Lastname',
+ 'code' => Str::random(SignupCode::CODE_LENGTH),
+ 'short_code' => SignupCode::generateShortCode(),
+ 'email' => 'test@' . \config('app.domain'),
+ 'first_name' => 'Firstname',
+ 'last_name' => 'Lastname',
]);
$mail = new self($code);
diff --git a/src/app/Mail/TrialEnd.php b/src/app/Mail/TrialEnd.php
--- a/src/app/Mail/TrialEnd.php
+++ b/src/app/Mail/TrialEnd.php
@@ -11,9 +11,7 @@
/**
* Create a new message instance.
*
- * @param \App\User $user An account owner
- *
- * @return void
+ * @param User $user An account owner
*/
public function __construct(User $user)
{
@@ -40,9 +38,9 @@
->text('emails.plain.trial_end')
->subject(\trans('mail.trialend-subject', $vars))
->with([
- 'vars' => $vars,
- 'paymentUrl' => $paymentUrl,
- 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
+ 'vars' => $vars,
+ 'paymentUrl' => $paymentUrl,
+ 'supportUrl' => Utils::serviceUrl($supportUrl, $this->user->tenant_id),
]);
return $this;
diff --git a/src/app/Meet/Room.php b/src/app/Meet/Room.php
--- a/src/app/Meet/Room.php
+++ b/src/app/Meet/Room.php
@@ -2,6 +2,7 @@
namespace App\Meet;
+use App\Permission;
use App\Traits\BelongsToTenantTrait;
use App\Traits\EntitleableTrait;
use App\Traits\Meet\RoomConfigTrait;
@@ -26,10 +27,10 @@
{
use BelongsToTenantTrait;
use EntitleableTrait;
- use RoomConfigTrait;
use NullableFields;
- use SettingsTrait;
use PermissibleTrait;
+ use RoomConfigTrait;
+ use SettingsTrait;
use SoftDeletes;
public const ROLE_SUBSCRIBER = 1 << 0;
@@ -60,7 +61,7 @@
/**
* Creates HTTP client for connections to Meet server
*
- * @return HTTP client instance
+ * @return Http client instance
*/
private function client()
{
@@ -97,6 +98,7 @@
* @param int $role User role (see self::ROLE_* constants)
*
* @return array|null Token data on success, NULL otherwise
+ *
* @throws \Exception if session does not exist
*/
public function getSessionToken($role = self::ROLE_SUBSCRIBER): ?array
@@ -219,6 +221,7 @@
* @param int $target Limit targets by their participant role
*
* @return bool True on success, False on failure
+ *
* @throws \Exception if session does not exist
*/
public function signal(string $name, array $data = [], $target = null): bool
@@ -229,9 +232,9 @@
$post = [
'roomId' => $this->session_id,
- 'type' => $name,
- 'role' => $target,
- 'data' => $data,
+ 'type' => $name,
+ 'role' => $target,
+ 'data' => $data,
];
$response = $this->client()->post('signal', $post);
@@ -249,7 +252,7 @@
protected function supportedACL(): array
{
return [
- 'full' => \App\Permission::READ | \App\Permission::WRITE | \App\Permission::ADMIN,
+ 'full' => Permission::READ | Permission::WRITE | Permission::ADMIN,
];
}
@@ -273,7 +276,7 @@
{
$code = $response->status();
if ($code != 200) {
- \Log::error("$str [$code]");
+ \Log::error("{$str} [{$code}]");
}
}
}
diff --git a/src/app/Meet/RoomSetting.php b/src/app/Meet/RoomSetting.php
--- a/src/app/Meet/RoomSetting.php
+++ b/src/app/Meet/RoomSetting.php
@@ -3,6 +3,7 @@
namespace App\Meet;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Room.
@@ -23,7 +24,7 @@
/**
* The room to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Room, $this>
+ * @return BelongsTo<Room, $this>
*/
public function room()
{
diff --git a/src/app/Meet/Service.php b/src/app/Meet/Service.php
--- a/src/app/Meet/Service.php
+++ b/src/app/Meet/Service.php
@@ -40,7 +40,7 @@
*
* @param ?string $roomName Room name
*
- * @return HTTP client instance
+ * @return Http client instance
*/
public static function clientForRoom($roomName = null)
{
@@ -64,7 +64,7 @@
*
* @param ?string $baseUrl Server location
*
- * @return HTTP client instance
+ * @return Http client instance
*/
public static function client($baseUrl = null)
{
diff --git a/src/app/Observers/DelegationObserver.php b/src/app/Observers/DelegationObserver.php
--- a/src/app/Observers/DelegationObserver.php
+++ b/src/app/Observers/DelegationObserver.php
@@ -3,6 +3,8 @@
namespace App\Observers;
use App\Delegation;
+use App\Jobs\User\Delegation\CreateJob;
+use App\Jobs\User\Delegation\DeleteJob;
class DelegationObserver
{
@@ -13,7 +15,7 @@
*/
public function created(Delegation $delegation): void
{
- \App\Jobs\User\Delegation\CreateJob::dispatch($delegation->id);
+ CreateJob::dispatch($delegation->id);
}
/**
@@ -23,6 +25,6 @@
*/
public function deleted(Delegation $delegation): void
{
- \App\Jobs\User\Delegation\DeleteJob::dispatch($delegation->user->email, $delegation->delegatee->email);
+ DeleteJob::dispatch($delegation->user->email, $delegation->delegatee->email);
}
}
diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php
--- a/src/app/Observers/DomainObserver.php
+++ b/src/app/Observers/DomainObserver.php
@@ -3,16 +3,18 @@
namespace App\Observers;
use App\Domain;
-use Illuminate\Support\Facades\DB;
+use App\EventLog;
+use App\Jobs\Domain\CreateJob;
+use App\Jobs\Domain\DeleteJob;
+use App\Jobs\Domain\UpdateJob;
+use App\Policy\RateLimit\Whitelist;
class DomainObserver
{
/**
* Handle the domain "created" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function creating(Domain $domain): void
{
@@ -24,49 +26,43 @@
/**
* Handle the domain "created" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function created(Domain $domain)
{
// Create domain record in LDAP
// Note: DomainCreate job will dispatch DomainVerify job
- \App\Jobs\Domain\CreateJob::dispatch($domain->id);
+ CreateJob::dispatch($domain->id);
}
/**
* Handle the domain "deleted" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function deleted(Domain $domain)
{
if ($domain->isForceDeleting()) {
// Remove EventLog records
- \App\EventLog::where('object_id', $domain->id)->where('object_type', Domain::class)->delete();
+ EventLog::where('object_id', $domain->id)->where('object_type', Domain::class)->delete();
return;
}
- \App\Jobs\Domain\DeleteJob::dispatch($domain->id);
+ DeleteJob::dispatch($domain->id);
}
/**
* Handle the domain "deleting" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function deleting(Domain $domain)
{
- \App\Policy\RateLimit\Whitelist::where(
+ Whitelist::where(
[
'whitelistable_id' => $domain->id,
- 'whitelistable_type' => Domain::class
+ 'whitelistable_type' => Domain::class,
]
)->delete();
}
@@ -74,23 +70,19 @@
/**
* Handle the domain "updated" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function updated(Domain $domain)
{
if (!$domain->trashed()) {
- \App\Jobs\Domain\UpdateJob::dispatch($domain->id);
+ UpdateJob::dispatch($domain->id);
}
}
/**
* Handle the domain "restoring" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function restoring(Domain $domain)
{
@@ -103,13 +95,11 @@
/**
* Handle the domain "restored" event.
*
- * @param \App\Domain $domain The domain.
- *
- * @return void
+ * @param Domain $domain the domain
*/
public function restored(Domain $domain)
{
// Create the domain in LDAP again
- \App\Jobs\Domain\CreateJob::dispatch($domain->id);
+ CreateJob::dispatch($domain->id);
}
}
diff --git a/src/app/Observers/EntitlementObserver.php b/src/app/Observers/EntitlementObserver.php
--- a/src/app/Observers/EntitlementObserver.php
+++ b/src/app/Observers/EntitlementObserver.php
@@ -3,7 +3,8 @@
namespace App\Observers;
use App\Entitlement;
-use Carbon\Carbon;
+use App\Transaction;
+use App\Wallet;
/**
* This is an observer for the Entitlement model definition.
@@ -18,16 +19,14 @@
* Ensures that the {@link \App\Wallet} to which it is to be billed is owned or controlled by
* the {@link \App\User} entitled.
*
- * @param Entitlement $entitlement The entitlement being created.
- *
- * @return bool
+ * @param Entitlement $entitlement the entitlement being created
*/
public function creating(Entitlement $entitlement): bool
{
// can't dispatch job here because it'll fail serialization
// Make sure the owner is at least a controller on the wallet
- $wallet = \App\Wallet::find($entitlement->wallet_id);
+ $wallet = Wallet::find($entitlement->wallet_id);
if (!$wallet || !$wallet->owner) {
return false;
@@ -49,13 +48,11 @@
/**
* Handle the entitlement "created" event.
*
- * @param \App\Entitlement $entitlement The entitlement.
- *
- * @return void
+ * @param Entitlement $entitlement the entitlement
*/
public function created(Entitlement $entitlement)
{
- $entitlement->createTransaction(\App\Transaction::ENTITLEMENT_CREATED);
+ $entitlement->createTransaction(Transaction::ENTITLEMENT_CREATED);
$entitlement->sku->handler_class::entitlementCreated($entitlement);
}
@@ -63,13 +60,11 @@
/**
* Handle the entitlement "deleted" event.
*
- * @param \App\Entitlement $entitlement The entitlement.
- *
- * @return void
+ * @param Entitlement $entitlement the entitlement
*/
public function deleted(Entitlement $entitlement)
{
- $entitlement->createTransaction(\App\Transaction::ENTITLEMENT_DELETED);
+ $entitlement->createTransaction(Transaction::ENTITLEMENT_DELETED);
$entitlement->sku->handler_class::entitlementDeleted($entitlement);
}
@@ -77,9 +72,7 @@
/**
* Handle the entitlement "deleting" event.
*
- * @param \App\Entitlement $entitlement The entitlement.
- *
- * @return void
+ * @param Entitlement $entitlement the entitlement
*/
public function deleting(Entitlement $entitlement)
{
diff --git a/src/app/Observers/EventLogObserver.php b/src/app/Observers/EventLogObserver.php
--- a/src/app/Observers/EventLogObserver.php
+++ b/src/app/Observers/EventLogObserver.php
@@ -3,18 +3,19 @@
namespace App\Observers;
use App\EventLog;
+use App\Utils;
class EventLogObserver
{
/**
* Ensure the event entry ID is a custom ID (uuid).
*
- * @param \App\EventLog $eventlog The EventLog object
+ * @param EventLog $eventlog The EventLog object
*/
public function creating(EventLog $eventlog): void
{
if (!isset($eventlog->user_email)) {
- $eventlog->user_email = \App\Utils::userEmailOrNull();
+ $eventlog->user_email = Utils::userEmailOrNull();
}
if (!isset($eventlog->type)) {
diff --git a/src/app/Observers/GroupObserver.php b/src/app/Observers/GroupObserver.php
--- a/src/app/Observers/GroupObserver.php
+++ b/src/app/Observers/GroupObserver.php
@@ -2,17 +2,18 @@
namespace App\Observers;
+use App\EventLog;
use App\Group;
-use Illuminate\Support\Facades\DB;
+use App\Jobs\Group\CreateJob;
+use App\Jobs\Group\DeleteJob;
+use App\Jobs\Group\UpdateJob;
class GroupObserver
{
/**
* Handle the group "creating" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function creating(Group $group): void
{
@@ -26,54 +27,46 @@
/**
* Handle the group "created" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function created(Group $group)
{
- \App\Jobs\Group\CreateJob::dispatch($group->id);
+ CreateJob::dispatch($group->id);
}
/**
* Handle the group "deleted" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function deleted(Group $group)
{
if ($group->isForceDeleting()) {
// Remove EventLog records
- \App\EventLog::where('object_id', $group->id)->where('object_type', Group::class)->delete();
+ EventLog::where('object_id', $group->id)->where('object_type', Group::class)->delete();
return;
}
- \App\Jobs\Group\DeleteJob::dispatch($group->id);
+ DeleteJob::dispatch($group->id);
}
/**
* Handle the group "updated" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function updated(Group $group)
{
if (!$group->trashed()) {
- \App\Jobs\Group\UpdateJob::dispatch($group->id);
+ UpdateJob::dispatch($group->id);
}
}
/**
* Handle the group "restoring" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function restoring(Group $group)
{
@@ -86,12 +79,10 @@
/**
* Handle the group "restored" event.
*
- * @param \App\Group $group The group
- *
- * @return void
+ * @param Group $group The group
*/
public function restored(Group $group)
{
- \App\Jobs\Group\CreateJob::dispatch($group->id);
+ CreateJob::dispatch($group->id);
}
}
diff --git a/src/app/Observers/GroupSettingObserver.php b/src/app/Observers/GroupSettingObserver.php
--- a/src/app/Observers/GroupSettingObserver.php
+++ b/src/app/Observers/GroupSettingObserver.php
@@ -3,15 +3,14 @@
namespace App\Observers;
use App\GroupSetting;
+use App\Jobs\Group\UpdateJob;
class GroupSettingObserver
{
/**
* Handle the group setting "created" event.
*
- * @param \App\GroupSetting $groupSetting Settings object
- *
- * @return void
+ * @param GroupSetting $groupSetting Settings object
*/
public function created(GroupSetting $groupSetting)
{
@@ -21,9 +20,7 @@
/**
* Handle the group setting "updated" event.
*
- * @param \App\GroupSetting $groupSetting Settings object
- *
- * @return void
+ * @param GroupSetting $groupSetting Settings object
*/
public function updated(GroupSetting $groupSetting)
{
@@ -33,9 +30,7 @@
/**
* Handle the group setting "deleted" event.
*
- * @param \App\GroupSetting $groupSetting Settings object
- *
- * @return void
+ * @param GroupSetting $groupSetting Settings object
*/
public function deleted(GroupSetting $groupSetting)
{
@@ -45,12 +40,12 @@
/**
* Dispatch group update job (if needed).
*
- * @param \App\GroupSetting $groupSetting Settings object
+ * @param GroupSetting $groupSetting Settings object
*/
private function dispatchUpdateJob(GroupSetting $groupSetting): void
{
if ($groupSetting->isBackendSetting()) {
- \App\Jobs\Group\UpdateJob::dispatch($groupSetting->group_id);
+ UpdateJob::dispatch($groupSetting->group_id);
}
}
}
diff --git a/src/app/Observers/Meet/RoomObserver.php b/src/app/Observers/Meet/RoomObserver.php
--- a/src/app/Observers/Meet/RoomObserver.php
+++ b/src/app/Observers/Meet/RoomObserver.php
@@ -3,22 +3,21 @@
namespace App\Observers\Meet;
use App\Meet\Room;
+use App\Utils;
class RoomObserver
{
/**
* Handle the room "created" event.
*
- * @param \App\Meet\Room $room The room
- *
- * @return void
+ * @param Room $room The room
*/
public function creating(Room $room): void
{
if (empty($room->name)) {
// Generate a random and unique room name
while (true) {
- $room->name = strtolower(\App\Utils::randStr(3, 3, '-'));
+ $room->name = strtolower(Utils::randStr(3, 3, '-'));
if (!Room::where('name', $room->name)->exists()) {
break;
}
diff --git a/src/app/Observers/PackageSkuObserver.php b/src/app/Observers/PackageSkuObserver.php
--- a/src/app/Observers/PackageSkuObserver.php
+++ b/src/app/Observers/PackageSkuObserver.php
@@ -11,9 +11,7 @@
*
* Ensures that the entries belong to the same tenant.
*
- * @param \App\PackageSku $packageSku The package-sku relation
- *
- * @return void
+ * @param PackageSku $packageSku The package-sku relation
*/
public function creating(PackageSku $packageSku)
{
@@ -28,9 +26,7 @@
/**
* Handle the "created" event on an PackageSku relation
*
- * @param \App\PackageSku $packageSku The package-sku relation
- *
- * @return void
+ * @param PackageSku $packageSku The package-sku relation
*/
public function created(PackageSku $packageSku)
{
diff --git a/src/app/Observers/Passport/TokenObserver.php b/src/app/Observers/Passport/TokenObserver.php
--- a/src/app/Observers/Passport/TokenObserver.php
+++ b/src/app/Observers/Passport/TokenObserver.php
@@ -2,13 +2,14 @@
namespace App\Observers\Passport;
+use App\Auth\PassportClient;
use Laravel\Passport\Token;
class TokenObserver
{
public function creating(Token $token): void
{
- /** @var \App\Auth\PassportClient */
+ /** @var PassportClient */
$client = $token->client;
$scopes = $token->scopes;
if ($scopes) {
@@ -16,7 +17,7 @@
if (!empty($allowedScopes)) {
$scopes = array_intersect($scopes, $allowedScopes);
}
- $scopes = array_unique($scopes, SORT_REGULAR);
+ $scopes = array_unique($scopes, \SORT_REGULAR);
$token->scopes = $scopes;
}
}
diff --git a/src/app/Observers/PlanPackageObserver.php b/src/app/Observers/PlanPackageObserver.php
--- a/src/app/Observers/PlanPackageObserver.php
+++ b/src/app/Observers/PlanPackageObserver.php
@@ -11,9 +11,7 @@
*
* Ensures that the entries belong to the same tenant.
*
- * @param \App\PlanPackage $planPackage The plan-package relation
- *
- * @return void
+ * @param PlanPackage $planPackage The plan-package relation
*/
public function creating(PlanPackage $planPackage)
{
diff --git a/src/app/Observers/PowerDNS/DomainObserver.php b/src/app/Observers/PowerDNS/DomainObserver.php
--- a/src/app/Observers/PowerDNS/DomainObserver.php
+++ b/src/app/Observers/PowerDNS/DomainObserver.php
@@ -3,12 +3,15 @@
namespace App\Observers\PowerDNS;
use App\PowerDNS\Domain;
+use App\PowerDNS\DomainSetting;
+use App\PowerDNS\Record;
+use Carbon\Carbon;
class DomainObserver
{
public function created(Domain $domain)
{
- \App\PowerDNS\Record::create(
+ Record::create(
[
'domain_id' => $domain->id,
'name' => $domain->name,
@@ -17,42 +20,42 @@
"ns.%s. hostmaster.%s. %s 1200 600 1814400 60",
$domain->name,
$domain->name,
- \Carbon\Carbon::now()->format('Ymd') . '01'
- )
+ Carbon::now()->format('Ymd') . '01'
+ ),
]
);
- \App\PowerDNS\Record::withoutEvents(
- function () use ($domain) {
- \App\PowerDNS\Record::create(
+ Record::withoutEvents(
+ static function () use ($domain) {
+ Record::create(
[
'domain_id' => $domain->id,
'name' => $domain->name,
'type' => "NS",
- 'content' => \config('app.woat_ns1')
+ 'content' => \config('app.woat_ns1'),
]
);
}
);
- \App\PowerDNS\Record::withoutEvents(
- function () use ($domain) {
- \App\PowerDNS\Record::create(
+ Record::withoutEvents(
+ static function () use ($domain) {
+ Record::create(
[
'domain_id' => $domain->id,
'name' => $domain->name,
'type' => "NS",
- 'content' => \config('app.woat_ns2')
+ 'content' => \config('app.woat_ns2'),
]
);
}
);
- \App\PowerDNS\DomainSetting::create(
+ DomainSetting::create(
[
'domain_id' => $domain->id,
'kind' => 'ENABLE-LUA-RECORDS',
- 'content' => "0"
+ 'content' => "0",
]
);
}
diff --git a/src/app/Observers/PowerDNS/RecordObserver.php b/src/app/Observers/PowerDNS/RecordObserver.php
--- a/src/app/Observers/PowerDNS/RecordObserver.php
+++ b/src/app/Observers/PowerDNS/RecordObserver.php
@@ -2,8 +2,6 @@
namespace App\Observers\PowerDNS;
-use App\PowerDNS\Record;
-
class RecordObserver
{
public function created($record)
diff --git a/src/app/Observers/ReferralCodeObserver.php b/src/app/Observers/ReferralCodeObserver.php
--- a/src/app/Observers/ReferralCodeObserver.php
+++ b/src/app/Observers/ReferralCodeObserver.php
@@ -11,9 +11,7 @@
*
* Ensure that the code entry is created with a random code.
*
- * @param ReferralCode $code The code being created.
- *
- * @return void
+ * @param ReferralCode $code the code being created
*/
public function creating(ReferralCode $code): void
{
diff --git a/src/app/Observers/ResourceObserver.php b/src/app/Observers/ResourceObserver.php
--- a/src/app/Observers/ResourceObserver.php
+++ b/src/app/Observers/ResourceObserver.php
@@ -2,6 +2,9 @@
namespace App\Observers;
+use App\Jobs\Resource\CreateJob;
+use App\Jobs\Resource\DeleteJob;
+use App\Jobs\Resource\UpdateJob;
use App\Resource;
class ResourceObserver
@@ -9,9 +12,7 @@
/**
* Handle the resource "creating" event.
*
- * @param \App\Resource $resource The resource
- *
- * @return void
+ * @param Resource $resource The resource
*/
public function creating(Resource $resource): void
{
@@ -21,9 +22,7 @@
/**
* Handle the resource "created" event.
*
- * @param \App\Resource $resource The resource
- *
- * @return void
+ * @param Resource $resource The resource
*/
public function created(Resource $resource)
{
@@ -46,15 +45,13 @@
$resource->settings()->insert(array_values($settings));
// Create the resource in the backend (LDAP and IMAP)
- \App\Jobs\Resource\CreateJob::dispatch($resource->id);
+ CreateJob::dispatch($resource->id);
}
/**
* Handle the resource "deleted" event.
*
- * @param \App\Resource $resource The resource
- *
- * @return void
+ * @param Resource $resource The resource
*/
public function deleted(Resource $resource)
{
@@ -62,20 +59,18 @@
return;
}
- \App\Jobs\Resource\DeleteJob::dispatch($resource->id);
+ DeleteJob::dispatch($resource->id);
}
/**
* Handle the resource "updated" event.
*
- * @param \App\Resource $resource The resource
- *
- * @return void
+ * @param Resource $resource The resource
*/
public function updated(Resource $resource)
{
if (!$resource->trashed()) {
- \App\Jobs\Resource\UpdateJob::dispatch($resource->id);
+ UpdateJob::dispatch($resource->id);
}
// Update the folder property if name changed
diff --git a/src/app/Observers/ResourceSettingObserver.php b/src/app/Observers/ResourceSettingObserver.php
--- a/src/app/Observers/ResourceSettingObserver.php
+++ b/src/app/Observers/ResourceSettingObserver.php
@@ -2,6 +2,7 @@
namespace App\Observers;
+use App\Jobs\Resource\UpdateJob;
use App\ResourceSetting;
class ResourceSettingObserver
@@ -9,9 +10,7 @@
/**
* Handle the resource setting "created" event.
*
- * @param \App\ResourceSetting $resourceSetting Settings object
- *
- * @return void
+ * @param ResourceSetting $resourceSetting Settings object
*/
public function created(ResourceSetting $resourceSetting)
{
@@ -21,9 +20,7 @@
/**
* Handle the resource setting "updated" event.
*
- * @param \App\ResourceSetting $resourceSetting Settings object
- *
- * @return void
+ * @param ResourceSetting $resourceSetting Settings object
*/
public function updated(ResourceSetting $resourceSetting)
{
@@ -33,9 +30,7 @@
/**
* Handle the resource setting "deleted" event.
*
- * @param \App\ResourceSetting $resourceSetting Settings object
- *
- * @return void
+ * @param ResourceSetting $resourceSetting Settings object
*/
public function deleted(ResourceSetting $resourceSetting)
{
@@ -45,13 +40,13 @@
/**
* Dispatch resource update job (if needed)
*
- * @param \App\ResourceSetting $resourceSetting Settings object
+ * @param ResourceSetting $resourceSetting Settings object
*/
private function dispatchUpdateJob(ResourceSetting $resourceSetting): void
{
if ($resourceSetting->isBackendSetting()) {
$props = [$resourceSetting->key => $resourceSetting->getOriginal('value')];
- \App\Jobs\Resource\UpdateJob::dispatch($resourceSetting->resource_id, $props);
+ UpdateJob::dispatch($resourceSetting->resource_id, $props);
}
}
}
diff --git a/src/app/Observers/SharedFolderAliasObserver.php b/src/app/Observers/SharedFolderAliasObserver.php
--- a/src/app/Observers/SharedFolderAliasObserver.php
+++ b/src/app/Observers/SharedFolderAliasObserver.php
@@ -3,21 +3,20 @@
namespace App\Observers;
use App\Domain;
-use App\SharedFolder;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolderAlias;
+use App\Utils;
class SharedFolderAliasObserver
{
/**
* Handle the "creating" event on an alias
*
- * @param \App\SharedFolderAlias $alias The shared folder email alias
- *
- * @return bool
+ * @param SharedFolderAlias $alias The shared folder email alias
*/
public function creating(SharedFolderAlias $alias): bool
{
- $alias->alias = \App\Utils::emailToLower($alias->alias);
+ $alias->alias = Utils::emailToLower($alias->alias);
$domainName = explode('@', $alias->alias)[1];
@@ -41,42 +40,36 @@
/**
* Handle the shared folder alias "created" event.
*
- * @param \App\SharedFolderAlias $alias Shared folder email alias
- *
- * @return void
+ * @param SharedFolderAlias $alias Shared folder email alias
*/
public function created(SharedFolderAlias $alias)
{
if ($alias->sharedFolder) {
- \App\Jobs\SharedFolder\UpdateJob::dispatch($alias->shared_folder_id);
+ UpdateJob::dispatch($alias->shared_folder_id);
}
}
/**
* Handle the shared folder alias "updated" event.
*
- * @param \App\SharedFolderAlias $alias Shared folder email alias
- *
- * @return void
+ * @param SharedFolderAlias $alias Shared folder email alias
*/
public function updated(SharedFolderAlias $alias)
{
if ($alias->sharedFolder) {
- \App\Jobs\SharedFolder\UpdateJob::dispatch($alias->shared_folder_id);
+ UpdateJob::dispatch($alias->shared_folder_id);
}
}
/**
* Handle the shared folder alias "deleted" event.
*
- * @param \App\SharedFolderAlias $alias Shared folder email alias
- *
- * @return void
+ * @param SharedFolderAlias $alias Shared folder email alias
*/
public function deleted(SharedFolderAlias $alias)
{
if ($alias->sharedFolder) {
- \App\Jobs\SharedFolder\UpdateJob::dispatch($alias->shared_folder_id);
+ UpdateJob::dispatch($alias->shared_folder_id);
}
}
}
diff --git a/src/app/Observers/SharedFolderObserver.php b/src/app/Observers/SharedFolderObserver.php
--- a/src/app/Observers/SharedFolderObserver.php
+++ b/src/app/Observers/SharedFolderObserver.php
@@ -2,6 +2,9 @@
namespace App\Observers;
+use App\Jobs\SharedFolder\CreateJob;
+use App\Jobs\SharedFolder\DeleteJob;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolder;
class SharedFolderObserver
@@ -9,9 +12,7 @@
/**
* Handle the shared folder "creating" event.
*
- * @param \App\SharedFolder $folder The folder
- *
- * @return void
+ * @param SharedFolder $folder The folder
*/
public function creating(SharedFolder $folder): void
{
@@ -25,9 +26,7 @@
/**
* Handle the shared folder "created" event.
*
- * @param \App\SharedFolder $folder The folder
- *
- * @return void
+ * @param SharedFolder $folder The folder
*/
public function created(SharedFolder $folder)
{
@@ -50,15 +49,13 @@
$folder->settings()->insert(array_values($settings));
// Create the shared folder in the backend (LDAP and IMAP)
- \App\Jobs\SharedFolder\CreateJob::dispatch($folder->id);
+ CreateJob::dispatch($folder->id);
}
/**
* Handle the shared folder "deleted" event.
*
- * @param \App\SharedFolder $folder The folder
- *
- * @return void
+ * @param SharedFolder $folder The folder
*/
public function deleted(SharedFolder $folder)
{
@@ -66,20 +63,18 @@
return;
}
- \App\Jobs\SharedFolder\DeleteJob::dispatch($folder->id);
+ DeleteJob::dispatch($folder->id);
}
/**
* Handle the shared folder "updated" event.
*
- * @param \App\SharedFolder $folder The folder
- *
- * @return void
+ * @param SharedFolder $folder The folder
*/
public function updated(SharedFolder $folder)
{
if (!$folder->trashed()) {
- \App\Jobs\SharedFolder\UpdateJob::dispatch($folder->id);
+ UpdateJob::dispatch($folder->id);
}
// Update the folder property if name changed
diff --git a/src/app/Observers/SharedFolderSettingObserver.php b/src/app/Observers/SharedFolderSettingObserver.php
--- a/src/app/Observers/SharedFolderSettingObserver.php
+++ b/src/app/Observers/SharedFolderSettingObserver.php
@@ -2,6 +2,7 @@
namespace App\Observers;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolderSetting;
class SharedFolderSettingObserver
@@ -9,9 +10,7 @@
/**
* Handle the shared folder setting "created" event.
*
- * @param \App\SharedFolderSetting $folderSetting Settings object
- *
- * @return void
+ * @param SharedFolderSetting $folderSetting Settings object
*/
public function created(SharedFolderSetting $folderSetting)
{
@@ -21,9 +20,7 @@
/**
* Handle the shared folder setting "updated" event.
*
- * @param \App\SharedFolderSetting $folderSetting Settings object
- *
- * @return void
+ * @param SharedFolderSetting $folderSetting Settings object
*/
public function updated(SharedFolderSetting $folderSetting)
{
@@ -33,9 +30,7 @@
/**
* Handle the shared folder setting "deleted" event.
*
- * @param \App\SharedFolderSetting $folderSetting Settings object
- *
- * @return void
+ * @param SharedFolderSetting $folderSetting Settings object
*/
public function deleted(SharedFolderSetting $folderSetting)
{
@@ -45,13 +40,13 @@
/**
* Dispatch shared folder update job (if needed).
*
- * @param \App\SharedFolderSetting $folderSetting Settings object
+ * @param SharedFolderSetting $folderSetting Settings object
*/
private function dispatchUpdateJob(SharedFolderSetting $folderSetting): void
{
if ($folderSetting->isBackendSetting()) {
$props = [$folderSetting->key => $folderSetting->getOriginal('value')];
- \App\Jobs\SharedFolder\UpdateJob::dispatch($folderSetting->shared_folder_id, $props);
+ UpdateJob::dispatch($folderSetting->shared_folder_id, $props);
}
}
}
diff --git a/src/app/Observers/SignupCodeObserver.php b/src/app/Observers/SignupCodeObserver.php
--- a/src/app/Observers/SignupCodeObserver.php
+++ b/src/app/Observers/SignupCodeObserver.php
@@ -13,14 +13,12 @@
*
* Ensure that the code entry is created with a random code/short_code.
*
- * @param \App\SignupCode $code The code being created.
- *
- * @return void
+ * @param SignupCode $code the code being created
*/
public function creating(SignupCode $code): void
{
$code_length = SignupCode::CODE_LENGTH;
- $exp_hours = env('SIGNUP_CODE_EXPIRY', SignupCode::CODE_EXP_HOURS);
+ $exp_hours = env('SIGNUP_CODE_EXPIRY', SignupCode::CODE_EXP_HOURS);
if (empty($code->code)) {
$code->short_code = SignupCode::generateShortCode();
@@ -35,11 +33,11 @@
}
$code->headers = collect(request()->headers->all())
- ->filter(function ($value, $key) {
+ ->filter(static function ($value, $key) {
// remove some headers we don't care about
return !in_array($key, ['cookie', 'referer', 'origin']);
})
- ->map(function ($value) {
+ ->map(static function ($value) {
return count($value) == 1 ? $value[0] : $value;
})
->all();
@@ -58,9 +56,7 @@
/**
* Handle the "updating" event.
*
- * @param SignupCode $code The code being updated.
- *
- * @return void
+ * @param SignupCode $code the code being updated
*/
public function updating(SignupCode $code)
{
diff --git a/src/app/Observers/SignupInvitationObserver.php b/src/app/Observers/SignupInvitationObserver.php
--- a/src/app/Observers/SignupInvitationObserver.php
+++ b/src/app/Observers/SignupInvitationObserver.php
@@ -2,6 +2,8 @@
namespace App\Observers;
+use App\Jobs\Mail\SignupInvitationJob;
+use App\SignupInvitation;
use App\SignupInvitation as SI;
/**
@@ -12,9 +14,7 @@
/**
* Ensure the invitation ID is a custom ID (uuid).
*
- * @param \App\SignupInvitation $invitation The invitation object
- *
- * @return void
+ * @param SignupInvitation $invitation The invitation object
*/
public function creating(SI $invitation)
{
@@ -24,21 +24,17 @@
/**
* Handle the invitation "created" event.
*
- * @param \App\SignupInvitation $invitation The invitation object
- *
- * @return void
+ * @param SignupInvitation $invitation The invitation object
*/
public function created(SI $invitation)
{
- \App\Jobs\Mail\SignupInvitationJob::dispatch($invitation);
+ SignupInvitationJob::dispatch($invitation);
}
/**
* Handle the invitation "updated" event.
*
- * @param \App\SignupInvitation $invitation The invitation object
- *
- * @return void
+ * @param SignupInvitation $invitation The invitation object
*/
public function updated(SI $invitation)
{
@@ -49,7 +45,7 @@
$invitation->status == SI::STATUS_NEW
&& ($oldStatus == SI::STATUS_FAILED || $oldStatus == SI::STATUS_SENT)
) {
- \App\Jobs\Mail\SignupInvitationJob::dispatch($invitation);
+ SignupInvitationJob::dispatch($invitation);
}
}
}
diff --git a/src/app/Observers/SignupTokenObserver.php b/src/app/Observers/SignupTokenObserver.php
--- a/src/app/Observers/SignupTokenObserver.php
+++ b/src/app/Observers/SignupTokenObserver.php
@@ -9,7 +9,7 @@
/**
* Ensure the token is uppercased.
*
- * @param \App\SignupToken $token The SignupToken object
+ * @param SignupToken $token The SignupToken object
*/
public function creating(SignupToken $token): void
{
diff --git a/src/app/Observers/TransactionObserver.php b/src/app/Observers/TransactionObserver.php
--- a/src/app/Observers/TransactionObserver.php
+++ b/src/app/Observers/TransactionObserver.php
@@ -3,20 +3,19 @@
namespace App\Observers;
use App\Transaction;
+use App\Utils;
class TransactionObserver
{
/**
* Ensure the transaction ID is a custom ID (uuid).
*
- * @param \App\Transaction $transaction The transaction object
- *
- * @return void
+ * @param Transaction $transaction The transaction object
*/
public function creating(Transaction $transaction): void
{
if (!isset($transaction->user_email)) {
- $transaction->user_email = \App\Utils::userEmailOrNull();
+ $transaction->user_email = Utils::userEmailOrNull();
}
}
}
diff --git a/src/app/Observers/UserAliasObserver.php b/src/app/Observers/UserAliasObserver.php
--- a/src/app/Observers/UserAliasObserver.php
+++ b/src/app/Observers/UserAliasObserver.php
@@ -3,6 +3,9 @@
namespace App\Observers;
use App\Domain;
+use App\Jobs\PGP\KeyCreateJob;
+use App\Jobs\PGP\KeyDeleteJob;
+use App\Jobs\User\UpdateJob;
use App\Tenant;
use App\User;
use App\UserAlias;
@@ -12,15 +15,13 @@
/**
* Handle the "creating" event on an alias
*
- * @param \App\UserAlias $alias The user email alias
- *
- * @return bool
+ * @param UserAlias $alias The user email alias
*/
public function creating(UserAlias $alias): bool
{
$alias->alias = \strtolower($alias->alias);
- list($login, $domain) = explode('@', $alias->alias);
+ [$login, $domain] = explode('@', $alias->alias);
$domain = Domain::where('namespace', $domain)->first();
@@ -42,17 +43,15 @@
/**
* Handle the user alias "created" event.
*
- * @param \App\UserAlias $alias User email alias
- *
- * @return void
+ * @param UserAlias $alias User email alias
*/
public function created(UserAlias $alias)
{
if ($alias->user) {
- \App\Jobs\User\UpdateJob::dispatch($alias->user_id);
+ UpdateJob::dispatch($alias->user_id);
if (Tenant::getConfig($alias->user->tenant_id, 'pgp.enable')) {
- \App\Jobs\PGP\KeyCreateJob::dispatch($alias->user_id, $alias->alias);
+ KeyCreateJob::dispatch($alias->user_id, $alias->alias);
}
}
}
@@ -60,31 +59,27 @@
/**
* Handle the user alias "updated" event.
*
- * @param \App\UserAlias $alias User email alias
- *
- * @return void
+ * @param UserAlias $alias User email alias
*/
public function updated(UserAlias $alias)
{
if ($alias->user) {
- \App\Jobs\User\UpdateJob::dispatch($alias->user_id);
+ UpdateJob::dispatch($alias->user_id);
}
}
/**
* Handle the user alias "deleted" event.
*
- * @param \App\UserAlias $alias User email alias
- *
- * @return void
+ * @param UserAlias $alias User email alias
*/
public function deleted(UserAlias $alias)
{
if ($alias->user) {
- \App\Jobs\User\UpdateJob::dispatch($alias->user_id);
+ UpdateJob::dispatch($alias->user_id);
if (Tenant::getConfig($alias->user->tenant_id, 'pgp.enable')) {
- \App\Jobs\PGP\KeyDeleteJob::dispatch($alias->user_id, $alias->alias);
+ KeyDeleteJob::dispatch($alias->user_id, $alias->alias);
}
}
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -3,9 +3,22 @@
namespace App\Observers;
use App\Delegation;
+use App\Entitlement;
+use App\EventLog;
use App\Group;
+use App\Jobs\PGP\KeyCreateJob;
+use App\Jobs\PGP\KeyDeleteJob;
+use App\Jobs\User\CreateJob;
+use App\Jobs\User\DeleteJob;
+use App\Jobs\User\UpdateJob;
+use App\Policy\RateLimit\Whitelist;
+use App\Rules\Password;
+use App\Tenant;
+use App\Transaction;
use App\User;
+use App\Utils;
use App\Wallet;
+use Carbon\Carbon;
class UserObserver
{
@@ -14,9 +27,7 @@
*
* Ensure that the user is created with a random, large integer.
*
- * @param \App\User $user The user being created.
- *
- * @return void
+ * @param User $user the user being created
*/
public function creating(User $user)
{
@@ -32,18 +43,16 @@
*
* Should ensure some basic settings are available as well.
*
- * @param \App\User $user The user created.
- *
- * @return void
+ * @param User $user the user created
*/
public function created(User $user)
{
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
return;
}
$settings = [
- 'country' => \App\Utils::countryForRequest(),
+ 'country' => Utils::countryForRequest(),
'currency' => \config('app.currency'),
/*
'first_name' => '',
@@ -70,38 +79,36 @@
$user->wallets()->create();
// Create user record in the backend (LDAP and IMAP)
- \App\Jobs\User\CreateJob::dispatch($user->id);
+ CreateJob::dispatch($user->id);
- if (\App\Tenant::getConfig($user->tenant_id, 'pgp.enable')) {
- \App\Jobs\PGP\KeyCreateJob::dispatch($user->id, $user->email);
+ if (Tenant::getConfig($user->tenant_id, 'pgp.enable')) {
+ KeyCreateJob::dispatch($user->id, $user->email);
}
}
/**
* Handle the "deleted" event.
*
- * @param \App\User $user The user deleted.
- *
- * @return void
+ * @param User $user the user deleted
*/
public function deleted(User $user)
{
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
return;
}
if (!$user->isForceDeleting()) {
- \App\Jobs\User\DeleteJob::dispatch($user->id);
+ DeleteJob::dispatch($user->id);
- if (\App\Tenant::getConfig($user->tenant_id, 'pgp.enable')) {
- \App\Jobs\PGP\KeyDeleteJob::dispatch($user->id, $user->email);
+ if (Tenant::getConfig($user->tenant_id, 'pgp.enable')) {
+ KeyDeleteJob::dispatch($user->id, $user->email);
}
}
// Remove the user from existing groups
$wallet = $user->wallet();
if ($wallet && $wallet->owner) {
- $wallet->owner->groups()->each(function ($group) use ($user) {
+ $wallet->owner->groups()->each(static function ($group) use ($user) {
/** @var Group $group */
if (in_array($user->email, $group->members)) {
$group->members = array_diff($group->members, [$user->email]);
@@ -112,7 +119,7 @@
// Remove delegation relations
$ids = Delegation::where('user_id', $user->id)->orWhere('delegatee_id', $user->id)->get()
- ->map(function ($delegation) use ($user) {
+ ->map(static function ($delegation) use ($user) {
$delegator = $delegation->user_id == $user->id
? $user : $delegation->user()->withTrashed()->first();
$delegatee = $delegation->delegatee_id == $user->id
@@ -135,13 +142,11 @@
/**
* Handle the "deleting" event.
*
- * @param User $user The user that is being deleted.
- *
- * @return void
+ * @param User $user the user that is being deleted
*/
public function deleting(User $user)
{
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
return;
}
@@ -152,9 +157,7 @@
/**
* Handle the user "restoring" event.
*
- * @param \App\User $user The user
- *
- * @return void
+ * @param User $user The user
*/
public function restoring(User $user)
{
@@ -167,13 +170,11 @@
/**
* Handle the user "restored" event.
*
- * @param \App\User $user The user
- *
- * @return void
+ * @param User $user The user
*/
public function restored(User $user)
{
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
return;
}
@@ -188,24 +189,22 @@
// FIXME: Should we reset user aliases? or re-validate them in any way?
// Create user record in the backend (LDAP and IMAP)
- \App\Jobs\User\CreateJob::dispatch($user->id);
+ CreateJob::dispatch($user->id);
}
/**
* Handle the "updated" event.
*
- * @param \App\User $user The user that is being updated.
- *
- * @return void
+ * @param User $user the user that is being updated
*/
public function updated(User $user)
{
- if ($user->role == \App\User::ROLE_SERVICE) {
+ if ($user->role == User::ROLE_SERVICE) {
return;
}
if (!$user->trashed()) {
- \App\Jobs\User\UpdateJob::dispatch($user->id);
+ UpdateJob::dispatch($user->id);
}
$oldStatus = $user->getOriginal('status');
@@ -224,7 +223,7 @@
// Remember time of the degradation for sending periodic reminders
// and reset it on un-degradation
- $val = $isDegraded ? \Carbon\Carbon::now()->toDateTimeString() : null;
+ $val = $isDegraded ? Carbon::now()->toDateTimeString() : null;
$wallet->setSetting('degraded_last_reminder', $val);
$wallets[] = $wallet->id;
@@ -234,13 +233,13 @@
// LDAP backend will read the wallet owner's degraded status and
// set LDAP attributes accordingly.
// We do not change their status as their wallets have its own state
- \App\Entitlement::whereIn('wallet_id', $wallets)
+ Entitlement::whereIn('wallet_id', $wallets)
->where('entitleable_id', '!=', $user->id)
->where('entitleable_type', User::class)
->pluck('entitleable_id')
->unique()
- ->each(function ($user_id) {
- \App\Jobs\User\UpdateJob::dispatch($user_id);
+ ->each(static function ($user_id) {
+ UpdateJob::dispatch($user_id);
});
}
@@ -254,19 +253,19 @@
/**
* Remove entities related to the user (in user's wallets), entitlements, transactions, etc.
*
- * @param \App\User $user The user
- * @param bool $force Force-delete mode
+ * @param User $user The user
+ * @param bool $force Force-delete mode
*/
private static function removeRelatedObjects(User $user, $force = false): void
{
$wallets = $user->wallets->pluck('id')->all();
- \App\Entitlement::withTrashed()
+ Entitlement::withTrashed()
->select('entitleable_id', 'entitleable_type')
->distinct()
->whereIn('wallet_id', $wallets)
->get()
- ->each(function ($entitlement) use ($user, $force) {
+ ->each(static function ($entitlement) use ($user, $force) {
// Skip the current user (infinite recursion loop)
if ($entitlement->entitleable_type == User::class && $entitlement->entitleable_id == $user->id) {
return;
@@ -286,19 +285,19 @@
if ($force) {
// Remove "wallet" transactions, they have no foreign key constraint
- \App\Transaction::where('object_type', Wallet::class)
+ Transaction::where('object_type', Wallet::class)
->whereIn('object_id', $wallets)
->delete();
// Remove EventLog records
- \App\EventLog::where('object_id', $user->id)->where('object_type', User::class)->delete();
+ EventLog::where('object_id', $user->id)->where('object_type', User::class)->delete();
}
// regardless of force delete, we're always purging whitelists... just in case
- \App\Policy\RateLimit\Whitelist::where(
+ Whitelist::where(
[
'whitelistable_id' => $user->id,
- 'whitelistable_type' => User::class
+ 'whitelistable_type' => User::class,
]
)->delete();
}
@@ -307,17 +306,17 @@
* Store the old password in user password history. Make sure
* we do not store more passwords than we need in the history.
*
- * @param \App\User $user The user
- * @param string $password The old password
+ * @param User $user The user
+ * @param string $password The old password
*/
private static function saveOldPassword(User $user, string $password): void
{
// Remember the timestamp of the last password change and unset the last warning date
$user->setSettings([
- 'password_expiration_warning' => null,
- // Note: We could get this from user_passwords table, but only if the policy
- // enables storing of old passwords there.
- 'password_update' => now()->format('Y-m-d H:i:s'),
+ 'password_expiration_warning' => null,
+ // Note: We could get this from user_passwords table, but only if the policy
+ // enables storing of old passwords there.
+ 'password_update' => now()->format('Y-m-d H:i:s'),
]);
// Note: All this is kinda heavy and complicated because we don't want to store
@@ -326,7 +325,7 @@
// removed the old passwords that were excessive before, but not now.
// Get the account password policy
- $policy = new \App\Rules\Password($user->walletOwner());
+ $policy = new Password($user->walletOwner());
$rules = $policy->rules();
// Password history disabled?
diff --git a/src/app/Observers/UserSettingObserver.php b/src/app/Observers/UserSettingObserver.php
--- a/src/app/Observers/UserSettingObserver.php
+++ b/src/app/Observers/UserSettingObserver.php
@@ -2,6 +2,7 @@
namespace App\Observers;
+use App\Jobs\User\UpdateJob;
use App\UserSetting;
class UserSettingObserver
@@ -9,9 +10,7 @@
/**
* Handle the user setting "created" event.
*
- * @param \App\UserSetting $userSetting Settings object
- *
- * @return void
+ * @param UserSetting $userSetting Settings object
*/
public function created(UserSetting $userSetting)
{
@@ -21,9 +20,7 @@
/**
* Handle the user setting "updated" event.
*
- * @param \App\UserSetting $userSetting Settings object
- *
- * @return void
+ * @param UserSetting $userSetting Settings object
*/
public function updated(UserSetting $userSetting)
{
@@ -33,9 +30,7 @@
/**
* Handle the user setting "deleted" event.
*
- * @param \App\UserSetting $userSetting Settings object
- *
- * @return void
+ * @param UserSetting $userSetting Settings object
*/
public function deleted(UserSetting $userSetting)
{
@@ -45,12 +40,12 @@
/**
* Dispatch the user update job (if needed).
*
- * @param \App\UserSetting $userSetting Settings object
+ * @param UserSetting $userSetting Settings object
*/
private function dispatchUpdateJob(UserSetting $userSetting): void
{
if ($userSetting->isBackendSetting()) {
- \App\Jobs\User\UpdateJob::dispatch($userSetting->user_id);
+ UpdateJob::dispatch($userSetting->user_id);
}
}
}
diff --git a/src/app/Observers/VerificationCodeObserver.php b/src/app/Observers/VerificationCodeObserver.php
--- a/src/app/Observers/VerificationCodeObserver.php
+++ b/src/app/Observers/VerificationCodeObserver.php
@@ -13,14 +13,12 @@
*
* Ensure that the code entry is created with a random code/short_code.
*
- * @param \App\VerificationCode $code The code being created.
- *
- * @return void
+ * @param VerificationCode $code the code being created
*/
public function creating(VerificationCode $code): void
{
$code_length = VerificationCode::CODE_LENGTH;
- $exp_hours = env('VERIFICATION_CODE_EXPIRY', VerificationCode::CODE_EXP_HOURS);
+ $exp_hours = env('VERIFICATION_CODE_EXPIRY', VerificationCode::CODE_EXP_HOURS);
if (empty($code->code)) {
$code->short_code = VerificationCode::generateShortCode();
diff --git a/src/app/Observers/WalletObserver.php b/src/app/Observers/WalletObserver.php
--- a/src/app/Observers/WalletObserver.php
+++ b/src/app/Observers/WalletObserver.php
@@ -4,6 +4,7 @@
use App\User;
use App\Wallet;
+use Carbon\Carbon;
/**
* This is an observer for the Wallet model definition.
@@ -12,10 +13,6 @@
{
/**
* Ensure the wallet ID is a custom ID (uuid).
- *
- * @param Wallet $wallet
- *
- * @return void
*/
public function creating(Wallet $wallet)
{
@@ -31,9 +28,7 @@
*
* Ensures that no entitlements are being billed to the wallet currently.
*
- * @param Wallet $wallet The wallet being deleted.
- *
- * @return bool
+ * @param Wallet $wallet the wallet being deleted
*/
public function deleting(Wallet $wallet): bool
{
@@ -55,12 +50,12 @@
if ($wallet->entitlements()->count() > 0) {
return false;
}
-/*
- // can't remove a wallet that has payments attached.
- if ($wallet->payments()->count() > 0) {
- return false;
- }
-*/
+ /*
+ // can't remove a wallet that has payments attached.
+ if ($wallet->payments()->count() > 0) {
+ return false;
+ }
+ */
return true;
}
@@ -68,9 +63,7 @@
/**
* Handle the wallet "updated" event.
*
- * @param \App\Wallet $wallet The wallet.
- *
- * @return void
+ * @param Wallet $wallet the wallet
*/
public function updated(Wallet $wallet)
{
@@ -78,16 +71,16 @@
if ($wallet->balance < 0) {
if (!$negative_since) {
- $now = \Carbon\Carbon::now()->toDateTimeString();
+ $now = Carbon::now()->toDateTimeString();
$wallet->setSetting('balance_negative_since', $now);
}
} elseif ($negative_since) {
$wallet->setSettings([
- 'balance_negative_since' => null,
- 'balance_warning_initial' => null,
- 'balance_warning_reminder' => null,
- 'balance_warning_suspended' => null,
- 'balance_warning_before_delete' => null,
+ 'balance_negative_since' => null,
+ 'balance_warning_initial' => null,
+ 'balance_warning_reminder' => null,
+ 'balance_warning_suspended' => null,
+ 'balance_warning_before_delete' => null,
]);
// FIXME: Since we use account degradation, should we leave suspended state untouched?
diff --git a/src/app/Package.php b/src/app/Package.php
--- a/src/app/Package.php
+++ b/src/app/Package.php
@@ -5,6 +5,7 @@
use App\Traits\BelongsToTenantTrait;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Spatie\Translatable\HasTranslations;
/**
@@ -24,12 +25,12 @@
*
* Selecting a package will therefore create a set of entitlments from SKUs.
*
- * @property string $description
- * @property int $discount_rate
- * @property string $id
- * @property string $name
- * @property ?int $tenant_id
- * @property string $title
+ * @property string $description
+ * @property int $discount_rate
+ * @property string $id
+ * @property string $name
+ * @property ?int $tenant_id
+ * @property string $title
*/
class Package extends Model
{
@@ -62,7 +63,7 @@
* NOTE: This results in the overall list price and foregoes additional wallet discount
* deductions.
*
- * @return int The costs in cents.
+ * @return int the costs in cents
*/
public function cost()
{
@@ -93,7 +94,7 @@
/**
* SKUs of this package.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Sku, $this, PackageSku>
+ * @return BelongsToMany<Sku, $this, PackageSku>
*/
public function skus()
{
diff --git a/src/app/PackageSku.php b/src/app/PackageSku.php
--- a/src/app/PackageSku.php
+++ b/src/app/PackageSku.php
@@ -2,17 +2,18 @@
namespace App;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* Link SKUs to Packages.
*
- * @property int $cost
- * @property string $package_id
- * @property \App\Package $package
- * @property int $qty
- * @property \App\Sku $sku
- * @property string $sku_id
+ * @property int $cost
+ * @property string $package_id
+ * @property Package $package
+ * @property int $qty
+ * @property Sku $sku
+ * @property string $sku_id
*/
class PackageSku extends Pivot
{
@@ -23,13 +24,13 @@
// to set the costs here overrides the sku->cost and package->discount_rate, see function
// cost() for more detail
'cost',
- 'qty'
+ 'qty',
];
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
'cost' => 'integer',
- 'qty' => 'integer'
+ 'qty' => 'integer',
];
/** @var list<string> The attributes that can be not set */
@@ -43,11 +44,10 @@
/** @var bool Indicates if the model should be timestamped. */
public $timestamps = false;
-
/**
* Under this package, how much does this SKU cost?
*
- * @return int The costs of this SKU under this package in cents.
+ * @return int the costs of this SKU under this package in cents
*/
public function cost(): int
{
@@ -82,7 +82,7 @@
/**
* Under this package, what fee this SKU has?
*
- * @return int The fee for this SKU under this package in cents.
+ * @return int the fee for this SKU under this package in cents
*/
public function fee()
{
@@ -98,7 +98,7 @@
/**
* The package for this relation.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Package, $this>
+ * @return BelongsTo<Package, $this>
*/
public function package()
{
@@ -108,7 +108,7 @@
/**
* The SKU for this relation.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Sku, $this>
+ * @return BelongsTo<Sku, $this>
*/
public function sku()
{
diff --git a/src/app/Payment.php b/src/app/Payment.php
--- a/src/app/Payment.php
+++ b/src/app/Payment.php
@@ -4,21 +4,22 @@
use Dyrynda\Database\Support\NullableFields;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A payment operation on a wallet.
*
- * @property int $amount Amount of money in cents of system currency (payment provider)
- * @property int $credit_amount Amount of money in cents of system currency (wallet balance)
- * @property string $description Payment description
- * @property string $id Mollie's Payment ID
- * @property string $status Payment status (Payment::STATUS_*)
- * @property string $type Payment type (Payment::TYPE_*)
- * @property ?string $vat_rate_id VAT rate identifier
- * @property \App\Wallet $wallet The wallet
- * @property string $wallet_id The ID of the wallet
- * @property string $currency Currency of this payment
- * @property int $currency_amount Amount of money in cents of $currency
+ * @property int $amount Amount of money in cents of system currency (payment provider)
+ * @property int $credit_amount Amount of money in cents of system currency (wallet balance)
+ * @property string $description Payment description
+ * @property string $id Mollie's Payment ID
+ * @property string $status Payment status (Payment::STATUS_*)
+ * @property string $type Payment type (Payment::TYPE_*)
+ * @property ?string $vat_rate_id VAT rate identifier
+ * @property Wallet $wallet The wallet
+ * @property string $wallet_id The ID of the wallet
+ * @property string $currency Currency of this payment
+ * @property int $currency_amount Amount of money in cents of $currency
*/
class Payment extends Model
{
@@ -74,17 +75,16 @@
'vat_rate_id',
];
-
/**
* Create a payment record in DB from array.
*
* @param array $payment Payment information (required: id, type, wallet_id, currency, amount, currency_amount)
*
- * @return \App\Payment Payment object
+ * @return Payment Payment object
*/
- public static function createFromArray(array $payment): Payment
+ public static function createFromArray(array $payment): self
{
- $db_payment = new Payment();
+ $db_payment = new self();
$db_payment->id = $payment['id'];
$db_payment->description = $payment['description'] ?? '';
$db_payment->status = $payment['status'] ?? self::STATUS_OPEN;
@@ -149,9 +149,9 @@
*
* @param array $refund A refund or chargeback data (id, type, amount, currency, description)
*
- * @return ?\App\Payment A payment object for the refund
+ * @return ?Payment A payment object for the refund
*/
- public function refund(array $refund): ?Payment
+ public function refund(array $refund): ?self
{
if (empty($refund) || empty($refund['amount'])) {
return null;
@@ -197,7 +197,7 @@
/**
* The wallet to which this payment belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Wallet, $this>
+ * @return BelongsTo<Wallet, $this>
*/
public function wallet()
{
@@ -207,7 +207,7 @@
/**
* The VAT rate assigned to this payment.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<VatRate, $this>
+ * @return BelongsTo<VatRate, $this>
*/
public function vatRate()
{
diff --git a/src/app/Permission.php b/src/app/Permission.php
--- a/src/app/Permission.php
+++ b/src/app/Permission.php
@@ -8,17 +8,17 @@
/**
* The eloquent definition of a Permission.
*
- * @property string $id Permission identifier
- * @property int $rights Access rights
- * @property int $permissible_id The shared object identifier
- * @property string $permissible_type The shared object type (class name)
- * @property string $user Permitted user (email)
+ * @property string $id Permission identifier
+ * @property int $rights Access rights
+ * @property int $permissible_id The shared object identifier
+ * @property string $permissible_type The shared object type (class name)
+ * @property string $user Permitted user (email)
*/
class Permission extends Model
{
use UuidStrKeyTrait;
- public const READ = 1;
+ public const READ = 1;
public const WRITE = 2;
public const ADMIN = 4;
diff --git a/src/app/Plan.php b/src/app/Plan.php
--- a/src/app/Plan.php
+++ b/src/app/Plan.php
@@ -5,6 +5,8 @@
use App\Traits\BelongsToTenantTrait;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
/**
@@ -15,18 +17,18 @@
* A "Family Plan" as such may exist of "2 or more Kolab packages",
* and apply a discount for the third and further Kolab packages.
*
- * @property string $description
- * @property int $discount_qty
- * @property int $discount_rate
- * @property int $free_months
- * @property bool $hidden
- * @property string $id
- * @property string $mode Plan signup mode (Plan::MODE_*)
- * @property string $name
- * @property \DateTime $promo_from
- * @property \DateTime $promo_to
- * @property ?int $tenant_id
- * @property string $title
+ * @property string $description
+ * @property int $discount_qty
+ * @property int $discount_rate
+ * @property int $free_months
+ * @property bool $hidden
+ * @property string $id
+ * @property string $mode Plan signup mode (Plan::MODE_*)
+ * @property string $name
+ * @property \DateTime $promo_from
+ * @property \DateTime $promo_to
+ * @property ?int $tenant_id
+ * @property string $title
*/
class Plan extends Model
{
@@ -69,7 +71,7 @@
'discount_rate' => 'integer',
'hidden' => 'boolean',
'months' => 'integer',
- 'free_months' => 'integer'
+ 'free_months' => 'integer',
];
/** @var array<int, string> Translatable properties */
@@ -81,7 +83,7 @@
/**
* The list price for this plan at the minimum configuration.
*
- * @return int The costs in cents.
+ * @return int the costs in cents
*/
public function cost(): int
{
@@ -105,25 +107,23 @@
* billing) or its maximum (to allow topping out "enterprise" customers on a "small business"
* plan).
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Package, $this, PlanPackage>
+ * @return BelongsToMany<Package, $this, PlanPackage>
*/
public function packages()
{
return $this->belongsToMany(Package::class, 'plan_packages')
->using(PlanPackage::class)
->withPivot([
- 'qty',
- 'qty_min',
- 'qty_max',
- 'discount_qty',
- 'discount_rate'
+ 'qty',
+ 'qty_min',
+ 'qty_max',
+ 'discount_qty',
+ 'discount_rate',
]);
}
/**
* Checks if the plan has any type of domain SKU assigned.
- *
- * @return bool
*/
public function hasDomain(): bool
{
@@ -139,7 +139,7 @@
/**
* The relationship to signup tokens.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<SignupToken, $this>
+ * @return HasMany<SignupToken, $this>
*/
public function signupTokens()
{
diff --git a/src/app/PlanPackage.php b/src/app/PlanPackage.php
--- a/src/app/PlanPackage.php
+++ b/src/app/PlanPackage.php
@@ -2,20 +2,21 @@
namespace App;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\Pivot;
/**
* Link Packages to Plans.
*
- * @property int $discount_qty
- * @property int $discount_rate
- * @property string $plan_id
- * @property string $package_id
- * @property int $qty
- * @property int $qty_max
- * @property int $qty_min
- * @property \App\Package $package
- * @property \App\Plan $plan
+ * @property int $discount_qty
+ * @property int $discount_rate
+ * @property string $plan_id
+ * @property string $package_id
+ * @property int $qty
+ * @property int $qty_max
+ * @property int $qty_min
+ * @property Package $package
+ * @property Plan $plan
*/
class PlanPackage extends Pivot
{
@@ -27,7 +28,7 @@
'qty_max',
'qty_min',
'discount_qty',
- 'discount_rate'
+ 'discount_rate',
];
/** @var array<string, string> The attributes that should be cast */
@@ -36,7 +37,7 @@
'qty_max' => 'integer',
'qty_min' => 'integer',
'discount_qty' => 'integer',
- 'discount_rate' => 'integer'
+ 'discount_rate' => 'integer',
];
/**
@@ -62,7 +63,7 @@
/**
* The package in this relation.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Package, $this>
+ * @return BelongsTo<Package, $this>
*/
public function package()
{
@@ -72,7 +73,7 @@
/**
* The plan in this relation.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Plan, $this>
+ * @return BelongsTo<Plan, $this>
*/
public function plan()
{
diff --git a/src/app/Policy/Greylist.php b/src/app/Policy/Greylist.php
--- a/src/app/Policy/Greylist.php
+++ b/src/app/Policy/Greylist.php
@@ -4,6 +4,8 @@
use App\Policy\Greylist\Connect;
use App\Policy\Greylist\Whitelist;
+use App\Utils;
+use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
class Greylist
@@ -13,8 +15,8 @@
protected $netID;
protected $netType;
protected $recipientHash;
- protected $recipientID = null;
- protected $recipientType = null;
+ protected $recipientID;
+ protected $recipientType;
protected $sender;
protected $senderLocal = 'unknown';
protected $senderDomain = 'unknown';
@@ -32,9 +34,9 @@
$this->request = $request;
if (array_key_exists('timestamp', $this->request)) {
- $this->timestamp = \Carbon\Carbon::parse($this->request['timestamp']);
+ $this->timestamp = Carbon::parse($this->request['timestamp']);
} else {
- $this->timestamp = \Carbon\Carbon::now();
+ $this->timestamp = Carbon::now();
}
}
@@ -45,7 +47,7 @@
*/
public static function handle($data): Response
{
- $request = new Greylist($data);
+ $request = new self($data);
if ($request->shouldDefer()) {
return new Response(Response::ACTION_DEFER_IF_PERMIT, 'Greylisted for 5 minutes. Try again later.', 403);
@@ -97,7 +99,7 @@
*/
public function shouldDefer(): bool
{
- list($this->netID, $this->netType) = \App\Utils::getNetFromAddress($this->request['client_address']);
+ [$this->netID, $this->netType] = Utils::getNetFromAddress($this->request['client_address']);
if (!$this->netID) {
return true;
@@ -105,10 +107,10 @@
$recipient = $this->recipientFromRequest();
- $this->sender = \App\Utils::normalizeAddress($this->request['sender']);
+ $this->sender = Utils::normalizeAddress($this->request['sender']);
- if (strpos($this->sender, '@') !== false) {
- list($this->senderLocal, $this->senderDomain) = explode('@', $this->sender);
+ if (str_contains($this->sender, '@')) {
+ [$this->senderLocal, $this->senderDomain] = explode('@', $this->sender);
}
if (strlen($this->senderLocal) > 255) {
@@ -172,11 +174,11 @@
} elseif ($all->count() >= 4) {
// Automatically create a whitelist if we have at least 5 (4 existing plus this) messages from the sender
$this->whitelist = Whitelist::create([
- 'sender_domain' => $this->senderDomain,
- 'net_id' => $this->netID,
- 'net_type' => $this->netType,
- 'created_at' => $this->timestamp,
- 'updated_at' => $this->timestamp
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
+ 'created_at' => $this->timestamp,
+ 'updated_at' => $this->timestamp,
]);
$all->where('greylisting', true)
@@ -196,7 +198,7 @@
// Update/Create an entry for the sender/recipient/net combination
if ($connect) {
- $connect->connect_count += 1;
+ $connect->connect_count++;
// TODO: The period of time for which the greylisting persists is configurable.
if ($connect->created_at < $this->timestamp->copy()->subMinutes(5)) {
@@ -208,15 +210,15 @@
$connect->save();
} else {
$connect = Connect::create([
- 'sender_local' => $this->senderLocal,
- 'sender_domain' => $this->senderDomain,
- 'net_id' => $this->netID,
- 'net_type' => $this->netType,
- 'recipient_hash' => $this->recipientHash,
- 'recipient_id' => $this->recipientID,
- 'recipient_type' => $this->recipientType,
- 'created_at' => $this->timestamp,
- 'updated_at' => $this->timestamp
+ 'sender_local' => $this->senderLocal,
+ 'sender_domain' => $this->senderDomain,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
+ 'recipient_hash' => $this->recipientHash,
+ 'recipient_id' => $this->recipientID,
+ 'recipient_type' => $this->recipientType,
+ 'created_at' => $this->timestamp,
+ 'updated_at' => $this->timestamp,
]);
}
@@ -230,19 +232,19 @@
protected function findConnectsCollection()
{
return Connect::where([
- 'sender_local' => $this->senderLocal,
- 'sender_domain' => $this->senderDomain,
- 'recipient_hash' => $this->recipientHash,
- 'net_id' => $this->netID,
- 'net_type' => $this->netType,
+ 'sender_local' => $this->senderLocal,
+ 'sender_domain' => $this->senderDomain,
+ 'recipient_hash' => $this->recipientHash,
+ 'net_id' => $this->netID,
+ 'net_type' => $this->netType,
]);
}
protected function recipientFromRequest()
{
- $recipients = \App\Utils::findObjectsByRecipientAddress($this->request['recipient']);
+ $recipients = Utils::findObjectsByRecipientAddress($this->request['recipient']);
- if (sizeof($recipients) > 1) {
+ if (count($recipients) > 1) {
\Log::warning(
"Only taking the first recipient from the request for {$this->request['recipient']}"
);
@@ -252,7 +254,7 @@
foreach ($recipients as $recipient) {
if ($recipient) {
$this->recipientID = $recipient->id;
- $this->recipientType = get_class($recipient);
+ $this->recipientType = $recipient::class;
break;
}
}
@@ -260,7 +262,7 @@
$recipient = null;
}
- $this->recipientHash = hash('sha256', \App\Utils::normalizeAddress($this->request['recipient']));
+ $this->recipientHash = hash('sha256', Utils::normalizeAddress($this->request['recipient']));
return $recipient;
}
diff --git a/src/app/Policy/Greylist/Connect.php b/src/app/Policy/Greylist/Connect.php
--- a/src/app/Policy/Greylist/Connect.php
+++ b/src/app/Policy/Greylist/Connect.php
@@ -2,12 +2,14 @@
namespace App\Policy\Greylist;
+use App\Domain;
+use App\User;
use Illuminate\Database\Eloquent\Model;
/**
- * @property \App\Domain $domain
- * @property \App\Domain|\App\User $recipient
- * @property \App\User $user
+ * @property Domain $domain
+ * @property Domain|User $recipient
+ * @property User $user
*/
class Connect extends Model
{
@@ -21,14 +23,14 @@
'recipient_type',
'connect_count',
'created_at',
- 'updated_at'
+ 'updated_at',
];
protected $table = 'greylist_connect';
public function domain()
{
- if ($this->recipient_type == \App\Domain::class) {
+ if ($this->recipient_type == Domain::class) {
return $this->recipient;
}
@@ -43,7 +45,7 @@
public function user()
{
- if ($this->recipient_type == \App\User::class) {
+ if ($this->recipient_type == User::class) {
return $this->recipient;
}
diff --git a/src/app/Policy/Greylist/Whitelist.php b/src/app/Policy/Greylist/Whitelist.php
--- a/src/app/Policy/Greylist/Whitelist.php
+++ b/src/app/Policy/Greylist/Whitelist.php
@@ -14,6 +14,6 @@
'net_id',
'net_type',
'created_at',
- 'updated_at'
+ 'updated_at',
];
}
diff --git a/src/app/Policy/Mailfilter.php b/src/app/Policy/Mailfilter.php
--- a/src/app/Policy/Mailfilter.php
+++ b/src/app/Policy/Mailfilter.php
@@ -14,7 +14,7 @@
/**
* SMTP Content Filter
*
- * @param Request $request The API request.
+ * @param Request $request the API request
*
* @return Response|StreamedResponse The response
*/
@@ -77,7 +77,8 @@
if ($result->getStatus() == Result::STATUS_REJECT) {
// FIXME: Better code? Should we use custom header instead?
return response('', 460);
- } elseif ($result->getStatus() == Result::STATUS_DISCARD) {
+ }
+ if ($result->getStatus() == Result::STATUS_DISCARD) {
// FIXME: Better code? Should we use custom header instead?
return response('', 461);
}
@@ -95,7 +96,7 @@
$stream = $parser->getStream();
- $response->setCallback(function () use ($stream) {
+ $response->setCallback(static function () use ($stream) {
fpassthru($stream);
fclose($stream);
});
diff --git a/src/app/Policy/Mailfilter/MailParser.php b/src/app/Policy/Mailfilter/MailParser.php
--- a/src/app/Policy/Mailfilter/MailParser.php
+++ b/src/app/Policy/Mailfilter/MailParser.php
@@ -434,10 +434,8 @@
switch ($encoding) {
case 'quoted-printable':
return \Mail_mimePart::quotedPrintableEncode($data, 76, "\r\n");
-
case 'base64':
return rtrim(chunk_split(base64_encode($data), 76, "\r\n"));
-
case '8bit':
case '7bit':
default:
diff --git a/src/app/Policy/Mailfilter/Modules/ItipModule.php b/src/app/Policy/Mailfilter/Modules/ItipModule.php
--- a/src/app/Policy/Mailfilter/Modules/ItipModule.php
+++ b/src/app/Policy/Mailfilter/Modules/ItipModule.php
@@ -2,11 +2,12 @@
namespace App\Policy\Mailfilter\Modules;
+use App\Auth\Utils;
use App\Backends\DAV;
-use App\Support\Facades\DAV as DAVFacade;
-use App\User;
use App\Policy\Mailfilter\MailParser;
use App\Policy\Mailfilter\Result;
+use App\Support\Facades\DAV as DAVFacade;
+use App\User;
use Sabre\VObject\Component;
use Sabre\VObject\Document;
use Sabre\VObject\Reader;
@@ -96,11 +97,11 @@
/**
* Get specific event/task recurrence instance from the VCALENDAR object
*/
- protected static function extractRecurrenceInstanceComponent(COmponent $vobject, string $recurrence_id): ?Component
+ protected static function extractRecurrenceInstanceComponent(Component $vobject, string $recurrence_id): ?Component
{
foreach ($vobject->getComponents() as $component) {
if ($component->name == 'VEVENT' || $component->name == 'VTODO') {
- if (strval($component->{'RECURRENCE-ID'}) === $recurrence_id) {
+ if ((string) $component->{'RECURRENCE-ID'} === $recurrence_id) {
return $component;
}
}
@@ -158,7 +159,7 @@
{
// Use short-lived token to authenticate as user
if (!$this->davTokenExpiresOn || now()->greaterThanOrEqualTo($this->davTokenExpiresOn)) {
- $password = \App\Auth\Utils::tokenCreate((string) $user->id, $this->davTTL);
+ $password = Utils::tokenCreate((string) $user->id, $this->davTTL);
$this->davTokenExpiresOn = now()->addSeconds($this->davTTL - 1);
$this->davClient = DAVFacade::getInstance($user->email, $password);
@@ -214,10 +215,10 @@
$this->uid = (string) $component->uid;
$this->type = (string) $component->name;
- // TODO: We should probably sanity check the VCALENDAR content,
- // e.g. we should ignore/remove all components with UID different then the main (first) one.
- // In case of some obvious issues, delivering the message to inbox is probably safer.
- } elseif (strval($component->uid) != $this->uid) {
+ // TODO: We should probably sanity check the VCALENDAR content,
+ // e.g. we should ignore/remove all components with UID different then the main (first) one.
+ // In case of some obvious issues, delivering the message to inbox is probably safer.
+ } elseif ((string) $component->uid != $this->uid) {
continue;
}
diff --git a/src/app/Policy/Mailfilter/Modules/ItipModule/CancelHandler.php b/src/app/Policy/Mailfilter/Modules/ItipModule/CancelHandler.php
--- a/src/app/Policy/Mailfilter/Modules/ItipModule/CancelHandler.php
+++ b/src/app/Policy/Mailfilter/Modules/ItipModule/CancelHandler.php
@@ -49,7 +49,7 @@
// SEQUENCE does not match, deliver the message, let the MUAs to deal with this
// FIXME: Is this even a valid aproach regarding recurrence?
- if (strval($existingMaster->SEQUENCE) != strval($cancelMaster->SEQUENCE)) {
+ if ((string) $existingMaster->SEQUENCE != (string) $cancelMaster->SEQUENCE) {
return null;
}
diff --git a/src/app/Policy/Mailfilter/Modules/ItipModule/ReplyHandler.php b/src/app/Policy/Mailfilter/Modules/ItipModule/ReplyHandler.php
--- a/src/app/Policy/Mailfilter/Modules/ItipModule/ReplyHandler.php
+++ b/src/app/Policy/Mailfilter/Modules/ItipModule/ReplyHandler.php
@@ -55,7 +55,7 @@
// SEQUENCE does not match, deliver the message, let the MUAs to deal with this
// FIXME: Is this even a valid aproach regarding recurrence?
- if (strval($existingMaster->SEQUENCE) != strval($replyMaster->SEQUENCE)) {
+ if ((string) $existingMaster->SEQUENCE != (string) $replyMaster->SEQUENCE) {
return null;
}
@@ -100,7 +100,7 @@
foreach ($existingInstance->ATTENDEE as $attendee) {
$value = strtolower(preg_replace('!^mailto:!i', '', (string) $attendee));
if ($value === $email) {
- if (empty($attendee['PARTSTAT']) || strval($attendee['PARTSTAT']) != $partstat) {
+ if (empty($attendee['PARTSTAT']) || (string) $attendee['PARTSTAT'] != $partstat) {
$attendee['PARTSTAT'] = $partstat;
$updated = true;
}
diff --git a/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php b/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
--- a/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
+++ b/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
@@ -54,7 +54,7 @@
// stop processing here and pass the message to the inbox?
$requestMaster = $this->extractMainComponent($this->itip);
- $recurrence_id = strval($requestMaster->{'RECURRENCE-ID'});
+ $recurrence_id = (string) $requestMaster->{'RECURRENCE-ID'};
// The event does not exist yet in the recipient's calendar, create it
if (!$existing) {
@@ -81,11 +81,11 @@
// A new recurrence instance, just add it to the existing event
if (!$existingInstance) {
$existing->add($requestMaster);
- // TODO: Bump LAST-MODIFIED on the master object
+ // TODO: Bump LAST-MODIFIED on the master object
} else {
// SEQUENCE does not match, deliver the message, let the MUAs deal with this
// TODO: A higher SEQUENCE indicates a re-scheduled object, we should update the existing event.
- if (intval(strval($existingInstance->SEQUENCE)) != intval(strval($requestMaster->SEQUENCE))) {
+ if ((int) ((string) $existingInstance->SEQUENCE) != (int) ((string) $requestMaster->SEQUENCE)) {
return null;
}
@@ -102,7 +102,7 @@
// SEQUENCE does not match, deliver the message, let the MUAs deal with this
// TODO: A higher SEQUENCE indicates a re-scheduled object, we should update the existing event.
- if (intval(strval($existingMaster->SEQUENCE)) != intval(strval($requestMaster->SEQUENCE))) {
+ if ((int) ((string) $existingMaster->SEQUENCE) != (int) ((string) $requestMaster->SEQUENCE)) {
return null;
}
diff --git a/src/app/Policy/Mailfilter/Notifications/ItipNotification.php b/src/app/Policy/Mailfilter/Notifications/ItipNotification.php
--- a/src/app/Policy/Mailfilter/Notifications/ItipNotification.php
+++ b/src/app/Policy/Mailfilter/Notifications/ItipNotification.php
@@ -29,7 +29,7 @@
{
$this->params->user = $user;
- return (new ItipNotificationMail($this->params));
+ return new ItipNotificationMail($this->params);
}
/**
diff --git a/src/app/Policy/Mailfilter/Notifications/ItipNotificationMail.php b/src/app/Policy/Mailfilter/Notifications/ItipNotificationMail.php
--- a/src/app/Policy/Mailfilter/Notifications/ItipNotificationMail.php
+++ b/src/app/Policy/Mailfilter/Notifications/ItipNotificationMail.php
@@ -12,8 +12,6 @@
* Create a new message instance.
*
* @param ItipNotificationParams $params Mail content parameters
- *
- * @return void
*/
public function __construct(ItipNotificationParams $params)
{
diff --git a/src/app/Policy/Mailfilter/Notifications/ItipNotificationParams.php b/src/app/Policy/Mailfilter/Notifications/ItipNotificationParams.php
--- a/src/app/Policy/Mailfilter/Notifications/ItipNotificationParams.php
+++ b/src/app/Policy/Mailfilter/Notifications/ItipNotificationParams.php
@@ -7,31 +7,31 @@
class ItipNotificationParams
{
- /** @var ?string $comment iTip COMMENT property */
+ /** @var ?string iTip COMMENT property */
public ?string $comment;
- /** @var ?string $mode Notification mode (iTip method) */
+ /** @var ?string Notification mode (iTip method) */
public ?string $mode;
- /** @var ?string $partstat Attendee PARTSTAT property in an iTip REPLY */
+ /** @var ?string Attendee PARTSTAT property in an iTip REPLY */
public ?string $partstat;
- /** @var ?string $recurrenceId Recurrence identifier of an event/task occurence */
+ /** @var ?string Recurrence identifier of an event/task occurence */
public ?string $recurrenceId;
- /** @var ?string $summary iTip sender (attendee or organizer) email address */
+ /** @var ?string iTip sender (attendee or organizer) email address */
public ?string $senderEmail;
- /** @var ?string $summary iTip sender (attendee or organizer) name */
+ /** @var ?string iTip sender (attendee or organizer) name */
public ?string $senderName;
- /** @var ?string $start Event/task start date or date-time */
+ /** @var ?string Event/task start date or date-time */
public ?string $start;
- /** @var ?string $summary Event/Task summary */
+ /** @var ?string Event/Task summary */
public ?string $summary;
- /** @var ?User $user The recipient of the notification */
+ /** @var ?User The recipient of the notification */
public ?User $user;
/**
diff --git a/src/app/Policy/RateLimit.php b/src/app/Policy/RateLimit.php
--- a/src/app/Policy/RateLimit.php
+++ b/src/app/Policy/RateLimit.php
@@ -2,10 +2,12 @@
namespace App\Policy;
+use App\Traits\BelongsToUserTrait;
use App\Transaction;
use App\User;
+use App\UserAlias;
+use App\Utils;
use Carbon\Carbon;
-use App\Traits\BelongsToUserTrait;
use Illuminate\Database\Eloquent\Model;
class RateLimit extends Model
@@ -17,7 +19,7 @@
'user_id',
'owner_id',
'recipient_hash',
- 'recipient_count'
+ 'recipient_count',
];
/** @var string Database table name */
@@ -32,7 +34,7 @@
*/
public static function handle($data): Response
{
- list($local, $domain) = \App\Utils::normalizeAddress($data['sender'], true);
+ [$local, $domain] = Utils::normalizeAddress($data['sender'], true);
if (empty($local) || empty($domain)) {
return new Response(Response::ACTION_HOLD, 'Invalid sender email', 403);
@@ -45,10 +47,10 @@
}
// Find the Kolab user
- $user = \App\User::withTrashed()->where('email', $sender)->first();
+ $user = User::withTrashed()->where('email', $sender)->first();
if (!$user) {
- $alias = \App\UserAlias::where('alias', $sender)->first();
+ $alias = UserAlias::where('alias', $sender)->first();
if (!$alias) {
// TODO: How about sender is a distlist address?
@@ -113,17 +115,17 @@
$owner = $wallet->owner;
// find or create the request
- $request = RateLimit::where('recipient_hash', $recipientHash)
+ $request = self::where('recipient_hash', $recipientHash)
->where('user_id', $user->id)
->where('updated_at', '>=', Carbon::now()->subHour())
->first();
if (!$request) {
- $request = RateLimit::create([
- 'user_id' => $user->id,
- 'owner_id' => $owner->id,
- 'recipient_hash' => $recipientHash,
- 'recipient_count' => $recipientCount
+ $request = self::create([
+ 'user_id' => $user->id,
+ 'owner_id' => $owner->id,
+ 'recipient_hash' => $recipientHash,
+ 'recipient_count' => $recipientCount,
]);
} else {
// ensure the request has an up to date timestamp
@@ -152,7 +154,7 @@
}
// Examine the rates at which the owner (or its users) is sending
- $ownerRates = RateLimit::where('owner_id', $owner->id)
+ $ownerRates = self::where('owner_id', $owner->id)
->where('updated_at', '>=', Carbon::now()->subHour());
if (($count = $ownerRates->count()) >= 10) {
@@ -187,7 +189,7 @@
// Examine the rates at which the user is sending (if not also the owner)
if ($user->id != $owner->id) {
- $userRates = RateLimit::where('user_id', $user->id)
+ $userRates = self::where('user_id', $user->id)
->where('updated_at', '>=', Carbon::now()->subHour());
if (($count = $userRates->count()) >= 10) {
diff --git a/src/app/Policy/RateLimit/Whitelist.php b/src/app/Policy/RateLimit/Whitelist.php
--- a/src/app/Policy/RateLimit/Whitelist.php
+++ b/src/app/Policy/RateLimit/Whitelist.php
@@ -7,9 +7,9 @@
/**
* The eloquent definition of a RateLimit Whitelist entry.
*
- * @property ?object $whitelistable The whitelistable object
- * @property int|string $whitelistable_id The whitelistable object identifier
- * @property string $whitelistable_type The whitelistable object type
+ * @property ?object $whitelistable The whitelistable object
+ * @property int|string $whitelistable_id The whitelistable object identifier
+ * @property string $whitelistable_type The whitelistable object type
*/
class Whitelist extends Model
{
diff --git a/src/app/Policy/Response.php b/src/app/Policy/Response.php
--- a/src/app/Policy/Response.php
+++ b/src/app/Policy/Response.php
@@ -27,7 +27,6 @@
/** @var array<string> Headers to prepend */
public array $prepends = [];
-
/**
* Object constructor
*
diff --git a/src/app/Policy/SPF.php b/src/app/Policy/SPF.php
--- a/src/app/Policy/SPF.php
+++ b/src/app/Policy/SPF.php
@@ -3,6 +3,10 @@
namespace App\Policy;
use App\Policy\SPF\Cache;
+use App\Utils;
+use SPFLib\Check\Environment;
+use SPFLib\Check\Result;
+use SPFLib\Checker;
class SPF
{
@@ -22,7 +26,7 @@
return $response;
}
- list($netID, $netType) = \App\Utils::getNetFromAddress($data['client_address']);
+ [$netID, $netType] = Utils::getNetFromAddress($data['client_address']);
// This network can not be recognized.
if (!$netID) {
@@ -41,8 +45,8 @@
$data['sender'] = '';
}
- if (strpos($data['sender'], '@') !== false) {
- list($senderLocal, $senderDomain) = explode('@', $data['sender']);
+ if (str_contains($data['sender'], '@')) {
+ [$senderLocal, $senderDomain] = explode('@', $data['sender']);
if (strlen($senderLocal) >= 255) {
$senderLocal = substr($senderLocal, 0, 255);
@@ -55,13 +59,13 @@
$result = Cache::get($cacheKey);
if (!$result) {
- $environment = new \SPFLib\Check\Environment(
+ $environment = new Environment(
$data['client_address'],
$data['client_name'],
$data['sender']
);
- $result = (new \SPFLib\Checker())->check($environment);
+ $result = (new Checker())->check($environment);
Cache::set($cacheKey, serialize($result));
} else {
@@ -72,33 +76,27 @@
$prependSPF = '';
switch ($result->getCode()) {
- case \SPFLib\Check\Result::CODE_ERROR_PERMANENT:
+ case Result::CODE_ERROR_PERMANENT:
$fail = true;
$prependSPF = 'Received-SPF: Permerror';
break;
-
- case \SPFLib\Check\Result::CODE_ERROR_TEMPORARY:
+ case Result::CODE_ERROR_TEMPORARY:
$prependSPF = 'Received-SPF: Temperror';
break;
-
- case \SPFLib\Check\Result::CODE_FAIL:
+ case Result::CODE_FAIL:
$fail = true;
$prependSPF = 'Received-SPF: Fail';
break;
-
- case \SPFLib\Check\Result::CODE_SOFTFAIL:
+ case Result::CODE_SOFTFAIL:
$prependSPF = 'Received-SPF: Softfail';
break;
-
- case \SPFLib\Check\Result::CODE_NEUTRAL:
+ case Result::CODE_NEUTRAL:
$prependSPF = 'Received-SPF: Neutral';
break;
-
- case \SPFLib\Check\Result::CODE_PASS:
+ case Result::CODE_PASS:
$prependSPF = 'Received-SPF: Pass';
break;
-
- case \SPFLib\Check\Result::CODE_NONE:
+ case Result::CODE_NONE:
$prependSPF = 'Received-SPF: None';
break;
}
@@ -113,7 +111,7 @@
// inbound mail to a local recipient address.
$objects = null;
if (array_key_exists('recipient', $data)) {
- $objects = \App\Utils::findObjectsByRecipientAddress($data['recipient']);
+ $objects = Utils::findObjectsByRecipientAddress($data['recipient']);
}
if (!empty($objects)) {
diff --git a/src/app/Policy/SmtpAccess.php b/src/app/Policy/SmtpAccess.php
--- a/src/app/Policy/SmtpAccess.php
+++ b/src/app/Policy/SmtpAccess.php
@@ -4,6 +4,7 @@
use App\User;
use App\UserAlias;
+use App\Utils;
class SmtpAccess
{
@@ -17,7 +18,7 @@
// TODO: The old SMTP access policy had an option ('empty_sender_hosts') to allow
// sending mail with no sender from configured networks.
- list($local, $domain) = \App\Utils::normalizeAddress($data['sender'], true);
+ [$local, $domain] = Utils::normalizeAddress($data['sender'], true);
if (empty($local) || empty($domain)) {
return new Response(Response::ACTION_REJECT, 'Invalid sender', 403);
@@ -25,7 +26,7 @@
$sender = $local . '@' . $domain;
- list($local, $domain) = \App\Utils::normalizeAddress($data['user'], true);
+ [$local, $domain] = Utils::normalizeAddress($data['user'], true);
if (empty($local) || empty($domain)) {
return new Response(Response::ACTION_REJECT, 'Invalid user', 403);
@@ -33,13 +34,13 @@
$sasl_user = $local . '@' . $domain;
- $user = \App\User::where('email', $sasl_user)->first();
+ $user = User::where('email', $sasl_user)->first();
if (!$user) {
return new Response(Response::ACTION_REJECT, "Could not find user {$data['user']}", 403);
}
- if (!SmtpAccess::verifySender($user, $sender)) {
+ if (!self::verifySender($user, $sender)) {
$reason = "{$sasl_user} is unauthorized to send mail as {$sender}";
return new Response(Response::ACTION_REJECT, $reason, 403);
}
@@ -59,7 +60,7 @@
*/
public static function verifySender(User $user, string $email): bool
{
- if ($user->isSuspended() || strpos($email, '@') === false) {
+ if ($user->isSuspended() || !str_contains($email, '@')) {
return false;
}
diff --git a/src/app/PowerDNS/Domain.php b/src/app/PowerDNS/Domain.php
--- a/src/app/PowerDNS/Domain.php
+++ b/src/app/PowerDNS/Domain.php
@@ -2,12 +2,14 @@
namespace App\PowerDNS;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
class Domain extends Model
{
protected $fillable = [
- 'name'
+ 'name',
];
protected $table = 'powerdns_domains';
@@ -19,17 +21,17 @@
{
$soa = $this->records()->where('type', 'SOA')->first();
- list($ns, $hm, $serial, $a, $b, $c, $d) = explode(" ", $soa->content);
+ [$ns, $hm, $serial, $a, $b, $c, $d] = explode(" ", $soa->content);
- $today = \Carbon\Carbon::now()->format('Ymd');
+ $today = Carbon::now()->format('Ymd');
$date = substr($serial, 0, 8);
if ($date != $today) {
$serial = $today . '01';
} else {
- $change = (int)(substr($serial, 8, 2));
+ $change = (int) substr($serial, 8, 2);
- $serial = sprintf("%s%02s", $date, ($change + 1));
+ $serial = sprintf("%s%02s", $date, $change + 1);
}
$soa->content = "{$ns} {$hm} {$serial} {$a} {$b} {$c} {$d}";
@@ -38,14 +40,12 @@
/**
* Returns the SOA record serial
- *
- * @return string
*/
public function getSerial(): string
{
$soa = $this->records()->where('type', 'SOA')->first();
- list($ns, $hm, $serial, $a, $b, $c, $d) = explode(" ", $soa->content);
+ [$ns, $hm, $serial, $a, $b, $c, $d] = explode(" ", $soa->content);
return $serial;
}
@@ -53,7 +53,7 @@
/**
* Any DNS records assigned to this domain.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Record, $this>
+ * @return HasMany<Record, $this>
*/
public function records()
{
@@ -63,7 +63,7 @@
/**
* Any (additional) properties of this domain.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<DomainSetting, $this>
+ * @return HasMany<DomainSetting, $this>
*/
public function settings()
{
diff --git a/src/app/PowerDNS/Record.php b/src/app/PowerDNS/Record.php
--- a/src/app/PowerDNS/Record.php
+++ b/src/app/PowerDNS/Record.php
@@ -10,14 +10,14 @@
'domain_id',
'name',
'type',
- 'content'
+ 'content',
];
protected $table = 'powerdns_records';
public function domain()
{
- return $this->belongsTo(\App\PowerDNS\Domain::class, 'domain_id', 'id');
+ return $this->belongsTo(Domain::class, 'domain_id', 'id');
}
public function toString()
diff --git a/src/app/Providers/AppServiceProvider.php b/src/app/Providers/AppServiceProvider.php
--- a/src/app/Providers/AppServiceProvider.php
+++ b/src/app/Providers/AppServiceProvider.php
@@ -2,6 +2,66 @@
namespace App\Providers;
+use App\Backends\DAV;
+use App\Backends\IMAP;
+use App\Backends\LDAP;
+use App\Backends\OpenExchangeRates;
+use App\Backends\PGP;
+use App\Backends\Roundcube;
+use App\Backends\Storage;
+use App\Delegation;
+use App\Domain;
+use App\Entitlement;
+use App\EventLog;
+use App\Group;
+use App\GroupSetting;
+use App\Meet\Room;
+use App\Observers\DelegationObserver;
+use App\Observers\DomainObserver;
+use App\Observers\EntitlementObserver;
+use App\Observers\EventLogObserver;
+use App\Observers\GroupObserver;
+use App\Observers\GroupSettingObserver;
+use App\Observers\Meet\RoomObserver;
+use App\Observers\PackageSkuObserver;
+use App\Observers\PlanPackageObserver;
+use App\Observers\PowerDNS\DomainObserver as DNSDomainObserver;
+use App\Observers\PowerDNS\RecordObserver as DNSRecordObserver;
+use App\Observers\ReferralCodeObserver;
+use App\Observers\ResourceObserver;
+use App\Observers\ResourceSettingObserver;
+use App\Observers\SharedFolderAliasObserver;
+use App\Observers\SharedFolderObserver;
+use App\Observers\SharedFolderSettingObserver;
+use App\Observers\SignupCodeObserver;
+use App\Observers\SignupInvitationObserver;
+use App\Observers\SignupTokenObserver;
+use App\Observers\TransactionObserver;
+use App\Observers\UserAliasObserver;
+use App\Observers\UserObserver;
+use App\Observers\UserSettingObserver;
+use App\Observers\VerificationCodeObserver;
+use App\Observers\WalletObserver;
+use App\PackageSku;
+use App\PlanPackage;
+use App\PowerDNS\Domain as DNSDomain;
+use App\PowerDNS\Record as DNSRecord;
+use App\ReferralCode;
+use App\Resource;
+use App\ResourceSetting;
+use App\SharedFolder;
+use App\SharedFolderAlias;
+use App\SharedFolderSetting;
+use App\SignupCode;
+use App\SignupInvitation;
+use App\SignupToken;
+use App\Transaction;
+use App\User;
+use App\UserAlias;
+use App\UserSetting;
+use App\VerificationCode;
+use App\Wallet;
+use GuzzleHttp\TransferStats;
use Illuminate\Database\Query\Builder;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Http;
@@ -19,26 +79,26 @@
// This must be here, not in PassportServiceProvider
Passport::ignoreRoutes();
- $this->app->bind('imap', function () {
- return new \App\Backends\IMAP();
+ $this->app->bind('imap', static function () {
+ return new IMAP();
});
- $this->app->bind('ldap', function () {
- return new \App\Backends\LDAP();
+ $this->app->bind('ldap', static function () {
+ return new LDAP();
});
- $this->app->bind('dav', function () {
- return new \App\Backends\DAV();
+ $this->app->bind('dav', static function () {
+ return new DAV();
});
- $this->app->bind('roundcube', function () {
- return new \App\Backends\Roundcube();
+ $this->app->bind('roundcube', static function () {
+ return new Roundcube();
});
- $this->app->bind('pgp', function () {
- return new \App\Backends\PGP();
+ $this->app->bind('pgp', static function () {
+ return new PGP();
});
- $this->app->bind('filestorage', function () {
- return new \App\Backends\Storage();
+ $this->app->bind('filestorage', static function () {
+ return new Storage();
});
- $this->app->bind('openexchangerates', function () {
- return new \App\Backends\OpenExchangeRates();
+ $this->app->bind('openexchangerates', static function () {
+ return new OpenExchangeRates();
});
}
@@ -64,78 +124,77 @@
*/
public function boot(): void
{
- \App\Delegation::observe(\App\Observers\DelegationObserver::class);
- \App\Domain::observe(\App\Observers\DomainObserver::class);
- \App\Entitlement::observe(\App\Observers\EntitlementObserver::class);
- \App\EventLog::observe(\App\Observers\EventLogObserver::class);
- \App\Group::observe(\App\Observers\GroupObserver::class);
- \App\GroupSetting::observe(\App\Observers\GroupSettingObserver::class);
- \App\Meet\Room::observe(\App\Observers\Meet\RoomObserver::class);
- \App\PackageSku::observe(\App\Observers\PackageSkuObserver::class);
- \App\PlanPackage::observe(\App\Observers\PlanPackageObserver::class);
- \App\ReferralCode::observe(\App\Observers\ReferralCodeObserver::class);
- \App\Resource::observe(\App\Observers\ResourceObserver::class);
- \App\ResourceSetting::observe(\App\Observers\ResourceSettingObserver::class);
- \App\SharedFolder::observe(\App\Observers\SharedFolderObserver::class);
- \App\SharedFolderAlias::observe(\App\Observers\SharedFolderAliasObserver::class);
- \App\SharedFolderSetting::observe(\App\Observers\SharedFolderSettingObserver::class);
- \App\SignupCode::observe(\App\Observers\SignupCodeObserver::class);
- \App\SignupInvitation::observe(\App\Observers\SignupInvitationObserver::class);
- \App\SignupToken::observe(\App\Observers\SignupTokenObserver::class);
- \App\Transaction::observe(\App\Observers\TransactionObserver::class);
- \App\User::observe(\App\Observers\UserObserver::class);
- \App\UserAlias::observe(\App\Observers\UserAliasObserver::class);
- \App\UserSetting::observe(\App\Observers\UserSettingObserver::class);
- \App\VerificationCode::observe(\App\Observers\VerificationCodeObserver::class);
- \App\Wallet::observe(\App\Observers\WalletObserver::class);
-
- \App\PowerDNS\Domain::observe(\App\Observers\PowerDNS\DomainObserver::class);
- \App\PowerDNS\Record::observe(\App\Observers\PowerDNS\RecordObserver::class);
+ Delegation::observe(DelegationObserver::class);
+ DNSDomain::observe(DNSDomainObserver::class);
+ DNSRecord::observe(DNSRecordObserver::class);
+ Domain::observe(DomainObserver::class);
+ Entitlement::observe(EntitlementObserver::class);
+ EventLog::observe(EventLogObserver::class);
+ Group::observe(GroupObserver::class);
+ GroupSetting::observe(GroupSettingObserver::class);
+ Room::observe(RoomObserver::class);
+ PackageSku::observe(PackageSkuObserver::class);
+ PlanPackage::observe(PlanPackageObserver::class);
+ ReferralCode::observe(ReferralCodeObserver::class);
+ Resource::observe(ResourceObserver::class);
+ ResourceSetting::observe(ResourceSettingObserver::class);
+ SharedFolder::observe(SharedFolderObserver::class);
+ SharedFolderAlias::observe(SharedFolderAliasObserver::class);
+ SharedFolderSetting::observe(SharedFolderSettingObserver::class);
+ SignupCode::observe(SignupCodeObserver::class);
+ SignupInvitation::observe(SignupInvitationObserver::class);
+ SignupToken::observe(SignupTokenObserver::class);
+ Transaction::observe(TransactionObserver::class);
+ User::observe(UserObserver::class);
+ UserAlias::observe(UserAliasObserver::class);
+ UserSetting::observe(UserSettingObserver::class);
+ VerificationCode::observe(VerificationCodeObserver::class);
+ Wallet::observe(WalletObserver::class);
Schema::defaultStringLength(191);
// Register some template helpers
Blade::directive(
'theme_asset',
- function ($path) {
+ static function ($path) {
$path = trim($path, '/\'"');
- return "<?php echo secure_asset('themes/' . \$env['app.theme'] . '/' . '$path'); ?>";
+ return "<?php echo secure_asset('themes/' . \$env['app.theme'] . '/' . '{$path}'); ?>";
}
);
Builder::macro(
'withEnvTenantContext',
- function (string $table = null) {
+ function (?string $table = null) {
$tenantId = \config('app.tenant_id');
if ($tenantId) {
- /** @var Builder $this */
- return $this->where(($table ? "$table." : "") . "tenant_id", $tenantId);
+ // @var Builder $this
+ return $this->where(($table ? "{$table}." : "") . "tenant_id", $tenantId);
}
- /** @var Builder $this */
- return $this->whereNull(($table ? "$table." : "") . "tenant_id");
+ // @var Builder $this
+ return $this->whereNull(($table ? "{$table}." : "") . "tenant_id");
}
);
Builder::macro(
'withObjectTenantContext',
- function (object $object, string $table = null) {
+ function (object $object, ?string $table = null) {
$tenantId = $object->tenant_id;
if ($tenantId) {
- /** @var Builder $this */
- return $this->where(($table ? "$table." : "") . "tenant_id", $tenantId);
+ // @var Builder $this
+ return $this->where(($table ? "{$table}." : "") . "tenant_id", $tenantId);
}
- /** @var Builder $this */
- return $this->whereNull(($table ? "$table." : "") . "tenant_id");
+ // @var Builder $this
+ return $this->whereNull(($table ? "{$table}." : "") . "tenant_id");
}
);
Builder::macro(
'withSubjectTenantContext',
- function (string $table = null) {
+ function (?string $table = null) {
if ($user = auth()->user()) {
$tenantId = $user->tenant_id;
} else {
@@ -143,18 +202,18 @@
}
if ($tenantId) {
- /** @var Builder $this */
- return $this->where(($table ? "$table." : "") . "tenant_id", $tenantId);
+ // @var Builder $this
+ return $this->where(($table ? "{$table}." : "") . "tenant_id", $tenantId);
}
- /** @var Builder $this */
- return $this->whereNull(($table ? "$table." : "") . "tenant_id");
+ // @var Builder $this
+ return $this->whereNull(($table ? "{$table}." : "") . "tenant_id");
}
);
Http::macro('withSlowLog', function () {
return Http::withOptions([
- 'on_stats' => function (\GuzzleHttp\TransferStats $stats) {
+ 'on_stats' => static function (TransferStats $stats) {
$threshold = \config('logging.slow_log');
if ($threshold && ($sec = $stats->getTransferTime()) > $threshold) {
$url = $stats->getEffectiveUri();
diff --git a/src/app/Providers/AuthServiceProvider.php b/src/app/Providers/AuthServiceProvider.php
--- a/src/app/Providers/AuthServiceProvider.php
+++ b/src/app/Providers/AuthServiceProvider.php
@@ -17,7 +17,5 @@
/**
* Register any authentication / authorization services.
*/
- public function boot(): void
- {
- }
+ public function boot(): void {}
}
diff --git a/src/app/Providers/BroadcastServiceProvider.php b/src/app/Providers/BroadcastServiceProvider.php
--- a/src/app/Providers/BroadcastServiceProvider.php
+++ b/src/app/Providers/BroadcastServiceProvider.php
@@ -2,8 +2,8 @@
namespace App\Providers;
-use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
+use Illuminate\Support\ServiceProvider;
class BroadcastServiceProvider extends ServiceProvider
{
diff --git a/src/app/Providers/EventServiceProvider.php b/src/app/Providers/EventServiceProvider.php
--- a/src/app/Providers/EventServiceProvider.php
+++ b/src/app/Providers/EventServiceProvider.php
@@ -2,6 +2,7 @@
namespace App\Providers;
+use App\Listeners\SqlDebug;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
@@ -20,16 +21,13 @@
* @var array
*/
protected $subscribe = [
- \App\Listeners\SqlDebug::class,
+ SqlDebug::class,
];
/**
* Register any events for your application.
*/
- public function boot(): void
- {
- //
- }
+ public function boot(): void {}
/**
* Determine if events and listeners should be automatically discovered.
@@ -41,8 +39,6 @@
/**
* Configure the proper event listeners for email verification.
- *
- * @return void
*/
protected function configureEmailVerification()
{
diff --git a/src/app/Providers/HorizonServiceProvider.php b/src/app/Providers/HorizonServiceProvider.php
--- a/src/app/Providers/HorizonServiceProvider.php
+++ b/src/app/Providers/HorizonServiceProvider.php
@@ -10,8 +10,6 @@
{
/**
* Bootstrap any application services.
- *
- * @return void
*/
public function boot()
{
@@ -28,7 +26,7 @@
{
Gate::define(
'viewHorizon',
- function ($user = null) {
+ static function ($user = null) {
return true;
}
);
diff --git a/src/app/Providers/PassportServiceProvider.php b/src/app/Providers/PassportServiceProvider.php
--- a/src/app/Providers/PassportServiceProvider.php
+++ b/src/app/Providers/PassportServiceProvider.php
@@ -2,9 +2,11 @@
namespace App\Providers;
-use Defuse\Crypto\Key as EncryptionKey;
+use App\Auth\PassportClient;
+use App\Observers\Passport\TokenObserver;
use Defuse\Crypto\Encoding as EncryptionEncoding;
-use Laravel\Passport\Bridge;
+use Defuse\Crypto\Key;
+use Defuse\Crypto\Key as EncryptionKey;
use Laravel\Passport\Passport;
use OpenIDConnect\Laravel\PassportServiceProvider as ServiceProvider;
@@ -12,8 +14,6 @@
{
/**
* Register any authentication / authorization services.
- *
- * @return void
*/
public function boot()
{
@@ -34,8 +34,8 @@
Passport::refreshTokensExpireIn(now()->addMinutes(\config('auth.refresh_token_expiry_minutes')));
Passport::personalAccessTokensExpireIn(now()->addMonths(6));
- Passport::useClientModel(\App\Auth\PassportClient::class);
- Passport::tokenModel()::observe(\App\Observers\Passport\TokenObserver::class);
+ Passport::useClientModel(PassportClient::class);
+ Passport::tokenModel()::observe(TokenObserver::class);
}
/**
@@ -44,7 +44,8 @@
* Based on https://github.com/laravel/passport/pull/820
*
* @param string $keyBytes
- * @return \Defuse\Crypto\Key|string
+ *
+ * @return Key|string
*/
protected function getEncryptionKey($keyBytes)
{
diff --git a/src/app/Providers/Payment/Coinbase.php b/src/app/Providers/Payment/Coinbase.php
--- a/src/app/Providers/Payment/Coinbase.php
+++ b/src/app/Providers/Payment/Coinbase.php
@@ -3,25 +3,26 @@
namespace App\Providers\Payment;
use App\Payment;
-use App\Utils;
+use App\Providers\PaymentProvider;
use App\Wallet;
+use GuzzleHttp\Client;
+use GuzzleHttp\TransferStats;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
-class Coinbase extends \App\Providers\PaymentProvider
+class Coinbase extends PaymentProvider
{
- /** @var \GuzzleHttp\Client|null HTTP client instance */
- private $client = null;
- /** @var \GuzzleHttp\Client|null test HTTP client instance */
- public static $testClient = null;
+ /** @var Client|null HTTP client instance */
+ private $client;
+ /** @var Client|null test HTTP client instance */
+ public static $testClient;
private const SATOSHI_MULTIPLIER = 10000000;
-
/**
* Get a link to the customer in the provider's control panel
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return string|null The string representing <a> tag
*/
@@ -33,12 +34,12 @@
/**
* Create a new auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents (optional)
- * - currency: The operation currency
- * - description: Operation desc.
- * - methodId: Payment method
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents (optional)
+ * - currency: The operation currency
+ * - description: Operation desc.
+ * - methodId: Payment method
*
* @return array Provider payment data:
* - id: Operation identifier
@@ -52,7 +53,7 @@
/**
* Revoke the auto-payment mandate for the wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return bool True on success, False on failure
*/
@@ -64,7 +65,7 @@
/**
* Get a auto-payment mandate for the wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return array|null Mandate information:
* - id: Mandate identifier
@@ -91,7 +92,7 @@
/**
* Creates HTTP client for connections to coinbase
*
- * @return \GuzzleHttp\Client HTTP client instance
+ * @return Client HTTP client instance
*/
private function client()
{
@@ -99,7 +100,7 @@
return self::$testClient;
}
if (!$this->client) {
- $this->client = new \GuzzleHttp\Client(
+ $this->client = new Client(
[
'http_errors' => false, // No exceptions from Guzzle
'base_uri' => 'https://api.commerce.coinbase.com/',
@@ -110,7 +111,7 @@
],
'connect_timeout' => 10,
'timeout' => 10,
- 'on_stats' => function (\GuzzleHttp\TransferStats $stats) {
+ 'on_stats' => static function (TransferStats $stats) {
$threshold = \config('logging.slow_log');
if ($threshold && ($sec = $stats->getTransferTime()) > $threshold) {
$url = $stats->getEffectiveUri();
@@ -127,13 +128,13 @@
/**
* Create a new payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents
- * - currency: The operation currency
- * - type: oneoff/recurring
- * - description: Operation desc.
- * - methodId: Payment method
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents
+ * - currency: The operation currency
+ * - type: oneoff/recurring
+ * - description: Operation desc.
+ * - methodId: Payment method
*
* @return array Provider payment data:
* - id: Operation identifier
@@ -156,8 +157,8 @@
'currency' => $wallet->currency,
'amount' => sprintf('%.2F', $amount),
],
- 'redirect_url' => self::redirectUrl()
- ]
+ 'redirect_url' => self::redirectUrl(),
+ ],
];
$response = $this->client()->request('POST', '/charges/', $post);
@@ -186,11 +187,10 @@
return [
'id' => $payment['id'],
- 'newWindowUrl' => $json['data']['hosted_url']
+ 'newWindowUrl' => $json['data']['hosted_url'],
];
}
-
/**
* Log an error for a failed request to the meet server
*
@@ -206,22 +206,21 @@
$decoded = json_decode($response->getBody(), true);
$message = '';
if (
- is_array($decoded) && array_key_exists('error', $decoded) &&
- is_array($decoded['error']) && array_key_exists('message', $decoded['error'])
+ is_array($decoded) && array_key_exists('error', $decoded)
+ && is_array($decoded['error']) && array_key_exists('message', $decoded['error'])
) {
$message = $decoded['error']['message'];
}
- \Log::error("$str [$code]: $message");
+ \Log::error("{$str} [{$code}]: {$message}");
}
}
-
/**
* Cancel a pending payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param string $paymentId Payment Id
+ * @param Wallet $wallet The wallet
+ * @param string $paymentId Payment Id
*
* @return bool True on success, False on failure
*/
@@ -241,12 +240,11 @@
return true;
}
-
/**
* Create a new automatic payment operation.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data (see self::payment())
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data (see self::payment())
*
* @return array Provider payment/session data:
* - id: Operation identifier
@@ -256,7 +254,6 @@
throw new \Exception("not available with coinbase");
}
-
private static function verifySignature($payload, $sigHeader)
{
$secret = \config('services.coinbase.webhook_secret');
@@ -348,7 +345,7 @@
/**
* List supported payment methods.
*
- * @param string $type The payment type for which we require a method (oneoff/recurring).
+ * @param string $type the payment type for which we require a method (oneoff/recurring)
* @param string $currency Currency code
*
* @return array Array of array with available payment methods:
@@ -368,7 +365,7 @@
'id' => 'bitcoin',
'name' => "Bitcoin",
'minimumAmount' => 0.001,
- 'currency' => 'BTC'
+ 'currency' => 'BTC',
];
}
@@ -381,10 +378,10 @@
* @param string $paymentId Payment identifier
*
* @return array Payment information:
- * - id: Payment identifier
- * - status: Payment status
- * - isCancelable: The payment can be canceled
- * - checkoutUrl: The checkout url to complete the payment or null if none
+ * - id: Payment identifier
+ * - status: Payment status
+ * - isCancelable: The payment can be canceled
+ * - checkoutUrl: The checkout url to complete the payment or null if none
*/
public function getPayment($paymentId): array
{
@@ -394,7 +391,7 @@
'id' => $payment->id,
'status' => $payment->status,
'isCancelable' => true,
- 'checkoutUrl' => "https://commerce.coinbase.com/charges/{$paymentId}"
+ 'checkoutUrl' => "https://commerce.coinbase.com/charges/{$paymentId}",
];
}
}
diff --git a/src/app/Providers/Payment/Mollie.php b/src/app/Providers/Payment/Mollie.php
--- a/src/app/Providers/Payment/Mollie.php
+++ b/src/app/Providers/Payment/Mollie.php
@@ -2,7 +2,9 @@
namespace App\Providers\Payment;
+use App\Jobs\Mail\PaymentJob;
use App\Payment;
+use App\Providers\PaymentProvider;
use App\Utils;
use App\Wallet;
use Illuminate\Support\Facades\DB;
@@ -10,12 +12,12 @@
use Mollie\Api\Types;
use Mollie\Laravel\Facades\Mollie as MollieAPI;
-class Mollie extends \App\Providers\PaymentProvider
+class Mollie extends PaymentProvider
{
/**
* Get a link to the customer in the provider's control panel
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return string|null The string representing <a> tag
*/
@@ -37,8 +39,9 @@
/**
* Validates that mollie available.
*
- * @throws ApiException on failure
* @return bool true on success
+ *
+ * @throws ApiException on failure
*/
public static function healthcheck()
{
@@ -49,13 +52,13 @@
/**
* Create a new auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents (optional)
- * - currency: The operation currency
- * - description: Operation desc.
- * - methodId: Payment method
- * - redirectUrl: The location to goto after checkout
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents (optional)
+ * - currency: The operation currency
+ * - description: Operation desc.
+ * - methodId: Payment method
+ * - redirectUrl: The location to goto after checkout
*
* @return array Provider payment data:
* - id: Operation identifier
@@ -84,7 +87,7 @@
'webhookUrl' => Utils::serviceUrl('/api/webhooks/payment/mollie'),
'redirectUrl' => $payment['redirectUrl'] ?? self::redirectUrl(),
'locale' => 'en_US',
- 'method' => $payment['methodId']
+ 'method' => $payment['methodId'],
];
// Create the payment in Mollie
@@ -115,7 +118,7 @@
/**
* Revoke the auto-payment mandate for the wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return bool True on success, False on failure
*/
@@ -137,7 +140,7 @@
/**
* Get a auto-payment mandate for the wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return array|null Mandate information:
* - id: Mandate identifier
@@ -160,7 +163,7 @@
'isPending' => $mandate->isPending(),
'isValid' => $mandate->isValid(),
'method' => self::paymentMethod($mandate, 'Unknown method'),
- 'methodId' => $mandate->method
+ 'methodId' => $mandate->method,
];
return $result;
@@ -179,13 +182,13 @@
/**
* Create a new payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents
- * - currency: The operation currency
- * - type: oneoff/recurring
- * - description: Operation desc.
- * - methodId: Payment method
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents
+ * - currency: The operation currency
+ * - type: oneoff/recurring
+ * - description: Operation desc.
+ * - methodId: Payment method
*
* @return array Provider payment data:
* - id: Operation identifier
@@ -217,7 +220,7 @@
'webhookUrl' => Utils::serviceUrl('/api/webhooks/payment/mollie'),
'locale' => 'en_US',
'method' => $payment['methodId'],
- 'redirectUrl' => self::redirectUrl() // required for non-recurring payments
+ 'redirectUrl' => self::redirectUrl(), // required for non-recurring payments
];
// TODO: Additional payment parameters for better fraud protection:
@@ -247,8 +250,8 @@
/**
* Cancel a pending payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param string $paymentId Payment Id
+ * @param Wallet $wallet The wallet
+ * @param string $paymentId Payment Id
*
* @return bool True on success, False on failure
*/
@@ -266,8 +269,8 @@
/**
* Create a new automatic payment operation.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data (see self::payment())
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data (see self::payment())
*
* @return array Provider payment/session data:
* - id: Operation identifier
@@ -300,7 +303,7 @@
'webhookUrl' => Utils::serviceUrl('/api/webhooks/payment/mollie'),
'locale' => 'en_US',
'method' => $payment['methodId'],
- 'mandateId' => $mandate->id
+ 'mandateId' => $mandate->id,
];
\Log::debug("Recurring payment for {$wallet->id}: " . json_encode($request));
@@ -340,7 +343,7 @@
DB::commit();
if (!empty($notify)) {
- \App\Jobs\Mail\PaymentJob::dispatch($payment);
+ PaymentJob::dispatch($payment);
}
return [
@@ -390,9 +393,9 @@
$refunds[] = [
'id' => $refund->id,
'description' => $refund->description,
- 'amount' => round(floatval($refund->amount->value) * 100),
+ 'amount' => round((float) $refund->amount->value * 100),
'type' => Payment::TYPE_REFUND,
- 'currency' => $refund->amount->currency
+ 'currency' => $refund->amount->currency,
];
}
}
@@ -405,9 +408,9 @@
if ($chargeback->amount->value) {
$refunds[] = [
'id' => $chargeback->id,
- 'amount' => round(floatval($chargeback->amount->value) * 100),
+ 'amount' => round((float) $chargeback->amount->value * 100),
'type' => Payment::TYPE_CHARGEBACK,
- 'currency' => $chargeback->amount->currency
+ 'currency' => $chargeback->amount->currency,
];
}
}
@@ -457,7 +460,7 @@
DB::commit();
if (!empty($notify)) {
- \App\Jobs\Mail\PaymentJob::dispatch($payment);
+ PaymentJob::dispatch($payment);
}
} catch (ApiException $e) {
\Log::error(sprintf('Mollie API call failed (%s)', $e->getMessage()));
@@ -470,8 +473,8 @@
* Get Mollie customer identifier for specified wallet.
* Create one if does not exist yet.
*
- * @param \App\Wallet $wallet The wallet
- * @param bool $create Create the customer if does not exist yet
+ * @param Wallet $wallet The wallet
+ * @param bool $create Create the customer if does not exist yet
*
* @return ?string Mollie customer identifier
*/
@@ -482,8 +485,8 @@
// Register the user in Mollie
if (empty($customer_id) && $create) {
$customer = MollieAPI::api()->customers->create([
- 'name' => $wallet->owner->name(),
- 'email' => $wallet->id . '@private.' . \config('app.domain'),
+ 'name' => $wallet->owner->name(),
+ 'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
$customer_id = $customer->id;
@@ -556,7 +559,6 @@
case self::METHOD_DIRECTDEBIT:
return sprintf('Direct Debit (%s)', $details->customerAccount);
-
case self::METHOD_PAYPAL:
return sprintf('PayPal (%s)', $details->consumerAccount);
}
@@ -567,7 +569,7 @@
/**
* List supported payment methods.
*
- * @param string $type The payment type for which we require a method (oneoff/recurring).
+ * @param string $type the payment type for which we require a method (oneoff/recurring)
* @param string $currency Currency code
*
* @return array Array of array with available payment methods:
@@ -586,8 +588,8 @@
'sequenceType' => $type,
'amount' => [
'value' => '1.00',
- 'currency' => $currency
- ]
+ 'currency' => $currency,
+ ],
]
);
@@ -598,8 +600,8 @@
'sequenceType' => $type,
'amount' => [
'value' => '1.00',
- 'currency' => 'EUR'
- ]
+ 'currency' => 'EUR',
+ ],
]
);
@@ -613,9 +615,9 @@
$availableMethods[$method->id] = [
'id' => $method->id,
'name' => $method->description,
- 'minimumAmount' => round(floatval($method->minimumAmount->value) * 100), // Converted to cents
+ 'minimumAmount' => round((float) $method->minimumAmount->value * 100), // Converted to cents
'currency' => $method->minimumAmount->currency,
- 'exchangeRate' => \App\Utils::exchangeRate($currency, $method->minimumAmount->currency)
+ 'exchangeRate' => Utils::exchangeRate($currency, $method->minimumAmount->currency),
];
}
@@ -628,10 +630,10 @@
* @param string $paymentId Payment identifier
*
* @return array Payment information:
- * - id: Payment identifier
- * - status: Payment status
- * - isCancelable: The payment can be canceled
- * - checkoutUrl: The checkout url to complete the payment or null if none
+ * - id: Payment identifier
+ * - status: Payment status
+ * - isCancelable: The payment can be canceled
+ * - checkoutUrl: The checkout url to complete the payment or null if none
*/
public function getPayment($paymentId): array
{
@@ -641,7 +643,7 @@
'id' => $payment->id,
'status' => $payment->status,
'isCancelable' => $payment->isCancelable,
- 'checkoutUrl' => $payment->getCheckoutUrl()
+ 'checkoutUrl' => $payment->getCheckoutUrl(),
];
}
diff --git a/src/app/Providers/Payment/Stripe.php b/src/app/Providers/Payment/Stripe.php
--- a/src/app/Providers/Payment/Stripe.php
+++ b/src/app/Providers/Payment/Stripe.php
@@ -2,15 +2,16 @@
namespace App\Providers\Payment;
+use App\Jobs\Mail\PaymentJob;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
-use App\Utils;
+use App\Providers\PaymentProvider;
use App\Wallet;
-use App\WalletSetting;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Request;
use Stripe as StripeAPI;
-class Stripe extends \App\Providers\PaymentProvider
+class Stripe extends PaymentProvider
{
/**
* Class constructor.
@@ -23,7 +24,7 @@
/**
* Get a link to the customer in the provider's control panel
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return string|null The string representing <a> tag
*/
@@ -39,7 +40,7 @@
$key = \config('services.stripe.key');
- if (strpos($key, 'sk_test_') === 0) {
+ if (str_starts_with($key, 'sk_test_')) {
$location .= '/test';
}
@@ -54,12 +55,12 @@
/**
* Create a new auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents (not used)
- * - currency: The operation currency
- * - description: Operation desc.
- * - redirectUrl: The location to goto after checkout
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents (not used)
+ * - currency: The operation currency
+ * - description: Operation desc.
+ * - redirectUrl: The location to goto after checkout
*
* @return array Provider payment/session data:
* - id: Session identifier
@@ -100,7 +101,7 @@
/**
* Revoke the auto-payment mandate.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return bool True on success, False on failure
*/
@@ -124,7 +125,7 @@
/**
* Get a auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return array|null Mandate information:
* - id: Mandate identifier
@@ -147,7 +148,7 @@
'id' => $mandate->id,
'isPending' => $mandate->status != 'succeeded' && $mandate->status != 'canceled',
'isValid' => $mandate->status == 'succeeded',
- 'method' => self::paymentMethod($pm, 'Unknown method')
+ 'method' => self::paymentMethod($pm, 'Unknown method'),
];
return $result;
@@ -166,12 +167,12 @@
/**
* Create a new payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents
- * - currency: The operation currency
- * - type: first/oneoff/recurring
- * - description: Operation desc.
+ * @param Wallet $wallet The wallet
+ * @param array $payment payment data:
+ * - amount: Value in cents
+ * - currency: The operation currency
+ * - type: first/oneoff/recurring
+ * - description: Operation desc
*
* @return array Provider payment/session data:
* - id: Session identifier
@@ -200,8 +201,8 @@
'amount' => $amount,
'currency' => \strtolower($payment['currency']),
'quantity' => 1,
- ]
- ]
+ ],
+ ],
];
$session = StripeAPI\Checkout\Session::create($request);
@@ -219,8 +220,8 @@
/**
* Create a new automatic payment operation.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data (see self::payment())
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data (see self::payment())
*
* @return array Provider payment/session data:
* - id: Session identifier
@@ -337,14 +338,13 @@
}
// Notify the user
- \App\Jobs\Mail\PaymentJob::dispatch($payment);
+ PaymentJob::dispatch($payment);
}
}
DB::commit();
break;
-
case StripeAPI\Event::SETUP_INTENT_SUCCEEDED:
case StripeAPI\Event::SETUP_INTENT_SETUP_FAILED:
case StripeAPI\Event::SETUP_INTENT_CANCELED:
@@ -375,7 +375,7 @@
// Top-up the wallet if balance is below the threshold
if ($payment->wallet->balance < $threshold && $payment->status != Payment::STATUS_PAID) {
- \App\Jobs\Wallet\ChargeJob::dispatch($payment->wallet->id);
+ ChargeJob::dispatch($payment->wallet->id);
}
}
@@ -383,7 +383,6 @@
$payment->save();
break;
-
default:
\Log::debug("Unhandled Stripe event: " . var_export($payload, true));
break;
@@ -396,8 +395,8 @@
* Get Stripe customer identifier for specified wallet.
* Create one if does not exist yet.
*
- * @param \App\Wallet $wallet The wallet
- * @param bool $create Create the customer if does not exist yet
+ * @param Wallet $wallet The wallet
+ * @param bool $create Create the customer if does not exist yet
*
* @return string|null Stripe customer identifier
*/
@@ -408,11 +407,11 @@
// Register the user in Stripe
if (empty($customer_id) && $create) {
$customer = StripeAPI\Customer::create([
- 'name' => $wallet->owner->name(),
- // Stripe will display the email on Checkout page, editable,
- // and use it to send the receipt (?), use the user email here
- // 'email' => $wallet->id . '@private.' . \config('app.domain'),
- 'email' => $wallet->owner->email,
+ 'name' => $wallet->owner->name(),
+ // Stripe will display the email on Checkout page, editable,
+ // and use it to send the receipt (?), use the user email here
+ // 'email' => $wallet->id . '@private.' . \config('app.domain'),
+ 'email' => $wallet->owner->email,
]);
$customer_id = $customer->id;
@@ -478,7 +477,7 @@
/**
* List supported payment methods.
*
- * @param string $type The payment type for which we require a method (oneoff/recurring).
+ * @param string $type the payment type for which we require a method (oneoff/recurring)
* @param string $currency Currency code
*
* @return array Array of array with available payment methods:
@@ -491,7 +490,7 @@
*/
public function providerPaymentMethods(string $type, string $currency): array
{
- //TODO get this from the stripe API?
+ // TODO get this from the stripe API?
$availableMethods = [];
switch ($type) {
case Payment::TYPE_ONEOFF:
@@ -501,15 +500,15 @@
'name' => "Credit Card",
'minimumAmount' => Payment::MIN_AMOUNT,
'currency' => $currency,
- 'exchangeRate' => 1.0
+ 'exchangeRate' => 1.0,
],
self::METHOD_PAYPAL => [
'id' => self::METHOD_PAYPAL,
'name' => "PayPal",
'minimumAmount' => Payment::MIN_AMOUNT,
'currency' => $currency,
- 'exchangeRate' => 1.0
- ]
+ 'exchangeRate' => 1.0,
+ ],
];
break;
case Payment::TYPE_RECURRING:
@@ -519,8 +518,8 @@
'name' => "Credit Card",
'minimumAmount' => Payment::MIN_AMOUNT, // Converted to cents,
'currency' => $currency,
- 'exchangeRate' => 1.0
- ]
+ 'exchangeRate' => 1.0,
+ ],
];
break;
}
@@ -534,10 +533,10 @@
* @param string $paymentId Payment identifier
*
* @return array Payment information:
- * - id: Payment identifier
- * - status: Payment status
- * - isCancelable: The payment can be canceled
- * - checkoutUrl: The checkout url to complete the payment or null if none
+ * - id: Payment identifier
+ * - status: Payment status
+ * - isCancelable: The payment can be canceled
+ * - checkoutUrl: The checkout url to complete the payment or null if none
*/
public function getPayment($paymentId): array
{
@@ -548,7 +547,7 @@
'id' => $payment->id,
'status' => $payment->status,
'isCancelable' => false,
- 'checkoutUrl' => null
+ 'checkoutUrl' => null,
];
}
}
diff --git a/src/app/Providers/PaymentProvider.php b/src/app/Providers/PaymentProvider.php
--- a/src/app/Providers/PaymentProvider.php
+++ b/src/app/Providers/PaymentProvider.php
@@ -3,7 +3,10 @@
namespace App\Providers;
use App\Payment;
-use App\Transaction;
+use App\Providers\Payment\Coinbase;
+use App\Providers\Payment\Mollie;
+use App\Providers\Payment\Stripe;
+use App\Utils;
use App\Wallet;
use Illuminate\Support\Facades\Cache;
@@ -29,7 +32,8 @@
/**
* Detect the name of the provider
*
- * @param \App\Wallet|string|null $provider_or_wallet
+ * @param Wallet|string|null $provider_or_wallet
+ *
* @return string The name of the provider
*/
private static function providerName($provider_or_wallet = null): string
@@ -56,23 +60,20 @@
/**
* Factory method
*
- * @param \App\Wallet|string|null $provider_or_wallet
+ * @param Wallet|string|null $provider_or_wallet
*/
public static function factory($provider_or_wallet = null, $currency = null)
{
if (is_string($currency) && \strtolower($currency) == 'btc') {
- return new \App\Providers\Payment\Coinbase();
+ return new Coinbase();
}
switch (self::providerName($provider_or_wallet)) {
case self::PROVIDER_STRIPE:
- return new \App\Providers\Payment\Stripe();
-
+ return new Stripe();
case self::PROVIDER_MOLLIE:
- return new \App\Providers\Payment\Mollie();
-
+ return new Mollie();
case self::PROVIDER_COINBASE:
- return new \App\Providers\Payment\Coinbase();
-
+ return new Coinbase();
default:
throw new \Exception("Invalid payment provider: {$provider_or_wallet}");
}
@@ -81,15 +82,15 @@
/**
* Create a new auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents (wallet currency)
- * - credit_amount: Balance'able base amount in cents (wallet currency)
- * - vat_rate_id: VAT rate id
- * - currency: The operation currency
- * - description: Operation desc.
- * - methodId: Payment method
- * - redirectUrl: The location to goto after checkout
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents (wallet currency)
+ * - credit_amount: Balance'able base amount in cents (wallet currency)
+ * - vat_rate_id: VAT rate id
+ * - currency: The operation currency
+ * - description: Operation desc.
+ * - methodId: Payment method
+ * - redirectUrl: The location to goto after checkout
*
* @return array Provider payment data:
* - id: Operation identifier
@@ -100,7 +101,7 @@
/**
* Revoke the auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return bool True on success, False on failure
*/
@@ -109,7 +110,7 @@
/**
* Get a auto-payment mandate for a wallet.
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return array|null Mandate information:
* - id: Mandate identifier
@@ -123,7 +124,7 @@
/**
* Get a link to the customer in the provider's control panel
*
- * @param \App\Wallet $wallet The wallet
+ * @param Wallet $wallet The wallet
*
* @return string|null The string representing <a> tag
*/
@@ -139,15 +140,15 @@
/**
* Create a new payment.
*
- * @param \App\Wallet $wallet The wallet
- * @param array $payment Payment data:
- * - amount: Value in cents (wallet currency)
- * - credit_amount: Balance'able base amount in cents (wallet currency)
- * - vat_rate_id: Vat rate id
- * - currency: The operation currency
- * - type: first/oneoff/recurring
- * - description: Operation description
- * - methodId: Payment method
+ * @param Wallet $wallet The wallet
+ * @param array $payment Payment data:
+ * - amount: Value in cents (wallet currency)
+ * - credit_amount: Balance'able base amount in cents (wallet currency)
+ * - vat_rate_id: Vat rate id
+ * - currency: The operation currency
+ * - type: first/oneoff/recurring
+ * - description: Operation description
+ * - methodId: Payment method
*
* @return array Provider payment/session data:
* - id: Operation identifier
@@ -168,7 +169,7 @@
* @param array $payment Payment information
* @param string $wallet_id Wallet ID
*
- * @return \App\Payment Payment object
+ * @return Payment Payment object
*/
protected function storePayment(array $payment, $wallet_id): Payment
{
@@ -189,13 +190,13 @@
*/
protected function exchange(int $amount, string $sourceCurrency, string $targetCurrency): int
{
- return intval(round($amount * \App\Utils::exchangeRate($sourceCurrency, $targetCurrency)));
+ return (int) round($amount * Utils::exchangeRate($sourceCurrency, $targetCurrency));
}
/**
* List supported payment methods from this provider
*
- * @param string $type The payment type for which we require a method (oneoff/recurring).
+ * @param string $type the payment type for which we require a method (oneoff/recurring)
* @param string $currency Currency code
*
* @return array Array of array with available payment methods:
@@ -214,17 +215,17 @@
* @param string $paymentId Payment identifier
*
* @return array Payment information:
- * - id: Payment identifier
- * - status: Payment status
- * - isCancelable: The payment can be canceled
- * - checkoutUrl: The checkout url to complete the payment or null if none
+ * - id: Payment identifier
+ * - status: Payment status
+ * - isCancelable: The payment can be canceled
+ * - checkoutUrl: The checkout url to complete the payment or null if none
*/
abstract public function getPayment($paymentId): array;
/**
* Return an array of whitelisted payment methods with override values.
*
- * @param string $type The payment type for which we require a method.
+ * @param string $type the payment type for which we require a method
*
* @return array Array of methods
*/
@@ -248,7 +249,7 @@
/**
* Return an array of whitelisted payment methods with override values.
*
- * @param string $type The payment type for which we require a method.
+ * @param string $type the payment type for which we require a method
*
* @return array Array of methods
*/
@@ -272,8 +273,8 @@
/**
* List supported payment methods for $wallet
*
- * @param \App\Wallet $wallet The wallet
- * @param string $type The payment type for which we require a method (oneoff/recurring).
+ * @param Wallet $wallet The wallet
+ * @param string $type the payment type for which we require a method (oneoff/recurring)
*
* @return array Array of array with available payment methods:
* - id: id of the method
@@ -294,11 +295,11 @@
return $methods;
}
- $provider = PaymentProvider::factory($providerName);
+ $provider = self::factory($providerName);
$methods = $provider->providerPaymentMethods($type, $wallet->currency);
if (!empty(\config('services.coinbase.key'))) {
- $coinbaseProvider = PaymentProvider::factory(self::PROVIDER_COINBASE);
+ $coinbaseProvider = self::factory(self::PROVIDER_COINBASE);
$methods = array_merge($methods, $coinbaseProvider->providerPaymentMethods($type, $wallet->currency));
}
$methods = self::applyMethodWhitelist($type, $methods);
@@ -318,11 +319,11 @@
*/
public static function redirectUrl(): string
{
- $url = \App\Utils::serviceUrl('/wallet');
+ $url = Utils::serviceUrl('/wallet');
$domain = preg_replace('/:[0-9]+$/', '', request()->getHttpHost());
- if (strpos($domain, 'reseller') === 0) {
- $url = preg_replace('|^(https?://)([^/]+)|', '\\1' . $domain, $url);
+ if (str_starts_with($domain, 'reseller')) {
+ $url = preg_replace('|^(https?://)([^/]+)|', '\1' . $domain, $url);
}
return $url;
diff --git a/src/app/Providers/RouteServiceProvider.php b/src/app/Providers/RouteServiceProvider.php
--- a/src/app/Providers/RouteServiceProvider.php
+++ b/src/app/Providers/RouteServiceProvider.php
@@ -17,8 +17,8 @@
{
$this->configureRateLimiting();
- $this->routes(function () {
- $prefix = \trim(\parse_url(\config('app.url'), PHP_URL_PATH), '/') . '/';
+ $this->routes(static function () {
+ $prefix = \trim(\parse_url(\config('app.url'), \PHP_URL_PATH), '/') . '/';
Route::prefix($prefix . 'api')
->group(base_path('routes/api.php'));
@@ -33,7 +33,7 @@
*/
protected function configureRateLimiting(): void
{
- RateLimiter::for('api', function (Request $request) {
+ RateLimiter::for('api', static function (Request $request) {
return Limit::perMinute(60)->by($request->user()?->id ?: $request->ip());
});
}
diff --git a/src/app/Referral.php b/src/app/Referral.php
--- a/src/app/Referral.php
+++ b/src/app/Referral.php
@@ -2,15 +2,17 @@
namespace App;
+use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* The eloquent definition of a Referral (code-to-referree relation).
*
- * @property string $code Referral code
- * @property int $id Record identifier
- * @property ?\Carbon\Carbon $redeemed_at When the award got applied
- * @property int $user_id User identifier
+ * @property string $code Referral code
+ * @property int $id Record identifier
+ * @property ?Carbon $redeemed_at When the award got applied
+ * @property int $user_id User identifier
*/
class Referral extends Model
{
@@ -32,7 +34,7 @@
/**
* The code this referral is assigned to
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<ReferralCode, $this>
+ * @return BelongsTo<ReferralCode, $this>
*/
public function code()
{
@@ -42,7 +44,7 @@
/**
* The user this referral is assigned to (referree)
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function user()
{
diff --git a/src/app/ReferralCode.php b/src/app/ReferralCode.php
--- a/src/app/ReferralCode.php
+++ b/src/app/ReferralCode.php
@@ -4,13 +4,15 @@
use BaconQrCode;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* The eloquent definition of a ReferralCode.
*
- * @property string $code Referral code
- * @property int $program_id Referral program identifier
- * @property int $user_id User identifier
+ * @property string $code Referral code
+ * @property int $program_id Referral program identifier
+ * @property int $user_id User identifier
*/
class ReferralCode extends Model
{
@@ -40,23 +42,20 @@
/** @var bool Indicates if the model should be timestamped. */
public $timestamps = false;
-
/**
* Generate a random code.
- *
- * @return string
*/
public static function generateCode(): string
{
$code_length = env('REFERRAL_CODE_LENGTH', self::CODE_LENGTH);
- return \App\Utils::randStr($code_length);
+ return Utils::randStr($code_length);
}
/**
* The referral code owner (user)
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function owner()
{
@@ -66,7 +65,7 @@
/**
* The referral program
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<ReferralProgram, $this>
+ * @return BelongsTo<ReferralProgram, $this>
*/
public function program()
{
@@ -76,7 +75,7 @@
/**
* The referrals using this code.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Referral, $this>
+ * @return HasMany<Referral, $this>
*/
public function referrals()
{
@@ -106,6 +105,6 @@
*/
public function signupUrl(): string
{
- return \App\Utils::serviceUrl("signup/referral/{$this->code}", $this->program->tenant_id);
+ return Utils::serviceUrl("signup/referral/{$this->code}", $this->program->tenant_id);
}
}
diff --git a/src/app/ReferralProgram.php b/src/app/ReferralProgram.php
--- a/src/app/ReferralProgram.php
+++ b/src/app/ReferralProgram.php
@@ -4,20 +4,22 @@
use App\Traits\BelongsToTenantTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
/**
* The eloquent definition of a ReferralProgram.
*
- * @property int $award_amount Award amount (in cents) - to apply to the referrer's wallet
- * @property int $award_percent Award percent - to apply to the referrer's wallet
- * @property bool $active Program state
- * @property string $description Program description
- * @property ?string $discount_id Discount identifier - to apply to the created account
- * @property int $id Program identifier
- * @property string $name Program name
- * @property int $payments_threshold Sum of payments (in cents) at which the award is applied
- * @property ?int $tenant_id Tenant identifier
+ * @property int $award_amount Award amount (in cents) - to apply to the referrer's wallet
+ * @property int $award_percent Award percent - to apply to the referrer's wallet
+ * @property bool $active Program state
+ * @property string $description Program description
+ * @property ?string $discount_id Discount identifier - to apply to the created account
+ * @property int $id Program identifier
+ * @property string $name Program name
+ * @property int $payments_threshold Sum of payments (in cents) at which the award is applied
+ * @property ?int $tenant_id Tenant identifier
*/
class ReferralProgram extends Model
{
@@ -106,7 +108,7 @@
/**
* The referral codes that use this program.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<ReferralCode, $this>
+ * @return HasMany<ReferralCode, $this>
*/
public function codes()
{
@@ -116,7 +118,7 @@
/**
* The discount assigned to the program.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Discount, $this>
+ * @return BelongsTo<Discount, $this>
*/
public function discount()
{
diff --git a/src/app/Resource.php b/src/app/Resource.php
--- a/src/app/Resource.php
+++ b/src/app/Resource.php
@@ -3,8 +3,8 @@
namespace App;
use App\Traits\BelongsToTenantTrait;
-use App\Traits\EntitleableTrait;
use App\Traits\EmailPropertyTrait;
+use App\Traits\EntitleableTrait;
use App\Traits\ResourceConfigTrait;
use App\Traits\SettingsTrait;
use App\Traits\StatusPropertyTrait;
@@ -30,16 +30,16 @@
use SoftDeletes;
use StatusPropertyTrait;
use UuidIntKeyTrait;
- use EmailPropertyTrait; // must be first after UuidIntKeyTrait
+ use EmailPropertyTrait; // must be after UuidIntKeyTrait
// we've simply never heard of this resource
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// resource has been activated
- public const STATUS_ACTIVE = 1 << 1;
+ public const STATUS_ACTIVE = 1 << 1;
// resource has been suspended.
// public const STATUS_SUSPENDED = 1 << 2;
// resource has been deleted
- public const STATUS_DELETED = 1 << 3;
+ public const STATUS_DELETED = 1 << 3;
// resource has been created in LDAP
public const STATUS_LDAP_READY = 1 << 4;
// resource has been created in IMAP
@@ -49,11 +49,11 @@
public const EMAIL_TEMPLATE = 'resource-{id}@{domainName}';
/** @var int The allowed states for this object used in StatusPropertyTrait */
- private int $allowed_states = self::STATUS_NEW |
- self::STATUS_ACTIVE |
- self::STATUS_DELETED |
- self::STATUS_LDAP_READY |
- self::STATUS_IMAP_READY;
+ private int $allowed_states = self::STATUS_NEW
+ | self::STATUS_ACTIVE
+ | self::STATUS_DELETED
+ | self::STATUS_LDAP_READY
+ | self::STATUS_IMAP_READY;
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
diff --git a/src/app/ResourceSetting.php b/src/app/ResourceSetting.php
--- a/src/app/ResourceSetting.php
+++ b/src/app/ResourceSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Resource.
@@ -20,7 +21,7 @@
/**
* The resource to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Resource, $this>
+ * @return BelongsTo<Resource, $this>
*/
public function resource()
{
diff --git a/src/app/Rules/ExternalEmail.php b/src/app/Rules/ExternalEmail.php
--- a/src/app/Rules/ExternalEmail.php
+++ b/src/app/Rules/ExternalEmail.php
@@ -17,8 +17,6 @@
*
* @param string $attribute Attribute name
* @param mixed $email Email address input
- *
- * @return bool
*/
public function passes($attribute, $email): bool
{
@@ -29,10 +27,10 @@
return false;
}
- list($local, $domain) = explode('@', $email);
+ [$local, $domain] = explode('@', $email);
// don't allow @localhost and other no-fqdn
- if (strpos($domain, '.') === false) {
+ if (!str_contains($domain, '.')) {
$this->message = \trans('validation.emailinvalid');
return false;
}
@@ -42,8 +40,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/FileName.php b/src/app/Rules/FileName.php
--- a/src/app/Rules/FileName.php
+++ b/src/app/Rules/FileName.php
@@ -13,8 +13,6 @@
*
* @param string $attribute Attribute name
* @param mixed $name The value to validate
- *
- * @return bool
*/
public function passes($attribute, $name): bool
{
@@ -48,8 +46,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/GroupName.php b/src/app/Rules/GroupName.php
--- a/src/app/Rules/GroupName.php
+++ b/src/app/Rules/GroupName.php
@@ -2,8 +2,8 @@
namespace App\Rules;
+use App\User;
use Illuminate\Contracts\Validation\Rule;
-use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class GroupName implements Rule
@@ -15,8 +15,8 @@
/**
* Class constructor.
*
- * @param \App\User $owner The account owner
- * @param string $domain The domain name of the group
+ * @param User $owner The account owner
+ * @param string $domain The domain name of the group
*/
public function __construct($owner, $domain)
{
@@ -29,8 +29,6 @@
*
* @param string $attribute Attribute name
* @param mixed $name The value to validate
- *
- * @return bool
*/
public function passes($attribute, $name): bool
{
@@ -62,8 +60,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/Password.php b/src/app/Rules/Password.php
--- a/src/app/Rules/Password.php
+++ b/src/app/Rules/Password.php
@@ -2,29 +2,28 @@
namespace App\Rules;
+use App\User;
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Hash;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
class Password implements Rule
{
/** @var ?string The validation error message */
private $message;
- /** @var ?\App\User The account owner which to take the policy from */
+ /** @var ?User The account owner which to take the policy from */
private $owner;
- /** @var ?\App\User The user to whom the checked password belongs */
+ /** @var ?User The user to whom the checked password belongs */
private $user;
/**
* Class constructor.
*
- * @param ?\App\User $owner The account owner (to take the policy from)
- * @param ?\App\User $user The user the password is for (Null for a new user)
+ * @param ?User $owner The account owner (to take the policy from)
+ * @param ?User $user The user the password is for (Null for a new user)
*/
- public function __construct(?\App\User $owner = null, ?\App\User $user = null)
+ public function __construct(?User $owner = null, ?User $user = null)
{
$this->owner = $owner;
$this->user = $user;
@@ -35,8 +34,6 @@
*
* @param string $attribute Attribute name
* @param mixed $password Password string
- *
- * @return bool
*/
public function passes($attribute, $password): bool
{
@@ -52,8 +49,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
@@ -73,41 +68,34 @@
switch ($name) {
case 'min':
// Check the min length
- $status = strlen($password) >= intval($rule['param']);
+ $status = strlen($password) >= (int) $rule['param'];
break;
-
case 'max':
// Check the max length
$length = strlen($password);
- $status = $length && $length <= intval($rule['param']);
+ $status = $length && $length <= (int) $rule['param'];
break;
-
case 'lower':
// Check if password contains a lower-case character
$status = preg_match('/[a-z]/', $password) > 0;
break;
-
case 'upper':
// Check if password contains a upper-case character
$status = preg_match('/[A-Z]/', $password) > 0;
break;
-
case 'digit':
// Check if password contains a digit
$status = preg_match('/[0-9]/', $password) > 0;
break;
-
case 'special':
// Check if password contains a special character
- $status = preg_match('/[-~!@#$%^&*_+=`(){}[]|:;"\'`<>,.?\/\\]/', $password) > 0;
+ $status = preg_match('/[-~!@#$%^&*_+=`(){}[]|:;"\'`<>,.?\/\]/', $password) > 0;
break;
-
case 'last':
// TODO: For performance reasons we might consider checking the history
// only when the password passed all other checks
$status = $this->checkPasswordHistory($password, (int) $rule['param']);
break;
-
default:
// Ignore unknown rule name
$status = true;
@@ -192,13 +180,13 @@
*/
protected function checkPasswordHistory($password, int $count): bool
{
- $status = strlen($password) > 0;
+ $status = $password !== '';
// Check if password is not the same as last X passwords
if ($status && $this->user && $count > 0) {
// Current password
if ($this->user->password) {
- $count -= 1;
+ $count--;
if (Hash::check($password, $this->user->password)) {
return false;
}
@@ -207,7 +195,7 @@
// Passwords from the history
if ($count > 0) {
$this->user->passwords()->latest()->limit($count)->get()
- ->each(function ($oldPassword) use (&$status, $password) {
+ ->each(static function ($oldPassword) use (&$status, $password) {
if (Hash::check($password, $oldPassword->password)) {
$status = false;
return false; // stop iteration
@@ -223,8 +211,6 @@
* Convert an array with password policy rules into one indexed by the rule name
*
* @param array $rules The rules list
- *
- * @return array
*/
private static function mapWithKeys(array $rules): array
{
@@ -235,7 +221,7 @@
$value = null;
if (strpos($key, ':')) {
- list($key, $value) = explode(':', $key, 2);
+ [$key, $value] = explode(':', $key, 2);
}
$result[$key] = $value;
diff --git a/src/app/Rules/ResourceName.php b/src/app/Rules/ResourceName.php
--- a/src/app/Rules/ResourceName.php
+++ b/src/app/Rules/ResourceName.php
@@ -2,8 +2,8 @@
namespace App\Rules;
+use App\User;
use Illuminate\Contracts\Validation\Rule;
-use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class ResourceName implements Rule
@@ -12,13 +12,13 @@
private $owner;
private $domain;
- private const FORBIDDEN_CHARS = '+/^%*!`@(){}|\\?<;"';
+ private const FORBIDDEN_CHARS = '+/^%*!`@(){}|\?<;"';
/**
* Class constructor.
*
- * @param \App\User $owner The account owner
- * @param string $domain The domain name of the group
+ * @param User $owner The account owner
+ * @param string $domain The domain name of the group
*/
public function __construct($owner, $domain)
{
@@ -31,8 +31,6 @@
*
* @param string $attribute Attribute name
* @param mixed $name Resource name input
- *
- * @return bool
*/
public function passes($attribute, $name): bool
{
@@ -75,8 +73,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/SharedFolderName.php b/src/app/Rules/SharedFolderName.php
--- a/src/app/Rules/SharedFolderName.php
+++ b/src/app/Rules/SharedFolderName.php
@@ -2,8 +2,8 @@
namespace App\Rules;
+use App\User;
use Illuminate\Contracts\Validation\Rule;
-use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
class SharedFolderName implements Rule
@@ -12,13 +12,13 @@
private $owner;
private $domain;
- private const FORBIDDEN_CHARS = '+^%*!`@(){}|\\?<;"';
+ private const FORBIDDEN_CHARS = '+^%*!`@(){}|\?<;"';
/**
* Class constructor.
*
- * @param \App\User $owner The account owner
- * @param string $domain The domain name of the group
+ * @param User $owner The account owner
+ * @param string $domain The domain name of the group
*/
public function __construct($owner, $domain)
{
@@ -31,8 +31,6 @@
*
* @param string $attribute Attribute name
* @param mixed $name Shared folder name input
- *
- * @return bool
*/
public function passes($attribute, $name): bool
{
@@ -78,8 +76,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/SharedFolderType.php b/src/app/Rules/SharedFolderType.php
--- a/src/app/Rules/SharedFolderType.php
+++ b/src/app/Rules/SharedFolderType.php
@@ -2,9 +2,8 @@
namespace App\Rules;
+use App\SharedFolder;
use Illuminate\Contracts\Validation\Rule;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Support\Str;
class SharedFolderType implements Rule
{
@@ -15,12 +14,10 @@
*
* @param string $attribute Attribute name
* @param mixed $type Shared folder type input
- *
- * @return bool
*/
public function passes($attribute, $type): bool
{
- if (empty($type) || !is_string($type) || !in_array($type, \App\SharedFolder::SUPPORTED_TYPES)) {
+ if (empty($type) || !is_string($type) || !in_array($type, SharedFolder::SUPPORTED_TYPES)) {
$this->message = \trans('validation.entryinvalid', ['attribute' => $attribute]);
return false;
}
@@ -30,8 +27,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/SignupExternalEmail.php b/src/app/Rules/SignupExternalEmail.php
--- a/src/app/Rules/SignupExternalEmail.php
+++ b/src/app/Rules/SignupExternalEmail.php
@@ -3,12 +3,10 @@
namespace App\Rules;
use App\SignupCode;
+use Carbon\Carbon;
class SignupExternalEmail extends ExternalEmail
{
- /**
- * {@inheritDoc}
- */
public function passes($attribute, $email): bool
{
if (!parent::passes($attribute, $email)) {
@@ -24,7 +22,7 @@
// Don't allow multiple open registrations against the same email address
if (($limit = \config('app.signup.email_limit')) > 0) {
$signups = SignupCode::where('email', $email)
- ->where('expires_at', '>', \Carbon\Carbon::now());
+ ->where('expires_at', '>', Carbon::now());
if ($signups->count() >= $limit) {
// @kanarip: this is deliberately an "email invalid" message
@@ -36,7 +34,7 @@
// Don't allow multiple open registrations against the same source ip address
if (($limit = \config('app.signup.ip_limit')) > 0) {
$signups = SignupCode::where('ip_address', request()->ip())
- ->where('expires_at', '>', \Carbon\Carbon::now());
+ ->where('expires_at', '>', Carbon::now());
if ($signups->count() >= $limit) {
// @kanarip: this is deliberately an "email invalid" message
diff --git a/src/app/Rules/SignupToken.php b/src/app/Rules/SignupToken.php
--- a/src/app/Rules/SignupToken.php
+++ b/src/app/Rules/SignupToken.php
@@ -25,8 +25,6 @@
*
* @param string $attribute Attribute name
* @param mixed $token The value to validate
- *
- * @return bool
*/
public function passes($attribute, $token): bool
{
@@ -53,8 +51,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/UserEmailDomain.php b/src/app/Rules/UserEmailDomain.php
--- a/src/app/Rules/UserEmailDomain.php
+++ b/src/app/Rules/UserEmailDomain.php
@@ -29,8 +29,6 @@
*
* @param string $attribute Attribute name
* @param mixed $domain Domain part of email address
- *
- * @return bool
*/
public function passes($attribute, $domain): bool
{
@@ -38,7 +36,7 @@
if (
empty($domain)
|| !is_string($domain)
- || strpos($domain, '.') === false
+ || !str_contains($domain, '.')
|| stripos($domain, 'www.') === 0
) {
$this->message = \trans('validation.domaininvalid');
@@ -71,8 +69,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/Rules/UserEmailLocal.php b/src/app/Rules/UserEmailLocal.php
--- a/src/app/Rules/UserEmailLocal.php
+++ b/src/app/Rules/UserEmailLocal.php
@@ -28,8 +28,6 @@
*
* @param string $attribute Attribute name
* @param mixed $login Local part of email address
- *
- * @return bool
*/
public function passes($attribute, $login): bool
{
@@ -66,8 +64,6 @@
/**
* Get the validation error message.
- *
- * @return string
*/
public function message(): ?string
{
diff --git a/src/app/SharedFolder.php b/src/app/SharedFolder.php
--- a/src/app/SharedFolder.php
+++ b/src/app/SharedFolder.php
@@ -4,10 +4,10 @@
use App\Traits\AliasesTrait;
use App\Traits\BelongsToTenantTrait;
-use App\Traits\EntitleableTrait;
use App\Traits\EmailPropertyTrait;
-use App\Traits\SharedFolderConfigTrait;
+use App\Traits\EntitleableTrait;
use App\Traits\SettingsTrait;
+use App\Traits\SharedFolderConfigTrait;
use App\Traits\StatusPropertyTrait;
use App\Traits\UuidIntKeyTrait;
use Illuminate\Database\Eloquent\Model;
@@ -28,21 +28,21 @@
use AliasesTrait;
use BelongsToTenantTrait;
use EntitleableTrait;
- use SharedFolderConfigTrait;
use SettingsTrait;
+ use SharedFolderConfigTrait;
use SoftDeletes;
use StatusPropertyTrait;
use UuidIntKeyTrait;
use EmailPropertyTrait; // must be first after UuidIntKeyTrait
// we've simply never heard of this folder
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// folder has been activated
- public const STATUS_ACTIVE = 1 << 1;
+ public const STATUS_ACTIVE = 1 << 1;
// folder has been suspended.
// public const STATUS_SUSPENDED = 1 << 2;
// folder has been deleted
- public const STATUS_DELETED = 1 << 3;
+ public const STATUS_DELETED = 1 << 3;
// folder has been created in LDAP
public const STATUS_LDAP_READY = 1 << 4;
// folder has been created in IMAP
@@ -55,11 +55,11 @@
public const EMAIL_TEMPLATE = '{type}-{id}@{domainName}';
/** @var int The allowed states for this object used in StatusPropertyTrait */
- private int $allowed_states = self::STATUS_NEW |
- self::STATUS_ACTIVE |
- self::STATUS_DELETED |
- self::STATUS_LDAP_READY |
- self::STATUS_IMAP_READY;
+ private int $allowed_states = self::STATUS_NEW
+ | self::STATUS_ACTIVE
+ | self::STATUS_DELETED
+ | self::STATUS_LDAP_READY
+ | self::STATUS_IMAP_READY;
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
diff --git a/src/app/SharedFolderAlias.php b/src/app/SharedFolderAlias.php
--- a/src/app/SharedFolderAlias.php
+++ b/src/app/SharedFolderAlias.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* An email address alias for a SharedFolder.
@@ -26,13 +27,13 @@
*/
public function setAliasAttribute(string $alias)
{
- $this->attributes['alias'] = \App\Utils::emailToLower($alias);
+ $this->attributes['alias'] = Utils::emailToLower($alias);
}
/**
* The shared folder to which this alias belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<SharedFolder, $this>
+ * @return BelongsTo<SharedFolder, $this>
*/
public function sharedFolder()
{
diff --git a/src/app/SharedFolderSetting.php b/src/app/SharedFolderSetting.php
--- a/src/app/SharedFolderSetting.php
+++ b/src/app/SharedFolderSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a SharedFolder.
@@ -20,7 +21,7 @@
/**
* The folder to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<SharedFolder, $this>
+ * @return BelongsTo<SharedFolder, $this>
*/
public function folder()
{
diff --git a/src/app/SignupCode.php b/src/app/SignupCode.php
--- a/src/app/SignupCode.php
+++ b/src/app/SignupCode.php
@@ -11,37 +11,36 @@
/**
* The eloquent definition of a SignupCode.
*
- * @property string $code The full code identifier
- * @property \Carbon\Carbon $created_at The creation timestamp
- * @property \Carbon\Carbon $deleted_at The deletion timestamp
- * @property ?string $domain_part Email domain
- * @property ?string $email Email address
- * @property \Carbon\Carbon $expires_at The code expiration timestamp
- * @property ?string $first_name Firstname
- * @property string $ip_address IP address the request came from
- * @property ?string $last_name Lastname
- * @property ?string $local_part Email local part
- * @property ?string $plan Plan title
- * @property ?string $referral Referral code
- * @property string $short_code Short validation code
- * @property \Carbon\Carbon $updated_at The update timestamp
- * @property string $submit_ip_address IP address the final signup submit request came from
- * @property ?int $tenant_id Tenant identifier
- * @property string $verify_ip_address IP address the code verify request came from
- * @property ?string $voucher Voucher discount code
+ * @property string $code The full code identifier
+ * @property Carbon $created_at The creation timestamp
+ * @property Carbon $deleted_at The deletion timestamp
+ * @property ?string $domain_part Email domain
+ * @property ?string $email Email address
+ * @property Carbon $expires_at The code expiration timestamp
+ * @property ?string $first_name Firstname
+ * @property string $ip_address IP address the request came from
+ * @property ?string $last_name Lastname
+ * @property ?string $local_part Email local part
+ * @property ?string $plan Plan title
+ * @property ?string $referral Referral code
+ * @property string $short_code Short validation code
+ * @property Carbon $updated_at The update timestamp
+ * @property string $submit_ip_address IP address the final signup submit request came from
+ * @property ?int $tenant_id Tenant identifier
+ * @property string $verify_ip_address IP address the code verify request came from
+ * @property ?string $voucher Voucher discount code
*/
class SignupCode extends Model
{
- use SoftDeletes;
use BelongsToTenantTrait;
use BelongsToUserTrait;
+ use SoftDeletes;
- public const SHORTCODE_LENGTH = 5;
- public const CODE_LENGTH = 32;
+ public const SHORTCODE_LENGTH = 5;
+ public const CODE_LENGTH = 32;
// Code expires after so many hours
- public const CODE_EXP_HOURS = 24;
-
+ public const CODE_EXP_HOURS = 24;
/** @var string The primary key associated with the table */
protected $primaryKey = 'code';
@@ -71,10 +70,9 @@
'deleted_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'expires_at' => 'datetime:Y-m-d H:i:s',
- 'headers' => 'array'
+ 'headers' => 'array',
];
-
/**
* Check if code is expired.
*
@@ -87,13 +85,11 @@
/**
* Generate a short code (for human).
- *
- * @return string
*/
public static function generateShortCode(): string
{
$code_length = env('SIGNUP_CODE_LENGTH', self::SHORTCODE_LENGTH);
- return \App\Utils::randStr($code_length);
+ return Utils::randStr($code_length);
}
}
diff --git a/src/app/SignupInvitation.php b/src/app/SignupInvitation.php
--- a/src/app/SignupInvitation.php
+++ b/src/app/SignupInvitation.php
@@ -2,19 +2,18 @@
namespace App;
-use Carbon\Carbon;
-use Illuminate\Database\Eloquent\Model;
use App\Traits\BelongsToTenantTrait;
use App\Traits\BelongsToUserTrait;
use App\Traits\UuidStrKeyTrait;
+use Illuminate\Database\Eloquent\Model;
/**
* The eloquent definition of a signup invitation.
*
- * @property string $email
- * @property string $id
- * @property ?int $tenant_id
- * @property ?int $user_id
+ * @property string $email
+ * @property string $id
+ * @property ?int $tenant_id
+ * @property ?int $user_id
*/
class SignupInvitation extends Model
{
@@ -23,23 +22,19 @@
use UuidStrKeyTrait;
// just created
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// it's been sent successfully
- public const STATUS_SENT = 1 << 1;
+ public const STATUS_SENT = 1 << 1;
// sending failed
- public const STATUS_FAILED = 1 << 2;
+ public const STATUS_FAILED = 1 << 2;
// the user signed up
public const STATUS_COMPLETED = 1 << 3;
-
/** @var list<string> The attributes that are mass assignable */
protected $fillable = ['email'];
-
/**
* Returns whether this invitation process completed (user signed up)
- *
- * @return bool
*/
public function isCompleted(): bool
{
@@ -48,8 +43,6 @@
/**
* Returns whether this invitation sending failed.
- *
- * @return bool
*/
public function isFailed(): bool
{
@@ -58,8 +51,6 @@
/**
* Returns whether this invitation is new.
- *
- * @return bool
*/
public function isNew(): bool
{
@@ -68,8 +59,6 @@
/**
* Returns whether this invitation has been sent.
- *
- * @return bool
*/
public function isSent(): bool
{
diff --git a/src/app/SignupToken.php b/src/app/SignupToken.php
--- a/src/app/SignupToken.php
+++ b/src/app/SignupToken.php
@@ -4,14 +4,15 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* The eloquent definition of a SignupToken.
*
- * @property \Carbon\Carbon $created_at The creation timestamp
- * @property int $counter Count of signups on this token
- * @property ?string $id Token
- * @property ?string $plan_id Plan identifier
+ * @property Carbon $created_at The creation timestamp
+ * @property int $counter Count of signups on this token
+ * @property ?string $id Token
+ * @property ?string $plan_id Plan identifier
*/
class SignupToken extends Model
{
@@ -40,7 +41,7 @@
/**
* The plan this token applies to
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Plan, $this>
+ * @return BelongsTo<Plan, $this>
*/
public function plan()
{
diff --git a/src/app/Sku.php b/src/app/Sku.php
--- a/src/app/Sku.php
+++ b/src/app/Sku.php
@@ -5,22 +5,24 @@
use App\Traits\BelongsToTenantTrait;
use App\Traits\UuidStrKeyTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Spatie\Translatable\HasTranslations;
/**
* The eloquent definition of a Stock Keeping Unit (SKU).
*
- * @property bool $active
- * @property int $cost
- * @property string $description
- * @property int $fee The fee that the tenant pays to us
- * @property string $handler_class
- * @property string $id
- * @property string $name
- * @property string $period
- * @property ?int $tenant_id
- * @property string $title
- * @property int $units_free
+ * @property bool $active
+ * @property int $cost
+ * @property string $description
+ * @property int $fee The fee that the tenant pays to us
+ * @property string $handler_class
+ * @property string $id
+ * @property string $name
+ * @property string $period
+ * @property ?int $tenant_id
+ * @property string $title
+ * @property int $units_free
*/
class Sku extends Model
{
@@ -30,7 +32,7 @@
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
- 'units_free' => 'integer'
+ 'units_free' => 'integer',
];
/** @var list<string> The attributes that are mass assignable */
@@ -56,7 +58,7 @@
/**
* List the entitlements that consume this SKU.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Entitlement, $this>
+ * @return HasMany<Entitlement, $this>
*/
public function entitlements()
{
@@ -66,7 +68,7 @@
/**
* List of packages that use this SKU.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Package, $this, PackageSku>
+ * @return BelongsToMany<Package, $this, PackageSku>
*/
public function packages()
{
diff --git a/src/app/Tenant.php b/src/app/Tenant.php
--- a/src/app/Tenant.php
+++ b/src/app/Tenant.php
@@ -4,6 +4,7 @@
use App\Traits\SettingsTrait;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* The eloquent definition of a Tenant.
@@ -18,7 +19,6 @@
/** @var list<string> The attributes that are mass assignable */
protected $fillable = ['id', 'title'];
-
/**
* Utility method to get tenant-specific system setting.
* If the setting is not specified for the tenant a system-wide value will be returned.
@@ -61,7 +61,7 @@
/**
* Discounts assigned to this tenant.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Discount, $this>
+ * @return HasMany<Discount, $this>
*/
public function discounts()
{
@@ -71,7 +71,7 @@
/**
* SignupInvitations assigned to this tenant.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<SignupInvitation, $this>
+ * @return HasMany<SignupInvitation, $this>
*/
public function signupInvitations()
{
diff --git a/src/app/TenantSetting.php b/src/app/TenantSetting.php
--- a/src/app/TenantSetting.php
+++ b/src/app/TenantSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Tenant.
@@ -20,7 +21,7 @@
/**
* The tenant to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Tenant, $this>
+ * @return BelongsTo<Tenant, $this>
*/
public function tenant()
{
diff --git a/src/app/Traits/AliasesTrait.php b/src/app/Traits/AliasesTrait.php
--- a/src/app/Traits/AliasesTrait.php
+++ b/src/app/Traits/AliasesTrait.php
@@ -2,12 +2,17 @@
namespace App\Traits;
+use App\SharedFolderAlias;
+use App\UserAlias;
+use App\Utils;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+
trait AliasesTrait
{
/**
* Email aliases of this object.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ * @return HasMany
*/
public function aliases()
{
@@ -23,11 +28,11 @@
*/
public static function aliasExists(string $email): bool
{
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return false;
}
- $email = \App\Utils::emailToLower($email);
+ $email = Utils::emailToLower($email);
$class = static::class . 'Alias';
return $class::where('alias', $email)->count() > 0;
@@ -44,8 +49,6 @@
* ```
*
* @param array $aliases An array of email addresses
- *
- * @return void
*/
public function setAliases(array $aliases): void
{
@@ -55,7 +58,7 @@
$existing_aliases = [];
foreach ($this->aliases()->get() as $alias) {
- /** @var \App\UserAlias|\App\SharedFolderAlias $alias */
+ /** @var UserAlias|SharedFolderAlias $alias */
if (!in_array($alias->alias, $aliases)) {
$alias->delete();
} else {
diff --git a/src/app/Traits/BelongsToTenantTrait.php b/src/app/Traits/BelongsToTenantTrait.php
--- a/src/app/Traits/BelongsToTenantTrait.php
+++ b/src/app/Traits/BelongsToTenantTrait.php
@@ -3,6 +3,7 @@
namespace App\Traits;
use App\Tenant;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
trait BelongsToTenantTrait
{
@@ -11,7 +12,7 @@
*/
protected static function bootBelongsToTenantTrait()
{
- static::creating(function ($model) {
+ static::creating(static function ($model) {
if (empty($model->tenant_id)) {
$model->tenant_id = \config('app.tenant_id');
}
@@ -21,7 +22,7 @@
/**
* The tenant for this model.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Tenant, $this>
+ * @return BelongsTo<Tenant, $this>
*/
public function tenant()
{
diff --git a/src/app/Traits/BelongsToUserTrait.php b/src/app/Traits/BelongsToUserTrait.php
--- a/src/app/Traits/BelongsToUserTrait.php
+++ b/src/app/Traits/BelongsToUserTrait.php
@@ -3,13 +3,14 @@
namespace App\Traits;
use App\User;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
trait BelongsToUserTrait
{
/**
* The user to which this object belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function user()
{
diff --git a/src/app/Traits/DomainConfigTrait.php b/src/app/Traits/DomainConfigTrait.php
--- a/src/app/Traits/DomainConfigTrait.php
+++ b/src/app/Traits/DomainConfigTrait.php
@@ -46,7 +46,7 @@
$value[$i] = $v;
- if ($v[0] !== '.' || !filter_var(substr($v, 1), FILTER_VALIDATE_DOMAIN)) {
+ if ($v[0] !== '.' || !filter_var(substr($v, 1), \FILTER_VALIDATE_DOMAIN)) {
$errors[$key][$i] = \trans('validation.spf-entry-invalid');
}
}
diff --git a/src/app/Traits/EmailPropertyTrait.php b/src/app/Traits/EmailPropertyTrait.php
--- a/src/app/Traits/EmailPropertyTrait.php
+++ b/src/app/Traits/EmailPropertyTrait.php
@@ -9,13 +9,12 @@
/** @var ?string Domain name for the to-be-created object */
public $domainName;
-
/**
* Boot function from Laravel.
*/
protected static function bootEmailPropertyTrait()
{
- static::creating(function ($model) {
+ static::creating(static function ($model) {
if (empty($model->email) && defined('static::EMAIL_TEMPLATE')) {
$template = static::EMAIL_TEMPLATE; // @phpstan-ignore-line
$defaults = [
@@ -23,7 +22,7 @@
];
foreach (['id', 'domainName', 'type'] as $prop) {
- if (strpos($template, "{{$prop}}") === false) {
+ if (!str_contains($template, "{{$prop}}")) {
continue;
}
@@ -84,7 +83,7 @@
*/
public static function emailExists(string $email, bool $return_object = false)
{
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return false;
}
diff --git a/src/app/Traits/EntitleableTrait.php b/src/app/Traits/EntitleableTrait.php
--- a/src/app/Traits/EntitleableTrait.php
+++ b/src/app/Traits/EntitleableTrait.php
@@ -3,8 +3,13 @@
namespace App\Traits;
use App\Entitlement;
+use App\Package;
use App\Sku;
+use App\Transaction;
+use App\User;
use App\Wallet;
+use Carbon\Carbon;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Str;
trait EntitleableTrait
@@ -12,12 +17,12 @@
/**
* Assign a package to an entitleable object. It should not have any existing entitlements.
*
- * @param \App\Package $package The package
- * @param \App\Wallet $wallet The wallet
+ * @param Package $package The package
+ * @param Wallet $wallet The wallet
*
* @return $this
*/
- public function assignPackageAndWallet(\App\Package $package, Wallet $wallet)
+ public function assignPackageAndWallet(Package $package, Wallet $wallet)
{
// TODO: There should be some sanity checks here. E.g. not package can be
// assigned to any entitleable, but we don't really have package types.
@@ -25,12 +30,12 @@
foreach ($package->skus as $sku) {
for ($i = $sku->pivot->qty; $i > 0; $i--) {
Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $sku->id,
- 'cost' => $sku->pivot->cost(),
- 'fee' => $sku->pivot->fee(),
- 'entitleable_id' => $this->id,
- 'entitleable_type' => self::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $sku->id,
+ 'cost' => $sku->pivot->cost(),
+ 'fee' => $sku->pivot->fee(),
+ 'entitleable_id' => $this->id,
+ 'entitleable_type' => self::class,
]);
}
}
@@ -41,11 +46,12 @@
/**
* Assign a SKU to an entitleable object.
*
- * @param \App\Sku $sku The sku to assign.
- * @param int $count Count of entitlements to add
- * @param ?\App\Wallet $wallet The wallet to use when objects's wallet is unknown
+ * @param Sku $sku the sku to assign
+ * @param int $count Count of entitlements to add
+ * @param ?Wallet $wallet The wallet to use when objects's wallet is unknown
*
* @return $this
+ *
* @throws \Exception
*/
public function assignSku(Sku $sku, int $count = 1, $wallet = null)
@@ -67,7 +73,7 @@
'cost' => $exists >= $sku->units_free ? $sku->cost : 0,
'fee' => $exists >= $sku->units_free ? $sku->fee : 0,
'entitleable_id' => $this->id,
- 'entitleable_type' => self::class
+ 'entitleable_type' => self::class,
]);
$exists++;
@@ -80,10 +86,11 @@
/**
* Assign the object to a wallet.
*
- * @param \App\Wallet $wallet The wallet
- * @param ?string $title Optional SKU title
+ * @param Wallet $wallet The wallet
+ * @param ?string $title Optional SKU title
*
* @return $this
+ *
* @throws \Exception
*/
public function assignToWallet(Wallet $wallet, $title = null)
@@ -111,7 +118,7 @@
'cost' => $exists >= $sku->units_free ? $sku->cost : 0,
'fee' => $exists >= $sku->units_free ? $sku->fee : 0,
'entitleable_id' => $this->id,
- 'entitleable_type' => self::class
+ 'entitleable_type' => self::class,
]);
return $this;
@@ -123,7 +130,7 @@
protected static function bootEntitleableTrait()
{
// Soft-delete and force-delete object's entitlements on object's delete
- static::deleting(function ($model) {
+ static::deleting(static function ($model) {
$force = $model->isForceDeleting();
$entitlements = $model->entitlements();
@@ -132,7 +139,7 @@
}
$list = $entitlements->get()
- ->map(function ($entitlement) use ($force) {
+ ->map(static function ($entitlement) use ($force) {
if ($force) {
$entitlement->forceDelete();
} else {
@@ -144,14 +151,14 @@
// Remove transactions, they have no foreign key constraint
if ($force && !empty($list)) {
- \App\Transaction::where('object_type', \App\Entitlement::class)
+ Transaction::where('object_type', Entitlement::class)
->whereIn('object_id', $list)
->delete();
}
});
// Restore object's entitlements on restore
- static::restored(function ($model) {
+ static::restored(static function ($model) {
$model->restoreEntitlements();
});
}
@@ -177,7 +184,7 @@
/**
* Entitlements for this object.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Entitlement, $this>
+ * @return HasMany<Entitlement, $this>
*/
public function entitlements()
{
@@ -200,8 +207,8 @@
/**
* Remove a number of entitlements for the SKU.
*
- * @param \App\Sku $sku The SKU
- * @param int $count The number of entitlements to remove
+ * @param Sku $sku The SKU
+ * @param int $count The number of entitlements to remove
*
* @return $this
*/
@@ -241,7 +248,7 @@
$deleted_at = $this->entitlements()->withTrashed()->max('deleted_at');
if ($deleted_at) {
- $threshold = (new \Carbon\Carbon($deleted_at))->subMinute();
+ $threshold = (new Carbon($deleted_at))->subMinute();
// Restore object entitlements
$this->entitlements()->withTrashed()
@@ -257,9 +264,9 @@
/**
* Find the SKU object by title. Use current object's tenant context.
*
- * @param string $title SKU title.
+ * @param string $title SKU title
*
- * @return ?\App\Sku A SKU object
+ * @return ?Sku A SKU object
*/
protected function skuByTitle(string $title): ?Sku
{
@@ -296,7 +303,7 @@
/**
* Returns the wallet by which the object is controlled
*
- * @return ?\App\Wallet A wallet object
+ * @return ?Wallet A wallet object
*/
public function wallet(): ?Wallet
{
@@ -308,7 +315,7 @@
// TODO: No entitlement should not happen, but in tests we have
// such cases, so we fallback to the user's wallet in this case
- if ($this instanceof \App\User) {
+ if ($this instanceof User) {
return $this->wallets()->first();
}
@@ -318,14 +325,14 @@
/**
* Return the owner of the wallet (account) this entitleable is assigned to
*
- * @return ?\App\User Account owner
+ * @return ?User Account owner
*/
- public function walletOwner(): ?\App\User
+ public function walletOwner(): ?User
{
$wallet = $this->wallet();
if ($wallet) {
- if ($this instanceof \App\User && $wallet->user_id == $this->id) {
+ if ($this instanceof User && $wallet->user_id == $this->id) {
return $this;
}
diff --git a/src/app/Traits/GroupConfigTrait.php b/src/app/Traits/GroupConfigTrait.php
--- a/src/app/Traits/GroupConfigTrait.php
+++ b/src/app/Traits/GroupConfigTrait.php
@@ -15,7 +15,7 @@
$config['sender_policy'] = array_filter(
$sp ? json_decode($sp, true) : [],
- function ($item) {
+ static function ($item) {
// remove the special "-" entry, it's an implementation detail
return $item !== '-';
}
@@ -50,8 +50,8 @@
if (empty($errors[$key])) {
// remove empty entries, and '-' entry
- $value = array_filter($value, function ($item) {
- return strlen($item) > 0 && $item !== '-';
+ $value = array_filter($value, static function ($item) {
+ return $item !== '' && $item !== '-';
});
if (!empty($value)) {
diff --git a/src/app/Traits/Meet/RoomConfigTrait.php b/src/app/Traits/Meet/RoomConfigTrait.php
--- a/src/app/Traits/Meet/RoomConfigTrait.php
+++ b/src/app/Traits/Meet/RoomConfigTrait.php
@@ -36,9 +36,9 @@
if ($key == 'password') {
if ($value === null || $value === '') {
$value = null;
- } else {
- // TODO: Do we have to validate the password in any way?
}
+ // TODO: Do we have to validate the password in any way?
+
$this->setSetting($key, $value);
} elseif ($key == 'locked' || $key == 'nomedia') {
$this->setSetting($key, $value ? 'true' : null);
diff --git a/src/app/Traits/PermissibleTrait.php b/src/app/Traits/PermissibleTrait.php
--- a/src/app/Traits/PermissibleTrait.php
+++ b/src/app/Traits/PermissibleTrait.php
@@ -3,6 +3,8 @@
namespace App\Traits;
use App\Permission;
+use App\User;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\Validator;
trait PermissibleTrait
@@ -13,7 +15,7 @@
protected static function bootPermissibleTrait()
{
// Selete object's shares on object's delete
- static::deleting(function ($model) {
+ static::deleting(static function ($model) {
$model->permissions()->delete();
});
}
@@ -21,7 +23,7 @@
/**
* Permissions for this object.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Permission, $this>
+ * @return HasMany<Permission, $this>
*/
public function permissions()
{
@@ -50,7 +52,7 @@
if (!is_string($v) || empty($v) || !substr_count($v, ',')) {
$errors[$i] = \trans('validation.acl-entry-invalid');
} else {
- list($user, $acl) = explode(',', $v, 2);
+ [$user, $acl] = explode(',', $v, 2);
$user = trim($user);
$acl = trim($acl);
$error = null;
@@ -61,7 +63,7 @@
$errors[$i] = $error ?: \trans('validation.acl-entry-invalid');
}
- $input[$i] = "$user, $acl";
+ $input[$i] = "{$user}, {$acl}";
$users[] = $user;
}
}
@@ -84,7 +86,7 @@
return \trans('validation.emailinvalid');
}
- $user = \App\User::where('email', \strtolower($identifier))->first();
+ $user = User::where('email', \strtolower($identifier))->first();
if ($user) {
return null;
@@ -103,7 +105,7 @@
$supported = $this->supportedACL();
return $this->permissions()->get()
- ->map(function ($permission) use ($supported) {
+ ->map(static function ($permission) use ($supported) {
$acl = array_search($permission->rights, $supported) ?: 'none';
return "{$permission->user}, {$acl}";
})
@@ -121,12 +123,12 @@
$supported = $this->supportedACL();
foreach ($acl as $item) {
- list($user, $right) = explode(',', $item, 2);
+ [$user, $right] = explode(',', $item, 2);
$users[\strtolower($user)] = $supported[trim($right)] ?? 0;
}
// Compare the input with existing shares
- $this->permissions()->get()->each(function ($permission) use (&$users) {
+ $this->permissions()->get()->each(static function ($permission) use (&$users) {
if (isset($users[$permission->user])) {
if ($permission->rights != $users[$permission->user]) {
$permission->rights = $users[$permission->user];
@@ -140,9 +142,9 @@
foreach ($users as $user => $rights) {
$this->permissions()->create([
- 'user' => $user,
- 'rights' => $rights,
- 'permissible_type' => self::class,
+ 'user' => $user,
+ 'rights' => $rights,
+ 'permissible_type' => self::class,
]);
}
}
diff --git a/src/app/Traits/ResourceConfigTrait.php b/src/app/Traits/ResourceConfigTrait.php
--- a/src/app/Traits/ResourceConfigTrait.php
+++ b/src/app/Traits/ResourceConfigTrait.php
@@ -2,6 +2,7 @@
namespace App\Traits;
+use App\User;
use Illuminate\Support\Facades\Validator;
trait ResourceConfigTrait
@@ -40,7 +41,7 @@
if ($error = $this->validateInvitationPolicyUser($email)) {
$errors[$key] = $error;
} else {
- $value = "manual:$email";
+ $value = "manual:{$email}";
}
} else {
$errors[$key] = \trans('validation.ipolicy-invalid');
@@ -72,7 +73,7 @@
return \trans('validation.emailinvalid');
}
- $user = \App\User::where('email', \strtolower($email))->first();
+ $user = User::where('email', \strtolower($email))->first();
// The user and resource must be in the same wallet
if ($user && ($wallet = $user->wallet())) {
diff --git a/src/app/Traits/SettingsTrait.php b/src/app/Traits/SettingsTrait.php
--- a/src/app/Traits/SettingsTrait.php
+++ b/src/app/Traits/SettingsTrait.php
@@ -2,6 +2,8 @@
namespace App\Traits;
+use Illuminate\Database\Eloquent\Relations\HasMany;
+
trait SettingsTrait
{
/**
@@ -42,7 +44,7 @@
}
$this->settings()->whereIn('key', $keys)->get()
- ->each(function ($setting) use (&$settings) {
+ ->each(static function ($setting) use (&$settings) {
$settings[$setting->key] = $setting->value;
});
@@ -60,8 +62,6 @@
* ```
*
* @param string $key Setting name
- *
- * @return void
*/
public function removeSetting(string $key): void
{
@@ -79,9 +79,7 @@
* ```
*
* @param string $key Setting name
- * @param string|null $value The new value for the setting.
- *
- * @return void
+ * @param string|null $value the new value for the setting
*/
public function setSetting(string $key, $value): void
{
@@ -98,9 +96,7 @@
* $user->setSettings(['locale' => 'en', 'country' => 'GB']);
* ```
*
- * @param array $data An associative array of key value pairs.
- *
- * @return void
+ * @param array $data an associative array of key value pairs
*/
public function setSettings(array $data = []): void
{
@@ -112,7 +108,7 @@
/**
* Any (additional) properties of this domain.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
+ * @return HasMany
*/
public function settings()
{
@@ -123,9 +119,7 @@
* Create or update a setting.
*
* @param string $key Setting name
- * @param string|null $value The new value for the setting.
- *
- * @return void
+ * @param string|null $value the new value for the setting
*/
private function storeSetting(string $key, $value): void
{
diff --git a/src/app/Traits/SharedFolderConfigTrait.php b/src/app/Traits/SharedFolderConfigTrait.php
--- a/src/app/Traits/SharedFolderConfigTrait.php
+++ b/src/app/Traits/SharedFolderConfigTrait.php
@@ -2,6 +2,7 @@
namespace App\Traits;
+use App\User;
use Illuminate\Support\Facades\Validator;
trait SharedFolderConfigTrait
@@ -56,7 +57,7 @@
if (!is_string($v) || empty($v) || !substr_count($v, ',')) {
$errors[$key][$i] = \trans('validation.acl-entry-invalid');
} else {
- list($user, $acl) = explode(',', $v, 2);
+ [$user, $acl] = explode(',', $v, 2);
$user = trim($user);
$acl = trim($acl);
$error = null;
@@ -69,7 +70,7 @@
$errors[$key][$i] = $error ?: \trans('validation.acl-entry-invalid');
}
- $value[$i] = "$user, $acl";
+ $value[$i] = "{$user}, {$acl}";
$users[] = $user;
}
}
@@ -104,7 +105,7 @@
return \trans('validation.emailinvalid');
}
- $user = \App\User::where('email', \strtolower($identifier))->first();
+ $user = User::where('email', \strtolower($identifier))->first();
// The user and shared folder must be in the same wallet
if ($user && ($wallet = $user->wallet())) {
diff --git a/src/app/Traits/StatusPropertyTrait.php b/src/app/Traits/StatusPropertyTrait.php
--- a/src/app/Traits/StatusPropertyTrait.php
+++ b/src/app/Traits/StatusPropertyTrait.php
@@ -8,8 +8,6 @@
{
/**
* Returns whether this object is active.
- *
- * @return bool
*/
public function isActive(): bool
{
@@ -18,8 +16,6 @@
/**
* Returns whether this object is deleted.
- *
- * @return bool
*/
public function isDeleted(): bool
{
@@ -28,8 +24,6 @@
/**
* Returns whether this object is registered in IMAP.
- *
- * @return bool
*/
public function isImapReady(): bool
{
@@ -38,8 +32,6 @@
/**
* Returns whether this object is registered in LDAP.
- *
- * @return bool
*/
public function isLdapReady(): bool
{
@@ -48,8 +40,6 @@
/**
* Returns whether this object is new.
- *
- * @return bool
*/
public function isNew(): bool
{
@@ -58,8 +48,6 @@
/**
* Returns whether this object is suspended.
- *
- * @return bool
*/
public function isSuspended(): bool
{
@@ -71,12 +59,12 @@
*/
public function statusText(): string
{
- $reflection = new \ReflectionClass(get_class($this));
+ $reflection = new \ReflectionClass(static::class);
$result = [];
foreach ($reflection->getConstants() as $const => $value) {
if (str_starts_with($const, 'STATUS_') && ($this->status & $value) > 0) {
- $result[] = Str::camel(strtolower(str_replace('STATUS_', '', $const))) . " ($value)";
+ $result[] = Str::camel(strtolower(str_replace('STATUS_', '', $const))) . " ({$value})";
}
}
@@ -85,8 +73,6 @@
/**
* Suspend this object.
- *
- * @return void
*/
public function suspend(): void
{
@@ -100,8 +86,6 @@
/**
* Unsuspend this object.
- *
- * @return void
*/
public function unsuspend(): void
{
diff --git a/src/app/Traits/UserConfigTrait.php b/src/app/Traits/UserConfigTrait.php
--- a/src/app/Traits/UserConfigTrait.php
+++ b/src/app/Traits/UserConfigTrait.php
@@ -2,7 +2,8 @@
namespace App\Traits;
-use App\Policy\Greylist;
+use App\Rules\Password;
+use App\Utils;
trait UserConfigTrait
{
@@ -12,11 +13,11 @@
public function getConfig(): array
{
$settings = $this->getSettings([
- 'greylist_enabled',
- 'guam_enabled',
- 'password_policy',
- 'max_password_age',
- 'limit_geo'
+ 'greylist_enabled',
+ 'guam_enabled',
+ 'password_policy',
+ 'max_password_age',
+ 'limit_geo',
]);
$config = [
@@ -54,13 +55,13 @@
$this->setSetting($key, !empty($value) ? json_encode($value) : null);
} elseif ($key == 'max_password_age') {
- $this->setSetting($key, intval($value) > 0 ? ((string) intval($value)) : null);
+ $this->setSetting($key, (int) $value > 0 ? ((string) (int) $value) : null);
} elseif ($key == 'password_policy') {
// Validate the syntax and make sure min and max is included
if (
!is_string($value)
- || strpos($value, 'min:') === false
- || strpos($value, 'max:') === false
+ || !str_contains($value, 'min:')
+ || !str_contains($value, 'max:')
|| !preg_match('/^[a-z0-9:,]+$/', $value)
) {
$errors[$key] = \trans('validation.invalid-password-policy');
@@ -93,32 +94,32 @@
protected function validatePasswordPolicyRule(string $rule): ?string
{
$regexp = [
- 'min:[0-9]+', 'max:[0-9]+', 'upper', 'lower', 'digit', 'special', 'last:[0-9]+'
+ 'min:[0-9]+', 'max:[0-9]+', 'upper', 'lower', 'digit', 'special', 'last:[0-9]+',
];
if (empty($rule) || !preg_match('/^(' . implode('|', $regexp) . ')$/', $rule)) {
return \trans('validation.invalid-password-policy');
}
- $systemPolicy = \App\Rules\Password::parsePolicy(\config('app.password_policy'));
+ $systemPolicy = Password::parsePolicy(\config('app.password_policy'));
// Min/Max values cannot exceed the system defaults, i.e. if system policy
// is min:5, user's policy cannot be set to a smaller number.
- if (!empty($systemPolicy['min']) && strpos($rule, 'min:') === 0) {
+ if (!empty($systemPolicy['min']) && str_starts_with($rule, 'min:')) {
$value = trim(substr($rule, 4));
if ($value < $systemPolicy['min']) {
return \trans('validation.password-policy-min-len-error', ['min' => $systemPolicy['min']]);
}
}
- if (!empty($systemPolicy['max']) && strpos($rule, 'max:') === 0) {
+ if (!empty($systemPolicy['max']) && str_starts_with($rule, 'max:')) {
$value = trim(substr($rule, 4));
if ($value > $systemPolicy['max']) {
return \trans('validation.password-policy-max-len-error', ['max' => $systemPolicy['max']]);
}
}
- if (!empty($systemPolicy['last']) && strpos($rule, 'last:') === 0) {
+ if (!empty($systemPolicy['last']) && str_starts_with($rule, 'last:')) {
$value = trim(substr($rule, 5));
if ($value < $systemPolicy['last']) {
return \trans('validation.password-policy-last-error', ['last' => $systemPolicy['last']]);
@@ -151,9 +152,10 @@
if (count($value) > 250) {
return \trans('validation.invalid-limit-geo');
- } elseif (count($value)) {
+ }
+ if (count($value)) {
// There MUST be country of the current connection included
- $currentCountry = \App\Utils::countryForRequest();
+ $currentCountry = Utils::countryForRequest();
if (!in_array($currentCountry, $value)) {
return \trans('validation.invalid-limit-geo-missing-current', ['code' => $currentCountry]);
diff --git a/src/app/Traits/UuidIntKeyTrait.php b/src/app/Traits/UuidIntKeyTrait.php
--- a/src/app/Traits/UuidIntKeyTrait.php
+++ b/src/app/Traits/UuidIntKeyTrait.php
@@ -2,6 +2,8 @@
namespace App\Traits;
+use App\Utils;
+
trait UuidIntKeyTrait
{
/**
@@ -9,18 +11,18 @@
*/
protected static function bootUuidIntKeyTrait()
{
- static::creating(function ($model) {
+ static::creating(static function ($model) {
if (empty($model->{$model->getKeyName()})) {
- $allegedly_unique = \App\Utils::uuidInt();
+ $allegedly_unique = Utils::uuidInt();
// Verify if unique
if (in_array('Illuminate\Database\Eloquent\SoftDeletes', class_uses($model))) {
while ($model->withTrashed()->find($allegedly_unique)) {
- $allegedly_unique = \App\Utils::uuidInt();
+ $allegedly_unique = Utils::uuidInt();
}
} else {
while ($model->find($allegedly_unique)) {
- $allegedly_unique = \App\Utils::uuidInt();
+ $allegedly_unique = Utils::uuidInt();
}
}
diff --git a/src/app/Traits/UuidStrKeyTrait.php b/src/app/Traits/UuidStrKeyTrait.php
--- a/src/app/Traits/UuidStrKeyTrait.php
+++ b/src/app/Traits/UuidStrKeyTrait.php
@@ -2,6 +2,8 @@
namespace App\Traits;
+use App\Utils;
+
trait UuidStrKeyTrait
{
/**
@@ -9,18 +11,18 @@
*/
protected static function bootUuidStrKeyTrait()
{
- static::creating(function ($model) {
+ static::creating(static function ($model) {
if (empty($model->{$model->getKeyName()})) {
- $allegedly_unique = \App\Utils::uuidStr();
+ $allegedly_unique = Utils::uuidStr();
// Verify if unique
$finder = $model;
- if (\App\Utils::isSoftDeletable($model)) {
+ if (Utils::isSoftDeletable($model)) {
$finder = $finder->withTrashed();
}
while ($finder->find($allegedly_unique)) {
- $allegedly_unique = \App\Utils::uuidStr();
+ $allegedly_unique = Utils::uuidStr();
}
$model->{$model->getKeyName()} = $allegedly_unique;
diff --git a/src/app/Transaction.php b/src/app/Transaction.php
--- a/src/app/Transaction.php
+++ b/src/app/Transaction.php
@@ -45,7 +45,7 @@
'amount',
'description',
// parent, for example wallet debit is parent for entitlements charged.
- 'transaction_id'
+ 'transaction_id',
];
/** @var array<string, string> Casts properties as type */
@@ -53,11 +53,10 @@
'amount' => 'integer',
];
-
/**
* Returns the entitlement to which the transaction is assigned (if any)
*
- * @return \App\Entitlement|null The entitlement
+ * @return Entitlement|null The entitlement
*/
public function entitlement(): ?Entitlement
{
@@ -82,7 +81,6 @@
// TODO: Must be an entitlement.
$this->attributes['type'] = $value;
break;
-
case self::WALLET_AWARD:
case self::WALLET_CREDIT:
case self::WALLET_DEBIT:
@@ -92,7 +90,6 @@
// TODO: This must be a wallet.
$this->attributes['type'] = $value;
break;
-
default:
throw new \Exception("Invalid type value");
}
@@ -127,7 +124,7 @@
/**
* Returns a wallet to which the transaction is assigned (if any)
*
- * @return \App\Wallet|null The wallet
+ * @return Wallet|null The wallet
*/
public function wallet(): ?Wallet
{
@@ -172,8 +169,6 @@
/**
* Get a string for use in translation tables derived from the object type.
- *
- * @return string|null
*/
private function objectTypeToLabelString(): ?string
{
diff --git a/src/app/User.php b/src/app/User.php
--- a/src/app/User.php
+++ b/src/app/User.php
@@ -2,23 +2,26 @@
namespace App;
-use App\AuthAttempt;
+use App\Auth\SecondFactor;
use App\Auth\Utils as AuthUtils;
use App\Traits\AliasesTrait;
use App\Traits\BelongsToTenantTrait;
-use App\Traits\EntitleableTrait;
use App\Traits\EmailPropertyTrait;
-use App\Traits\UserConfigTrait;
-use App\Traits\UuidIntKeyTrait;
+use App\Traits\EntitleableTrait;
use App\Traits\SettingsTrait;
use App\Traits\StatusPropertyTrait;
+use App\Traits\UserConfigTrait;
+use App\Traits\UuidIntKeyTrait;
use Dyrynda\Database\Support\NullableFields;
+use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
+use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
-use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
use League\OAuth2\Server\Exception\OAuthServerException;
@@ -38,30 +41,30 @@
use AliasesTrait;
use BelongsToTenantTrait;
use EntitleableTrait;
- use EmailPropertyTrait;
use HasApiTokens;
use Notifiable;
use NullableFields;
- use UserConfigTrait;
- use UuidIntKeyTrait;
use SettingsTrait;
use SoftDeletes;
use StatusPropertyTrait;
+ use UserConfigTrait;
+ use UuidIntKeyTrait;
+ use EmailPropertyTrait; // must be after UuidIntKeyTrait
// a new user, default on creation
- public const STATUS_NEW = 1 << 0;
+ public const STATUS_NEW = 1 << 0;
// it's been activated
- public const STATUS_ACTIVE = 1 << 1;
+ public const STATUS_ACTIVE = 1 << 1;
// user has been suspended
- public const STATUS_SUSPENDED = 1 << 2;
+ public const STATUS_SUSPENDED = 1 << 2;
// user has been deleted
- public const STATUS_DELETED = 1 << 3;
+ public const STATUS_DELETED = 1 << 3;
// user has been created in LDAP
public const STATUS_LDAP_READY = 1 << 4;
// user mailbox has been created in IMAP
public const STATUS_IMAP_READY = 1 << 5;
// user in "limited feature-set" state
- public const STATUS_DEGRADED = 1 << 6;
+ public const STATUS_DEGRADED = 1 << 6;
// a restricted user
public const STATUS_RESTRICTED = 1 << 7;
@@ -70,14 +73,14 @@
public const ROLE_SERVICE = 'service';
/** @var int The allowed states for this object used in StatusPropertyTrait */
- private int $allowed_states = self::STATUS_NEW |
- self::STATUS_ACTIVE |
- self::STATUS_SUSPENDED |
- self::STATUS_DELETED |
- self::STATUS_LDAP_READY |
- self::STATUS_IMAP_READY |
- self::STATUS_DEGRADED |
- self::STATUS_RESTRICTED;
+ private int $allowed_states = self::STATUS_NEW
+ | self::STATUS_ACTIVE
+ | self::STATUS_SUSPENDED
+ | self::STATUS_DELETED
+ | self::STATUS_LDAP_READY
+ | self::STATUS_IMAP_READY
+ | self::STATUS_DEGRADED
+ | self::STATUS_RESTRICTED;
/** @var list<string> The attributes that are mass assignable */
protected $fillable = [
@@ -92,7 +95,7 @@
protected $hidden = [
'password',
'password_ldap',
- 'role'
+ 'role',
];
/** @var array<int, string> The attributes that can be null */
@@ -114,7 +117,7 @@
*
* This does not include wallets owned by the user.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<Wallet, $this>
+ * @return BelongsToMany<Wallet, $this>
*/
public function accounts()
{
@@ -129,10 +132,10 @@
/**
* Assign a package to a user. The user should not have any existing entitlements.
*
- * @param \App\Package $package The package to assign.
- * @param \App\User|null $user Assign the package to another user.
+ * @param Package $package the package to assign
+ * @param User|null $user assign the package to another user
*
- * @return \App\User
+ * @return User
*/
public function assignPackage($package, $user = null)
{
@@ -146,15 +149,16 @@
/**
* Assign a package plan to a user.
*
- * @param \App\Plan $plan The plan to assign
- * @param \App\Domain $domain Optional domain object
+ * @param Plan $plan The plan to assign
+ * @param Domain $domain Optional domain object
+ *
+ * @return User Self
*
- * @return \App\User Self
* @throws \Exception
*/
- public function assignPlan($plan, $domain = null): User
+ public function assignPlan($plan, $domain = null): self
{
- $domain_packages = $plan->packages->filter(function ($package) {
+ $domain_packages = $plan->packages->filter(static function ($package) {
return $package->isDomain();
});
@@ -213,12 +217,12 @@
return true;
}
- if ($object instanceof User && $this->id == $object->id) {
+ if ($object instanceof self && $this->id == $object->id) {
return true;
}
if ($this->role == self::ROLE_RESELLER) {
- if ($object instanceof User && $object->role == self::ROLE_ADMIN) {
+ if ($object instanceof self && $object->role == self::ROLE_ADMIN) {
return false;
}
@@ -251,7 +255,7 @@
*/
public function canUpdate($object): bool
{
- if ($object instanceof User && $this->id == $object->id) {
+ if ($object instanceof self && $this->id == $object->id) {
return true;
}
@@ -260,7 +264,7 @@
}
if ($this->role == self::ROLE_RESELLER) {
- if ($object instanceof User && $object->role == self::ROLE_ADMIN) {
+ if ($object instanceof self && $object->role == self::ROLE_ADMIN) {
return false;
}
@@ -277,7 +281,7 @@
/**
* Contacts (global addressbook) for this user.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Contact, $this>
+ * @return HasMany<Contact, $this>
*/
public function contacts()
{
@@ -286,8 +290,6 @@
/**
* Degrade the user
- *
- * @return void
*/
public function degrade(): void
{
@@ -295,18 +297,18 @@
return;
}
- $this->status |= User::STATUS_DEGRADED;
+ $this->status |= self::STATUS_DEGRADED;
$this->save();
}
/**
* Users that this user is delegatee of.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<User, $this, Delegation>
+ * @return BelongsToMany<User, $this, Delegation>
*/
public function delegators()
{
- return $this->belongsToMany(User::class, 'delegations', 'delegatee_id', 'user_id')
+ return $this->belongsToMany(self::class, 'delegations', 'delegatee_id', 'user_id')
->as('delegation')
->using(Delegation::class);
}
@@ -314,11 +316,11 @@
/**
* Users that are delegatees of this user.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<User, $this, Delegation>
+ * @return BelongsToMany<User, $this, Delegation>
*/
public function delegatees()
{
- return $this->belongsToMany(User::class, 'delegations', 'user_id', 'delegatee_id')
+ return $this->belongsToMany(self::class, 'delegations', 'user_id', 'delegatee_id')
->as('delegation')
->using(Delegation::class)
->withPivot('options');
@@ -327,11 +329,11 @@
/**
* List the domains to which this user is entitled.
*
- * @param bool $with_accounts Include domains assigned to wallets
- * the current user controls but not owns.
- * @param bool $with_public Include active public domains (for the user tenant).
+ * @param bool $with_accounts include domains assigned to wallets
+ * the current user controls but not owns
+ * @param bool $with_public include active public domains (for the user tenant)
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function domains($with_accounts = true, $with_public = true)
{
@@ -357,10 +359,10 @@
* Return entitleable objects of a specified type controlled by the current user.
*
* @param string $class Object class
- * @param bool $with_accounts Include objects assigned to wallets
- * the current user controls, but not owns.
+ * @param bool $with_accounts include objects assigned to wallets
+ * the current user controls, but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
private function entitleables(string $class, bool $with_accounts = true)
{
@@ -374,7 +376,7 @@
$table = $object->getTable();
return $object->select("{$table}.*")
- ->whereExists(function ($query) use ($table, $wallets, $class) {
+ ->whereExists(static function ($query) use ($table, $wallets, $class) {
$query->select(DB::raw(1))
->from('entitlements')
->whereColumn('entitleable_id', "{$table}.id")
@@ -392,11 +394,11 @@
* @param string $email Email address
* @param bool $external Search also for an external email
*
- * @return \App\User|null User model object if found
+ * @return User|null User model object if found
*/
- public static function findByEmail(string $email, bool $external = false): ?User
+ public static function findByEmail(string $email, bool $external = false): ?self
{
- if (strpos($email, '@') === false) {
+ if (!str_contains($email, '@')) {
return null;
}
@@ -422,7 +424,7 @@
/**
* Storage items for this user.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Fs\Item, $this>
+ * @return HasMany<Fs\Item, $this>
*/
public function fsItems()
{
@@ -432,10 +434,10 @@
/**
* Return groups controlled by the current user.
*
- * @param bool $with_accounts Include groups assigned to wallets
- * the current user controls but not owns.
+ * @param bool $with_accounts include groups assigned to wallets
+ * the current user controls but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function groups($with_accounts = true)
{
@@ -446,8 +448,6 @@
* Returns whether this user (or its wallet owner) is degraded.
*
* @param bool $owner Check also the wallet owner instead just the user himself
- *
- * @return bool
*/
public function isDegraded(bool $owner = false): bool
{
@@ -464,20 +464,16 @@
/**
* Check if multi factor authentication is enabled
- *
- * @return bool
*/
public function isMFAEnabled(): bool
{
- return \App\CompanionApp::where('user_id', $this->id)
+ return CompanionApp::where('user_id', $this->id)
->where('mfa_enabled', true)
->exists();
}
/**
* Returns whether this user is restricted.
- *
- * @return bool
*/
public function isRestricted(): bool
{
@@ -487,7 +483,7 @@
/**
* Licenses whis user has.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<License, $this>
+ * @return HasMany<License, $this>
*/
public function licenses()
{
@@ -517,7 +513,7 @@
/**
* Old passwords for this user.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<UserPassword, $this>
+ * @return HasMany<UserPassword, $this>
*/
public function passwords()
{
@@ -526,8 +522,6 @@
/**
* Restrict this user.
- *
- * @return void
*/
public function restrict(): void
{
@@ -535,17 +529,17 @@
return;
}
- $this->status |= User::STATUS_RESTRICTED;
+ $this->status |= self::STATUS_RESTRICTED;
$this->save();
}
/**
* Return resources controlled by the current user.
*
- * @param bool $with_accounts Include resources assigned to wallets
- * the current user controls but not owns.
+ * @param bool $with_accounts include resources assigned to wallets
+ * the current user controls but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function resources($with_accounts = true)
{
@@ -555,10 +549,10 @@
/**
* Return rooms controlled by the current user.
*
- * @param bool $with_accounts Include rooms assigned to wallets
- * the current user controls but not owns.
+ * @param bool $with_accounts include rooms assigned to wallets
+ * the current user controls but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function rooms($with_accounts = true)
{
@@ -568,10 +562,10 @@
/**
* Return shared folders controlled by the current user.
*
- * @param bool $with_accounts Include folders assigned to wallets
- * the current user controls but not owns.
+ * @param bool $with_accounts include folders assigned to wallets
+ * the current user controls but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function sharedFolders($with_accounts = true)
{
@@ -581,11 +575,11 @@
/**
* Return companion apps by the current user.
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function companionApps()
{
- return \App\CompanionApp::where('user_id', $this->id);
+ return CompanionApp::where('user_id', $this->id);
}
public function senderPolicyFrameworkWhitelist($clientName)
@@ -612,7 +606,7 @@
}
if (substr($entry, 0, 1) == '.') {
- if (substr($clientName, (-1 * strlen($entry))) == $entry) {
+ if (substr($clientName, -1 * strlen($entry)) == $entry) {
$matchFound = true;
}
@@ -630,8 +624,6 @@
/**
* Un-degrade this user.
- *
- * @return void
*/
public function undegrade(): void
{
@@ -639,7 +631,7 @@
return;
}
- $this->status ^= User::STATUS_DEGRADED;
+ $this->status ^= self::STATUS_DEGRADED;
$this->save();
}
@@ -647,22 +639,20 @@
* Un-restrict this user.
*
* @param bool $deep Unrestrict also all users in the account
- *
- * @return void
*/
public function unrestrict(bool $deep = false): void
{
if ($this->isRestricted()) {
- $this->status ^= User::STATUS_RESTRICTED;
+ $this->status ^= self::STATUS_RESTRICTED;
$this->save();
}
// Remove the flag from all users in the user's wallets
if ($deep) {
- $this->wallets->each(function ($wallet) {
+ $this->wallets->each(static function ($wallet) {
User::whereIn('id', $wallet->entitlements()->select('entitleable_id')
->where('entitleable_type', User::class))
- ->each(function ($user) {
+ ->each(static function ($user) {
$user->unrestrict();
});
});
@@ -672,20 +662,20 @@
/**
* Return users controlled by the current user.
*
- * @param bool $with_accounts Include users assigned to wallets
- * the current user controls but not owns.
+ * @param bool $with_accounts include users assigned to wallets
+ * the current user controls but not owns
*
- * @return \Illuminate\Database\Eloquent\Builder Query builder
+ * @return Builder Query builder
*/
public function users($with_accounts = true)
{
- return $this->entitleables(User::class, $with_accounts);
+ return $this->entitleables(self::class, $with_accounts);
}
/**
* Verification codes for this user.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<VerificationCode, $this>
+ * @return HasMany<VerificationCode, $this>
*/
public function verificationcodes()
{
@@ -695,7 +685,7 @@
/**
* Wallets this user owns.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Wallet, $this>
+ * @return HasMany<Wallet, $this>
*/
public function wallets()
{
@@ -705,9 +695,7 @@
/**
* User password mutator
*
- * @param string $password The password in plain text.
- *
- * @return void
+ * @param string $password the password in plain text
*/
public function setPasswordAttribute($password)
{
@@ -722,9 +710,7 @@
/**
* User LDAP password mutator
*
- * @param string $password The password in plain text.
- *
- * @return void
+ * @param string $password the password in plain text
*/
public function setPasswordLdapAttribute($password)
{
@@ -756,7 +742,7 @@
$wallet->entitlements()->select('entitleable_id', 'entitleable_type')
->distinct()
->get()
- ->each(function ($entitlement) {
+ ->each(static function ($entitlement) {
if (
defined($entitlement->entitleable_type . '::STATUS_SUSPENDED')
&& $entitlement->entitleable
@@ -770,7 +756,7 @@
/**
* Validate the user credentials
*
- * @param string $password The password in plain text.
+ * @param string $password the password in plain text
*/
public function validatePassword(string $password): bool
{
@@ -808,8 +794,6 @@
* Validate request location regarding geo-lockin
*
* @param string $ip IP address to check, usually request()->ip()
- *
- * @return bool
*/
public function validateLocation($ip): bool
{
@@ -819,15 +803,15 @@
return true;
}
- return in_array(\App\Utils::countryForIP($ip), $countryCodes);
+ return in_array(Utils::countryForIP($ip), $countryCodes);
}
/**
* Retrieve and authenticate a user
*
- * @param string $username The username
- * @param string $password The password in plain text
- * @param ?string $clientIP The IP address of the client
+ * @param string $username The username
+ * @param string $password The password in plain text
+ * @param ?string $clientIP The IP address of the client
* @param ?bool $withChecks Enable MFA and location checks
*
* @return array ['user', 'reason', 'errorMessage']
@@ -840,7 +824,7 @@
$clientIP = request()->ip();
}
- $user = User::where('email', $username)->first();
+ $user = self::where('email', $username)->first();
if (!$user) {
$error = AuthAttempt::REASON_NOTFOUND;
@@ -853,7 +837,7 @@
}
} else {
if (!$withChecks) {
- $cacheId = hash('sha256', "{$user->id}-$password");
+ $cacheId = hash('sha256', "{$user->id}-{$password}");
// Skip the slow password verification for cases where we also don't verify mfa.
// We rely on this for fast cyrus-sasl authentication.
if (Cache::has($cacheId)) {
@@ -877,7 +861,7 @@
// Check 2FA
if (!$error) {
try {
- (new \App\Auth\SecondFactor($user))->validate(request()->secondfactor);
+ (new SecondFactor($user))->validate(request()->secondfactor);
} catch (\Exception $e) {
$error = AuthAttempt::REASON_2FA_GENERIC;
$message = $e->getMessage();
@@ -904,7 +888,7 @@
}
if ($user) {
- \Log::info("Authentication failed for {$user->email}. Error: $error");
+ \Log::info("Authentication failed for {$user->email}. Error: {$error}");
}
return ['reason' => $error, 'errorMessage' => $message ?? \trans("auth.error.{$error}")];
@@ -923,11 +907,11 @@
/**
* Hook for passport
*
- * @throws \Throwable
+ * @return User User model object if found
*
- * @return \App\User User model object if found
+ * @throws \Throwable
*/
- public static function findAndValidateForPassport($username, $password): User
+ public static function findAndValidateForPassport($username, $password): self
{
$verifyMFA = true;
if (request()->scope == "mfa") {
diff --git a/src/app/UserSetting.php b/src/app/UserSetting.php
--- a/src/app/UserSetting.php
+++ b/src/app/UserSetting.php
@@ -20,7 +20,6 @@
/** @var list<string> The attributes that are mass assignable */
protected $fillable = ['user_id', 'key', 'value'];
-
/**
* Check if the setting is used in any storage backend.
*/
diff --git a/src/app/Utils.php b/src/app/Utils.php
--- a/src/app/Utils.php
+++ b/src/app/Utils.php
@@ -2,6 +2,7 @@
namespace App;
+use App\Http\Controllers\ContentController;
use Carbon\Carbon;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Http;
@@ -25,13 +26,13 @@
*
* Useful for progress bars.
*
- * @param string $file The filepath to count the lines of.
+ * @param string $file the filepath to count the lines of
*
* @return int
*/
public static function countLines($file)
{
- $fh = fopen($file, 'rb');
+ $fh = fopen($file, 'r');
$numLines = 0;
while (!feof($fh)) {
@@ -53,10 +54,10 @@
*/
public static function countryForIP($ip, $fallback = 'CH')
{
- if (strpos($ip, ':') === false) {
- $net = \App\IP4Net::getNet($ip);
+ if (!str_contains($ip, ':')) {
+ $net = IP4Net::getNet($ip);
} else {
- $net = \App\IP6Net::getNet($ip);
+ $net = IP6Net::getNet($ip);
}
return $net && $net->country ? $net->country : $fallback;
@@ -83,7 +84,7 @@
$start = new Carbon('first day of last month');
$end = new Carbon('last day of last month');
- return intval($start->diffInDays($end)) + 1;
+ return (int) $start->diffInDays($end) + 1;
}
/**
@@ -106,7 +107,7 @@
*
* @param string $source The source location
* @param string $target The target location
- * @param bool $force Force the download (and overwrite target)
+ * @param bool $force Force the download (and overwrite target)
*
* @throws \Exception
*/
@@ -185,14 +186,14 @@
$alphaLow = 'abcdefghijklmnopqrstuvwxyz';
$alphaUp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$num = '0123456789';
- $stdSpecial = '~`!@#$%^&*()-_+=[{]}\\|\'";:/?.>,<';
+ $stdSpecial = '~`!@#$%^&*()-_+=[{]}\|\'";:/?.>,<';
$source = $alphaLow . $alphaUp . $num . $stdSpecial;
$result = '';
for ($x = 0; $x < 16; $x++) {
- $result .= substr($source, rand(0, (strlen($source) - 1)), 1);
+ $result .= substr($source, random_int(0, strlen($source) - 1), 1);
}
return $result;
@@ -207,23 +208,23 @@
*/
public static function findObjectsByRecipientAddress($address)
{
- $address = \App\Utils::normalizeAddress($address);
+ $address = self::normalizeAddress($address);
- list($local, $domainName) = explode('@', $address);
+ [$local, $domainName] = explode('@', $address);
- $domain = \App\Domain::where('namespace', $domainName)->first();
+ $domain = Domain::where('namespace', $domainName)->first();
if (!$domain) {
return [];
}
- $user = \App\User::where('email', $address)->first();
+ $user = User::where('email', $address)->first();
if ($user) {
return [$user];
}
- $userAliases = \App\UserAlias::where('alias', $address)->get();
+ $userAliases = UserAlias::where('alias', $address)->get();
if (count($userAliases) > 0) {
$users = [];
@@ -235,7 +236,7 @@
return $users;
}
- $userAliases = \App\UserAlias::where('alias', "catchall@{$domain->namespace}")->get();
+ $userAliases = UserAlias::where('alias', "catchall@{$domain->namespace}")->get();
if (count($userAliases) > 0) {
$users = [];
@@ -253,23 +254,23 @@
/**
* Retrieve the network ID and Type from a client address
*
- * @param string $clientAddress The IPv4 or IPv6 address.
+ * @param string $clientAddress the IPv4 or IPv6 address
*
- * @return array An array of ID and class or null and null.
+ * @return array an array of ID and class or null and null
*/
public static function getNetFromAddress($clientAddress)
{
- if (strpos($clientAddress, ':') === false) {
- $net = \App\IP4Net::getNet($clientAddress);
+ if (!str_contains($clientAddress, ':')) {
+ $net = IP4Net::getNet($clientAddress);
if ($net) {
- return [$net->id, \App\IP4Net::class];
+ return [$net->id, IP4Net::class];
}
} else {
- $net = \App\IP6Net::getNet($clientAddress);
+ $net = IP6Net::getNet($clientAddress);
if ($net) {
- return [$net->id, \App\IP6Net::class];
+ return [$net->id, IP6Net::class];
}
}
@@ -279,8 +280,8 @@
/**
* Calculate the broadcast address provided a net number and a prefix.
*
- * @param string $net A valid IPv6 network number.
- * @param int $prefix The network prefix.
+ * @param string $net a valid IPv6 network number
+ * @param int $prefix the network prefix
*
* @return string
*/
@@ -307,7 +308,7 @@
$origval = hexdec($orig);
// OR it with (2^flexbits)-1, with flexbits limited to 4 at a time
- $newval = $origval | (pow(2, min(4, $flexbits)) - 1);
+ $newval = $origval | (2 ** min(4, $flexbits) - 1);
// Convert it back to a hexadecimal character
$new = dechex($newval);
@@ -317,7 +318,7 @@
// We processed one nibble, move to previous position
$flexbits -= 4;
- $pos -= 1;
+ $pos--;
}
// Convert the hexadecimal string to a binary string
@@ -361,13 +362,13 @@
$address = self::emailToLower($address);
- if (strpos($address, '@') === false) {
+ if (!str_contains($address, '@')) {
return $asArray ? [$address, ''] : $address;
}
- list($local, $domain) = explode('@', $address);
+ [$local, $domain] = explode('@', $address);
- if (strpos($local, '+') !== false) {
+ if (str_contains($local, '+')) {
$local = explode('+', $local)[0];
}
@@ -376,8 +377,6 @@
/**
* Returns the current user's email address or null.
- *
- * @return string
*/
public static function userEmailOrNull(): ?string
{
@@ -400,9 +399,9 @@
* // $roomName == '3qb-7cs-cjj'
* ```
*
- * @param int $length The length of each segment
- * @param int $qty The quantity of segments
- * @param string $join The string to use to join the segments
+ * @param int $length The length of each segment
+ * @param int $qty The quantity of segments
+ * @param string $join The string to use to join the segments
*
* @return string
*/
@@ -416,7 +415,7 @@
$string = [];
for ($y = 0; $y < $length; $y++) {
- $string[] = $chars[rand(0, strlen($chars) - 1)];
+ $string[] = $chars[random_int(0, strlen($chars) - 1)];
}
shuffle($string);
@@ -429,8 +428,6 @@
/**
* Returns a UUID in the form of an integer.
- *
- * @return int
*/
public static function uuidInt(): int
{
@@ -444,8 +441,6 @@
/**
* Returns a UUID in the form of a string.
- *
- * @return string
*/
public static function uuidStr(): string
{
@@ -468,10 +463,10 @@
return $route;
}
- $url = \App\Tenant::getConfig($tenantId, 'app.public_url');
+ $url = Tenant::getConfig($tenantId, 'app.public_url');
if (!$url) {
- $url = \App\Tenant::getConfig($tenantId, 'app.url');
+ $url = Tenant::getConfig($tenantId, 'app.url');
}
return rtrim(trim($url, '/') . '/' . ltrim($route, '/'), '/');
@@ -500,7 +495,7 @@
'app.company.copyright',
'app.companion_download_link',
'app.with_signup',
- 'mail.from.address'
+ 'mail.from.address',
];
$env = \app('config')->getMany($opts);
@@ -509,17 +504,17 @@
$env['view'] = 'root';
$env['jsapp'] = 'user.js';
- if ($req_domain == "admin.$sys_domain") {
+ if ($req_domain == "admin.{$sys_domain}") {
$env['jsapp'] = 'admin.js';
- } elseif ($req_domain == "reseller.$sys_domain") {
+ } elseif ($req_domain == "reseller.{$sys_domain}") {
$env['jsapp'] = 'reseller.js';
}
$env['paymentProvider'] = \config('services.payment_provider');
$env['stripePK'] = \config('services.stripe.public_key');
- $env['languages'] = \App\Http\Controllers\ContentController::locales();
- $env['menu'] = \App\Http\Controllers\ContentController::menu();
+ $env['languages'] = ContentController::locales();
+ $env['menu'] = ContentController::menu();
return $env;
}
@@ -527,7 +522,7 @@
/**
* Set test exchange rates.
*
- * @param array $rates: Exchange rates
+ * @param array $rates: Exchange rates
*/
public static function setTestExchangeRates(array $rates): void
{
@@ -537,8 +532,8 @@
/**
* Retrieve an exchange rate.
*
- * @param string $sourceCurrency: Currency from which to convert
- * @param string $targetCurrency: Currency to convert to
+ * @param string $sourceCurrency: Currency from which to convert
+ * @param string $targetCurrency: Currency to convert to
*
* @return float Exchange rate
*/
@@ -549,18 +544,18 @@
}
if (isset(self::$testRates[$targetCurrency])) {
- return floatval(self::$testRates[$targetCurrency]);
+ return (float) self::$testRates[$targetCurrency];
}
- $currencyFile = resource_path("exchangerates-$sourceCurrency.php");
+ $currencyFile = resource_path("exchangerates-{$sourceCurrency}.php");
- //Attempt to find the reverse exchange rate, if we don't have the file for the source currency
+ // Attempt to find the reverse exchange rate, if we don't have the file for the source currency
if (!file_exists($currencyFile)) {
- $rates = include resource_path("exchangerates-$targetCurrency.php");
+ $rates = include resource_path("exchangerates-{$targetCurrency}.php");
if (!isset($rates[$sourceCurrency])) {
throw new \Exception("Failed to find the reverse exchange rate for " . $sourceCurrency);
}
- return 1.0 / floatval($rates[$sourceCurrency]);
+ return 1.0 / (float) $rates[$sourceCurrency];
}
$rates = include $currencyFile;
@@ -568,7 +563,7 @@
throw new \Exception("Failed to find exchange rate for " . $targetCurrency);
}
- return floatval($rates[$targetCurrency]);
+ return (float) $rates[$targetCurrency];
}
/**
@@ -599,14 +594,14 @@
*
* @return string String representation, e.g. "0 %", "7.7 %"
*/
- public static function percent(int|float $percent, $locale = 'de_DE'): string
+ public static function percent(float|int $percent, $locale = 'de_DE'): string
{
$nf = new \NumberFormatter($locale, \NumberFormatter::PERCENT);
$sep = $nf->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
$result = sprintf('%.2F', $percent);
$result = preg_replace('/\.00/', '', $result);
- $result = preg_replace('/(\.[0-9])0/', '\\1', $result);
+ $result = preg_replace('/(\.[0-9])0/', '\1', $result);
$result = str_replace('.', $sep, $result);
return $result . ' %';
diff --git a/src/app/VatRate.php b/src/app/VatRate.php
--- a/src/app/VatRate.php
+++ b/src/app/VatRate.php
@@ -8,10 +8,10 @@
/**
* The eloquent definition of a Vat Rate.
*
- * @property string $id Rate identifier (uuid)
- * @property string $country Two-letter country code
- * @property float $rate Tax rate
- * @property string $start Start date of the rate
+ * @property string $id Rate identifier (uuid)
+ * @property string $country Two-letter country code
+ * @property float $rate Tax rate
+ * @property string $start Start date of the rate
*/
class VatRate extends Model
{
@@ -20,7 +20,7 @@
/** @var array<string, string> The attributes that should be cast */
protected $casts = [
'start' => 'datetime:Y-m-d H:i:s',
- 'rate' => 'float'
+ 'rate' => 'float',
];
/** @var list<string> The attributes that are mass assignable */
diff --git a/src/app/VerificationCode.php b/src/app/VerificationCode.php
--- a/src/app/VerificationCode.php
+++ b/src/app/VerificationCode.php
@@ -9,12 +9,12 @@
/**
* The eloquent definition of a VerificationCode
*
- * @property bool $active Active status
- * @property string $code The code
- * @property \Carbon\Carbon $expires_at Expiration date-time
- * @property string $mode Mode, e.g. password-reset
- * @property int $user_id User identifier
- * @property string $short_code Short code
+ * @property bool $active Active status
+ * @property string $code The code
+ * @property Carbon $expires_at Expiration date-time
+ * @property string $mode Mode, e.g. password-reset
+ * @property int $user_id User identifier
+ * @property string $short_code Short code
*/
class VerificationCode extends Model
{
@@ -49,17 +49,14 @@
/** @var list<string> The attributes that are mass assignable */
protected $fillable = ['user_id', 'code', 'short_code', 'mode', 'expires_at', 'active'];
-
/**
* Generate a short code (for human).
- *
- * @return string
*/
public static function generateShortCode(): string
{
$code_length = env('VERIFICATION_CODE_LENGTH', self::SHORTCODE_LENGTH);
- return \App\Utils::randStr($code_length);
+ return Utils::randStr($code_length);
}
/**
diff --git a/src/app/Wallet.php b/src/app/Wallet.php
--- a/src/app/Wallet.php
+++ b/src/app/Wallet.php
@@ -2,13 +2,17 @@
namespace App;
+use App\Jobs\Mail\PaymentMandateDisabledJob;
use App\Providers\PaymentProvider;
use App\Traits\SettingsTrait;
use App\Traits\UuidStrKeyTrait;
use Carbon\Carbon;
use Dyrynda\Database\Support\NullableFields;
-use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Facades\DB;
/**
@@ -16,12 +20,12 @@
*
* A wallet is owned by an {@link \App\User}.
*
- * @property int $balance Current balance in cents
- * @property string $currency Currency code
- * @property ?string $description Description
- * @property string $id Unique identifier
- * @property ?\App\User $owner Owner (can be null when owner is deleted)
- * @property int $user_id Owner's identifier
+ * @property int $balance Current balance in cents
+ * @property string $currency Currency code
+ * @property ?string $description Description
+ * @property string $id Unique identifier
+ * @property ?User $owner Owner (can be null when owner is deleted)
+ * @property int $user_id Owner's identifier
*/
class Wallet extends Model
{
@@ -40,7 +44,7 @@
/** @var list<string> The attributes that are mass assignable */
protected $fillable = [
'currency',
- 'description'
+ 'description',
];
/** @var array<int, string> The attributes that can be not set */
@@ -53,13 +57,10 @@
'balance' => 'integer',
];
-
/**
* Add a controller to this wallet.
*
- * @param \App\User $user The user to add as a controller to this wallet.
- *
- * @return void
+ * @param User $user the user to add as a controller to this wallet
*/
public function addController(User $user)
{
@@ -71,12 +72,12 @@
/**
* Add an award to this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of award (in cents) or Payment object
- * @param string $description The transaction description
+ * @param int|Payment $amount The amount of award (in cents) or Payment object
+ * @param string $description The transaction description
*
* @return Wallet Self
*/
- public function award(int|Payment $amount, string $description = ''): Wallet
+ public function award(int|Payment $amount, string $description = ''): self
{
return $this->balanceUpdate(Transaction::WALLET_AWARD, $amount, $description);
}
@@ -102,16 +103,16 @@
// Get all relevant entitlements...
$entitlements = $this->entitlements()->withTrashed()
- ->where(function (Builder $query) {
+ ->where(static function (Builder $query) {
// existing entitlements created, or billed last less than a month ago
- $query->where(function (Builder $query) {
+ $query->where(static function (Builder $query) {
$query->whereNull('deleted_at')
->where('updated_at', '<=', Carbon::now()->subMonthsWithoutOverflow(1));
})
// deleted entitlements not yet charged
- ->orWhere(function (Builder $query) {
- $query->whereColumn('updated_at', '<', 'deleted_at');
- });
+ ->orWhere(static function (Builder $query) {
+ $query->whereColumn('updated_at', '<', 'deleted_at');
+ });
})
->get();
@@ -159,7 +160,7 @@
*
* Returns NULL for balance < 0 or discount = 100% or on a fresh account
*
- * @return \Carbon\Carbon|null Date
+ * @return Carbon|null Date
*/
public function balanceLastsUntil()
{
@@ -173,10 +174,10 @@
// Get all entitlements...
$entitlements = $this->entitlements()->orderBy('updated_at')->get()
- ->filter(function ($entitlement) {
+ ->filter(static function ($entitlement) {
return $entitlement->cost > 0;
})
- ->map(function ($entitlement) {
+ ->map(static function ($entitlement) {
return [
'date' => $entitlement->updated_at ?: $entitlement->created_at,
'cost' => $entitlement->cost,
@@ -223,12 +224,12 @@
/**
* Chargeback an amount of pecunia from this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of pecunia to charge back (in cents) or Payment object
- * @param string $description The transaction description
+ * @param int|Payment $amount The amount of pecunia to charge back (in cents) or Payment object
+ * @param string $description The transaction description
*
* @return Wallet Self
*/
- public function chargeback(int|Payment $amount, string $description = ''): Wallet
+ public function chargeback(int|Payment $amount, string $description = ''): self
{
return $this->balanceUpdate(Transaction::WALLET_CHARGEBACK, $amount, $description);
}
@@ -236,7 +237,7 @@
/**
* Controllers of this wallet.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany<User, $this>
+ * @return BelongsToMany<User, $this>
*/
public function controllers()
{
@@ -251,12 +252,12 @@
/**
* Add an amount of pecunia to this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of pecunia to add (in cents) or Payment object
- * @param string $description The transaction description
+ * @param int|Payment $amount The amount of pecunia to add (in cents) or Payment object
+ * @param string $description The transaction description
*
* @return Wallet Self
*/
- public function credit(int|Payment $amount, string $description = ''): Wallet
+ public function credit(int|Payment $amount, string $description = ''): self
{
return $this->balanceUpdate(Transaction::WALLET_CREDIT, $amount, $description);
}
@@ -264,13 +265,14 @@
/**
* Deduct an amount of pecunia from this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of pecunia to deduct (in cents) or Payment object
- * @param string $description The transaction description
- * @param array $eTIDs List of transaction IDs for the individual entitlements
- * that make up this debit record, if any.
+ * @param int|Payment $amount The amount of pecunia to deduct (in cents) or Payment object
+ * @param string $description The transaction description
+ * @param array $eTIDs list of transaction IDs for the individual entitlements
+ * that make up this debit record, if any
+ *
* @return Wallet Self
*/
- public function debit(int|Payment $amount, string $description = '', array $eTIDs = []): Wallet
+ public function debit(int|Payment $amount, string $description = '', array $eTIDs = []): self
{
return $this->balanceUpdate(Transaction::WALLET_DEBIT, $amount, $description, $eTIDs);
}
@@ -278,7 +280,7 @@
/**
* The discount assigned to the wallet.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Discount, $this>
+ * @return BelongsTo<Discount, $this>
*/
public function discount()
{
@@ -288,7 +290,7 @@
/**
* Entitlements billed to this wallet.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Entitlement, $this>
+ * @return HasMany<Entitlement, $this>
*/
public function entitlements()
{
@@ -308,7 +310,7 @@
/**
* Return the exact, numeric version of the discount to be applied.
*
- * @return int Discount in percent, ranges from 0 - 100.
+ * @return int discount in percent, ranges from 0 - 100
*/
public function getDiscount(): int
{
@@ -348,7 +350,7 @@
/**
* Check if the specified user is a controller to this wallet.
*
- * @param \App\User $user The user object.
+ * @param User $user the user object
*
* @return bool True if the user is one of the wallet controllers (including user), False otherwise
*/
@@ -368,13 +370,13 @@
*/
public function money(int $amount, $locale = 'de_DE')
{
- return \App\Utils::money($amount, $this->currency, $locale);
+ return Utils::money($amount, $this->currency, $locale);
}
/**
* The owner of the wallet -- the wallet is in his/her back pocket.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<User, $this>
+ * @return BelongsTo<User, $this>
*/
public function owner()
{
@@ -398,9 +400,8 @@
case 1:
// In this mode tax is added on top of the payment. The amount
// to pay grows, but we keep wallet balance without tax.
- $request['amount'] = $request['amount'] + round($request['amount'] * $rate->rate / 100);
+ $request['amount'] += round($request['amount'] * $rate->rate / 100);
break;
-
default:
// In this mode tax is "swallowed" by the vendor. The payment
// amount does not change
@@ -414,7 +415,7 @@
/**
* Payments on this wallet.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Payment, $this>
+ * @return HasMany<Payment, $this>
*/
public function payments()
{
@@ -424,12 +425,12 @@
/**
* Add a penalty to this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of penalty (in cents) or Payment object
- * @param string $description The transaction description
+ * @param int|Payment $amount The amount of penalty (in cents) or Payment object
+ * @param string $description The transaction description
*
* @return Wallet Self
*/
- public function penalty(int|Payment $amount, string $description = ''): Wallet
+ public function penalty(int|Payment $amount, string $description = ''): self
{
return $this->balanceUpdate(Transaction::WALLET_PENALTY, $amount, $description);
}
@@ -437,7 +438,7 @@
/**
* Plan of the wallet.
*
- * @return ?\App\Plan
+ * @return ?Plan
*/
public function plan()
{
@@ -449,9 +450,7 @@
/**
* Remove a controller from this wallet.
*
- * @param \App\User $user The user to remove as a controller from this wallet.
- *
- * @return void
+ * @param User $user the user to remove as a controller from this wallet
*/
public function removeController(User $user)
{
@@ -463,12 +462,12 @@
/**
* Refund an amount of pecunia from this wallet's balance.
*
- * @param int|\App\Payment $amount The amount of pecunia to refund (in cents) or Payment object
- * @param string $description The transaction description
+ * @param int|Payment $amount The amount of pecunia to refund (in cents) or Payment object
+ * @param string $description The transaction description
*
* @return Wallet Self
*/
- public function refund($amount, string $description = ''): Wallet
+ public function refund($amount, string $description = ''): self
{
return $this->balanceUpdate(Transaction::WALLET_REFUND, $amount, $description);
}
@@ -489,8 +488,8 @@
return false;
}
- $min_balance = (int) round(floatval($settings['mandate_balance']) * 100);
- $amount = (int) round(floatval($settings['mandate_amount']) * 100);
+ $min_balance = (int) round((float) $settings['mandate_balance'] * 100);
+ $amount = (int) round((float) $settings['mandate_amount'] * 100);
// The wallet balance is greater than the auto-payment threshold
if ($this->balance >= $min_balance) {
@@ -517,7 +516,7 @@
// Disable (not remove) the mandate
\Log::warning("Top-up for wallet {$this->id}: mandate too little");
$this->setSetting('mandate_disabled', '1');
- \App\Jobs\Mail\PaymentMandateDisabledJob::dispatch($this);
+ PaymentMandateDisabledJob::dispatch($this);
return false;
}
@@ -549,12 +548,12 @@
/**
* Get the VAT rate for the wallet owner country.
*
- * @param ?\DateTime $start Get the rate valid for the specified date-time,
- * without it the current rate will be returned (if exists).
+ * @param ?\DateTime $start get the rate valid for the specified date-time,
+ * without it the current rate will be returned (if exists)
*
- * @return ?\App\VatRate VAT rate
+ * @return ?VatRate VAT rate
*/
- public function vatRate(\DateTime $start = null): ?VatRate
+ public function vatRate(?\DateTime $start = null): ?VatRate
{
$owner = $this->owner;
@@ -579,12 +578,12 @@
/**
* Retrieve the transactions against this wallet.
*
- * @return \Illuminate\Database\Eloquent\Relations\HasMany<Transaction, $this>
+ * @return HasMany<Transaction, $this>
*/
public function transactions()
{
return $this->hasMany(Transaction::class, 'object_id')
- ->where('object_type', Wallet::class);
+ ->where('object_type', self::class);
}
/**
@@ -605,11 +604,11 @@
// - if we change plan definition at some point in time, the old users would use
// the old definition, instead of the current one
// TODO: The same for plan's free_months value
- $trialSkus = \App\Sku::select('id')
- ->whereIn('id', function ($query) use ($plan) {
+ $trialSkus = Sku::select('id')
+ ->whereIn('id', static function ($query) use ($plan) {
$query->select('sku_id')
->from('package_skus')
- ->whereIn('package_id', function ($query) use ($plan) {
+ ->whereIn('package_id', static function ($query) use ($plan) {
$query->select('package_id')
->from('plan_packages')
->where('plan_id', $plan->id);
@@ -726,12 +725,12 @@
$this->save();
$transaction = Transaction::create([
- 'user_email' => \App\Utils::userEmailOrNull(),
- 'object_id' => $this->id,
- 'object_type' => Wallet::class,
- 'type' => $type,
- 'amount' => $amount,
- 'description' => $description,
+ 'user_email' => Utils::userEmailOrNull(),
+ 'object_id' => $this->id,
+ 'object_type' => self::class,
+ 'type' => $type,
+ 'amount' => $amount,
+ 'description' => $description,
]);
if (!empty($eTIDs)) {
@@ -750,7 +749,7 @@
*
* @return array Result in form of [cost, fee, end-of-period]
*/
- protected function entitlementCosts(Entitlement $entitlement, array $trial = null, bool $useCostPerDay = false)
+ protected function entitlementCosts(Entitlement $entitlement, ?array $trial = null, bool $useCostPerDay = false)
{
if ($entitlement->wallet_id != $this->id) {
throw new \Exception("Entitlement assigned to another wallet");
@@ -787,14 +786,14 @@
$fee = 0;
// Charge for full months first
- if (($diff = intval($startDate->diffInMonths($endDate, true))) > 0) {
+ if (($diff = (int) $startDate->diffInMonths($endDate, true)) > 0) {
$cost += floor($entitlement->cost * $discountRate) * $diff;
$fee += $entitlement->fee * $diff;
$startDate->addMonthsWithoutOverflow($diff);
}
// Charge for the rest of the period
- if (($diff = intval($startDate->diffInDays($endDate, true))) > 0) {
+ if (($diff = (int) $startDate->diffInDays($endDate, true)) > 0) {
// The price per day is based on the number of days in the month(s)
// Note: The $endDate does not have to be the current month
$endMonthDiff = $endDate->day > $diff ? $diff : $endDate->day;
diff --git a/src/app/WalletSetting.php b/src/app/WalletSetting.php
--- a/src/app/WalletSetting.php
+++ b/src/app/WalletSetting.php
@@ -3,6 +3,7 @@
namespace App;
use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* A collection of settings for a Wallet.
@@ -20,7 +21,7 @@
/**
* The wallet to which this setting belongs.
*
- * @return \Illuminate\Database\Eloquent\Relations\BelongsTo<Wallet, $this>
+ * @return BelongsTo<Wallet, $this>
*/
public function wallet()
{
diff --git a/src/bootstrap/app.php b/src/bootstrap/app.php
--- a/src/bootstrap/app.php
+++ b/src/bootstrap/app.php
@@ -6,7 +6,6 @@
}
if (!function_exists('array_first')) {
-
/**
* Get first element from an array
*
diff --git a/src/composer.json b/src/composer.json
--- a/src/composer.json
+++ b/src/composer.json
@@ -41,12 +41,13 @@
},
"require-dev": {
"code-lts/doctum": "dev-main",
+ "diablomedia/arcanist-extensions": "^1.1",
+ "friendsofphp/php-cs-fixer": "^3.0",
"larastan/larastan": "^3.4",
"laravel/dusk": "~8.2.2",
"mockery/mockery": "^1.5",
"phpstan/phpstan": "^2.0",
- "phpunit/phpunit": "^10.5.32",
- "squizlabs/php_codesniffer": "^3.6"
+ "phpunit/phpunit": "^10.5.32"
},
"config": {
"optimize-autoloader": true,
diff --git a/src/config/2fa.php b/src/config/2fa.php
--- a/src/config/2fa.php
+++ b/src/config/2fa.php
@@ -1,12 +1,10 @@
<?php
return [
-
'totp' => [
'digits' => (int) env('MFA_TOTP_DIGITS', 6),
'interval' => (int) env('MFA_TOTP_INTERVAL', 30),
'digest' => env('MFA_TOTP_DIGEST', 'sha1'),
'issuer' => env('APP_NAME', 'Laravel'),
],
-
];
diff --git a/src/config/app.php b/src/config/app.php
--- a/src/config/app.php
+++ b/src/config/app.php
@@ -1,10 +1,15 @@
<?php
+use App\Providers\AppServiceProvider;
+use App\Providers\AuthServiceProvider;
+use App\Providers\EventServiceProvider;
+use App\Providers\HorizonServiceProvider;
+use App\Providers\PassportServiceProvider;
+use App\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Facade;
use Illuminate\Support\ServiceProvider;
return [
-
/*
|--------------------------------------------------------------------------
| Application Name
@@ -176,16 +181,14 @@
*/
'providers' => ServiceProvider::defaultProviders()->merge([
- /*
- * Application Service Providers...
- */
- App\Providers\AppServiceProvider::class,
- App\Providers\AuthServiceProvider::class,
+ // Application Service Providers...
+ AppServiceProvider::class,
+ AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class,
- App\Providers\EventServiceProvider::class,
- App\Providers\HorizonServiceProvider::class,
- App\Providers\PassportServiceProvider::class,
- App\Providers\RouteServiceProvider::class,
+ EventServiceProvider::class,
+ HorizonServiceProvider::class,
+ PassportServiceProvider::class,
+ RouteServiceProvider::class,
])->toArray(),
/*
@@ -278,5 +281,5 @@
'token_signing_key' => env('VPN_TOKEN_SIGNING_KEY', 0),
],
- 'mta_sts' => env('MTA_STS')
+ 'mta_sts' => env('MTA_STS'),
];
diff --git a/src/config/auth.php b/src/config/auth.php
--- a/src/config/auth.php
+++ b/src/config/auth.php
@@ -1,7 +1,8 @@
<?php
-return [
+use App\User;
+return [
/*
|--------------------------------------------------------------------------
| Authentication Defaults
@@ -67,7 +68,7 @@
'providers' => [
'users' => [
'driver' => 'eloquent',
- 'model' => App\User::class,
+ 'model' => User::class,
],
// 'users' => [
@@ -116,7 +117,6 @@
'password_timeout' => 10800,
-
/*
|--------------------------------------------------------------------------
| OAuth Proxy Authentication
diff --git a/src/config/broadcasting.php b/src/config/broadcasting.php
--- a/src/config/broadcasting.php
+++ b/src/config/broadcasting.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Default Broadcaster
@@ -29,7 +28,6 @@
*/
'connections' => [
-
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
@@ -37,7 +35,7 @@
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
- 'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
+ 'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
'port' => env('PUSHER_PORT', 443),
'scheme' => env('PUSHER_SCHEME', 'https'),
'encrypted' => true,
@@ -65,7 +63,5 @@
'null' => [
'driver' => 'null',
],
-
],
-
];
diff --git a/src/config/cache.php b/src/config/cache.php
--- a/src/config/cache.php
+++ b/src/config/cache.php
@@ -1,9 +1,6 @@
<?php
-use Illuminate\Support\Str;
-
return [
-
/*
|--------------------------------------------------------------------------
| Default Cache Store
@@ -30,7 +27,6 @@
*/
'stores' => [
-
'apc' => [
'driver' => 'apc',
],
@@ -90,7 +86,6 @@
'octane' => [
'driver' => 'octane',
],
-
],
/*
@@ -105,5 +100,4 @@
*/
'prefix' => env('CACHE_PREFIX', 'laravel_cache_'),
-
];
diff --git a/src/config/cors.php b/src/config/cors.php
--- a/src/config/cors.php
+++ b/src/config/cors.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Cross-Origin Resource Sharing (CORS) Configuration
@@ -30,5 +29,4 @@
'max_age' => 0,
'supports_credentials' => false,
-
];
diff --git a/src/config/database.php b/src/config/database.php
--- a/src/config/database.php
+++ b/src/config/database.php
@@ -1,9 +1,6 @@
<?php
-use Illuminate\Support\Str;
-
return [
-
/*
|--------------------------------------------------------------------------
| Default Database Connection Name
@@ -34,7 +31,6 @@
*/
'connections' => [
-
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
@@ -124,7 +120,6 @@
*/
'redis' => [
-
'client' => env('REDIS_CLIENT', 'predis'),
'options' => [
@@ -149,7 +144,5 @@
'port' => env('REDIS_PORT', 6379),
'database' => env('REDIS_CACHE_DB', 1),
],
-
],
-
];
diff --git a/src/config/dompdf.php b/src/config/dompdf.php
--- a/src/config/dompdf.php
+++ b/src/config/dompdf.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Settings
@@ -14,7 +13,7 @@
'show_warnings' => false, // Throw an Exception on warnings from dompdf
'orientation' => 'portrait',
'defines' => [
- /**
+ /*
* The location of the DOMPDF font directory
*
* The location of the directory where DOMPDF will store fonts and font metrics
@@ -40,7 +39,7 @@
*/
'font_dir' => storage_path('fonts/'), // advised by dompdf (https://github.com/dompdf/dompdf/pull/782)
- /**
+ /*
* The location of the DOMPDF font cache directory
*
* This directory contains the cached font metrics for the fonts used by DOMPDF.
@@ -50,7 +49,7 @@
*/
'font_cache' => storage_path('fonts/'),
- /**
+ /*
* The location of a temporary directory.
*
* The directory specified must be writeable by the webserver process.
@@ -59,7 +58,7 @@
*/
'temp_dir' => sys_get_temp_dir(),
- /**
+ /*
* ==== IMPORTANT ====
*
* dompdf's "chroot": Prevents dompdf from accessing system files or other
@@ -73,12 +72,10 @@
*/
'chroot' => realpath(base_path()),
- /**
- * Whether to enable font subsetting or not.
- */
+ // Whether to enable font subsetting or not.
'enable_font_subsetting' => false,
- /**
+ /*
* The PDF rendering backend to use
*
* Valid settings are 'PDFLib', 'CPDF' (the bundled R&OS PDF class), 'GD' and
@@ -108,7 +105,7 @@
*/
'pdf_backend' => 'CPDF',
- /**
+ /*
* PDFlib license key
*
* If you are using a licensed, commercial version of PDFlib, specify
@@ -120,9 +117,9 @@
* If pdflib present in web server and auto or selected explicitely above,
* a real license code must exist!
*/
- //'DOMPDF_PDFLIB_LICENSE' => 'your license key here',
+ // 'DOMPDF_PDFLIB_LICENSE' => 'your license key here',
- /**
+ /*
* html target media view which should be rendered into pdf.
* List of types and parsing rules for future extensions:
* http://www.w3.org/TR/REC-html40/types.html
@@ -134,7 +131,7 @@
*/
'default_media_type' => 'print',
- /**
+ /*
* The default paper size.
*
* North America standard is "letter"; other countries generally "a4"
@@ -143,7 +140,7 @@
*/
'default_paper_size' => 'a4',
- /**
+ /*
* The default font family
*
* Used if no suitable fonts can be found. This must exist in the font folder.
@@ -151,7 +148,7 @@
*/
'default_font' => 'serif',
- /**
+ /*
* Image DPI setting
*
* This setting determines the default DPI setting for images and fonts. The
@@ -186,7 +183,7 @@
*/
'dpi' => 96,
- /**
+ /*
* Enable inline PHP
*
* If this setting is set to true then DOMPDF will automatically evaluate
@@ -200,7 +197,7 @@
*/
'enable_php' => false,
- /**
+ /*
* Enable inline Javascript
*
* If this setting is set to true then DOMPDF will automatically insert
@@ -210,7 +207,7 @@
*/
'enable_javascript' => false,
- /**
+ /*
* Enable remote file access
*
* If this setting is set to true, DOMPDF will access remote sites for
@@ -229,15 +226,10 @@
*/
'enable_remote' => false,
- /**
- * A ratio applied to the fonts height to be more like browsers' line height
- */
+ // A ratio applied to the fonts height to be more like browsers' line height
'font_height_ratio' => 1.1,
- /**
- * Use the more-than-experimental HTML5 Lib parser
- */
+ // Use the more-than-experimental HTML5 Lib parser
'enable_html5_parser' => false,
],
-
];
diff --git a/src/config/filesystems.php b/src/config/filesystems.php
--- a/src/config/filesystems.php
+++ b/src/config/filesystems.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Default Filesystem Disk
@@ -29,7 +28,6 @@
*/
'disks' => [
-
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
@@ -75,7 +73,6 @@
'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
'throw' => false,
],
-
],
/*
@@ -92,5 +89,4 @@
'links' => [
public_path('storage') => storage_path('app/public'),
],
-
];
diff --git a/src/config/hashing.php b/src/config/hashing.php
--- a/src/config/hashing.php
+++ b/src/config/hashing.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Default Hash Driver
@@ -48,5 +47,4 @@
'threads' => 1,
'time' => 4,
],
-
];
diff --git a/src/config/horizon.php b/src/config/horizon.php
--- a/src/config/horizon.php
+++ b/src/config/horizon.php
@@ -3,7 +3,6 @@
use App\Enums\Queue;
return [
-
/*
|--------------------------------------------------------------------------
| Horizon Domain
diff --git a/src/config/laravelpwa.php b/src/config/laravelpwa.php
--- a/src/config/laravelpwa.php
+++ b/src/config/laravelpwa.php
@@ -9,7 +9,7 @@
'background_color' => '#ffffff',
'theme_color' => '#000000',
'display' => 'standalone',
- 'orientation'=> 'any',
+ 'orientation' => 'any',
'icons' => [
'72x72' => '/images/icons/icon-72x72.png',
'96x96' => '/images/icons/icon-96x96.png',
@@ -18,7 +18,7 @@
'152x152' => '/images/icons/icon-152x152.png',
'192x192' => '/images/icons/icon-192x192.png',
'384x384' => '/images/icons/icon-384x384.png',
- '512x512' => '/images/icons/icon-512x512.png'
+ '512x512' => '/images/icons/icon-512x512.png',
],
'splash' => [
'640x1136' => '/images/icons/splash-640x1136.png',
@@ -32,6 +32,6 @@
'1668x2388' => '/images/icons/splash-1668x2388.png',
'2048x2732' => '/images/icons/splash-2048x2732.png',
],
- 'custom' => []
- ]
+ 'custom' => [],
+ ],
];
diff --git a/src/config/logging.php b/src/config/logging.php
--- a/src/config/logging.php
+++ b/src/config/logging.php
@@ -5,7 +5,6 @@
use Monolog\Handler\SyslogUdpHandler;
return [
-
/*
|--------------------------------------------------------------------------
| Default Log Channel
@@ -116,7 +115,7 @@
'syslog' => [
'driver' => 'syslog',
'level' => env('LOG_LEVEL', 'debug'),
- 'facility' => LOG_USER,
+ 'facility' => \LOG_USER,
'replace_placeholders' => true,
],
@@ -135,5 +134,4 @@
'path' => storage_path('logs/laravel.log'),
],
],
-
];
diff --git a/src/config/mail.php b/src/config/mail.php
--- a/src/config/mail.php
+++ b/src/config/mail.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Default Mailer
@@ -44,7 +43,7 @@
'password' => env('MAIL_PASSWORD'),
'timeout' => null,
'local_domain' => env('MAIL_EHLO_DOMAIN'),
- 'verify_peer' => env('MAIL_VERIFY_PEER', 'true')
+ 'verify_peer' => env('MAIL_VERIFY_PEER', 'true'),
],
'ses' => [
@@ -138,5 +137,4 @@
resource_path('views/vendor/mail'),
],
],
-
];
diff --git a/src/config/meet.php b/src/config/meet.php
--- a/src/config/meet.php
+++ b/src/config/meet.php
@@ -1,11 +1,11 @@
<?php
- return [
- 'api_token' => env('MEET_SERVER_TOKEN', 'MY_SECRET'),
- 'api_urls' => explode(
- ',',
- env('MEET_SERVER_URLS', "https://localhost:12443/meetmedia/api/,https://localhost:12444/meetmedia/api/")
- ),
- 'api_verify_tls' => (bool) env('MEET_SERVER_VERIFY_TLS', true),
- 'webhook_token' => env('MEET_WEBHOOK_TOKEN', 'MY_SECRET'),
- ];
+return [
+ 'api_token' => env('MEET_SERVER_TOKEN', 'MY_SECRET'),
+ 'api_urls' => explode(
+ ',',
+ env('MEET_SERVER_URLS', "https://localhost:12443/meetmedia/api/,https://localhost:12444/meetmedia/api/")
+ ),
+ 'api_verify_tls' => (bool) env('MEET_SERVER_VERIFY_TLS', true),
+ 'webhook_token' => env('MEET_WEBHOOK_TOKEN', 'MY_SECRET'),
+];
diff --git a/src/config/octane.php b/src/config/octane.php
--- a/src/config/octane.php
+++ b/src/config/octane.php
@@ -22,7 +22,6 @@
use Laravel\Octane\Octane;
return [
-
/*
|--------------------------------------------------------------------------
| Octane Server
@@ -71,11 +70,9 @@
RequestReceived::class => [
...Octane::prepareApplicationForNextOperation(),
...Octane::prepareApplicationForNextRequest(),
- //
],
RequestHandled::class => [
- //
],
RequestTerminated::class => [
@@ -84,20 +81,16 @@
TaskReceived::class => [
...Octane::prepareApplicationForNextOperation(),
- //
],
TaskTerminated::class => [
- //
],
TickReceived::class => [
...Octane::prepareApplicationForNextOperation(),
- //
],
TickTerminated::class => [
- //
],
OperationTerminated::class => [
@@ -112,7 +105,6 @@
],
WorkerStopping::class => [
- //
],
],
@@ -162,7 +154,7 @@
*/
'tables' => [
-/*
+ /*
'example:1000' => [
'name' => 'string:1000',
'votes' => 'int',
@@ -239,10 +231,10 @@
'upload_max_filesize' => env('SWOOLE_UPLOAD_MAX_FILESIZE', 10 * 1024 * 1024),
'enable_coroutine' => false,
- //FIXME the daemonize option does not work
+ // FIXME the daemonize option does not work
// 'daemonize' => env('OCTANE_DAEMONIZE', true),
- //FIXME accessing app()->environment in here renders artisan disfunctional. I suppose it's too early.
- //'log_level' => app()->environment('local') ? SWOOLE_LOG_INFO : SWOOLE_LOG_ERROR,
+ // FIXME accessing app()->environment in here renders artisan disfunctional. I suppose it's too early.
+ // 'log_level' => app()->environment('local') ? SWOOLE_LOG_INFO : SWOOLE_LOG_ERROR,
// 'reactor_num' => , // number of available cpus by default
'send_yield' => true,
'socket_buffer_size' => 10 * 1024 * 1024,
diff --git a/src/config/openid.php b/src/config/openid.php
--- a/src/config/openid.php
+++ b/src/config/openid.php
@@ -1,9 +1,11 @@
<?php
+use App\Auth\IdentityRepository;
+use Lcobucci\JWT\Signer\Rsa\Sha256;
+
return [
'passport' => [
-
- /**
+ /*
* Place your Passport and OpenID Connect scopes here.
* To receive an `id_token`, you should at least provide the openid scope.
*/
@@ -18,9 +20,7 @@
],
],
- /**
- * Place your custom claim sets here.
- */
+ // Place your custom claim sets here.
'custom_claim_sets' => [
// 'login' => [
// 'last-login',
@@ -33,57 +33,45 @@
// ],
'auth.token' => [
'auth.token',
- ]
+ ],
],
- /**
- * You can override the repositories below.
- */
+ // You can override the repositories below.
'repositories' => [
// 'identity' => \OpenIDConnect\Repositories\IdentityRepository::class,
- 'identity' => \App\Auth\IdentityRepository::class,
+ 'identity' => IdentityRepository::class,
],
'routes' => [
- /**
+ /*
* When set to true, this package will expose the OpenID Connect Discovery endpoint.
* - /.well-known/openid-configuration
*/
'discovery' => true,
- /**
- * When set to true, this package will expose the JSON Web Key Set endpoint.
- */
+ // When set to true, this package will expose the JSON Web Key Set endpoint.
'jwks' => false,
- /**
+ /*
* Optional URL to change the JWKS path to align with your custom Passport routes.
* Defaults to /oauth/jwks
*/
'jwks_url' => '/oauth/jwks',
],
- /**
- * Settings for the discovery endpoint
- */
+ // Settings for the discovery endpoint
'discovery' => [
- /**
- * Hide scopes that aren't from the OpenID Core spec from the Discovery,
- * default = false (all scopes are listed)
- */
+ /*
+ * Hide scopes that aren't from the OpenID Core spec from the Discovery,
+ * default = false (all scopes are listed)
+ */
'hide_scopes' => false,
],
- /**
- * The signer to be used
- */
- 'signer' => \Lcobucci\JWT\Signer\Rsa\Sha256::class,
+ // The signer to be used
+ 'signer' => Sha256::class,
- /**
- * Optional associative array that will be used to set headers on the JWT
- */
+ // Optional associative array that will be used to set headers on the JWT
'token_headers' => [],
- /**
- * By default, microseconds are included.
- */
+ // By default, microseconds are included.
'use_microseconds' => true,
];
diff --git a/src/config/passport.php b/src/config/passport.php
--- a/src/config/passport.php
+++ b/src/config/passport.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Encryption Keys
@@ -62,5 +61,4 @@
'connection' => env('DB_CONNECTION', 'mysql'),
],
],
-
];
diff --git a/src/config/pgp.php b/src/config/pgp.php
--- a/src/config/pgp.php
+++ b/src/config/pgp.php
@@ -1,7 +1,6 @@
<?php
return [
-
// Enables PGP keypair generation on user creation
'enable' => env('PGP_ENABLE', false),
@@ -16,5 +15,4 @@
// Default size of the new RSA key
'length' => (int) env('PGP_LENGTH', 3072),
-
];
diff --git a/src/config/queue.php b/src/config/queue.php
--- a/src/config/queue.php
+++ b/src/config/queue.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Default Queue Connection Name
@@ -29,7 +28,6 @@
*/
'connections' => [
-
'sync' => [
'driver' => 'sync',
],
@@ -70,10 +68,8 @@
'block_for' => null,
'after_commit' => true,
],
-
],
-
/*
|--------------------------------------------------------------------------
| Job Batching
@@ -90,7 +86,6 @@
'table' => 'job_batches',
],
-
/*
|--------------------------------------------------------------------------
| Failed Queue Jobs
@@ -106,5 +101,4 @@
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
-
];
diff --git a/src/config/services.php b/src/config/services.php
--- a/src/config/services.php
+++ b/src/config/services.php
@@ -1,7 +1,8 @@
<?php
-return [
+use App\Backends\Helper;
+return [
/*
----------------------------------------------------------------------------
Third Party Services
@@ -44,7 +45,7 @@
// api_key available in: Firebase Console -> Project Settings -> CLOUD MESSAGING -> Server key
'api_key' => env('FIREBASE_API_KEY'),
'api_url' => env('FIREBASE_API_URL', 'https://fcm.googleapis.com/fcm/send'),
- 'api_verify_tls' => (bool) env('FIREBASE_API_VERIFY_TLS', true)
+ 'api_verify_tls' => (bool) env('FIREBASE_API_VERIFY_TLS', true),
],
'openexchangerates' => [
@@ -59,7 +60,7 @@
'dav' => [
'uri' => env('DAV_URI', 'https://proxy/'),
- 'default_folders' => \App\Backends\Helper::defaultDavFolders(),
+ 'default_folders' => Helper::defaultDavFolders(),
'verify' => (bool) env('DAV_VERIFY', true),
],
@@ -72,14 +73,14 @@
'host' => env('IMAP_HOST', '172.18.0.5'),
'imap_port' => env('IMAP_PORT', 12143),
'guam_port' => env('IMAP_GUAM_PORT', 9143),
- 'default_folders' => \App\Backends\Helper::defaultImapFolders(),
+ 'default_folders' => Helper::defaultImapFolders(),
],
'ldap' => [
'hosts' => explode(' ', env('LDAP_HOSTS', '127.0.0.1')),
'port' => env('LDAP_PORT', 636),
- 'use_tls' => (boolean)env('LDAP_USE_TLS', false),
- 'use_ssl' => (boolean)env('LDAP_USE_SSL', true),
+ 'use_tls' => (bool) env('LDAP_USE_TLS', false),
+ 'use_ssl' => (bool) env('LDAP_USE_SSL', true),
'admin' => [
'bind_dn' => env('LDAP_ADMIN_BIND_DN', null),
@@ -104,7 +105,7 @@
'filter' => env('LDAP_FILTER', '(&(objectclass=kolabinetorgperson)(uid=%s))'),
'domain_name_attribute' => env('LDAP_DOMAIN_NAME_ATTRIBUTE', 'associateddomain'),
'domain_base_dn' => env('LDAP_DOMAIN_BASE_DN', null),
- 'domain_filter' => env('LDAP_DOMAIN_FILTER', '(associateddomain=%s)')
+ 'domain_filter' => env('LDAP_DOMAIN_FILTER', '(associateddomain=%s)'),
],
'autodiscover' => [
diff --git a/src/config/session.php b/src/config/session.php
--- a/src/config/session.php
+++ b/src/config/session.php
@@ -3,7 +3,6 @@
use Illuminate\Support\Str;
return [
-
/*
|--------------------------------------------------------------------------
| Default Session Driver
@@ -194,5 +193,4 @@
*/
'same_site' => 'lax',
-
];
diff --git a/src/config/view.php b/src/config/view.php
--- a/src/config/view.php
+++ b/src/config/view.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| View Storage Paths
@@ -33,5 +32,4 @@
'VIEW_COMPILED_PATH',
realpath(storage_path('framework/views'))
),
-
];
diff --git a/src/database/migrations/2014_10_12_000000_create_users_table.php b/src/database/migrations/2014_10_12_000000_create_users_table.php
--- a/src/database/migrations/2014_10_12_000000_create_users_table.php
+++ b/src/database/migrations/2014_10_12_000000_create_users_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'users',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('id');
$table->string('email')->unique();
$table->string('password')->nullable();
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_17_102626_create_wallet_table.php b/src/database/migrations/2019_09_17_102626_create_wallet_table.php
--- a/src/database/migrations/2019_09_17_102626_create_wallet_table.php
+++ b/src/database/migrations/2019_09_17_102626_create_wallet_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateWalletTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'wallets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->string('description', 128)->nullable();
$table->string('currency', 4);
@@ -33,8 +30,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_17_102627_wallet_controllers.php b/src/database/migrations/2019_09_17_102627_wallet_controllers.php
--- a/src/database/migrations/2019_09_17_102627_wallet_controllers.php
+++ b/src/database/migrations/2019_09_17_102627_wallet_controllers.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class WalletControllers extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'user_accounts',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('wallet_id', 36);
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_17_102628_create_sku_entitlements.php b/src/database/migrations/2019_09_17_102628_create_sku_entitlements.php
--- a/src/database/migrations/2019_09_17_102628_create_sku_entitlements.php
+++ b/src/database/migrations/2019_09_17_102628_create_sku_entitlements.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateSkuEntitlements extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'skus',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->string('title', 64);
// were json, but mariadb
@@ -35,7 +32,7 @@
Schema::create(
'entitlements',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->bigInteger('entitleable_id');
$table->string('entitleable_type');
@@ -53,8 +50,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_17_105606_create_jobs_table.php b/src/database/migrations/2019_09_17_105606_create_jobs_table.php
--- a/src/database/migrations/2019_09_17_105606_create_jobs_table.php
+++ b/src/database/migrations/2019_09_17_105606_create_jobs_table.php
@@ -1,20 +1,17 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateJobsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('jobs', function (Blueprint $table) {
+ Schema::create('jobs', static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
@@ -27,8 +24,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_17_132012_create_user_settings_table.php b/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
--- a/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
+++ b/src/database/migrations/2019_09_17_132012_create_user_settings_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateUserSettingsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'user_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('key');
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_23_071701_create_domains_table.php b/src/database/migrations/2019_09_23_071701_create_domains_table.php
--- a/src/database/migrations/2019_09_23_071701_create_domains_table.php
+++ b/src/database/migrations/2019_09_23_071701_create_domains_table.php
@@ -1,20 +1,17 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateDomainsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('domains', function (Blueprint $table) {
+ Schema::create('domains', static function (Blueprint $table) {
$table->bigInteger('id');
$table->string('namespace')->unique();
$table->smallinteger('status');
@@ -26,8 +23,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php b/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
--- a/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
+++ b/src/database/migrations/2019_09_23_110000_create_signupcodes_table.php
@@ -3,17 +3,14 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
-// phpcs:ignore
class CreateSignupCodesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('signup_codes', function (Blueprint $table) {
+ Schema::create('signup_codes', static function (Blueprint $table) {
$table->string('code', 32);
$table->string('short_code', 8);
$table->text('data');
@@ -25,8 +22,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php b/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
--- a/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
+++ b/src/database/migrations/2019_09_24_082203_create_failed_jobs_table.php
@@ -1,20 +1,17 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateFailedJobsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('failed_jobs', function (Blueprint $table) {
+ Schema::create('failed_jobs', static function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('connection');
$table->text('queue');
@@ -26,8 +23,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_11_21_110000_create_data_migrator_queues_table.php b/src/database/migrations/2019_11_21_110000_create_data_migrator_queues_table.php
--- a/src/database/migrations/2019_11_21_110000_create_data_migrator_queues_table.php
+++ b/src/database/migrations/2019_11_21_110000_create_data_migrator_queues_table.php
@@ -1,19 +1,16 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('data_migrator_queues', function (Blueprint $table) {
+ Schema::create('data_migrator_queues', static function (Blueprint $table) {
$table->string('id', 32);
$table->integer('jobs_started');
$table->integer('jobs_finished');
@@ -26,8 +23,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_12_10_095027_create_packages_table.php b/src/database/migrations/2019_12_10_095027_create_packages_table.php
--- a/src/database/migrations/2019_12_10_095027_create_packages_table.php
+++ b/src/database/migrations/2019_12_10_095027_create_packages_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePackagesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'packages',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->string('title', 36);
// were json, but mariadb
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_12_10_100355_create_package_skus_table.php b/src/database/migrations/2019_12_10_100355_create_package_skus_table.php
--- a/src/database/migrations/2019_12_10_100355_create_package_skus_table.php
+++ b/src/database/migrations/2019_12_10_100355_create_package_skus_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePackageSkusTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'package_skus',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('package_id', 36);
$table->string('sku_id', 36);
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_12_10_105428_create_plans_table.php b/src/database/migrations/2019_12_10_105428_create_plans_table.php
--- a/src/database/migrations/2019_12_10_105428_create_plans_table.php
+++ b/src/database/migrations/2019_12_10_105428_create_plans_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePlansTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->string('title', 36);
// were json, but mariadb
@@ -37,8 +34,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php b/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
--- a/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
+++ b/src/database/migrations/2019_12_10_105942_create_plan_packages_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePlanPackagesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'plan_packages',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('plan_id', 36);
$table->string('package_id', 36);
@@ -39,8 +36,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php b/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
--- a/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
+++ b/src/database/migrations/2019_12_20_130000_create_verification_codes_table.php
@@ -3,17 +3,14 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
-// phpcs:ignore
class CreateVerificationCodesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('verification_codes', function (Blueprint $table) {
+ Schema::create('verification_codes', static function (Blueprint $table) {
$table->bigInteger('user_id');
$table->string('code', 32);
$table->string('short_code', 16);
@@ -28,8 +25,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_02_11_110959_users_add_deleted_at.php b/src/database/migrations/2020_02_11_110959_users_add_deleted_at.php
--- a/src/database/migrations/2020_02_11_110959_users_add_deleted_at.php
+++ b/src/database/migrations/2020_02_11_110959_users_add_deleted_at.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class UsersAddDeletedAt extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'users',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->softDeletes();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'users',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn(['deleted_at']);
}
);
diff --git a/src/database/migrations/2020_02_11_110960_domains_add_deleted_at.php b/src/database/migrations/2020_02_11_110960_domains_add_deleted_at.php
--- a/src/database/migrations/2020_02_11_110960_domains_add_deleted_at.php
+++ b/src/database/migrations/2020_02_11_110960_domains_add_deleted_at.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class DomainsAddDeletedAt extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'domains',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->softDeletes();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'domains',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn(['deleted_at']);
}
);
diff --git a/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php b/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
--- a/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
+++ b/src/database/migrations/2020_02_26_000000_create_user_aliases_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateUserAliasesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'user_aliases',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('alias')->unique();
@@ -31,8 +28,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_02_26_085835_entitlements_add_deleted_at.php b/src/database/migrations/2020_02_26_085835_entitlements_add_deleted_at.php
--- a/src/database/migrations/2020_02_26_085835_entitlements_add_deleted_at.php
+++ b/src/database/migrations/2020_02_26_085835_entitlements_add_deleted_at.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class EntitlementsAddDeletedAt extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'entitlements',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->softDeletes();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'entitlements',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn(['deleted_at']);
}
);
diff --git a/src/database/migrations/2020_03_16_100000_create_payments.php b/src/database/migrations/2020_03_16_100000_create_payments.php
--- a/src/database/migrations/2020_03_16_100000_create_payments.php
+++ b/src/database/migrations/2020_03_16_100000_create_payments.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePayments extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 32)->primary();
$table->string('wallet_id', 36);
$table->string('status', 16);
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_03_27_134609_user_table_add_role_column.php b/src/database/migrations/2020_03_27_134609_user_table_add_role_column.php
--- a/src/database/migrations/2020_03_27_134609_user_table_add_role_column.php
+++ b/src/database/migrations/2020_03_27_134609_user_table_add_role_column.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class UserTableAddRoleColumn extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'users',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('role')->nullable();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'users',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('role');
}
);
diff --git a/src/database/migrations/2020_03_30_100000_create_discounts.php b/src/database/migrations/2020_03_30_100000_create_discounts.php
--- a/src/database/migrations/2020_03_30_100000_create_discounts.php
+++ b/src/database/migrations/2020_03_30_100000_create_discounts.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateDiscounts extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'discounts',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->tinyInteger('discount')->unsigned();
// was json, but mariadb
@@ -33,7 +30,7 @@
Schema::table(
'wallets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('discount_id', 36)->nullable();
$table->foreign('discount_id')->references('id')
@@ -44,14 +41,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'wallets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['discount_id']);
$table->dropColumn('discount_id');
}
diff --git a/src/database/migrations/2020_04_21_100000_create_wallet_settings.php b/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
--- a/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
+++ b/src/database/migrations/2020_04_21_100000_create_wallet_settings.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateWalletSettings extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'wallet_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('wallet_id');
$table->string('key');
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_04_30_115440_create_openvidu_tables.php b/src/database/migrations/2020_04_30_115440_create_openvidu_tables.php
--- a/src/database/migrations/2020_04_30_115440_create_openvidu_tables.php
+++ b/src/database/migrations/2020_04_30_115440_create_openvidu_tables.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateOpenviduTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('name', 16)->unique();
@@ -29,7 +26,7 @@
Schema::create(
'openvidu_room_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('room_id')->unsigned();
$table->string('key', 16);
@@ -44,8 +41,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_05_05_095212_create_tenants_table.php b/src/database/migrations/2020_05_05_095212_create_tenants_table.php
--- a/src/database/migrations/2020_05_05_095212_create_tenants_table.php
+++ b/src/database/migrations/2020_05_05_095212_create_tenants_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateTenantsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'tenants',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('title', 32);
$table->timestamps();
@@ -26,7 +23,7 @@
foreach (['users', 'discounts', 'domains', 'plans', 'packages', 'skus'] as $tableName) {
Schema::table(
$tableName,
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('tenant_id')->unsigned()->nullable();
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('set null');
}
@@ -37,7 +34,7 @@
foreach (['entitlements', 'skus'] as $table) {
Schema::table(
$table,
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->integer('fee')->nullable();
}
);
@@ -46,15 +43,13 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
foreach (['users', 'discounts', 'domains', 'plans', 'packages', 'skus'] as $tableName) {
Schema::table(
$tableName,
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['tenant_id']);
$table->dropColumn('tenant_id');
}
@@ -64,7 +59,7 @@
foreach (['entitlements', 'skus'] as $table) {
Schema::table(
$table,
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('fee');
}
);
diff --git a/src/database/migrations/2020_05_21_080131_create_transactions_table.php b/src/database/migrations/2020_05_21_080131_create_transactions_table.php
--- a/src/database/migrations/2020_05_21_080131_create_transactions_table.php
+++ b/src/database/migrations/2020_05_21_080131_create_transactions_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateTransactionsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'transactions',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->string('user_email')->nullable();
$table->string('object_id', 36)->index();
@@ -35,8 +32,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_06_04_115409_create_powerdns_tables.php b/src/database/migrations/2020_06_04_115409_create_powerdns_tables.php
--- a/src/database/migrations/2020_06_04_115409_create_powerdns_tables.php
+++ b/src/database/migrations/2020_06_04_115409_create_powerdns_tables.php
@@ -4,17 +4,14 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePowerDNSTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- //Drop the tables from the mysql initialization
+ // Drop the tables from the mysql initialization
Schema::dropIfExists('powerdns_domains');
Schema::dropIfExists('powerdns_records');
Schema::dropIfExists('powerdns_masters');
@@ -25,7 +22,7 @@
Schema::create(
'powerdns_domains',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 255)->unique()->index();
$table->string('master', 128)->nullable();
@@ -39,7 +36,7 @@
Schema::create(
'powerdns_records',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id')->unsigned();
$table->string('name', 255)->nullable();
@@ -57,13 +54,13 @@
$table->index('domain_id');
$table->index(['name', 'type']);
- //$table->index('ordername');
+ // $table->index('ordername');
}
);
Schema::create(
'powerdns_masters',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('ip', 64);
$table->string('nameserver', 255);
$table->string('account', 40);
@@ -76,7 +73,7 @@
Schema::create(
'powerdns_comments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id')->unsigned();
$table->string('name', 255);
@@ -95,7 +92,7 @@
Schema::create(
'powerdns_domain_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id')->unsigned();
$table->string('kind', 32);
@@ -109,7 +106,7 @@
Schema::create(
'powerdns_cryptokeys',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id')->unsigned();
$table->integer('flags');
@@ -126,7 +123,7 @@
Schema::create(
'powerdns_tsigkeys',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name', 255);
$table->string('algorithm', 50);
@@ -140,8 +137,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_06_04_140800_create_ip4nets_table.php b/src/database/migrations/2020_06_04_140800_create_ip4nets_table.php
--- a/src/database/migrations/2020_06_04_140800_create_ip4nets_table.php
+++ b/src/database/migrations/2020_06_04_140800_create_ip4nets_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateIp4netsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'ip4nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->string('net_number', 15)->index();
@@ -33,8 +30,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_06_04_140800_create_ip6nets_table.php b/src/database/migrations/2020_06_04_140800_create_ip6nets_table.php
--- a/src/database/migrations/2020_06_04_140800_create_ip6nets_table.php
+++ b/src/database/migrations/2020_06_04_140800_create_ip6nets_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateIp6netsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'ip6nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->string('net_number', 39)->index();
@@ -33,8 +30,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_06_18_150000_update_user_aliases_unique_key.php b/src/database/migrations/2020_06_18_150000_update_user_aliases_unique_key.php
--- a/src/database/migrations/2020_06_18_150000_update_user_aliases_unique_key.php
+++ b/src/database/migrations/2020_06_18_150000_update_user_aliases_unique_key.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class UpdateUserAliasesUniqueKey extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'user_aliases',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropUnique(['alias']);
$table->unique(['alias', 'user_id']);
}
@@ -25,10 +22,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
- public function down()
- {
- }
+ public function down() {}
}
diff --git a/src/database/migrations/2020_10_18_091319_create_greylist_tables.php b/src/database/migrations/2020_10_18_091319_create_greylist_tables.php
--- a/src/database/migrations/2020_10_18_091319_create_greylist_tables.php
+++ b/src/database/migrations/2020_10_18_091319_create_greylist_tables.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateGreylistTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'greylist_connect',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->charset = 'latin1';
$table->collation = 'latin1_general_ci';
$table->bigIncrements('id');
@@ -31,35 +28,29 @@
$table->bigInteger('connect_count')->unsigned()->default(1);
$table->timestamps();
- /**
- * Index for recipient request.
- */
+ // Index for recipient request.
$table->index(
[
'sender_local',
'sender_domain',
'recipient_hash',
'net_id',
- 'net_type'
+ 'net_type',
],
'ssrnn_idx'
);
- /**
- * Index for domain whitelist query.
- */
+ // Index for domain whitelist query.
$table->index(
[
'sender_domain',
'net_id',
- 'net_type'
+ 'net_type',
],
'snn_idx'
);
- /**
- * Index for updated_at
- */
+ // Index for updated_at
$table->index('updated_at');
$table->unique(
@@ -71,7 +62,7 @@
Schema::create(
'greylist_penpals',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('local_id');
$table->string('local_type', 16);
@@ -83,7 +74,7 @@
Schema::create(
'greylist_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('object_id');
$table->string('object_type', 16);
@@ -97,7 +88,7 @@
Schema::create(
'greylist_whitelist',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->charset = 'latin1';
$table->collation = 'latin1_general_ci';
$table->bigIncrements('id');
@@ -114,8 +105,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_11_20_120000_add_domains_primary_key.php b/src/database/migrations/2020_11_20_120000_add_domains_primary_key.php
--- a/src/database/migrations/2020_11_20_120000_add_domains_primary_key.php
+++ b/src/database/migrations/2020_11_20_120000_add_domains_primary_key.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class AddDomainsPrimaryKey extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'domains',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->primary('id');
}
);
@@ -24,15 +21,13 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
if (Schema::hasTable('domains')) {
Schema::table(
'domains',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropPrimary('id');
}
);
diff --git a/src/database/migrations/2020_11_20_130000_create_domain_settings_table.php b/src/database/migrations/2020_11_20_130000_create_domain_settings_table.php
--- a/src/database/migrations/2020_11_20_130000_create_domain_settings_table.php
+++ b/src/database/migrations/2020_11_20_130000_create_domain_settings_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateDomainSettingsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'domain_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('domain_id');
$table->string('key');
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_11_20_140000_extend_settings_value_column.php b/src/database/migrations/2020_11_20_140000_extend_settings_value_column.php
--- a/src/database/migrations/2020_11_20_140000_extend_settings_value_column.php
+++ b/src/database/migrations/2020_11_20_140000_extend_settings_value_column.php
@@ -1,29 +1,26 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class ExtendSettingsValueColumn extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'user_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->text('value')->change();
}
);
Schema::table(
'wallet_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->text('value')->change();
}
);
@@ -31,8 +28,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2020_12_28_140000_create_groups_table.php b/src/database/migrations/2020_12_28_140000_create_groups_table.php
--- a/src/database/migrations/2020_12_28_140000_create_groups_table.php
+++ b/src/database/migrations/2020_12_28_140000_create_groups_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateGroupsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('id');
$table->string('email')->unique();
$table->text('members')->nullable();
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_01_13_120000_create_openvidu_connections_table.php b/src/database/migrations/2021_01_13_120000_create_openvidu_connections_table.php
--- a/src/database/migrations/2021_01_13_120000_create_openvidu_connections_table.php
+++ b/src/database/migrations/2021_01_13_120000_create_openvidu_connections_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateOpenviduConnectionsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'openvidu_connections',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
// I'm not sure about the max. length of the OpenVidu identifiers
// In examples they have 14 characters, so 16 should be enough, but
// let's be on the safe side with 24.
@@ -36,8 +33,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_02_23_084157_payment_table_add_currency_columns.php b/src/database/migrations/2021_02_23_084157_payment_table_add_currency_columns.php
--- a/src/database/migrations/2021_02_23_084157_payment_table_add_currency_columns.php
+++ b/src/database/migrations/2021_02_23_084157_payment_table_add_currency_columns.php
@@ -2,22 +2,19 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class PaymentTableAddCurrencyColumns extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('currency')->nullable();
$table->integer('currency_amount')->nullable();
}
@@ -25,12 +22,12 @@
DB::table('payments')->update([
'currency' => 'CHF',
- 'currency_amount' => DB::raw("`amount`")
+ 'currency_amount' => DB::raw("`amount`"),
]);
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('currency')->nullable(false)->change();
$table->integer('currency_amount')->nullable(false)->change();
}
@@ -39,14 +36,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('currency');
$table->dropColumn('currency_amount');
}
diff --git a/src/database/migrations/2021_03_25_100000_signup_code_refactor.php b/src/database/migrations/2021_03_25_100000_signup_code_refactor.php
--- a/src/database/migrations/2021_03_25_100000_signup_code_refactor.php
+++ b/src/database/migrations/2021_03_25_100000_signup_code_refactor.php
@@ -1,23 +1,21 @@
<?php
+use App\SignupCode;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class SignupCodeRefactor extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('email');
$table->string('first_name')->nullable();
$table->string('last_name')->nullable();
@@ -32,7 +30,7 @@
}
);
- \App\SignupCode::withTrashed()->get()->each(function ($code) {
+ SignupCode::withTrashed()->get()->each(static function ($code) {
if (empty($code->data)) {
return;
}
@@ -61,7 +59,7 @@
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('data');
}
);
@@ -69,25 +67,23 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->text('data');
}
);
- DB::table('signup_codes')->get()->each(function ($code) {
+ DB::table('signup_codes')->get()->each(static function ($code) {
$data = json_encode([
- 'email' => $code->email,
- 'first_name' => $code->first_name,
- 'last_name' => $code->last_name,
- 'plan' => $code->plan,
- 'voucher' => $code->voucher,
+ 'email' => $code->email,
+ 'first_name' => $code->first_name,
+ 'last_name' => $code->last_name,
+ 'plan' => $code->plan,
+ 'voucher' => $code->voucher,
]);
DB::table('signup_codes')
@@ -97,19 +93,19 @@
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn([
- 'created_at',
- 'updated_at',
- 'deleted_at',
- 'ip_address',
- 'email',
- 'local_part',
- 'domain_part',
- 'first_name',
- 'last_name',
- 'plan',
- 'voucher',
+ 'created_at',
+ 'updated_at',
+ 'deleted_at',
+ 'ip_address',
+ 'email',
+ 'local_part',
+ 'domain_part',
+ 'first_name',
+ 'last_name',
+ 'plan',
+ 'voucher',
]);
}
);
diff --git a/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php b/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
--- a/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
+++ b/src/database/migrations/2021_03_25_144555_create_auth_attempts_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateAuthAttemptsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'auth_attempts',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->bigInteger('user_id');
$table->string('ip', 36);
@@ -40,8 +37,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_03_26_080000_create_signup_invitations_table.php b/src/database/migrations/2021_03_26_080000_create_signup_invitations_table.php
--- a/src/database/migrations/2021_03_26_080000_create_signup_invitations_table.php
+++ b/src/database/migrations/2021_03_26_080000_create_signup_invitations_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateSignupInvitationsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'signup_invitations',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36);
$table->string('email');
$table->smallInteger('status');
@@ -39,8 +36,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_04_08_150000_signup_code_headers.php b/src/database/migrations/2021_04_08_150000_signup_code_headers.php
--- a/src/database/migrations/2021_04_08_150000_signup_code_headers.php
+++ b/src/database/migrations/2021_04_08_150000_signup_code_headers.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class SignupCodeHeaders extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->text('headers')->nullable();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('headers');
}
);
diff --git a/src/database/migrations/2021_04_08_160000_expires_at_column_fix.php b/src/database/migrations/2021_04_08_160000_expires_at_column_fix.php
--- a/src/database/migrations/2021_04_08_160000_expires_at_column_fix.php
+++ b/src/database/migrations/2021_04_08_160000_expires_at_column_fix.php
@@ -3,13 +3,10 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
-// phpcs:ignore
class ExpiresAtColumnFix extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
@@ -28,8 +25,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_04_28_090011_create_oauth_tables.php b/src/database/migrations/2021_04_28_090011_create_oauth_tables.php
--- a/src/database/migrations/2021_04_28_090011_create_oauth_tables.php
+++ b/src/database/migrations/2021_04_28_090011_create_oauth_tables.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateOauthTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'oauth_clients',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->uuid('id')->primary();
$table->bigInteger('user_id')->nullable()->index();
$table->string('name');
@@ -37,7 +34,7 @@
Schema::create(
'oauth_personal_access_clients',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->uuid('client_id');
$table->timestamps();
@@ -51,7 +48,7 @@
Schema::create(
'oauth_auth_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->bigInteger('user_id')->index();
$table->uuid('client_id');
@@ -73,7 +70,7 @@
Schema::create(
'oauth_access_tokens',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->bigInteger('user_id')->nullable()->index();
$table->uuid('client_id');
@@ -97,7 +94,7 @@
Schema::create(
'oauth_refresh_tokens',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100)->index();
$table->boolean('revoked');
@@ -108,8 +105,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_05_05_134357_create_companion_apps_table.php b/src/database/migrations/2021_05_05_134357_create_companion_apps_table.php
--- a/src/database/migrations/2021_05_05_134357_create_companion_apps_table.php
+++ b/src/database/migrations/2021_05_05_134357_create_companion_apps_table.php
@@ -4,17 +4,14 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateCompanionAppsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('companion_apps', function (Blueprint $table) {
+ Schema::create('companion_apps', static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
// Seems to grow over time, no clear specification.
@@ -35,8 +32,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_05_12_150000_groups_add_tenant_id.php b/src/database/migrations/2021_05_12_150000_groups_add_tenant_id.php
--- a/src/database/migrations/2021_05_12_150000_groups_add_tenant_id.php
+++ b/src/database/migrations/2021_05_12_150000_groups_add_tenant_id.php
@@ -5,19 +5,16 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class GroupsAddTenantId extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('tenant_id')->unsigned()->nullable();
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('set null');
}
@@ -30,14 +27,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['tenant_id']);
$table->dropColumn('tenant_id');
}
diff --git a/src/database/migrations/2021_07_12_100000_create_tenant_settings_table.php b/src/database/migrations/2021_07_12_100000_create_tenant_settings_table.php
--- a/src/database/migrations/2021_07_12_100000_create_tenant_settings_table.php
+++ b/src/database/migrations/2021_07_12_100000_create_tenant_settings_table.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateTenantSettingsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'tenant_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id');
$table->string('key');
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_08_25_120000_drop_greylist_settings_table.php b/src/database/migrations/2021_08_25_120000_drop_greylist_settings_table.php
--- a/src/database/migrations/2021_08_25_120000_drop_greylist_settings_table.php
+++ b/src/database/migrations/2021_08_25_120000_drop_greylist_settings_table.php
@@ -4,13 +4,10 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class DropGreylistSettingsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
@@ -19,8 +16,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
@@ -28,7 +23,7 @@
Schema::create(
'greylist_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('object_id');
$table->string('object_type', 16);
diff --git a/src/database/migrations/2021_08_27_105020_drop_greylist_connect_index.php b/src/database/migrations/2021_08_27_105020_drop_greylist_connect_index.php
--- a/src/database/migrations/2021_08_27_105020_drop_greylist_connect_index.php
+++ b/src/database/migrations/2021_08_27_105020_drop_greylist_connect_index.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class DropGreylistConnectIndex extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'greylist_connect',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropIndex('ssrnn_idx');
}
);
@@ -24,24 +21,20 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'greylist_connect',
- function (Blueprint $table) {
- /**
- * Index for recipient request.
- */
+ static function (Blueprint $table) {
+ // Index for recipient request.
$table->index(
[
'sender_local',
'sender_domain',
'recipient_hash',
'net_id',
- 'net_type'
+ 'net_type',
],
'ssrnn_idx'
);
diff --git a/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php b/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
--- a/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
+++ b/src/database/migrations/2021_10_27_120000_extend_openvidu_rooms_session_id.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class ExtendOpenviduRoomsSessionId extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('session_id', 36)->nullable()->change();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
// $table->string('session_id', 16)->change();
}
);
diff --git a/src/database/migrations/2021_11_05_100000_create_group_settings_table.php b/src/database/migrations/2021_11_05_100000_create_group_settings_table.php
--- a/src/database/migrations/2021_11_05_100000_create_group_settings_table.php
+++ b/src/database/migrations/2021_11_05_100000_create_group_settings_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateGroupSettingsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'group_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('group_id');
$table->string('key');
@@ -34,8 +31,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_11_10_100000_add_group_name_column.php b/src/database/migrations/2021_11_10_100000_add_group_name_column.php
--- a/src/database/migrations/2021_11_10_100000_add_group_name_column.php
+++ b/src/database/migrations/2021_11_10_100000_add_group_name_column.php
@@ -2,34 +2,31 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class AddGroupNameColumn extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('name')->nullable()->after('email');
}
);
// Fill the name with the local part of the email address
DB::table('groups')->update([
- 'name' => DB::raw("SUBSTRING_INDEX(`email`, '@', 1)")
+ 'name' => DB::raw("SUBSTRING_INDEX(`email`, '@', 1)"),
]);
Schema::table(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('name')->nullable(false)->change();
}
);
@@ -37,14 +34,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'groups',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('name');
}
);
diff --git a/src/database/migrations/2021_11_16_100000_create_resources_tables.php b/src/database/migrations/2021_11_16_100000_create_resources_tables.php
--- a/src/database/migrations/2021_11_16_100000_create_resources_tables.php
+++ b/src/database/migrations/2021_11_16_100000_create_resources_tables.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateResourcesTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'resources',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->unsignedBigInteger('id');
$table->string('email')->unique();
$table->string('name');
@@ -32,7 +29,7 @@
Schema::create(
'resource_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('resource_id');
$table->string('key');
@@ -49,8 +46,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_11_25_100000_create_shared_folders_table.php b/src/database/migrations/2021_11_25_100000_create_shared_folders_table.php
--- a/src/database/migrations/2021_11_25_100000_create_shared_folders_table.php
+++ b/src/database/migrations/2021_11_25_100000_create_shared_folders_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateSharedFoldersTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'shared_folders',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->unsignedBigInteger('id');
$table->string('email')->unique();
$table->string('name');
@@ -34,7 +31,7 @@
Schema::create(
'shared_folder_settings',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('shared_folder_id');
$table->string('key');
@@ -51,8 +48,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2021_12_28_103243_create_policy_ratelimit_tables.php b/src/database/migrations/2021_12_28_103243_create_policy_ratelimit_tables.php
--- a/src/database/migrations/2021_12_28_103243_create_policy_ratelimit_tables.php
+++ b/src/database/migrations/2021_12_28_103243_create_policy_ratelimit_tables.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreatePolicyRatelimitTables extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'policy_ratelimit',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->bigInteger('owner_id');
@@ -35,7 +32,7 @@
Schema::create(
'policy_ratelimit_wl',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('whitelistable_id');
$table->string('whitelistable_type');
@@ -49,8 +46,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2022_01_03_120000_signup_codes_indices.php b/src/database/migrations/2022_01_03_120000_signup_codes_indices.php
--- a/src/database/migrations/2022_01_03_120000_signup_codes_indices.php
+++ b/src/database/migrations/2022_01_03_120000_signup_codes_indices.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class SignupCodesIndices extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->index('email');
$table->index('ip_address');
$table->index('expires_at');
@@ -26,14 +23,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropIndex('signup_codes_email_index');
$table->dropIndex('signup_codes_ip_address_index');
$table->dropIndex('signup_codes_expires_at_index');
diff --git a/src/database/migrations/2022_01_13_100000_verification_code_active_column.php b/src/database/migrations/2022_01_13_100000_verification_code_active_column.php
--- a/src/database/migrations/2022_01_13_100000_verification_code_active_column.php
+++ b/src/database/migrations/2022_01_13_100000_verification_code_active_column.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class VerificationCodeActiveColumn extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'verification_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->boolean('active')->default(true);
}
);
@@ -24,8 +21,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
@@ -35,7 +30,7 @@
Schema::table(
'verification_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('active');
}
);
diff --git a/src/database/migrations/2022_01_25_100000_create_shared_folder_aliases_table.php b/src/database/migrations/2022_01_25_100000_create_shared_folder_aliases_table.php
--- a/src/database/migrations/2022_01_25_100000_create_shared_folder_aliases_table.php
+++ b/src/database/migrations/2022_01_25_100000_create_shared_folder_aliases_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateSharedFolderAliasesTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'shared_folder_aliases',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('shared_folder_id');
$table->string('alias');
@@ -33,8 +30,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2022_02_04_100000_create_user_passwords_table.php b/src/database/migrations/2022_02_04_100000_create_user_passwords_table.php
--- a/src/database/migrations/2022_02_04_100000_create_user_passwords_table.php
+++ b/src/database/migrations/2022_02_04_100000_create_user_passwords_table.php
@@ -1,22 +1,19 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CreateUserPasswordsTable extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'user_passwords',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('password');
@@ -32,8 +29,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php b/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php
--- a/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php
+++ b/src/database/migrations/2022_03_02_100000_create_filesystem_tables.php
@@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -13,7 +12,7 @@
{
Schema::create(
'fs_items',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->bigInteger('user_id')->index();
$table->integer('type')->unsigned()->default(0);
@@ -28,7 +27,7 @@
Schema::create(
'fs_properties',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('item_id', 36);
$table->string('key')->index();
@@ -45,7 +44,7 @@
Schema::create(
'fs_chunks',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('item_id', 36);
$table->string('chunk_id', 36);
diff --git a/src/database/migrations/2022_05_13_100000_permissions_and_room_subscriptions.php b/src/database/migrations/2022_05_13_100000_permissions_and_room_subscriptions.php
--- a/src/database/migrations/2022_05_13_100000_permissions_and_room_subscriptions.php
+++ b/src/database/migrations/2022_05_13_100000_permissions_and_room_subscriptions.php
@@ -1,11 +1,14 @@
<?php
+use App\Entitlement;
+use App\Meet\Room;
+use App\Sku;
+use App\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -13,7 +16,7 @@
{
Schema::create(
'permissions',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->bigInteger('permissible_id');
$table->string('permissible_type');
@@ -28,7 +31,7 @@
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('tenant_id')->unsigned()->nullable();
$table->string('description')->nullable();
$table->softDeletes();
@@ -38,11 +41,11 @@
);
// Create the new SKUs
- $sku = \App\Sku::where('title', 'room')->first();
+ $sku = Sku::where('title', 'room')->first();
// Create the entitlement for every existing room
- foreach (\App\Meet\Room::get() as $room) {
- $user = \App\User::find($room->user_id); // @phpstan-ignore-line
+ foreach (Room::get() as $room) {
+ $user = User::find($room->user_id); // @phpstan-ignore-line
if (!$user) {
$room->forceDelete();
continue;
@@ -56,22 +59,22 @@
$wallet = $user->wallets()->first();
- \App\Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $sku->id,
- 'cost' => 0,
- 'fee' => 0,
- 'entitleable_id' => $room->id,
- 'entitleable_type' => \App\Meet\Room::class
+ Entitlement::create([
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $sku->id,
+ 'cost' => 0,
+ 'fee' => 0,
+ 'entitleable_id' => $room->id,
+ 'entitleable_type' => Room::class,
]);
}
// Remove 'meet' SKU/entitlements
- \App\Sku::where('title', 'meet')->delete();
+ Sku::where('title', 'meet')->delete();
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign('openvidu_rooms_user_id_foreign');
$table->dropColumn('user_id');
}
@@ -85,7 +88,7 @@
{
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign('openvidu_rooms_tenant_id_foreign');
$table->dropColumn('tenant_id');
$table->dropColumn('description');
@@ -96,7 +99,7 @@
);
// Set user_id back
- foreach (\App\Meet\Room::get() as $room) {
+ foreach (Room::get() as $room) {
$wallet = $room->wallet();
if (!$wallet) {
$room->forceDelete();
@@ -109,12 +112,12 @@
Schema::table(
'openvidu_rooms',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropSoftDeletes();
}
);
- \App\Entitlement::where('entitleable_type', \App\Meet\Room::class)->forceDelete();
+ Entitlement::where('entitleable_type', Room::class)->forceDelete();
Schema::dropIfExists('permissions');
}
diff --git a/src/database/migrations/2022_07_07_100000_ip_nets_optimization.php b/src/database/migrations/2022_07_07_100000_ip_nets_optimization.php
--- a/src/database/migrations/2022_07_07_100000_ip_nets_optimization.php
+++ b/src/database/migrations/2022_07_07_100000_ip_nets_optimization.php
@@ -5,8 +5,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -17,7 +16,7 @@
Schema::create(
'ip4nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->bigInteger('net_number');
@@ -33,7 +32,7 @@
Schema::create(
'ip6nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->bigInteger('net_number');
@@ -64,7 +63,7 @@
Schema::create(
'ip4nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->string('net_number', 15)->index();
@@ -80,7 +79,7 @@
Schema::create(
'ip6nets',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('rir_name', 8);
$table->string('net_number', 39)->index();
diff --git a/src/database/migrations/2022_07_19_100000_create_stats_table.php b/src/database/migrations/2022_07_19_100000_create_stats_table.php
--- a/src/database/migrations/2022_07_19_100000_create_stats_table.php
+++ b/src/database/migrations/2022_07_19_100000_create_stats_table.php
@@ -1,19 +1,16 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('stats', function (Blueprint $table) {
+ Schema::create('stats', static function (Blueprint $table) {
$table->bigIncrements('id');
$table->unsignedBigInteger('tenant_id')->nullable();
$table->integer('type')->unsigned();
@@ -30,8 +27,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2022_09_01_100000_plans_mode.php b/src/database/migrations/2022_09_01_100000_plans_mode.php
--- a/src/database/migrations/2022_09_01_100000_plans_mode.php
+++ b/src/database/migrations/2022_09_01_100000_plans_mode.php
@@ -1,21 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('mode', 32)->default('email');
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('mode');
}
);
diff --git a/src/database/migrations/2022_09_08_100000_plans_free_months.php b/src/database/migrations/2022_09_08_100000_plans_free_months.php
--- a/src/database/migrations/2022_09_08_100000_plans_free_months.php
+++ b/src/database/migrations/2022_09_08_100000_plans_free_months.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->tinyInteger('free_months')->unsigned()->default(0);
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('free_months');
}
);
diff --git a/src/database/migrations/2022_10_10_100000_signup_codes_user_id.php b/src/database/migrations/2022_10_10_100000_signup_codes_user_id.php
--- a/src/database/migrations/2022_10_10_100000_signup_codes_user_id.php
+++ b/src/database/migrations/2022_10_10_100000_signup_codes_user_id.php
@@ -2,21 +2,17 @@
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
-use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('verify_ip_address')->index()->nullable();
$table->string('submit_ip_address')->index()->nullable();
@@ -29,14 +25,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->dropColumn('user_id');
$table->dropColumn('verify_ip_address');
diff --git a/src/database/migrations/2022_11_04_120000_companion_app_uuids_oauth_client.php b/src/database/migrations/2022_11_04_120000_companion_app_uuids_oauth_client.php
--- a/src/database/migrations/2022_11_04_120000_companion_app_uuids_oauth_client.php
+++ b/src/database/migrations/2022_11_04_120000_companion_app_uuids_oauth_client.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class CompanionAppUuidsOauthClient extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::dropIfExists('companion_apps');
- Schema::create('companion_apps', function (Blueprint $table) {
+ Schema::create('companion_apps', static function (Blueprint $table) {
$table->string('id', 36);
$table->string('oauth_client_id', 36)->nullable();
$table->bigInteger('user_id');
@@ -36,20 +33,18 @@
->onUpdate('cascade');
$table->foreign('oauth_client_id')
- ->references('id')->on('oauth_clients')
- ->onDelete('set null');
+ ->references('id')->on('oauth_clients')
+ ->onDelete('set null');
});
}
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::dropIfExists('companion_apps');
- Schema::create('companion_apps', function (Blueprint $table) {
+ Schema::create('companion_apps', static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
// Seems to grow over time, no clear specification.
diff --git a/src/database/migrations/2022_11_04_130000_oauth_client_scopes.php b/src/database/migrations/2022_11_04_130000_oauth_client_scopes.php
--- a/src/database/migrations/2022_11_04_130000_oauth_client_scopes.php
+++ b/src/database/migrations/2022_11_04_130000_oauth_client_scopes.php
@@ -4,19 +4,16 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-// phpcs:ignore
class OauthClientScopes extends Migration
{
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'oauth_clients',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('allowed_scopes')->nullable();
}
);
@@ -24,14 +21,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'oauth_clients',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('allowed_scopes');
}
);
diff --git a/src/database/migrations/2022_11_14_100000_add_entitltments_entitleable_index.php b/src/database/migrations/2022_11_14_100000_add_entitltments_entitleable_index.php
--- a/src/database/migrations/2022_11_14_100000_add_entitltments_entitleable_index.php
+++ b/src/database/migrations/2022_11_14_100000_add_entitltments_entitleable_index.php
@@ -1,21 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'entitlements',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->index(['entitleable_id', 'entitleable_type']);
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'entitlements',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropIndex(['entitleable_id', 'entitleable_type']);
}
);
diff --git a/src/database/migrations/2023_02_17_100000_vat_rates_table.php b/src/database/migrations/2023_02_17_100000_vat_rates_table.php
--- a/src/database/migrations/2023_02_17_100000_vat_rates_table.php
+++ b/src/database/migrations/2023_02_17_100000_vat_rates_table.php
@@ -1,20 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
+use App\VatRate;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
- Schema::create('vat_rates', function (Blueprint $table) {
+ Schema::create('vat_rates', static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->string('country', 2);
$table->timestamp('start')->useCurrent();
@@ -25,7 +23,7 @@
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('vat_rate_id', 36)->nullable();
$table->integer('credit_amount')->nullable(); // temporarily allow null
@@ -37,7 +35,7 @@
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->integer('credit_amount')->nullable(false)->change(); // remove nullable
}
);
@@ -47,37 +45,35 @@
$countries = explode(',', strtoupper(trim($countries)));
foreach ($countries as $country) {
- $vatRate = \App\VatRate::create([
- 'start' => new DateTime('2010-01-01 00:00:00'),
- 'rate' => $rate,
- 'country' => $country,
+ $vatRate = VatRate::create([
+ 'start' => new DateTime('2010-01-01 00:00:00'),
+ 'rate' => $rate,
+ 'country' => $country,
]);
- DB::table('payments')->whereIn('wallet_id', function ($query) use ($country) {
+ DB::table('payments')->whereIn('wallet_id', static function ($query) use ($country) {
$query->select('id')
->from('wallets')
- ->whereIn('user_id', function ($query) use ($country) {
+ ->whereIn('user_id', static function ($query) use ($country) {
$query->select('user_id')
->from('user_settings')
->where('key', 'country')
->where('value', $country);
});
})
- ->update(['vat_rate_id' => $vatRate->id]);
+ ->update(['vat_rate_id' => $vatRate->id]);
}
}
}
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'payments',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['vat_rate_id']);
$table->dropColumn('vat_rate_id');
$table->dropColumn('credit_amount');
diff --git a/src/database/migrations/2023_03_01_100000_plans_months.php b/src/database/migrations/2023_03_01_100000_plans_months.php
--- a/src/database/migrations/2023_03_01_100000_plans_months.php
+++ b/src/database/migrations/2023_03_01_100000_plans_months.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->tinyInteger('months')->unsigned()->default(1);
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('months');
}
);
diff --git a/src/database/migrations/2023_03_05_100000_fs_relations_table.php b/src/database/migrations/2023_03_05_100000_fs_relations_table.php
--- a/src/database/migrations/2023_03_05_100000_fs_relations_table.php
+++ b/src/database/migrations/2023_03_05_100000_fs_relations_table.php
@@ -1,21 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up(): void
{
Schema::create(
'fs_relations',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('item_id', 36);
$table->string('related_id', 36);
@@ -31,8 +28,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down(): void
{
diff --git a/src/database/migrations/2023_04_11_100000_plan_packages_cost_default.php b/src/database/migrations/2023_04_11_100000_plan_packages_cost_default.php
--- a/src/database/migrations/2023_04_11_100000_plan_packages_cost_default.php
+++ b/src/database/migrations/2023_04_11_100000_plan_packages_cost_default.php
@@ -1,21 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'package_skus',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->integer('cost')->default(null)->nullable()->change();
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'package_skus',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->integer('cost')->default(0)->nullable()->change();
}
);
diff --git a/src/database/migrations/2023_06_06_100000_create_eventlog_table.php b/src/database/migrations/2023_06_06_100000_create_eventlog_table.php
--- a/src/database/migrations/2023_06_06_100000_create_eventlog_table.php
+++ b/src/database/migrations/2023_06_06_100000_create_eventlog_table.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'eventlog',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id', 36)->primary();
$table->string('object_id', 36);
$table->string('object_type', 36);
@@ -33,8 +30,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2023_10_18_100000_plans_hidden.php b/src/database/migrations/2023_10_18_100000_plans_hidden.php
--- a/src/database/migrations/2023_10_18_100000_plans_hidden.php
+++ b/src/database/migrations/2023_10_18_100000_plans_hidden.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->boolean('hidden')->default(false);
}
);
@@ -23,14 +20,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'plans',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('hidden');
}
);
diff --git a/src/database/migrations/2023_12_14_100000_create_signup_tokens_table.php b/src/database/migrations/2023_12_14_100000_create_signup_tokens_table.php
--- a/src/database/migrations/2023_12_14_100000_create_signup_tokens_table.php
+++ b/src/database/migrations/2023_12_14_100000_create_signup_tokens_table.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'signup_tokens',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('id')->primary();
$table->string('plan_id', 36);
$table->integer('counter')->unsigned()->default(0);
@@ -28,8 +25,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2024_06_13_100000_signup_codes_tenant_id.php b/src/database/migrations/2024_06_13_100000_signup_codes_tenant_id.php
--- a/src/database/migrations/2024_06_13_100000_signup_codes_tenant_id.php
+++ b/src/database/migrations/2024_06_13_100000_signup_codes_tenant_id.php
@@ -1,21 +1,18 @@
<?php
-use Illuminate\Support\Facades\Schema;
-use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigInteger('tenant_id')->unsigned()->nullable();
$table->foreign('tenant_id')->references('id')->on('tenants')->onDelete('set null');
}
@@ -28,14 +25,12 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropForeign(['tenant_id']);
$table->dropColumn('tenant_id');
}
diff --git a/src/database/migrations/2024_09_13_100000_create_licenses_table.php b/src/database/migrations/2024_09_13_100000_create_licenses_table.php
--- a/src/database/migrations/2024_09_13_100000_create_licenses_table.php
+++ b/src/database/migrations/2024_09_13_100000_create_licenses_table.php
@@ -4,18 +4,15 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
- *
- * @return void
*/
public function up()
{
Schema::create(
'licenses',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id')->nullable()->index();
$table->bigInteger('tenant_id')->unsigned()->nullable()->index();
@@ -35,8 +32,6 @@
/**
* Reverse the migrations.
- *
- * @return void
*/
public function down()
{
diff --git a/src/database/migrations/2024_11_07_100000_create_referrals_tables.php b/src/database/migrations/2024_11_07_100000_create_referrals_tables.php
--- a/src/database/migrations/2024_11_07_100000_create_referrals_tables.php
+++ b/src/database/migrations/2024_11_07_100000_create_referrals_tables.php
@@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -13,7 +12,7 @@
{
Schema::create(
'referral_programs',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('tenant_id')->unsigned()->nullable();
$table->boolean('active')->default(false);
@@ -34,7 +33,7 @@
Schema::create(
'referral_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('code', 16)->primary();
$table->bigInteger('user_id');
$table->bigInteger('program_id')->unsigned();
@@ -52,7 +51,7 @@
Schema::create(
'referrals',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('code', 16);
$table->bigInteger('user_id');
@@ -71,7 +70,7 @@
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->string('referral', 16)->nullable();
}
);
@@ -84,7 +83,7 @@
{
Schema::table(
'signup_codes',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->dropColumn('referral');
}
);
diff --git a/src/database/migrations/2025_03_28_100000_create_delegations_table.php b/src/database/migrations/2025_03_28_100000_create_delegations_table.php
--- a/src/database/migrations/2025_03_28_100000_create_delegations_table.php
+++ b/src/database/migrations/2025_03_28_100000_create_delegations_table.php
@@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -13,7 +12,7 @@
{
Schema::create(
'delegations',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->bigInteger('delegatee_id');
diff --git a/src/database/migrations/2025_05_02_100000_create_contacts_table.php b/src/database/migrations/2025_05_02_100000_create_contacts_table.php
--- a/src/database/migrations/2025_05_02_100000_create_contacts_table.php
+++ b/src/database/migrations/2025_05_02_100000_create_contacts_table.php
@@ -4,8 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
-return new class extends Migration
-{
+return new class extends Migration {
/**
* Run the migrations.
*/
@@ -13,7 +12,7 @@
{
Schema::create(
'contacts',
- function (Blueprint $table) {
+ static function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('user_id');
$table->string('name');
diff --git a/src/doctum.config.php b/src/doctum.config.php
--- a/src/doctum.config.php
+++ b/src/doctum.config.php
@@ -11,7 +11,6 @@
->exclude('database')
->exclude('include')
->exclude('node_modules')
- ->exclude('tests')
->exclude('vendor')
->in(__DIR__);
@@ -21,6 +20,6 @@
'build_dir' => __DIR__ . '/../docs/build/%version%/',
'cache_dir' => __DIR__ . '/cache/',
'default_opened_level' => 1,
- //'include_parent_data' => false,
+ // 'include_parent_data' => false,
]
);
diff --git a/src/package-lock.json b/src/package-lock.json
--- a/src/package-lock.json
+++ b/src/package-lock.json
@@ -3816,9 +3816,9 @@
}
},
"node_modules/caniuse-lite": {
- "version": "1.0.30001680",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz",
- "integrity": "sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==",
+ "version": "1.0.30001717",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001717.tgz",
+ "integrity": "sha512-auPpttCq6BDEG8ZAuHJIplGw6GODhjw+/11e7IjpnYCxZcW/ONgPs0KVBJ0d1bY3e2+7PRe5RCLyP+PfwVgkYw==",
"dev": true,
"funding": [
{
diff --git a/src/phpcs.xml b/src/phpcs.xml
deleted file mode 100644
--- a/src/phpcs.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0"?>
-<ruleset name="Kolab">
- <description>Custom ruleset for Kolab</description>
-
- <arg name="extensions" value="php,inc,phtml"/>
-
- <rule ref="PSR1"/>
- <rule ref="PSR12"/>
-
- <file>app/</file>
- <file>tests/</file>
- <file>database/</file>
-</ruleset>
diff --git a/src/resources/build/before.php b/src/resources/build/before.php
--- a/src/resources/build/before.php
+++ b/src/resources/build/before.php
@@ -31,7 +31,7 @@
preg_match('|([a-z]+)/ui\.php$|', $file, $matches);
$file = "{$rootDir}/resources/build/js/{$matches[1]}.json";
- $opts = JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_UNESCAPED_UNICODE;
+ $opts = \JSON_PRETTY_PRINT | \JSON_INVALID_UTF8_SUBSTITUTE | \JSON_UNESCAPED_UNICODE;
file_put_contents($file, json_encode($content, $opts));
}
@@ -45,7 +45,7 @@
$theme = $matches[1];
$file = "{$rootDir}/resources/build/js/{$theme}-{$matches[2]}.json";
- $opts = JSON_PRETTY_PRINT | JSON_INVALID_UTF8_SUBSTITUTE | JSON_UNESCAPED_UNICODE;
+ $opts = \JSON_PRETTY_PRINT | \JSON_INVALID_UTF8_SUBSTITUTE | \JSON_UNESCAPED_UNICODE;
file_put_contents($file, json_encode($content, $opts));
}
@@ -60,9 +60,9 @@
mkdir("{$rootDir}/public/themes");
}
-foreach (glob("{$rootDir}/resources/themes/*", GLOB_ONLYDIR) as $file) {
+foreach (glob("{$rootDir}/resources/themes/*", \GLOB_ONLYDIR) as $file) {
$path = explode('/', $file);
- $theme = $path[count($path)-1];
+ $theme = $path[count($path) - 1];
if (!file_exists("{$rootDir}/public/themes/{$theme}")) {
mkdir("{$rootDir}/public/themes/{$theme}");
@@ -77,7 +77,7 @@
}
foreach (glob("{$rootDir}/resources/themes/{$theme}/{$subDir}/*") as $file) {
- $filename = pathinfo($file, PATHINFO_BASENAME);
+ $filename = pathinfo($file, \PATHINFO_BASENAME);
copy($file, "{$rootDir}/public/themes/{$theme}/{$subDir}/{$filename}");
}
}
diff --git a/src/resources/countries.php b/src/resources/countries.php
--- a/src/resources/countries.php
+++ b/src/resources/countries.php
@@ -1,251 +1,253 @@
-<?php return [
- 'AF' => ['AFN','Afghanistan'],
- 'AX' => ['EUR','Aland Islands'],
- 'AL' => ['ALL','Albania'],
- 'DZ' => ['DZD','Algeria'],
- 'AS' => ['USD','American Samoa'],
- 'AD' => ['EUR','Andorra'],
- 'AO' => ['AOA','Angola'],
- 'AI' => ['XCD','Anguilla'],
- 'AG' => ['XCD','Antigua and Barbuda'],
- 'AR' => ['ARS','Argentina'],
- 'AM' => ['AMD','Armenia'],
- 'AW' => ['AWG','Aruba'],
- 'AU' => ['AUD','Australia'],
- 'AT' => ['EUR','Austria'],
- 'AZ' => ['AZN','Azerbaijan'],
- 'BS' => ['BSD','Bahamas'],
- 'BH' => ['BHD','Bahrain'],
- 'BD' => ['BDT','Bangladesh'],
- 'BB' => ['BBD','Barbados'],
- 'BY' => ['BYR','Belarus'],
- 'BE' => ['EUR','Belgium'],
- 'BZ' => ['BZD','Belize'],
- 'BJ' => ['XOF','Benin'],
- 'BM' => ['BMD','Bermuda'],
- 'BT' => ['BTN','Bhutan'],
- 'BO' => ['BOB','Bolivia'],
- 'BQ' => ['USD','Bonaire, Saint Eustatius and Saba '],
- 'BA' => ['BAM','Bosnia and Herzegovina'],
- 'BW' => ['BWP','Botswana'],
- 'BV' => ['NOK','Bouvet Island'],
- 'BR' => ['BRL','Brazil'],
- 'IO' => ['USD','British Indian Ocean Territory'],
- 'VG' => ['USD','British Virgin Islands'],
- 'BN' => ['BND','Brunei'],
- 'BG' => ['BGN','Bulgaria'],
- 'BF' => ['XOF','Burkina Faso'],
- 'BI' => ['BIF','Burundi'],
- 'KH' => ['KHR','Cambodia'],
- 'CM' => ['XAF','Cameroon'],
- 'CA' => ['CAD','Canada'],
- 'CV' => ['CVE','Cape Verde'],
- 'KY' => ['KYD','Cayman Islands'],
- 'CF' => ['XAF','Central African Republic'],
- 'TD' => ['XAF','Chad'],
- 'CL' => ['CLP','Chile'],
- 'CN' => ['CNY','China'],
- 'CX' => ['AUD','Christmas Island'],
- 'CC' => ['AUD','Cocos Islands'],
- 'CO' => ['COP','Colombia'],
- 'KM' => ['KMF','Comoros'],
- 'CK' => ['NZD','Cook Islands'],
- 'CR' => ['CRC','Costa Rica'],
- 'HR' => ['HRK','Croatia'],
- 'CU' => ['CUP','Cuba'],
- 'CW' => ['ANG','Curacao'],
- 'CY' => ['EUR','Cyprus'],
- 'CZ' => ['CZK','Czech Republic'],
- 'CD' => ['CDF','Democratic Republic of the Congo'],
- 'DK' => ['DKK','Denmark'],
- 'DJ' => ['DJF','Djibouti'],
- 'DM' => ['XCD','Dominica'],
- 'DO' => ['DOP','Dominican Republic'],
- 'TL' => ['USD','East Timor'],
- 'EC' => ['USD','Ecuador'],
- 'EG' => ['EGP','Egypt'],
- 'SV' => ['USD','El Salvador'],
- 'GQ' => ['XAF','Equatorial Guinea'],
- 'ER' => ['ERN','Eritrea'],
- 'EE' => ['EUR','Estonia'],
- 'ET' => ['ETB','Ethiopia'],
- 'FK' => ['FKP','Falkland Islands'],
- 'FO' => ['DKK','Faroe Islands'],
- 'FJ' => ['FJD','Fiji'],
- 'FI' => ['EUR','Finland'],
- 'FR' => ['EUR','France'],
- 'GF' => ['EUR','French Guiana'],
- 'PF' => ['XPF','French Polynesia'],
- 'TF' => ['EUR','French Southern Territories'],
- 'GA' => ['XAF','Gabon'],
- 'GM' => ['GMD','Gambia'],
- 'GE' => ['GEL','Georgia'],
- 'DE' => ['EUR','Germany'],
- 'GH' => ['GHS','Ghana'],
- 'GI' => ['GIP','Gibraltar'],
- 'GR' => ['EUR','Greece'],
- 'GL' => ['DKK','Greenland'],
- 'GD' => ['XCD','Grenada'],
- 'GP' => ['EUR','Guadeloupe'],
- 'GU' => ['USD','Guam'],
- 'GT' => ['GTQ','Guatemala'],
- 'GG' => ['GBP','Guernsey'],
- 'GN' => ['GNF','Guinea'],
- 'GW' => ['XOF','Guinea-Bissau'],
- 'GY' => ['GYD','Guyana'],
- 'HT' => ['HTG','Haiti'],
- 'HM' => ['AUD','Heard Island and McDonald Islands'],
- 'HN' => ['HNL','Honduras'],
- 'HK' => ['HKD','Hong Kong'],
- 'HU' => ['HUF','Hungary'],
- 'IS' => ['ISK','Iceland'],
- 'IN' => ['INR','India'],
- 'ID' => ['IDR','Indonesia'],
- 'IR' => ['IRR','Iran'],
- 'IQ' => ['IQD','Iraq'],
- 'IE' => ['EUR','Ireland'],
- 'IM' => ['GBP','Isle of Man'],
- 'IL' => ['ILS','Israel'],
- 'IT' => ['EUR','Italy'],
- 'CI' => ['XOF','Ivory Coast'],
- 'JM' => ['JMD','Jamaica'],
- 'JP' => ['JPY','Japan'],
- 'JE' => ['GBP','Jersey'],
- 'JO' => ['JOD','Jordan'],
- 'KZ' => ['KZT','Kazakhstan'],
- 'KE' => ['KES','Kenya'],
- 'KI' => ['AUD','Kiribati'],
- 'XK' => ['EUR','Kosovo'],
- 'KW' => ['KWD','Kuwait'],
- 'KG' => ['KGS','Kyrgyzstan'],
- 'LA' => ['LAK','Laos'],
- 'LV' => ['EUR','Latvia'],
- 'LB' => ['LBP','Lebanon'],
- 'LS' => ['LSL','Lesotho'],
- 'LR' => ['LRD','Liberia'],
- 'LY' => ['LYD','Libya'],
- 'LI' => ['CHF','Liechtenstein'],
- 'LT' => ['EUR','Lithuania'],
- 'LU' => ['EUR','Luxembourg'],
- 'MO' => ['MOP','Macao'],
- 'MK' => ['MKD','Macedonia'],
- 'MG' => ['MGA','Madagascar'],
- 'MW' => ['MWK','Malawi'],
- 'MY' => ['MYR','Malaysia'],
- 'MV' => ['MVR','Maldives'],
- 'ML' => ['XOF','Mali'],
- 'MT' => ['EUR','Malta'],
- 'MH' => ['USD','Marshall Islands'],
- 'MQ' => ['EUR','Martinique'],
- 'MR' => ['MRO','Mauritania'],
- 'MU' => ['MUR','Mauritius'],
- 'YT' => ['EUR','Mayotte'],
- 'MX' => ['MXN','Mexico'],
- 'FM' => ['USD','Micronesia'],
- 'MD' => ['MDL','Moldova'],
- 'MC' => ['EUR','Monaco'],
- 'MN' => ['MNT','Mongolia'],
- 'ME' => ['EUR','Montenegro'],
- 'MS' => ['XCD','Montserrat'],
- 'MA' => ['MAD','Morocco'],
- 'MZ' => ['MZN','Mozambique'],
- 'MM' => ['MMK','Myanmar'],
- 'NA' => ['NAD','Namibia'],
- 'NR' => ['AUD','Nauru'],
- 'NP' => ['NPR','Nepal'],
- 'NL' => ['EUR','Netherlands'],
- 'NC' => ['XPF','New Caledonia'],
- 'NZ' => ['NZD','New Zealand'],
- 'NI' => ['NIO','Nicaragua'],
- 'NE' => ['XOF','Niger'],
- 'NG' => ['NGN','Nigeria'],
- 'NU' => ['NZD','Niue'],
- 'NF' => ['AUD','Norfolk Island'],
- 'KP' => ['KPW','North Korea'],
- 'MP' => ['USD','Northern Mariana Islands'],
- 'NO' => ['NOK','Norway'],
- 'OM' => ['OMR','Oman'],
- 'PK' => ['PKR','Pakistan'],
- 'PW' => ['USD','Palau'],
- 'PS' => ['ILS','Palestinian Territory'],
- 'PA' => ['PAB','Panama'],
- 'PG' => ['PGK','Papua New Guinea'],
- 'PY' => ['PYG','Paraguay'],
- 'PE' => ['PEN','Peru'],
- 'PH' => ['PHP','Philippines'],
- 'PN' => ['NZD','Pitcairn'],
- 'PL' => ['PLN','Poland'],
- 'PT' => ['EUR','Portugal'],
- 'PR' => ['USD','Puerto Rico'],
- 'QA' => ['QAR','Qatar'],
- 'CG' => ['XAF','Republic of the Congo'],
- 'RE' => ['EUR','Reunion'],
- 'RO' => ['RON','Romania'],
- 'RU' => ['RUB','Russia'],
- 'RW' => ['RWF','Rwanda'],
- 'BL' => ['EUR','Saint Barthelemy'],
- 'SH' => ['SHP','Saint Helena'],
- 'KN' => ['XCD','Saint Kitts and Nevis'],
- 'LC' => ['XCD','Saint Lucia'],
- 'MF' => ['EUR','Saint Martin'],
- 'PM' => ['EUR','Saint Pierre and Miquelon'],
- 'VC' => ['XCD','Saint Vincent and the Grenadines'],
- 'WS' => ['WST','Samoa'],
- 'SM' => ['EUR','San Marino'],
- 'ST' => ['STD','Sao Tome and Principe'],
- 'SA' => ['SAR','Saudi Arabia'],
- 'SN' => ['XOF','Senegal'],
- 'RS' => ['RSD','Serbia'],
- 'SC' => ['SCR','Seychelles'],
- 'SL' => ['SLL','Sierra Leone'],
- 'SG' => ['SGD','Singapore'],
- 'SX' => ['ANG','Sint Maarten'],
- 'SK' => ['EUR','Slovakia'],
- 'SI' => ['EUR','Slovenia'],
- 'SB' => ['SBD','Solomon Islands'],
- 'SO' => ['SOS','Somalia'],
- 'ZA' => ['ZAR','South Africa'],
- 'GS' => ['GBP','South Georgia and the South Sandwich Islands'],
- 'KR' => ['KRW','South Korea'],
- 'SS' => ['SSP','South Sudan'],
- 'ES' => ['EUR','Spain'],
- 'LK' => ['LKR','Sri Lanka'],
- 'SD' => ['SDG','Sudan'],
- 'SR' => ['SRD','Suriname'],
- 'SJ' => ['NOK','Svalbard and Jan Mayen'],
- 'SZ' => ['SZL','Swaziland'],
- 'SE' => ['SEK','Sweden'],
- 'CH' => ['CHF','Switzerland'],
- 'SY' => ['SYP','Syria'],
- 'TW' => ['TWD','Taiwan'],
- 'TJ' => ['TJS','Tajikistan'],
- 'TZ' => ['TZS','Tanzania'],
- 'TH' => ['THB','Thailand'],
- 'TG' => ['XOF','Togo'],
- 'TK' => ['NZD','Tokelau'],
- 'TO' => ['TOP','Tonga'],
- 'TT' => ['TTD','Trinidad and Tobago'],
- 'TN' => ['TND','Tunisia'],
- 'TR' => ['TRY','Turkey'],
- 'TM' => ['TMT','Turkmenistan'],
- 'TC' => ['USD','Turks and Caicos Islands'],
- 'TV' => ['AUD','Tuvalu'],
- 'VI' => ['USD','U.S. Virgin Islands'],
- 'UG' => ['UGX','Uganda'],
- 'UA' => ['UAH','Ukraine'],
- 'AE' => ['AED','United Arab Emirates'],
- 'GB' => ['GBP','United Kingdom'],
- 'US' => ['USD','United States'],
- 'UM' => ['USD','United States Minor Outlying Islands'],
- 'UY' => ['UYU','Uruguay'],
- 'UZ' => ['UZS','Uzbekistan'],
- 'VU' => ['VUV','Vanuatu'],
- 'VA' => ['EUR','Vatican'],
- 'VE' => ['VEF','Venezuela'],
- 'VN' => ['VND','Vietnam'],
- 'WF' => ['XPF','Wallis and Futuna'],
- 'EH' => ['MAD','Western Sahara'],
- 'YE' => ['YER','Yemen'],
- 'ZM' => ['ZMK','Zambia'],
- 'ZW' => ['ZWL','Zimbabwe'],
+<?php
+
+return [
+ 'AF' => ['AFN', 'Afghanistan'],
+ 'AX' => ['EUR', 'Aland Islands'],
+ 'AL' => ['ALL', 'Albania'],
+ 'DZ' => ['DZD', 'Algeria'],
+ 'AS' => ['USD', 'American Samoa'],
+ 'AD' => ['EUR', 'Andorra'],
+ 'AO' => ['AOA', 'Angola'],
+ 'AI' => ['XCD', 'Anguilla'],
+ 'AG' => ['XCD', 'Antigua and Barbuda'],
+ 'AR' => ['ARS', 'Argentina'],
+ 'AM' => ['AMD', 'Armenia'],
+ 'AW' => ['AWG', 'Aruba'],
+ 'AU' => ['AUD', 'Australia'],
+ 'AT' => ['EUR', 'Austria'],
+ 'AZ' => ['AZN', 'Azerbaijan'],
+ 'BS' => ['BSD', 'Bahamas'],
+ 'BH' => ['BHD', 'Bahrain'],
+ 'BD' => ['BDT', 'Bangladesh'],
+ 'BB' => ['BBD', 'Barbados'],
+ 'BY' => ['BYR', 'Belarus'],
+ 'BE' => ['EUR', 'Belgium'],
+ 'BZ' => ['BZD', 'Belize'],
+ 'BJ' => ['XOF', 'Benin'],
+ 'BM' => ['BMD', 'Bermuda'],
+ 'BT' => ['BTN', 'Bhutan'],
+ 'BO' => ['BOB', 'Bolivia'],
+ 'BQ' => ['USD', 'Bonaire, Saint Eustatius and Saba '],
+ 'BA' => ['BAM', 'Bosnia and Herzegovina'],
+ 'BW' => ['BWP', 'Botswana'],
+ 'BV' => ['NOK', 'Bouvet Island'],
+ 'BR' => ['BRL', 'Brazil'],
+ 'IO' => ['USD', 'British Indian Ocean Territory'],
+ 'VG' => ['USD', 'British Virgin Islands'],
+ 'BN' => ['BND', 'Brunei'],
+ 'BG' => ['BGN', 'Bulgaria'],
+ 'BF' => ['XOF', 'Burkina Faso'],
+ 'BI' => ['BIF', 'Burundi'],
+ 'KH' => ['KHR', 'Cambodia'],
+ 'CM' => ['XAF', 'Cameroon'],
+ 'CA' => ['CAD', 'Canada'],
+ 'CV' => ['CVE', 'Cape Verde'],
+ 'KY' => ['KYD', 'Cayman Islands'],
+ 'CF' => ['XAF', 'Central African Republic'],
+ 'TD' => ['XAF', 'Chad'],
+ 'CL' => ['CLP', 'Chile'],
+ 'CN' => ['CNY', 'China'],
+ 'CX' => ['AUD', 'Christmas Island'],
+ 'CC' => ['AUD', 'Cocos Islands'],
+ 'CO' => ['COP', 'Colombia'],
+ 'KM' => ['KMF', 'Comoros'],
+ 'CK' => ['NZD', 'Cook Islands'],
+ 'CR' => ['CRC', 'Costa Rica'],
+ 'HR' => ['HRK', 'Croatia'],
+ 'CU' => ['CUP', 'Cuba'],
+ 'CW' => ['ANG', 'Curacao'],
+ 'CY' => ['EUR', 'Cyprus'],
+ 'CZ' => ['CZK', 'Czech Republic'],
+ 'CD' => ['CDF', 'Democratic Republic of the Congo'],
+ 'DK' => ['DKK', 'Denmark'],
+ 'DJ' => ['DJF', 'Djibouti'],
+ 'DM' => ['XCD', 'Dominica'],
+ 'DO' => ['DOP', 'Dominican Republic'],
+ 'TL' => ['USD', 'East Timor'],
+ 'EC' => ['USD', 'Ecuador'],
+ 'EG' => ['EGP', 'Egypt'],
+ 'SV' => ['USD', 'El Salvador'],
+ 'GQ' => ['XAF', 'Equatorial Guinea'],
+ 'ER' => ['ERN', 'Eritrea'],
+ 'EE' => ['EUR', 'Estonia'],
+ 'ET' => ['ETB', 'Ethiopia'],
+ 'FK' => ['FKP', 'Falkland Islands'],
+ 'FO' => ['DKK', 'Faroe Islands'],
+ 'FJ' => ['FJD', 'Fiji'],
+ 'FI' => ['EUR', 'Finland'],
+ 'FR' => ['EUR', 'France'],
+ 'GF' => ['EUR', 'French Guiana'],
+ 'PF' => ['XPF', 'French Polynesia'],
+ 'TF' => ['EUR', 'French Southern Territories'],
+ 'GA' => ['XAF', 'Gabon'],
+ 'GM' => ['GMD', 'Gambia'],
+ 'GE' => ['GEL', 'Georgia'],
+ 'DE' => ['EUR', 'Germany'],
+ 'GH' => ['GHS', 'Ghana'],
+ 'GI' => ['GIP', 'Gibraltar'],
+ 'GR' => ['EUR', 'Greece'],
+ 'GL' => ['DKK', 'Greenland'],
+ 'GD' => ['XCD', 'Grenada'],
+ 'GP' => ['EUR', 'Guadeloupe'],
+ 'GU' => ['USD', 'Guam'],
+ 'GT' => ['GTQ', 'Guatemala'],
+ 'GG' => ['GBP', 'Guernsey'],
+ 'GN' => ['GNF', 'Guinea'],
+ 'GW' => ['XOF', 'Guinea-Bissau'],
+ 'GY' => ['GYD', 'Guyana'],
+ 'HT' => ['HTG', 'Haiti'],
+ 'HM' => ['AUD', 'Heard Island and McDonald Islands'],
+ 'HN' => ['HNL', 'Honduras'],
+ 'HK' => ['HKD', 'Hong Kong'],
+ 'HU' => ['HUF', 'Hungary'],
+ 'IS' => ['ISK', 'Iceland'],
+ 'IN' => ['INR', 'India'],
+ 'ID' => ['IDR', 'Indonesia'],
+ 'IR' => ['IRR', 'Iran'],
+ 'IQ' => ['IQD', 'Iraq'],
+ 'IE' => ['EUR', 'Ireland'],
+ 'IM' => ['GBP', 'Isle of Man'],
+ 'IL' => ['ILS', 'Israel'],
+ 'IT' => ['EUR', 'Italy'],
+ 'CI' => ['XOF', 'Ivory Coast'],
+ 'JM' => ['JMD', 'Jamaica'],
+ 'JP' => ['JPY', 'Japan'],
+ 'JE' => ['GBP', 'Jersey'],
+ 'JO' => ['JOD', 'Jordan'],
+ 'KZ' => ['KZT', 'Kazakhstan'],
+ 'KE' => ['KES', 'Kenya'],
+ 'KI' => ['AUD', 'Kiribati'],
+ 'XK' => ['EUR', 'Kosovo'],
+ 'KW' => ['KWD', 'Kuwait'],
+ 'KG' => ['KGS', 'Kyrgyzstan'],
+ 'LA' => ['LAK', 'Laos'],
+ 'LV' => ['EUR', 'Latvia'],
+ 'LB' => ['LBP', 'Lebanon'],
+ 'LS' => ['LSL', 'Lesotho'],
+ 'LR' => ['LRD', 'Liberia'],
+ 'LY' => ['LYD', 'Libya'],
+ 'LI' => ['CHF', 'Liechtenstein'],
+ 'LT' => ['EUR', 'Lithuania'],
+ 'LU' => ['EUR', 'Luxembourg'],
+ 'MO' => ['MOP', 'Macao'],
+ 'MK' => ['MKD', 'Macedonia'],
+ 'MG' => ['MGA', 'Madagascar'],
+ 'MW' => ['MWK', 'Malawi'],
+ 'MY' => ['MYR', 'Malaysia'],
+ 'MV' => ['MVR', 'Maldives'],
+ 'ML' => ['XOF', 'Mali'],
+ 'MT' => ['EUR', 'Malta'],
+ 'MH' => ['USD', 'Marshall Islands'],
+ 'MQ' => ['EUR', 'Martinique'],
+ 'MR' => ['MRO', 'Mauritania'],
+ 'MU' => ['MUR', 'Mauritius'],
+ 'YT' => ['EUR', 'Mayotte'],
+ 'MX' => ['MXN', 'Mexico'],
+ 'FM' => ['USD', 'Micronesia'],
+ 'MD' => ['MDL', 'Moldova'],
+ 'MC' => ['EUR', 'Monaco'],
+ 'MN' => ['MNT', 'Mongolia'],
+ 'ME' => ['EUR', 'Montenegro'],
+ 'MS' => ['XCD', 'Montserrat'],
+ 'MA' => ['MAD', 'Morocco'],
+ 'MZ' => ['MZN', 'Mozambique'],
+ 'MM' => ['MMK', 'Myanmar'],
+ 'NA' => ['NAD', 'Namibia'],
+ 'NR' => ['AUD', 'Nauru'],
+ 'NP' => ['NPR', 'Nepal'],
+ 'NL' => ['EUR', 'Netherlands'],
+ 'NC' => ['XPF', 'New Caledonia'],
+ 'NZ' => ['NZD', 'New Zealand'],
+ 'NI' => ['NIO', 'Nicaragua'],
+ 'NE' => ['XOF', 'Niger'],
+ 'NG' => ['NGN', 'Nigeria'],
+ 'NU' => ['NZD', 'Niue'],
+ 'NF' => ['AUD', 'Norfolk Island'],
+ 'KP' => ['KPW', 'North Korea'],
+ 'MP' => ['USD', 'Northern Mariana Islands'],
+ 'NO' => ['NOK', 'Norway'],
+ 'OM' => ['OMR', 'Oman'],
+ 'PK' => ['PKR', 'Pakistan'],
+ 'PW' => ['USD', 'Palau'],
+ 'PS' => ['ILS', 'Palestinian Territory'],
+ 'PA' => ['PAB', 'Panama'],
+ 'PG' => ['PGK', 'Papua New Guinea'],
+ 'PY' => ['PYG', 'Paraguay'],
+ 'PE' => ['PEN', 'Peru'],
+ 'PH' => ['PHP', 'Philippines'],
+ 'PN' => ['NZD', 'Pitcairn'],
+ 'PL' => ['PLN', 'Poland'],
+ 'PT' => ['EUR', 'Portugal'],
+ 'PR' => ['USD', 'Puerto Rico'],
+ 'QA' => ['QAR', 'Qatar'],
+ 'CG' => ['XAF', 'Republic of the Congo'],
+ 'RE' => ['EUR', 'Reunion'],
+ 'RO' => ['RON', 'Romania'],
+ 'RU' => ['RUB', 'Russia'],
+ 'RW' => ['RWF', 'Rwanda'],
+ 'BL' => ['EUR', 'Saint Barthelemy'],
+ 'SH' => ['SHP', 'Saint Helena'],
+ 'KN' => ['XCD', 'Saint Kitts and Nevis'],
+ 'LC' => ['XCD', 'Saint Lucia'],
+ 'MF' => ['EUR', 'Saint Martin'],
+ 'PM' => ['EUR', 'Saint Pierre and Miquelon'],
+ 'VC' => ['XCD', 'Saint Vincent and the Grenadines'],
+ 'WS' => ['WST', 'Samoa'],
+ 'SM' => ['EUR', 'San Marino'],
+ 'ST' => ['STD', 'Sao Tome and Principe'],
+ 'SA' => ['SAR', 'Saudi Arabia'],
+ 'SN' => ['XOF', 'Senegal'],
+ 'RS' => ['RSD', 'Serbia'],
+ 'SC' => ['SCR', 'Seychelles'],
+ 'SL' => ['SLL', 'Sierra Leone'],
+ 'SG' => ['SGD', 'Singapore'],
+ 'SX' => ['ANG', 'Sint Maarten'],
+ 'SK' => ['EUR', 'Slovakia'],
+ 'SI' => ['EUR', 'Slovenia'],
+ 'SB' => ['SBD', 'Solomon Islands'],
+ 'SO' => ['SOS', 'Somalia'],
+ 'ZA' => ['ZAR', 'South Africa'],
+ 'GS' => ['GBP', 'South Georgia and the South Sandwich Islands'],
+ 'KR' => ['KRW', 'South Korea'],
+ 'SS' => ['SSP', 'South Sudan'],
+ 'ES' => ['EUR', 'Spain'],
+ 'LK' => ['LKR', 'Sri Lanka'],
+ 'SD' => ['SDG', 'Sudan'],
+ 'SR' => ['SRD', 'Suriname'],
+ 'SJ' => ['NOK', 'Svalbard and Jan Mayen'],
+ 'SZ' => ['SZL', 'Swaziland'],
+ 'SE' => ['SEK', 'Sweden'],
+ 'CH' => ['CHF', 'Switzerland'],
+ 'SY' => ['SYP', 'Syria'],
+ 'TW' => ['TWD', 'Taiwan'],
+ 'TJ' => ['TJS', 'Tajikistan'],
+ 'TZ' => ['TZS', 'Tanzania'],
+ 'TH' => ['THB', 'Thailand'],
+ 'TG' => ['XOF', 'Togo'],
+ 'TK' => ['NZD', 'Tokelau'],
+ 'TO' => ['TOP', 'Tonga'],
+ 'TT' => ['TTD', 'Trinidad and Tobago'],
+ 'TN' => ['TND', 'Tunisia'],
+ 'TR' => ['TRY', 'Turkey'],
+ 'TM' => ['TMT', 'Turkmenistan'],
+ 'TC' => ['USD', 'Turks and Caicos Islands'],
+ 'TV' => ['AUD', 'Tuvalu'],
+ 'VI' => ['USD', 'U.S. Virgin Islands'],
+ 'UG' => ['UGX', 'Uganda'],
+ 'UA' => ['UAH', 'Ukraine'],
+ 'AE' => ['AED', 'United Arab Emirates'],
+ 'GB' => ['GBP', 'United Kingdom'],
+ 'US' => ['USD', 'United States'],
+ 'UM' => ['USD', 'United States Minor Outlying Islands'],
+ 'UY' => ['UYU', 'Uruguay'],
+ 'UZ' => ['UZS', 'Uzbekistan'],
+ 'VU' => ['VUV', 'Vanuatu'],
+ 'VA' => ['EUR', 'Vatican'],
+ 'VE' => ['VEF', 'Venezuela'],
+ 'VN' => ['VND', 'Vietnam'],
+ 'WF' => ['XPF', 'Wallis and Futuna'],
+ 'EH' => ['MAD', 'Western Sahara'],
+ 'YE' => ['YER', 'Yemen'],
+ 'ZM' => ['ZMK', 'Zambia'],
+ 'ZW' => ['ZWL', 'Zimbabwe'],
];
diff --git a/src/resources/exchangerates-CHF.php b/src/resources/exchangerates-CHF.php
--- a/src/resources/exchangerates-CHF.php
+++ b/src/resources/exchangerates-CHF.php
@@ -1,172 +1,174 @@
-<?php return [
- 'AED' => '3.9552959825289',
- 'AFN' => '83.613671484215',
- 'ALL' => '111.47078618895',
- 'AMD' => '568.26008190657',
- 'ANG' => '1.9326009913646',
- 'AOA' => '674.30453178322',
- 'ARS' => '98.608363602295',
- 'AUD' => '1.4005248654184',
- 'AWG' => '1.9383622346732',
- 'AZN' => '1.8315423225241',
- 'BAM' => '1.765440939718',
- 'BBD' => '2.1537358163036',
- 'BDT' => '91.161248046831',
- 'BGN' => '1.76640258276',
- 'BHD' => '0.40598781631649',
- 'BIF' => '2095.7472160272',
- 'BMD' => '1.0768679081518',
- 'BND' => '1.4428166987753',
- 'BOB' => '7.4343600550926',
- 'BRL' => '5.9304203338506',
- 'BSD' => '1.0768679081518',
- 'BTC' => '1.9792923685602E-5',
- 'BTN' => '77.837962608992',
- 'BWP' => '11.786340792079',
- 'BYN' => '2.7980743448066',
- 'BZD' => '2.1702905066556',
- 'CAD' => '1.3518138224611',
- 'CDF' => '2116.9551990644',
- 'CHF' => '1',
- 'CLF' => '0.027974874517967',
- 'CLP' => '771.89865273056',
- 'CNH' => '7.0074023900006',
- 'CNY' => '7.0104100820681',
- 'COP' => '3842.7175763149',
- 'CRC' => '657.98680298379',
- 'CUC' => '1.0768679081518',
- 'CUP' => '27.729348634908',
- 'CVE' => '61.047641713125',
- 'CZK' => '23.665033775962',
- 'DJF' => '191.67469005049',
- 'DKK' => '6.7297783052037',
- 'DOP' => '61.257419889104',
- 'DZD' => '143.75354477994',
- 'EGP' => '16.95528521385',
- 'ERN' => '16.154426088633',
- 'ETB' => '44.007619917318',
- 'EUR' => '0.90503424978382',
- 'FJD' => '2.1941722062547',
- 'FKP' => '0.77972343878383',
- 'GBP' => '0.77972343878383',
- 'GEL' => '3.5805857946047',
- 'GGP' => '0.77972343878383',
- 'GHS' => '6.1747045882111',
- 'GIP' => '0.77972343878383',
- 'GMD' => '55.189480292779',
- 'GNF' => '10817.922694883',
- 'GTQ' => '8.3118318707672',
- 'GYD' => '225.03202066725',
- 'HKD' => '8.3636130641307',
- 'HNL' => '25.899206240665',
- 'HRK' => '6.85609491083',
- 'HTG' => '85.509264833048',
- 'HUF' => '331.7893366386',
- 'IDR' => '15495.725407298',
- 'ILS' => '3.5472890388846',
- 'IMP' => '0.77972343878383',
- 'INR' => '77.954048969491',
- 'IQD' => '1570.6716338994',
- 'IRR' => '45341.523272731',
- 'ISK' => '135.22230322662',
- 'JEP' => '0.77972343878383',
- 'JMD' => '157.70066841191',
- 'JOD' => '0.76349934687961',
- 'JPY' => '117.11369248314',
- 'KES' => '118.29393971047',
- 'KGS' => '91.318753977681',
- 'KHR' => '4376.275274359',
- 'KMF' => '444.07379452714',
- 'KPW' => '969.1811173366',
- 'KRW' => '1215.4069376138',
- 'KWD' => '0.32537563844806',
- 'KYD' => '0.89714942296033',
- 'KZT' => '453.27712011062',
- 'LAK' => '10084.767400839',
- 'LBP' => '1627.9546875522',
- 'LKR' => '213.44889346438',
- 'LRD' => '186.83658529494',
- 'LSL' => '15.830499914389',
- 'LYD' => '4.8516237552753',
- 'MAD' => '9.6543512463131',
- 'MDL' => '19.238468090789',
- 'MGA' => '4077.6026098971',
- 'MKD' => '55.639268634391',
- 'MMK' => '1518.1264813664',
- 'MNT' => '3063.4631479649',
- 'MOP' => '8.6120551054846',
- 'MRO' => '384.44165798891',
- 'MRU' => '38.706188436808',
- 'MUR' => '43.397775621649',
- 'MVR' => '16.648377860027',
- 'MWK' => '845.13715851173',
- 'MXN' => '22.260479270831',
- 'MYR' => '4.4366957815853',
- 'MZN' => '77.618485083764',
- 'NAD' => '15.851495607994',
- 'NGN' => '443.32165505983',
- 'NIO' => '37.576054334447',
- 'NOK' => '9.1987650478829',
- 'NPR' => '124.54219760741',
- 'NZD' => '1.5235527164531',
- 'OMR' => '0.41463183501522',
- 'PAB' => '1.0768679081518',
- 'PEN' => '3.9984923849286',
- 'PGK' => '3.7984060201224',
- 'PHP' => '52.354625524569',
- 'PKR' => '167.28288781513',
- 'PLN' => '4.1605933111427',
- 'PYG' => '7037.5479933105',
- 'QAR' => '3.9208760535806',
- 'RON' => '4.4244625621487',
- 'RSD' => '106.13422512354',
- 'RUB' => '81.443654502008',
- 'RWF' => '1070.2236170055',
- 'SAR' => '4.0385831002812',
- 'SBD' => '8.5811651495393',
- 'SCR' => '22.836425918488',
- 'SDG' => '409.74823905175',
- 'SEK' => '9.2106892062299',
- 'SGD' => '1.4442252419991',
- 'SHP' => '0.77972343878383',
- 'SLL' => '11009.305450352',
- 'SOS' => '622.83776231156',
- 'SRD' => '15.24198837198',
- 'SSP' => '140.27281371585',
- 'STD' => '22204.04937224',
- 'STN' => '22.291165698742',
- 'SVC' => '9.4201120157998',
- 'SYP' => '1086.8852521863',
- 'SZL' => '15.823320436045',
- 'THB' => '33.332123292761',
- 'TJS' => '12.273947657758',
- 'TMT' => '3.7690376785312',
- 'TND' => '2.9457721627492',
- 'TOP' => '2.4455788649597',
- 'TRY' => '8.3189327377536',
- 'TTD' => '7.3114183534905',
- 'TWD' => '30.643246584444',
- 'TZS' => '2497.256679004',
- 'UAH' => '29.808460735781',
- 'UGX' => '3945.9795987375',
- 'USD' => '1.0768679081518',
- 'UYU' => '47.707876965688',
- 'UZS' => '11308.539064999',
- 'VES' => '1941046.2073111',
- 'VND' => '24912.524365752',
- 'VUV' => '116.88367026735',
- 'WST' => '2.7063122766172',
- 'XAF' => '593.66326771259',
- 'XAG' => '0.042055320858178',
- 'XAU' => '0.0006191236664337',
- 'XCD' => '2.9102893651756',
- 'XDR' => '0.75382584246069',
- 'XOF' => '593.66326771259',
- 'XPD' => '0.00041475567482466',
- 'XPF' => '107.99926234548',
- 'XPT' => '0.00091222557367446',
- 'YER' => '269.64770697132',
- 'ZAR' => '15.946586274888',
- 'ZMW' => '23.740867890922',
- 'ZWL' => '346.75146642487',
+<?php
+
+return [
+ 'AED' => '3.9552959825289',
+ 'AFN' => '83.613671484215',
+ 'ALL' => '111.47078618895',
+ 'AMD' => '568.26008190657',
+ 'ANG' => '1.9326009913646',
+ 'AOA' => '674.30453178322',
+ 'ARS' => '98.608363602295',
+ 'AUD' => '1.4005248654184',
+ 'AWG' => '1.9383622346732',
+ 'AZN' => '1.8315423225241',
+ 'BAM' => '1.765440939718',
+ 'BBD' => '2.1537358163036',
+ 'BDT' => '91.161248046831',
+ 'BGN' => '1.76640258276',
+ 'BHD' => '0.40598781631649',
+ 'BIF' => '2095.7472160272',
+ 'BMD' => '1.0768679081518',
+ 'BND' => '1.4428166987753',
+ 'BOB' => '7.4343600550926',
+ 'BRL' => '5.9304203338506',
+ 'BSD' => '1.0768679081518',
+ 'BTC' => '1.9792923685602E-5',
+ 'BTN' => '77.837962608992',
+ 'BWP' => '11.786340792079',
+ 'BYN' => '2.7980743448066',
+ 'BZD' => '2.1702905066556',
+ 'CAD' => '1.3518138224611',
+ 'CDF' => '2116.9551990644',
+ 'CHF' => '1',
+ 'CLF' => '0.027974874517967',
+ 'CLP' => '771.89865273056',
+ 'CNH' => '7.0074023900006',
+ 'CNY' => '7.0104100820681',
+ 'COP' => '3842.7175763149',
+ 'CRC' => '657.98680298379',
+ 'CUC' => '1.0768679081518',
+ 'CUP' => '27.729348634908',
+ 'CVE' => '61.047641713125',
+ 'CZK' => '23.665033775962',
+ 'DJF' => '191.67469005049',
+ 'DKK' => '6.7297783052037',
+ 'DOP' => '61.257419889104',
+ 'DZD' => '143.75354477994',
+ 'EGP' => '16.95528521385',
+ 'ERN' => '16.154426088633',
+ 'ETB' => '44.007619917318',
+ 'EUR' => '0.90503424978382',
+ 'FJD' => '2.1941722062547',
+ 'FKP' => '0.77972343878383',
+ 'GBP' => '0.77972343878383',
+ 'GEL' => '3.5805857946047',
+ 'GGP' => '0.77972343878383',
+ 'GHS' => '6.1747045882111',
+ 'GIP' => '0.77972343878383',
+ 'GMD' => '55.189480292779',
+ 'GNF' => '10817.922694883',
+ 'GTQ' => '8.3118318707672',
+ 'GYD' => '225.03202066725',
+ 'HKD' => '8.3636130641307',
+ 'HNL' => '25.899206240665',
+ 'HRK' => '6.85609491083',
+ 'HTG' => '85.509264833048',
+ 'HUF' => '331.7893366386',
+ 'IDR' => '15495.725407298',
+ 'ILS' => '3.5472890388846',
+ 'IMP' => '0.77972343878383',
+ 'INR' => '77.954048969491',
+ 'IQD' => '1570.6716338994',
+ 'IRR' => '45341.523272731',
+ 'ISK' => '135.22230322662',
+ 'JEP' => '0.77972343878383',
+ 'JMD' => '157.70066841191',
+ 'JOD' => '0.76349934687961',
+ 'JPY' => '117.11369248314',
+ 'KES' => '118.29393971047',
+ 'KGS' => '91.318753977681',
+ 'KHR' => '4376.275274359',
+ 'KMF' => '444.07379452714',
+ 'KPW' => '969.1811173366',
+ 'KRW' => '1215.4069376138',
+ 'KWD' => '0.32537563844806',
+ 'KYD' => '0.89714942296033',
+ 'KZT' => '453.27712011062',
+ 'LAK' => '10084.767400839',
+ 'LBP' => '1627.9546875522',
+ 'LKR' => '213.44889346438',
+ 'LRD' => '186.83658529494',
+ 'LSL' => '15.830499914389',
+ 'LYD' => '4.8516237552753',
+ 'MAD' => '9.6543512463131',
+ 'MDL' => '19.238468090789',
+ 'MGA' => '4077.6026098971',
+ 'MKD' => '55.639268634391',
+ 'MMK' => '1518.1264813664',
+ 'MNT' => '3063.4631479649',
+ 'MOP' => '8.6120551054846',
+ 'MRO' => '384.44165798891',
+ 'MRU' => '38.706188436808',
+ 'MUR' => '43.397775621649',
+ 'MVR' => '16.648377860027',
+ 'MWK' => '845.13715851173',
+ 'MXN' => '22.260479270831',
+ 'MYR' => '4.4366957815853',
+ 'MZN' => '77.618485083764',
+ 'NAD' => '15.851495607994',
+ 'NGN' => '443.32165505983',
+ 'NIO' => '37.576054334447',
+ 'NOK' => '9.1987650478829',
+ 'NPR' => '124.54219760741',
+ 'NZD' => '1.5235527164531',
+ 'OMR' => '0.41463183501522',
+ 'PAB' => '1.0768679081518',
+ 'PEN' => '3.9984923849286',
+ 'PGK' => '3.7984060201224',
+ 'PHP' => '52.354625524569',
+ 'PKR' => '167.28288781513',
+ 'PLN' => '4.1605933111427',
+ 'PYG' => '7037.5479933105',
+ 'QAR' => '3.9208760535806',
+ 'RON' => '4.4244625621487',
+ 'RSD' => '106.13422512354',
+ 'RUB' => '81.443654502008',
+ 'RWF' => '1070.2236170055',
+ 'SAR' => '4.0385831002812',
+ 'SBD' => '8.5811651495393',
+ 'SCR' => '22.836425918488',
+ 'SDG' => '409.74823905175',
+ 'SEK' => '9.2106892062299',
+ 'SGD' => '1.4442252419991',
+ 'SHP' => '0.77972343878383',
+ 'SLL' => '11009.305450352',
+ 'SOS' => '622.83776231156',
+ 'SRD' => '15.24198837198',
+ 'SSP' => '140.27281371585',
+ 'STD' => '22204.04937224',
+ 'STN' => '22.291165698742',
+ 'SVC' => '9.4201120157998',
+ 'SYP' => '1086.8852521863',
+ 'SZL' => '15.823320436045',
+ 'THB' => '33.332123292761',
+ 'TJS' => '12.273947657758',
+ 'TMT' => '3.7690376785312',
+ 'TND' => '2.9457721627492',
+ 'TOP' => '2.4455788649597',
+ 'TRY' => '8.3189327377536',
+ 'TTD' => '7.3114183534905',
+ 'TWD' => '30.643246584444',
+ 'TZS' => '2497.256679004',
+ 'UAH' => '29.808460735781',
+ 'UGX' => '3945.9795987375',
+ 'USD' => '1.0768679081518',
+ 'UYU' => '47.707876965688',
+ 'UZS' => '11308.539064999',
+ 'VES' => '1941046.2073111',
+ 'VND' => '24912.524365752',
+ 'VUV' => '116.88367026735',
+ 'WST' => '2.7063122766172',
+ 'XAF' => '593.66326771259',
+ 'XAG' => '0.042055320858178',
+ 'XAU' => '0.0006191236664337',
+ 'XCD' => '2.9102893651756',
+ 'XDR' => '0.75382584246069',
+ 'XOF' => '593.66326771259',
+ 'XPD' => '0.00041475567482466',
+ 'XPF' => '107.99926234548',
+ 'XPT' => '0.00091222557367446',
+ 'YER' => '269.64770697132',
+ 'ZAR' => '15.946586274888',
+ 'ZMW' => '23.740867890922',
+ 'ZWL' => '346.75146642487',
];
diff --git a/src/resources/lang/de/ui.php b/src/resources/lang/de/ui.php
--- a/src/resources/lang/de/ui.php
+++ b/src/resources/lang/de/ui.php
@@ -1,7 +1,6 @@
<?php
return [
-
'btn' => [
'cancel' => "Stornieren",
'save' => "Speichern",
@@ -26,5 +25,4 @@
'signup' => "Signup",
'toggle' => "Navigation umschalten",
],
-
];
diff --git a/src/resources/lang/en/app.php b/src/resources/lang/en/app.php
--- a/src/resources/lang/en/app.php
+++ b/src/resources/lang/en/app.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Application Language Lines
@@ -177,5 +176,4 @@
'wallet-notice-trial-end' => 'Your free trial is about to end, top up to continue.',
'vat-incl' => 'Incl. VAT :vat (:rate of :cost)',
-
];
diff --git a/src/resources/lang/en/auth.php b/src/resources/lang/en/auth.php
--- a/src/resources/lang/en/auth.php
+++ b/src/resources/lang/en/auth.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
diff --git a/src/resources/lang/en/documents.php b/src/resources/lang/en/documents.php
--- a/src/resources/lang/en/documents.php
+++ b/src/resources/lang/en/documents.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Language files for document templates
diff --git a/src/resources/lang/en/mail.php b/src/resources/lang/en/mail.php
--- a/src/resources/lang/en/mail.php
+++ b/src/resources/lang/en/mail.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Mail Language Lines
diff --git a/src/resources/lang/en/meet.php b/src/resources/lang/en/meet.php
--- a/src/resources/lang/en/meet.php
+++ b/src/resources/lang/en/meet.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
diff --git a/src/resources/lang/en/ui.php b/src/resources/lang/en/ui.php
--- a/src/resources/lang/en/ui.php
+++ b/src/resources/lang/en/ui.php
@@ -7,7 +7,6 @@
*/
return [
-
'app' => [
'faq' => "FAQ",
],
@@ -66,16 +65,16 @@
'description' => "Use the Companion App on your mobile phone as multi-factor authentication device.",
'download-description' => "You may download the Companion App for Android here: "
. "<a href=\"{href}\">Download</a>",
- 'description-detailed' => "Here is how this works: " .
- "Pairing a device will automatically enable multi-factor autentication for all login attempts. " .
- "This includes not only the Cockpit, but also logins via Webmail, IMAP, SMPT, DAV and ActiveSync. " .
- "Any authentication attempt will result in a notification on your device, " .
- "that you can use to confirm if it was you, or deny otherwise. " .
- "Once confirmed, the same username + IP address combination will be whitelisted for 8 hours. " .
- "Unpair all your active devices to disable multi-factor authentication again.",
- 'description-warning' => "Warning: Loosing access to all your multi-factor authentication devices, " .
- "will permanently lock you out of your account with no course for recovery. " .
- "Always make sure you have a recovery QR-Code printed to pair a recovery device.",
+ 'description-detailed' => "Here is how this works: "
+ . "Pairing a device will automatically enable multi-factor autentication for all login attempts. "
+ . "This includes not only the Cockpit, but also logins via Webmail, IMAP, SMPT, DAV and ActiveSync. "
+ . "Any authentication attempt will result in a notification on your device, "
+ . "that you can use to confirm if it was you, or deny otherwise. "
+ . "Once confirmed, the same username + IP address combination will be whitelisted for 8 hours. "
+ . "Unpair all your active devices to disable multi-factor authentication again.",
+ 'description-warning' => "Warning: Loosing access to all your multi-factor authentication devices, "
+ . "will permanently lock you out of your account with no course for recovery. "
+ . "Always make sure you have a recovery QR-Code printed to pair a recovery device.",
'new' => "Pair new device",
'recovery' => "Prepare recovery device",
'paired' => "Paired devices",
@@ -87,10 +86,10 @@
'list-empty' => "There are currently no devices",
'delete' => "Delete/Unpair",
'delete-companion' => "Delete/Unpair",
- 'delete-text' => "You are about to delete this entry and unpair any paired companion app. " .
- "This cannot be undone, but you can pair the device again.",
- 'pairing-successful' => "Your companion app is paired and ready to be used " .
- "as a multi-factor authentication device.",
+ 'delete-text' => "You are about to delete this entry and unpair any paired companion app. "
+ . "This cannot be undone, but you can pair the device again.",
+ 'pairing-successful' => "Your companion app is paired and ready to be used "
+ . "as a multi-factor authentication device.",
],
'dashboard' => [
@@ -270,7 +269,7 @@
'header' => "Please sign in",
'sign_in' => "Sign in",
'signing_in' => "Signing in...",
- 'webmail' => "Webmail"
+ 'webmail' => "Webmail",
],
'meet' => [
diff --git a/src/resources/lang/en/validation.php b/src/resources/lang/en/validation.php
--- a/src/resources/lang/en/validation.php
+++ b/src/resources/lang/en/validation.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Validation Language Lines
diff --git a/src/resources/lang/fr/app.php b/src/resources/lang/fr/app.php
--- a/src/resources/lang/fr/app.php
+++ b/src/resources/lang/fr/app.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Application Language Lines
diff --git a/src/resources/lang/fr/auth.php b/src/resources/lang/fr/auth.php
--- a/src/resources/lang/fr/auth.php
+++ b/src/resources/lang/fr/auth.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Authentication Language Lines
@@ -16,5 +15,4 @@
'failed' => "Nom d'utilisateur et mot de passe invalide.",
'throttle' => "Trop de tentatives de connexion. Veuillez ré-essayer dans :seconds secondes.",
'logoutsuccess' => "Déconnecté avec succès.",
-
-];
\ No newline at end of file
+];
diff --git a/src/resources/lang/fr/documents.php b/src/resources/lang/fr/documents.php
--- a/src/resources/lang/fr/documents.php
+++ b/src/resources/lang/fr/documents.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Language files for document templates
diff --git a/src/resources/lang/fr/mail.php b/src/resources/lang/fr/mail.php
--- a/src/resources/lang/fr/mail.php
+++ b/src/resources/lang/fr/mail.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Mail Language Lines
@@ -83,5 +82,4 @@
'signupinvitation-header' => "Salut,",
'signupinvitation-body1' => "Vous êtes invité à joindre :site. Cliquez sur le lien ci-dessous pour vous inscrire.",
'signupinvitation-body2' => "",
-
];
diff --git a/src/resources/lang/fr/meet.php b/src/resources/lang/fr/meet.php
--- a/src/resources/lang/fr/meet.php
+++ b/src/resources/lang/fr/meet.php
@@ -1,7 +1,6 @@
<?php
return [
-
/*
|--------------------------------------------------------------------------
| Pagination Language Lines
diff --git a/src/resources/lang/fr/ui.php b/src/resources/lang/fr/ui.php
--- a/src/resources/lang/fr/ui.php
+++ b/src/resources/lang/fr/ui.php
@@ -7,7 +7,6 @@
*/
return [
-
'app' => [
'faq' => "FAQ",
],
@@ -64,7 +63,7 @@
'sender-policy-text' => "Cette liste vous permet de spécifier qui peut envoyer du courrier à la liste de distribution."
. " Vous pouvez mettre une adresse e-mail complète (jane@kolab.org), un domaine (kolab.org) ou un suffixe (.org)"
. " auquel l'adresse électronique de l'expéditeur est assimilée."
- . " Si la liste est vide, le courriels de quiconque est autorisé."
+ . " Si la liste est vide, le courriels de quiconque est autorisé.",
],
'domain' => [
@@ -171,7 +170,7 @@
'forgot_password' => "Mot de passe oublié?",
'header' => "Veuillez vous connecter",
'sign_in' => "Se connecter",
- 'webmail' => "Webmail"
+ 'webmail' => "Webmail",
],
'meet' => [
diff --git a/src/resources/lang/fr/validation.php b/src/resources/lang/fr/validation.php
--- a/src/resources/lang/fr/validation.php
+++ b/src/resources/lang/fr/validation.php
@@ -12,153 +12,153 @@
*/
return [
- 'accepted' => 'Le champ :attribute doit être accepté.',
- 'active_url' => 'Le champ :attribute n\'est pas une URL valide.',
- 'after' => 'Le champ :attribute doit être une date postérieure au :date.',
- 'after_or_equal' => 'Le champ :attribute doit être une date postérieure ou égale au :date.',
- 'alpha' => 'Le champ :attribute doit contenir uniquement des lettres.',
- 'alpha_dash' => 'Le champ :attribute doit contenir uniquement des lettres, des chiffres et des tirets.',
- 'alpha_num' => 'Le champ :attribute doit contenir uniquement des chiffres et des lettres.',
- 'array' => 'Le champ :attribute doit être un tableau.',
- 'attached' => ':attribute est déjà attaché(e).',
- 'before' => 'Le champ :attribute doit être une date antérieure au :date.',
- 'before_or_equal' => 'Le champ :attribute doit être une date antérieure ou égale au :date.',
- 'between' => [
- 'array' => 'Le tableau :attribute doit contenir entre :min et :max éléments.',
- 'file' => 'La taille du fichier de :attribute doit être comprise entre :min et :max kilo-octets.',
+ 'accepted' => 'Le champ :attribute doit être accepté.',
+ 'active_url' => 'Le champ :attribute n\'est pas une URL valide.',
+ 'after' => 'Le champ :attribute doit être une date postérieure au :date.',
+ 'after_or_equal' => 'Le champ :attribute doit être une date postérieure ou égale au :date.',
+ 'alpha' => 'Le champ :attribute doit contenir uniquement des lettres.',
+ 'alpha_dash' => 'Le champ :attribute doit contenir uniquement des lettres, des chiffres et des tirets.',
+ 'alpha_num' => 'Le champ :attribute doit contenir uniquement des chiffres et des lettres.',
+ 'array' => 'Le champ :attribute doit être un tableau.',
+ 'attached' => ':attribute est déjà attaché(e).',
+ 'before' => 'Le champ :attribute doit être une date antérieure au :date.',
+ 'before_or_equal' => 'Le champ :attribute doit être une date antérieure ou égale au :date.',
+ 'between' => [
+ 'array' => 'Le tableau :attribute doit contenir entre :min et :max éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être comprise entre :min et :max kilo-octets.',
'numeric' => 'La valeur de :attribute doit être comprise entre :min et :max.',
- 'string' => 'Le texte :attribute doit contenir entre :min et :max caractères.',
+ 'string' => 'Le texte :attribute doit contenir entre :min et :max caractères.',
],
- 'boolean' => 'Le champ :attribute doit être vrai ou faux.',
- 'confirmed' => 'Le champ de confirmation :attribute ne correspond pas.',
- 'current_password' => 'Le mot de passe est incorrect.',
- 'date' => 'Le champ :attribute n\'est pas une date valide.',
- 'date_equals' => 'Le champ :attribute doit être une date égale à :date.',
- 'date_format' => 'Le champ :attribute ne correspond pas au format :format.',
- 'different' => 'Les champs :attribute et :other doivent être différents.',
- 'digits' => 'Le champ :attribute doit contenir :digits chiffres.',
- 'digits_between' => 'Le champ :attribute doit contenir entre :min et :max chiffres.',
- 'dimensions' => 'La taille de l\'image :attribute n\'est pas conforme.',
- 'distinct' => 'Le champ :attribute a une valeur en double.',
- 'email' => 'Le champ :attribute doit être une adresse email valide.',
- 'ends_with' => 'Le champ :attribute doit se terminer par une des valeurs suivantes : :values',
- 'exists' => 'Le champ :attribute sélectionné est invalide.',
- 'file' => 'Le champ :attribute doit être un fichier.',
- 'filled' => 'Le champ :attribute doit avoir une valeur.',
- 'gt' => [
- 'array' => 'Le tableau :attribute doit contenir plus de :value éléments.',
- 'file' => 'La taille du fichier de :attribute doit être supérieure à :value kilo-octets.',
+ 'boolean' => 'Le champ :attribute doit être vrai ou faux.',
+ 'confirmed' => 'Le champ de confirmation :attribute ne correspond pas.',
+ 'current_password' => 'Le mot de passe est incorrect.',
+ 'date' => 'Le champ :attribute n\'est pas une date valide.',
+ 'date_equals' => 'Le champ :attribute doit être une date égale à :date.',
+ 'date_format' => 'Le champ :attribute ne correspond pas au format :format.',
+ 'different' => 'Les champs :attribute et :other doivent être différents.',
+ 'digits' => 'Le champ :attribute doit contenir :digits chiffres.',
+ 'digits_between' => 'Le champ :attribute doit contenir entre :min et :max chiffres.',
+ 'dimensions' => 'La taille de l\'image :attribute n\'est pas conforme.',
+ 'distinct' => 'Le champ :attribute a une valeur en double.',
+ 'email' => 'Le champ :attribute doit être une adresse email valide.',
+ 'ends_with' => 'Le champ :attribute doit se terminer par une des valeurs suivantes : :values',
+ 'exists' => 'Le champ :attribute sélectionné est invalide.',
+ 'file' => 'Le champ :attribute doit être un fichier.',
+ 'filled' => 'Le champ :attribute doit avoir une valeur.',
+ 'gt' => [
+ 'array' => 'Le tableau :attribute doit contenir plus de :value éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être supérieure à :value kilo-octets.',
'numeric' => 'La valeur de :attribute doit être supérieure à :value.',
- 'string' => 'Le texte :attribute doit contenir plus de :value caractères.',
+ 'string' => 'Le texte :attribute doit contenir plus de :value caractères.',
],
- 'gte' => [
- 'array' => 'Le tableau :attribute doit contenir au moins :value éléments.',
- 'file' => 'La taille du fichier de :attribute doit être supérieure ou égale à :value kilo-octets.',
+ 'gte' => [
+ 'array' => 'Le tableau :attribute doit contenir au moins :value éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être supérieure ou égale à :value kilo-octets.',
'numeric' => 'La valeur de :attribute doit être supérieure ou égale à :value.',
- 'string' => 'Le texte :attribute doit contenir au moins :value caractères.',
+ 'string' => 'Le texte :attribute doit contenir au moins :value caractères.',
],
- 'image' => 'Le champ :attribute doit être une image.',
- 'in' => 'Le champ :attribute est invalide.',
- 'in_array' => 'Le champ :attribute n\'existe pas dans :other.',
- 'integer' => 'Le champ :attribute doit être un entier.',
- 'ip' => 'Le champ :attribute doit être une adresse IP valide.',
- 'ipv4' => 'Le champ :attribute doit être une adresse IPv4 valide.',
- 'ipv6' => 'Le champ :attribute doit être une adresse IPv6 valide.',
- 'json' => 'Le champ :attribute doit être un document JSON valide.',
- 'lt' => [
- 'array' => 'Le tableau :attribute doit contenir moins de :value éléments.',
- 'file' => 'La taille du fichier de :attribute doit être inférieure à :value kilo-octets.',
+ 'image' => 'Le champ :attribute doit être une image.',
+ 'in' => 'Le champ :attribute est invalide.',
+ 'in_array' => 'Le champ :attribute n\'existe pas dans :other.',
+ 'integer' => 'Le champ :attribute doit être un entier.',
+ 'ip' => 'Le champ :attribute doit être une adresse IP valide.',
+ 'ipv4' => 'Le champ :attribute doit être une adresse IPv4 valide.',
+ 'ipv6' => 'Le champ :attribute doit être une adresse IPv6 valide.',
+ 'json' => 'Le champ :attribute doit être un document JSON valide.',
+ 'lt' => [
+ 'array' => 'Le tableau :attribute doit contenir moins de :value éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être inférieure à :value kilo-octets.',
'numeric' => 'La valeur de :attribute doit être inférieure à :value.',
- 'string' => 'Le texte :attribute doit contenir moins de :value caractères.',
+ 'string' => 'Le texte :attribute doit contenir moins de :value caractères.',
],
- 'lte' => [
- 'array' => 'Le tableau :attribute doit contenir au plus :value éléments.',
- 'file' => 'La taille du fichier de :attribute doit être inférieure ou égale à :value kilo-octets.',
+ 'lte' => [
+ 'array' => 'Le tableau :attribute doit contenir au plus :value éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être inférieure ou égale à :value kilo-octets.',
'numeric' => 'La valeur de :attribute doit être inférieure ou égale à :value.',
- 'string' => 'Le texte :attribute doit contenir au plus :value caractères.',
+ 'string' => 'Le texte :attribute doit contenir au plus :value caractères.',
],
- 'max' => [
- 'array' => 'Le tableau :attribute ne peut contenir plus de :max éléments.',
- 'file' => 'La taille du fichier de :attribute ne peut pas dépasser :max kilo-octets.',
+ 'max' => [
+ 'array' => 'Le tableau :attribute ne peut contenir plus de :max éléments.',
+ 'file' => 'La taille du fichier de :attribute ne peut pas dépasser :max kilo-octets.',
'numeric' => 'La valeur de :attribute ne peut être supérieure à :max.',
- 'string' => 'Le texte de :attribute ne peut contenir plus de :max caractères.',
+ 'string' => 'Le texte de :attribute ne peut contenir plus de :max caractères.',
],
- 'mimes' => 'Le champ :attribute doit être un fichier de type : :values.',
- 'mimetypes' => 'Le champ :attribute doit être un fichier de type : :values.',
- 'min' => [
- 'array' => 'Le tableau :attribute doit contenir au moins :min éléments.',
- 'file' => 'La taille du fichier de :attribute doit être supérieure à :min kilo-octets.',
+ 'mimes' => 'Le champ :attribute doit être un fichier de type : :values.',
+ 'mimetypes' => 'Le champ :attribute doit être un fichier de type : :values.',
+ 'min' => [
+ 'array' => 'Le tableau :attribute doit contenir au moins :min éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être supérieure à :min kilo-octets.',
'numeric' => 'La valeur de :attribute doit être supérieure ou égale à :min.',
- 'string' => 'Le texte :attribute doit contenir au moins :min caractères.',
+ 'string' => 'Le texte :attribute doit contenir au moins :min caractères.',
],
- 'multiple_of' => 'La valeur de :attribute doit être un multiple de :value',
- 'not_in' => 'Le champ :attribute sélectionné n\'est pas valide.',
- 'not_regex' => 'Le format du champ :attribute n\'est pas valide.',
- 'numeric' => 'Le champ :attribute doit contenir un nombre.',
- 'password' => 'Le mot de passe est incorrect',
- 'present' => 'Le champ :attribute doit être présent.',
- 'prohibited' => 'Le champ :attribute est interdit.',
- 'prohibited_if' => 'Le champ :attribute est interdit quand :other a la valeur :value.',
- 'prohibited_unless' => 'Le champ :attribute est interdit à moins que :other est l\'une des valeurs :values.',
- 'regex' => 'Le format du champ :attribute est invalide.',
- 'relatable' => ':attribute n\'est sans doute pas associé(e) avec cette donnée.',
- 'required' => 'Le champ :attribute est obligatoire.',
- 'required_if' => 'Le champ :attribute est obligatoire quand la valeur de :other est :value.',
- 'required_unless' => 'Le champ :attribute est obligatoire sauf si :other est :values.',
- 'required_with' => 'Le champ :attribute est obligatoire quand :values est présent.',
- 'required_with_all' => 'Le champ :attribute est obligatoire quand :values sont présents.',
- 'required_without' => 'Le champ :attribute est obligatoire quand :values n\'est pas présent.',
+ 'multiple_of' => 'La valeur de :attribute doit être un multiple de :value',
+ 'not_in' => 'Le champ :attribute sélectionné n\'est pas valide.',
+ 'not_regex' => 'Le format du champ :attribute n\'est pas valide.',
+ 'numeric' => 'Le champ :attribute doit contenir un nombre.',
+ 'password' => 'Le mot de passe est incorrect',
+ 'present' => 'Le champ :attribute doit être présent.',
+ 'prohibited' => 'Le champ :attribute est interdit.',
+ 'prohibited_if' => 'Le champ :attribute est interdit quand :other a la valeur :value.',
+ 'prohibited_unless' => 'Le champ :attribute est interdit à moins que :other est l\'une des valeurs :values.',
+ 'regex' => 'Le format du champ :attribute est invalide.',
+ 'relatable' => ':attribute n\'est sans doute pas associé(e) avec cette donnée.',
+ 'required' => 'Le champ :attribute est obligatoire.',
+ 'required_if' => 'Le champ :attribute est obligatoire quand la valeur de :other est :value.',
+ 'required_unless' => 'Le champ :attribute est obligatoire sauf si :other est :values.',
+ 'required_with' => 'Le champ :attribute est obligatoire quand :values est présent.',
+ 'required_with_all' => 'Le champ :attribute est obligatoire quand :values sont présents.',
+ 'required_without' => 'Le champ :attribute est obligatoire quand :values n\'est pas présent.',
'required_without_all' => 'Le champ :attribute est requis quand aucun de :values n\'est présent.',
- 'same' => 'Les champs :attribute et :other doivent être identiques.',
- 'size' => [
- 'array' => 'Le tableau :attribute doit contenir :size éléments.',
- 'file' => 'La taille du fichier de :attribute doit être de :size kilo-octets.',
+ 'same' => 'Les champs :attribute et :other doivent être identiques.',
+ 'size' => [
+ 'array' => 'Le tableau :attribute doit contenir :size éléments.',
+ 'file' => 'La taille du fichier de :attribute doit être de :size kilo-octets.',
'numeric' => 'La valeur de :attribute doit être :size.',
- 'string' => 'Le texte de :attribute doit contenir :size caractères.',
+ 'string' => 'Le texte de :attribute doit contenir :size caractères.',
],
- 'starts_with' => 'Le champ :attribute doit commencer avec une des valeurs suivantes : :values',
- 'string' => 'Le champ :attribute doit être une chaîne de caractères.',
- 'timezone' => 'Le champ :attribute doit être un fuseau horaire valide.',
- 'unique' => 'La valeur du champ :attribute est déjà utilisée.',
- 'uploaded' => 'Le fichier du champ :attribute n\'a pu être téléversé.',
- 'url' => 'Le format de l\'URL de :attribute n\'est pas valide.',
- 'uuid' => 'Le champ :attribute doit être un UUID valide',
- 'custom' => [
+ 'starts_with' => 'Le champ :attribute doit commencer avec une des valeurs suivantes : :values',
+ 'string' => 'Le champ :attribute doit être une chaîne de caractères.',
+ 'timezone' => 'Le champ :attribute doit être un fuseau horaire valide.',
+ 'unique' => 'La valeur du champ :attribute est déjà utilisée.',
+ 'uploaded' => 'Le fichier du champ :attribute n\'a pu être téléversé.',
+ 'url' => 'Le format de l\'URL de :attribute n\'est pas valide.',
+ 'uuid' => 'Le champ :attribute doit être un UUID valide',
+ 'custom' => [
'attribute-name' => [
'rule-name' => 'custom-message',
],
],
- 'attributes' => [
- 'address' => 'adresse',
- 'age' => 'âge',
- 'available' => 'disponible',
- 'city' => 'ville',
- 'content' => 'contenu',
- 'country' => 'pays',
- 'current_password' => 'mot de passe actuel',
- 'date' => 'date',
- 'day' => 'jour',
- 'description' => 'description',
- 'email' => 'adresse email',
- 'excerpt' => 'extrait',
- 'first_name' => 'prénom',
- 'gender' => 'genre',
- 'hour' => 'heure',
- 'last_name' => 'nom',
- 'minute' => 'minute',
- 'mobile' => 'portable',
- 'month' => 'mois',
- 'name' => 'nom',
- 'password' => 'mot de passe',
+ 'attributes' => [
+ 'address' => 'adresse',
+ 'age' => 'âge',
+ 'available' => 'disponible',
+ 'city' => 'ville',
+ 'content' => 'contenu',
+ 'country' => 'pays',
+ 'current_password' => 'mot de passe actuel',
+ 'date' => 'date',
+ 'day' => 'jour',
+ 'description' => 'description',
+ 'email' => 'adresse email',
+ 'excerpt' => 'extrait',
+ 'first_name' => 'prénom',
+ 'gender' => 'genre',
+ 'hour' => 'heure',
+ 'last_name' => 'nom',
+ 'minute' => 'minute',
+ 'mobile' => 'portable',
+ 'month' => 'mois',
+ 'name' => 'nom',
+ 'password' => 'mot de passe',
'password_confirmation' => 'confirmation du mot de passe',
- 'phone' => 'téléphone',
- 'second' => 'seconde',
- 'sex' => 'sexe',
- 'size' => 'taille',
- 'time' => 'heure',
- 'title' => 'titre',
- 'username' => 'nom d\'utilisateur',
- 'year' => 'année',
+ 'phone' => 'téléphone',
+ 'second' => 'seconde',
+ 'sex' => 'sexe',
+ 'size' => 'taille',
+ 'time' => 'heure',
+ 'title' => 'titre',
+ 'username' => 'nom d\'utilisateur',
+ 'year' => 'année',
],
'2fareq' => "Le code du second facteur est requis.",
'2fainvalid' => "Le code du deuxième facteur n'est pas valideSecond factor code is invalid.",
diff --git a/src/resources/themes/default/lang/de/faq.php b/src/resources/themes/default/lang/de/faq.php
--- a/src/resources/themes/default/lang/de/faq.php
+++ b/src/resources/themes/default/lang/de/faq.php
@@ -1,9 +1,7 @@
<?php
return [
-
'account-upgrade' => "Kann ich ein einzelnes Konto auf ein Gruppenkonto aktualisieren?",
'storage' => "Wie viel Speicherplatz ist in meinem Konto enthalten?",
'tos' => "Was sind Ihre Nutzungsbedingungen?",
-
];
diff --git a/src/resources/themes/default/lang/de/menu.php b/src/resources/themes/default/lang/de/menu.php
--- a/src/resources/themes/default/lang/de/menu.php
+++ b/src/resources/themes/default/lang/de/menu.php
@@ -1,10 +1,8 @@
<?php
return [
-
'blog' => "Blog",
'explore' => "Erkunden",
'support' => "Unterstützung",
'tos' => "LdD",
-
-];
\ No newline at end of file
+];
diff --git a/src/resources/themes/default/lang/en/faq.php b/src/resources/themes/default/lang/en/faq.php
--- a/src/resources/themes/default/lang/en/faq.php
+++ b/src/resources/themes/default/lang/en/faq.php
@@ -1,10 +1,8 @@
<?php
return [
-
'account-upgrade' => "Can I upgrade an individual account to a group account?",
'storage' => "How much storage comes with my account?",
'tos' => "What are your terms of service?",
'support' => "Need support?",
-
];
diff --git a/src/resources/themes/default/lang/en/menu.php b/src/resources/themes/default/lang/en/menu.php
--- a/src/resources/themes/default/lang/en/menu.php
+++ b/src/resources/themes/default/lang/en/menu.php
@@ -1,10 +1,8 @@
<?php
return [
-
'blog' => "Blog",
'explore' => "Explore",
'support' => "Support",
'tos' => "ToS",
-
-];
\ No newline at end of file
+];
diff --git a/src/resources/themes/default/lang/en/support.php b/src/resources/themes/default/lang/en/support.php
--- a/src/resources/themes/default/lang/en/support.php
+++ b/src/resources/themes/default/lang/en/support.php
@@ -12,5 +12,4 @@
'documentation' => "Documentation",
'support' => "Support",
'search-kb' => "Search Knowledgebase",
-
];
diff --git a/src/resources/themes/default/lang/fr/faq.php b/src/resources/themes/default/lang/fr/faq.php
--- a/src/resources/themes/default/lang/fr/faq.php
+++ b/src/resources/themes/default/lang/fr/faq.php
@@ -1,9 +1,7 @@
<?php
return [
-
'account-upgrade' => "Est-il possible de convertir un compte individuel en compte de groupe?",
'storage' => "Combien d'espace de stockage est fourni avec mon compte?",
'tos' => "quelles sont vos conditions de service?",
-
];
diff --git a/src/resources/themes/default/lang/fr/menu.php b/src/resources/themes/default/lang/fr/menu.php
--- a/src/resources/themes/default/lang/fr/menu.php
+++ b/src/resources/themes/default/lang/fr/menu.php
@@ -1,10 +1,8 @@
<?php
return [
-
'blog' => "Blog",
'explore' => "Explorer",
'support' => "Support",
'tos' => "Conditions de Service",
-
];
diff --git a/src/resources/themes/default/lang/fr/support.php b/src/resources/themes/default/lang/fr/support.php
--- a/src/resources/themes/default/lang/fr/support.php
+++ b/src/resources/themes/default/lang/fr/support.php
@@ -1,7 +1,6 @@
<?php
return [
-
'title' => "Contacter Support",
'text1' => "Notre équipe de support technique est là pour vous aider si vous rencontrez des difficultés."
. " Vous ne devriez pas avoir à parler à des machines ou à naviguer dans des menus vocaux,"
@@ -9,5 +8,4 @@
'text2' => "Cette aide est déjà intégrée dans votre souscription, il n'y a donc aucun coût supplémentaire pour vous."
. " Si vous rencontrez des problèmes avec votre compte :site, ou si vous avez des questions"
. " sur notre produit avant de vous inscrire, veuillez nous contacter.",
-
];
diff --git a/src/resources/views/documents/receipt.blade.php b/src/resources/views/documents/receipt.blade.php
--- a/src/resources/views/documents/receipt.blade.php
+++ b/src/resources/views/documents/receipt.blade.php
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<style>
-<?php include public_path('/themes/' . config('app.theme') . '/document.css') ?>
+<?php include public_path('/themes/' . config('app.theme') . '/document.css'); ?>
</style>
</head>
<body>
diff --git a/src/resources/views/emails/plain/degraded_account_reminder.blade.php b/src/resources/views/emails/plain/degraded_account_reminder.blade.php
--- a/src/resources/views/emails/plain/degraded_account_reminder.blade.php
+++ b/src/resources/views/emails/plain/degraded_account_reminder.blade.php
@@ -12,6 +12,6 @@
{!! __('mail.degradedaccountreminder-body5', $vars) !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/negative_balance.blade.php b/src/resources/views/emails/plain/negative_balance.blade.php
--- a/src/resources/views/emails/plain/negative_balance.blade.php
+++ b/src/resources/views/emails/plain/negative_balance.blade.php
@@ -12,6 +12,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/negative_balance_degraded.blade.php b/src/resources/views/emails/plain/negative_balance_degraded.blade.php
--- a/src/resources/views/emails/plain/negative_balance_degraded.blade.php
+++ b/src/resources/views/emails/plain/negative_balance_degraded.blade.php
@@ -12,6 +12,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php b/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php
--- a/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php
+++ b/src/resources/views/emails/plain/negative_balance_reminder_degrade.blade.php
@@ -14,6 +14,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/password_expiration_reminder.blade.php b/src/resources/views/emails/plain/password_expiration_reminder.blade.php
--- a/src/resources/views/emails/plain/password_expiration_reminder.blade.php
+++ b/src/resources/views/emails/plain/password_expiration_reminder.blade.php
@@ -4,6 +4,6 @@
{!! $link !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/password_reset.blade.php b/src/resources/views/emails/plain/password_reset.blade.php
--- a/src/resources/views/emails/plain/password_reset.blade.php
+++ b/src/resources/views/emails/plain/password_reset.blade.php
@@ -11,6 +11,6 @@
{!! __('mail.passwordreset-body4', $vars) !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/payment_failure.blade.php b/src/resources/views/emails/plain/payment_failure.blade.php
--- a/src/resources/views/emails/plain/payment_failure.blade.php
+++ b/src/resources/views/emails/plain/payment_failure.blade.php
@@ -14,6 +14,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
\ No newline at end of file
diff --git a/src/resources/views/emails/plain/payment_mandate_disabled.blade.php b/src/resources/views/emails/plain/payment_mandate_disabled.blade.php
--- a/src/resources/views/emails/plain/payment_mandate_disabled.blade.php
+++ b/src/resources/views/emails/plain/payment_mandate_disabled.blade.php
@@ -14,6 +14,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/payment_success.blade.php b/src/resources/views/emails/plain/payment_success.blade.php
--- a/src/resources/views/emails/plain/payment_success.blade.php
+++ b/src/resources/views/emails/plain/payment_success.blade.php
@@ -10,6 +10,6 @@
{!! $supportUrl !!}
@endif
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
\ No newline at end of file
diff --git a/src/resources/views/emails/plain/signup_invitation.blade.php b/src/resources/views/emails/plain/signup_invitation.blade.php
--- a/src/resources/views/emails/plain/signup_invitation.blade.php
+++ b/src/resources/views/emails/plain/signup_invitation.blade.php
@@ -6,6 +6,6 @@
{!! __('mail.signupinvitation-body2', $vars) !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/signup_verification.blade.php b/src/resources/views/emails/plain/signup_verification.blade.php
--- a/src/resources/views/emails/plain/signup_verification.blade.php
+++ b/src/resources/views/emails/plain/signup_verification.blade.php
@@ -8,6 +8,6 @@
{!! $href !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/resources/views/emails/plain/trial_end.blade.php b/src/resources/views/emails/plain/trial_end.blade.php
--- a/src/resources/views/emails/plain/trial_end.blade.php
+++ b/src/resources/views/emails/plain/trial_end.blade.php
@@ -14,6 +14,6 @@
{!! $supportUrl !!}
---
+--
{!! __('mail.footer1', $vars) !!}
{!! __('mail.footer2', $vars) !!}
diff --git a/src/routes/api.php b/src/routes/api.php
--- a/src/routes/api.php
+++ b/src/routes/api.php
@@ -1,7 +1,6 @@
<?php
use App\Http\Controllers\API;
-use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
Route::post('oauth/approve', [API\AuthController::class, 'oauthApprove'])
@@ -10,14 +9,14 @@
Route::group(
[
'middleware' => 'api',
- 'prefix' => 'auth'
+ 'prefix' => 'auth',
],
- function () {
+ static function () {
Route::post('login', [API\AuthController::class, 'login']);
Route::group(
['middleware' => ['auth:api', 'scope:api']],
- function () {
+ static function () {
Route::get('info', [API\AuthController::class, 'info']);
Route::post('info', [API\AuthController::class, 'info']);
Route::get('location', [API\AuthController::class, 'location']);
@@ -32,9 +31,9 @@
[
'domain' => \config('app.website_domain'),
'middleware' => 'api',
- 'prefix' => 'auth'
+ 'prefix' => 'auth',
],
- function () {
+ static function () {
Route::post('password-policy/check', [API\PasswordPolicyController::class, 'check']);
Route::post('password-reset/init', [API\PasswordResetController::class, 'init']);
@@ -48,9 +47,9 @@
[
'domain' => \config('app.website_domain'),
'middleware' => 'api',
- 'prefix' => 'auth'
+ 'prefix' => 'auth',
],
- function () {
+ static function () {
Route::get('signup/domains', [API\SignupController::class, 'domains']);
Route::post('signup/init', [API\SignupController::class, 'init']);
Route::get('signup/invitations/{id}', [API\SignupController::class, 'invitation']);
@@ -66,9 +65,9 @@
[
'domain' => \config('app.website_domain'),
'middleware' => ['auth:api', 'scope:mfa,api'],
- 'prefix' => 'v4'
+ 'prefix' => 'v4',
],
- function () {
+ static function () {
Route::post('auth-attempts/{id}/confirm', [API\V4\AuthAttemptsController::class, 'confirm']);
Route::post('auth-attempts/{id}/deny', [API\V4\AuthAttemptsController::class, 'deny']);
Route::get('auth-attempts/{id}/details', [API\V4\AuthAttemptsController::class, 'details']);
@@ -82,25 +81,25 @@
Route::group(
[
'middleware' => ['auth:api', 'scope:fs,api'],
- 'prefix' => 'v4'
+ 'prefix' => 'v4',
],
- function () {
- Route::apiResource('fs', API\V4\FsController::class);
- Route::get('fs/{itemId}/permissions', [API\V4\FsController::class, 'getPermissions']);
- Route::post('fs/{itemId}/permissions', [API\V4\FsController::class, 'createPermission']);
- Route::put('fs/{itemId}/permissions/{id}', [API\V4\FsController::class, 'updatePermission']);
- Route::delete('fs/{itemId}/permissions/{id}', [API\V4\FsController::class, 'deletePermission']);
+ static function () {
+ Route::apiResource('fs', API\V4\FsController::class);
+ Route::get('fs/{itemId}/permissions', [API\V4\FsController::class, 'getPermissions']);
+ Route::post('fs/{itemId}/permissions', [API\V4\FsController::class, 'createPermission']);
+ Route::put('fs/{itemId}/permissions/{id}', [API\V4\FsController::class, 'updatePermission']);
+ Route::delete('fs/{itemId}/permissions/{id}', [API\V4\FsController::class, 'deletePermission']);
}
);
Route::group(
[
'middleware' => [],
- 'prefix' => 'v4'
+ 'prefix' => 'v4',
],
- function () {
- Route::post('fs/uploads/{id}', [API\V4\FsController::class, 'upload'])
- ->middleware(['api']);
- Route::get('fs/downloads/{id}', [API\V4\FsController::class, 'download']);
+ static function () {
+ Route::post('fs/uploads/{id}', [API\V4\FsController::class, 'upload'])
+ ->middleware(['api']);
+ Route::get('fs/downloads/{id}', [API\V4\FsController::class, 'download']);
}
);
}
@@ -109,9 +108,9 @@
[
'domain' => \config('app.website_domain'),
'middleware' => ['auth:api', 'scope:api'],
- 'prefix' => 'v4'
+ 'prefix' => 'v4',
],
- function () {
+ static function () {
Route::apiResource('companions', API\V4\CompanionAppsController::class);
// This must not be accessible with the 2fa token,
// to prevent an attacker from pairing a new device with a stolen token.
@@ -174,7 +173,7 @@
Route::delete('password-reset/code/{id}', [API\PasswordResetController::class, 'codeDelete']);
Route::post('payments', [API\V4\PaymentsController::class, 'store']);
- //Route::delete('payments', [API\V4\PaymentsController::class, 'cancel']);
+ // Route::delete('payments', [API\V4\PaymentsController::class, 'cancel']);
Route::get('payments/mandate', [API\V4\PaymentsController::class, 'mandate']);
Route::post('payments/mandate', [API\V4\PaymentsController::class, 'mandateCreate']);
Route::put('payments/mandate', [API\V4\PaymentsController::class, 'mandateUpdate']);
@@ -203,9 +202,9 @@
Route::group(
[
'domain' => \config('app.website_domain'),
- 'prefix' => 'webhooks'
+ 'prefix' => 'webhooks',
],
- function () {
+ static function () {
Route::post('payment/{provider}', [API\V4\PaymentsController::class, 'webhook']);
Route::post('meet', [API\V4\MeetController::class, 'webhook']);
}
@@ -215,9 +214,9 @@
Route::group(
[
'middleware' => ['allowedHosts'],
- 'prefix' => 'webhooks'
+ 'prefix' => 'webhooks',
],
- function () {
+ static function () {
Route::get('nginx', [API\V4\NGINXController::class, 'authenticate']);
Route::get('nginx-roundcube', [API\V4\NGINXController::class, 'authenticateRoundcube']);
Route::get('nginx-httpauth', [API\V4\NGINXController::class, 'httpauth']);
@@ -244,7 +243,7 @@
'middleware' => ['auth:api', 'admin'],
'prefix' => 'v4',
],
- function () {
+ static function () {
Route::apiResource('domains', API\V4\Admin\DomainsController::class);
Route::get('domains/{id}/skus', [API\V4\Admin\DomainsController::class, 'skus']);
Route::post('domains/{id}/suspend', [API\V4\Admin\DomainsController::class, 'suspend']);
@@ -285,7 +284,7 @@
'domain' => 'admin.' . \config('app.website_domain'),
'prefix' => 'v4',
],
- function () {
+ static function () {
Route::get('inspect-request', [API\V4\Admin\UsersController::class, 'inspectRequest']);
}
);
@@ -298,7 +297,7 @@
'middleware' => ['auth:api', 'reseller'],
'prefix' => 'v4',
],
- function () {
+ static function () {
Route::apiResource('domains', API\V4\Reseller\DomainsController::class);
Route::get('domains/{id}/skus', [API\V4\Reseller\DomainsController::class, 'skus']);
Route::post('domains/{id}/suspend', [API\V4\Reseller\DomainsController::class, 'suspend']);
diff --git a/src/routes/channels.php b/src/routes/channels.php
--- a/src/routes/channels.php
+++ b/src/routes/channels.php
@@ -2,6 +2,6 @@
use Illuminate\Support\Facades\Broadcast;
-Broadcast::channel('App.User.{id}', function ($user, $id) {
+Broadcast::channel('App.User.{id}', static function ($user, $id) {
return (int) $user->id === (int) $id;
});
diff --git a/src/routes/web.php b/src/routes/web.php
--- a/src/routes/web.php
+++ b/src/routes/web.php
@@ -1,10 +1,11 @@
<?php
use App\Http\Controllers;
+use App\Utils;
use Illuminate\Support\Facades\Route;
use Laravel\Passport\Http\Controllers as PassportControllers;
-Route::get('204', function () {
+Route::get('204', static function () {
return response()->noContent();
});
@@ -13,29 +14,29 @@
// This way we don't have to define any "deep link" routes here.
Route::group(
[
- //'domain' => \config('app.website_domain'),
+ // 'domain' => \config('app.website_domain'),
],
- function () {
+ static function () {
Route::get('content/page/{page}', [Controllers\ContentController::class, 'pageContent'])
->where('page', '(.*)');
Route::get('content/faq/{page}', [Controllers\ContentController::class, 'faqContent'])
->where('page', '(.*)');
- Route::fallback([\App\Utils::class, 'defaultView']);
+ Route::fallback([Utils::class, 'defaultView']);
}
);
Route::group(
[
- 'prefix' => 'oauth'
+ 'prefix' => 'oauth',
],
- function () {
+ static function () {
// We manually specify a subset of endpoints from https://github.com/laravel/passport/blob/11.x/routes/web.php
// after having disabled automatic routes via Passport::ignoreRoutes()
Route::post('/token', [PassportControllers\AccessTokenController::class, 'issueToken'])
->name('passport.token'); // needed for .well-known/openid-configuration handler
- Route::middleware(['web', 'auth'])->group(function () {
+ Route::middleware(['web', 'auth'])->group(static function () {
Route::get('/tokens', [PassportControllers\AuthorizedAccessTokenController::class, 'forUser'])
->name('passport.tokens.index');
@@ -50,16 +51,16 @@
->middleware(['auth:api', 'scope:email'])
->name('openid.userinfo'); // needed for .well-known/openid-configuration handler
- Route::get('/authorize', [\App\Utils::class, 'defaultView'])
+ Route::get('/authorize', [Utils::class, 'defaultView'])
->name('passport.authorizations.authorize'); // needed for .well-known/openid-configuration handler
}
);
Route::group(
[
- 'prefix' => '.well-known'
+ 'prefix' => '.well-known',
],
- function () {
+ static function () {
// .well-known/openid-configuration is handled by an external package (see config/openid.php)
Route::get('/mta-sts.txt', [Controllers\WellKnownController::class, 'mtaSts']);
}
diff --git a/src/server.php b/src/server.php
--- a/src/server.php
+++ b/src/server.php
@@ -3,19 +3,17 @@
/**
* Laravel - A PHP Framework For Web Artisans
*
- * @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
-
$uri = urldecode(
- parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
+ parse_url($_SERVER['REQUEST_URI'], \PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
-if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
+if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
return false;
}
-require_once __DIR__.'/public/index.php';
+require_once __DIR__ . '/public/index.php';
diff --git a/src/stubs.php b/src/stubs.php
--- a/src/stubs.php
+++ b/src/stubs.php
@@ -1,3 +1,3 @@
<?php
-class Log extends Illuminate\Support\Facades\Log {}
+class stubs extends Illuminate\Support\Facades\Log {}
diff --git a/src/tests/BackendsTrait.php b/src/tests/BackendsTrait.php
--- a/src/tests/BackendsTrait.php
+++ b/src/tests/BackendsTrait.php
@@ -2,8 +2,8 @@
namespace Tests;
-use App\Backends\IMAP;
use App\Backends\DAV;
+use App\Backends\IMAP;
use App\DataMigrator\Account;
use App\DataMigrator\Engine;
use App\Utils;
@@ -18,7 +18,6 @@
Engine::TYPE_GROUP => DAV::TYPE_VCARD,
];
-
/**
* Append an DAV object to a DAV folder
*/
@@ -385,7 +384,7 @@
$folders = array_filter(
$folders,
- function ($folder) {
+ static function ($folder) {
return !preg_match('~(Shared Folders|Other Users)/.*~', $folder);
}
);
@@ -401,7 +400,7 @@
$imap = $this->getImapClient($account);
foreach ($flags as $flag) {
- if (strpos($flag, 'UN') === 0) {
+ if (str_starts_with($flag, 'UN')) {
$flagged = $imap->unflag($folder, $uids, substr($flag, 2));
} else {
$flagged = $imap->flag($folder, $uids, $flag);
diff --git a/src/tests/Browser.php b/src/tests/Browser.php
--- a/src/tests/Browser.php
+++ b/src/tests/Browser.php
@@ -18,8 +18,8 @@
public function assertAttributeRegExp($selector, $attribute, $regexp)
{
$element = $this->resolver->findOrFail($selector);
- $value = (string) $element->getAttribute($attribute);
- $error = "No expected text in [$selector][$attribute]. Found: $value";
+ $value = (string) $element->getAttribute($attribute);
+ $error = "No expected text in [{$selector}][{$attribute}]. Found: {$value}";
Assert::assertMatchesRegularExpression($regexp, $value, $error);
@@ -42,7 +42,7 @@
}
}
- Assert::assertEquals($expected_count, $count, "Count of [$selector] elements is not $expected_count");
+ Assert::assertEquals($expected_count, $count, "Count of [{$selector}] elements is not {$expected_count}");
return $this;
}
@@ -53,7 +53,7 @@
public function assertTip($selector, $content)
{
return $this->click($selector)
- ->withinBody(function ($browser) use ($content) {
+ ->withinBody(static function ($browser) use ($content) {
$browser->waitFor('div.tooltip .tooltip-inner')
->assertSeeIn('div.tooltip .tooltip-inner', $content);
})
@@ -65,8 +65,8 @@
*/
public function assertToast(string $type, string $message, $title = null)
{
- return $this->withinBody(function ($browser) use ($type, $title, $message) {
- $browser->with(new Toast($type), function (Browser $browser) use ($title, $message) {
+ return $this->withinBody(static function ($browser) use ($type, $title, $message) {
+ $browser->with(new Toast($type), static function (Browser $browser) use ($title, $message) {
$browser->assertToastTitle($title)
->assertToastMessage($message)
->closeToast();
@@ -79,7 +79,7 @@
*/
public function assertErrorPage(int $error_code, string $hint = '')
{
- $this->with(new Error($error_code, $hint), function ($browser) {
+ $this->with(new Error($error_code, $hint), static function ($browser) {
// empty, assertions will be made by the Error component itself
});
@@ -94,7 +94,7 @@
$element = $this->resolver->findOrFail($selector);
$classes = explode(' ', (string) $element->getAttribute('class'));
- Assert::assertContains($class_name, $classes, "[$selector] has no class '{$class_name}'");
+ Assert::assertContains($class_name, $classes, "[{$selector}] has no class '{$class_name}'");
return $this;
}
@@ -107,7 +107,7 @@
$element = $this->resolver->findOrFail($selector);
$value = $element->getAttribute('readonly');
- Assert::assertTrue($value == 'true', "Element [$selector] is not readonly");
+ Assert::assertTrue($value == 'true', "Element [{$selector}] is not readonly");
return $this;
}
@@ -120,7 +120,7 @@
$element = $this->resolver->findOrFail($selector);
$value = $element->getAttribute('readonly');
- Assert::assertTrue($value != 'true', "Element [$selector] is not readonly");
+ Assert::assertTrue($value != 'true', "Element [{$selector}] is not readonly");
return $this;
}
@@ -134,9 +134,9 @@
$element = $this->resolver->findOrFail($selector);
if ($text === '') {
- Assert::assertTrue((string) $element->getText() === $text, "Element's text is not empty [$selector]");
+ Assert::assertTrue((string) $element->getText() === $text, "Element's text is not empty [{$selector}]");
} else {
- Assert::assertTrue(strpos($element->getText(), $text) !== false, "No expected text in [$selector]");
+ Assert::assertTrue(str_contains($element->getText(), $text), "No expected text in [{$selector}]");
}
return $this;
@@ -150,7 +150,7 @@
{
$element = $this->resolver->findOrFail($selector);
- Assert::assertMatchesRegularExpression($regexp, $element->getText(), "No expected text in [$selector]");
+ Assert::assertMatchesRegularExpression($regexp, $element->getText(), "No expected text in [{$selector}]");
return $this;
}
@@ -211,7 +211,7 @@
*/
public function readDownloadedFile($filename, $sleep = 5)
{
- $filename = __DIR__ . "/Browser/downloads/$filename";
+ $filename = __DIR__ . "/Browser/downloads/{$filename}";
// Give the browser a chance to finish download
// Note: For unknown reason Chromium would create files with added underscore
@@ -221,7 +221,8 @@
if (file_exists($filename)) {
return file_get_contents($filename);
- } elseif (file_exists("{$filename}_")) {
+ }
+ if (file_exists("{$filename}_")) {
return file_get_contents("{$filename}_");
}
@@ -233,7 +234,7 @@
*/
public function removeDownloadedFile($filename)
{
- @unlink(__DIR__ . "/Browser/downloads/$filename");
+ @unlink(__DIR__ . "/Browser/downloads/{$filename}");
@unlink(__DIR__ . "/Browser/downloads/{$filename}_"); // see readDownloadedFile() method
return $this;
@@ -250,7 +251,7 @@
// We have to clear the field and dispatch 'input' event programatically.
$this->script(
- "var element = document.querySelector('$selector');"
+ "var element = document.querySelector('{$selector}');"
. "element.value = '';"
. "element.dispatchEvent(new Event('input'))"
);
@@ -281,7 +282,8 @@
/**
* Store the console output with the given name. Overwrites Dusk's method.
*
- * @param string $name
+ * @param string $name
+ *
* @return $this
*/
public function storeConsoleLog($name)
@@ -305,7 +307,7 @@
if (!empty($console)) {
$file = sprintf('%s/%s.log', rtrim(static::$storeConsoleLogAt, '/'), $name);
- $content = json_encode($console, JSON_PRETTY_PRINT);
+ $content = json_encode($console, \JSON_PRETTY_PRINT);
file_put_contents($file, $content);
}
@@ -319,7 +321,6 @@
*
* This allows to propagte custom config values to the server that interacts with the browser.
*
- * @param array $config
* @return $this
*/
public function withConfig(array $config)
diff --git a/src/tests/Browser/Admin/DashboardTest.php b/src/tests/Browser/Admin/DashboardTest.php
--- a/src/tests/Browser/Admin/DashboardTest.php
+++ b/src/tests/Browser/Admin/DashboardTest.php
@@ -2,6 +2,9 @@
namespace Tests\Browser\Admin;
+use App\Domain;
+use App\Plan;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
use Tests\Browser\Components\Toast;
@@ -11,10 +14,7 @@
class DashboardTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -26,10 +26,7 @@
$this->deleteTestDomain('testsearch.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSetting('external_email', null);
@@ -42,13 +39,14 @@
/**
* Test user search
+ *
* @group skipci
*/
public function testSearch(): void
{
$this->browse(function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertFocused('@search input')
->assertMissing('@search table');
@@ -67,9 +65,9 @@
$browser->type('@search input', 'john.doe.external@gmail.com')
->click('@search form button')
->assertToast(Toast::TYPE_INFO, '2 user accounts have been found.')
- ->whenAvailable('@search table', function (Browser $browser) use ($john, $jack) {
+ ->whenAvailable('@search table', static function (Browser $browser) use ($john, $jack) {
$browser->assertElementsCount('tbody tr', 2)
- ->with('tbody tr:first-child', function (Browser $browser) use ($jack) {
+ ->with('tbody tr:first-child', static function (Browser $browser) use ($jack) {
$browser->assertSeeIn('td:nth-child(1) a', $jack->email)
->assertSeeIn('td:nth-child(2) a', $jack->id);
@@ -82,7 +80,7 @@
->assertText('td:nth-child(4)', '');
}
})
- ->with('tbody tr:last-child', function (Browser $browser) use ($john) {
+ ->with('tbody tr:last-child', static function (Browser $browser) use ($john) {
$browser->assertSeeIn('td:nth-child(1) a', $john->email)
->assertSeeIn('td:nth-child(2) a', $john->id);
@@ -103,7 +101,7 @@
->assertMissing('@search table')
->waitForLocation('/user/' . $john->id)
->waitUntilMissing('.app-loader')
- ->whenAvailable('#user-info', function (Browser $browser) use ($john) {
+ ->whenAvailable('#user-info', static function (Browser $browser) use ($john) {
$browser->assertSeeIn('.card-title', $john->email);
});
});
@@ -111,21 +109,22 @@
/**
* Test user search deleted user/domain
+ *
* @group skipci
*/
public function testSearchDeleted(): void
{
$this->browse(function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertFocused('@search input')
->assertMissing('@search table');
// Deleted users/domains
- $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]);
+ $domain = $this->getTestDomain('testsearch.com', ['type' => Domain::TYPE_EXTERNAL]);
$user = $this->getTestUser('test@testsearch.com');
- $plan = \App\Plan::where('title', 'group')->first();
+ $plan = Plan::where('title', 'group')->first();
$user->assignPlan($plan, $domain);
$user->setAliases(['alias@testsearch.com']);
Queue::fake();
@@ -135,10 +134,10 @@
$browser->type('@search input', 'testsearch.com')
->click('@search form button')
->assertToast(Toast::TYPE_INFO, '1 user accounts have been found.')
- ->whenAvailable('@search table', function (Browser $browser) use ($user) {
+ ->whenAvailable('@search table', static function (Browser $browser) use ($user) {
$browser->assertElementsCount('tbody tr', 1)
->assertVisible('tbody tr:first-child.text-secondary')
- ->with('tbody tr:first-child', function (Browser $browser) use ($user) {
+ ->with('tbody tr:first-child', static function (Browser $browser) use ($user) {
$browser->assertSeeIn('td:nth-child(1) span', $user->email)
->assertSeeIn('td:nth-child(2) span', $user->id);
diff --git a/src/tests/Browser/Admin/DistlistTest.php b/src/tests/Browser/Admin/DistlistTest.php
--- a/src/tests/Browser/Admin/DistlistTest.php
+++ b/src/tests/Browser/Admin/DistlistTest.php
@@ -4,6 +4,7 @@
use App\EventLog;
use App\Group;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
@@ -16,25 +17,19 @@
class DistlistTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
$this->deleteTestGroup('group-test@kolab.org');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
parent::tearDown();
}
@@ -80,7 +75,7 @@
// Goto the distlist page
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -89,7 +84,7 @@
->click('@user-distlists table tbody tr:first-child td a')
->on($distlist_page)
->assertSeeIn('@distlist-info .card-title', $group->email)
- ->with('@distlist-info form', function (Browser $browser) use ($group) {
+ ->with('@distlist-info form', static function (Browser $browser) use ($group) {
$browser->assertElementsCount('.row', 4)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #distlistid', "{$group->id} ({$group->created_at})")
@@ -103,7 +98,7 @@
})
->assertElementsCount('ul.nav-tabs li', 2)
->assertSeeIn('ul.nav-tabs #tab-settings', 'Settings')
- ->with('@distlist-settings form', function (Browser $browser) {
+ ->with('@distlist-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Sender Access List')
->assertSeeIn('.row:nth-child(1) #sender_policy', 'test1.com, test2.com');
@@ -112,7 +107,7 @@
// Assert History tab
$browser->assertSeeIn('ul.nav-tabs #tab-history', 'History')
->click('ul.nav-tabs #tab-history')
- ->whenAvailable('@distlist-history table', function (Browser $browser) use ($event1, $event2) {
+ ->whenAvailable('@distlist-history table', static function (Browser $browser) use ($event1, $event2) {
$browser->waitFor('tbody tr')->assertElementsCount('tbody tr', 2)
// row 1
->assertSeeIn('tr:nth-child(1) td:nth-child(1)', $event2->created_at->toDateTimeString())
@@ -150,7 +145,7 @@
public function testSuspendAndUnsuspend(): void
{
Queue::fake();
- Eventlog::query()->delete();
+ EventLog::query()->delete();
$this->browse(function (Browser $browser) {
$user = $this->getTestUser('john@kolab.org');
@@ -164,7 +159,7 @@
->assertMissing('@distlist-info #button-unsuspend')
->assertSeeIn('@distlist-info #status.text-success', 'Active')
->click('@distlist-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -177,10 +172,10 @@
$event = EventLog::where('type', EventLog::TYPE_SUSPENDED)->first();
$this->assertSame('test suspend', $event->comment);
- $this->assertEquals($group->id, $event->object_id);
+ $this->assertSame((string) $group->id, (string) $event->object_id);
$browser->click('@distlist-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -192,8 +187,8 @@
->assertMissing('@distlist-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
- $this->assertEquals($group->id, $event->object_id);
+ $this->assertNull($event->comment);
+ $this->assertSame((string) $group->id, (string) $event->object_id);
});
}
}
diff --git a/src/tests/Browser/Admin/DomainTest.php b/src/tests/Browser/Admin/DomainTest.php
--- a/src/tests/Browser/Admin/DomainTest.php
+++ b/src/tests/Browser/Admin/DomainTest.php
@@ -3,7 +3,10 @@
namespace Tests\Browser\Admin;
use App\Domain;
+use App\Entitlement;
use App\EventLog;
+use App\Sku;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -12,29 +15,22 @@
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
class DomainTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$domain = $this->getTestDomain('kolab.org');
$domain->setSetting('spf_whitelist', null);
@@ -42,7 +38,7 @@
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
parent::tearDown();
}
@@ -80,7 +76,7 @@
// Goto the domain page
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -90,7 +86,7 @@
$browser->on($domain_page)
->assertSeeIn('@domain-info .card-title', 'kolab.org')
- ->with('@domain-info form', function (Browser $browser) use ($domain) {
+ ->with('@domain-info form', static function (Browser $browser) use ($domain) {
$browser->assertElementsCount('.row', 2)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #domainid', "{$domain->id} ({$domain->created_at})")
@@ -104,7 +100,7 @@
// Assert Configuration tab
$browser->assertSeeIn('@nav #tab-config', 'Configuration')
- ->with('@domain-config', function (Browser $browser) {
+ ->with('@domain-config', static function (Browser $browser) {
$browser->assertSeeIn('pre#dns-confirm', 'kolab-verify.kolab.org.')
->assertSeeIn('pre#dns-config', 'kolab.org.');
});
@@ -112,7 +108,7 @@
// Assert Settings tab
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('@domain-settings form', function (Browser $browser) {
+ ->with('@domain-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:first-child label', 'SPF Whitelist')
->assertSeeIn('.row:first-child .form-control-plaintext', 'none');
@@ -125,14 +121,14 @@
->on($domain_page)
->waitFor('@nav #tab-settings')
->click('@nav #tab-settings')
- ->whenAvailable('@domain-settings form', function (Browser $browser) {
+ ->whenAvailable('@domain-settings form', static function (Browser $browser) {
$browser->assertSeeIn('.row:first-child .form-control-plaintext', '.test1.com, .test2.com');
});
// Assert History tab
$browser->assertSeeIn('@nav #tab-history', 'History')
->click('@nav #tab-history')
- ->whenAvailable('@domain-history table', function (Browser $browser) use ($event1, $event2) {
+ ->whenAvailable('@domain-history table', static function (Browser $browser) use ($event1, $event2) {
$browser->waitFor('tbody tr')->assertElementsCount('tbody tr', 2)
// row 1
->assertSeeIn('tr:nth-child(1) td:nth-child(1)', $event2->created_at->toDateTimeString())
@@ -169,27 +165,27 @@
EventLog::query()->delete();
$this->browse(function (Browser $browser) {
- $sku_domain = \App\Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $sku_domain = Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user = $this->getTestUser('test1@domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE
- | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED
- | Domain::STATUS_VERIFIED,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE
+ | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED
+ | Domain::STATUS_VERIFIED,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- \App\Entitlement::create([
+ Entitlement::create([
'wallet_id' => $user->wallets()->first()->id,
'sku_id' => $sku_domain->id,
'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'entitleable_type' => Domain::class,
]);
$browser->visit(new DomainPage($domain->id))
->assertVisible('@domain-info #button-suspend')
->assertMissing('@domain-info #button-unsuspend')
->click('@domain-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -202,10 +198,10 @@
$event = EventLog::where('type', EventLog::TYPE_SUSPENDED)->first();
$this->assertSame('test suspend', $event->comment);
- $this->assertEquals($domain->id, $event->object_id);
+ $this->assertSame((string) $domain->id, (string) $event->object_id);
$browser->click('@domain-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -217,8 +213,8 @@
->assertMissing('@domain-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
- $this->assertEquals($domain->id, $event->object_id);
+ $this->assertNull($event->comment);
+ $this->assertSame((string) $domain->id, (string) $event->object_id);
});
}
}
diff --git a/src/tests/Browser/Admin/LogonTest.php b/src/tests/Browser/Admin/LogonTest.php
--- a/src/tests/Browser/Admin/LogonTest.php
+++ b/src/tests/Browser/Admin/LogonTest.php
@@ -2,20 +2,17 @@
namespace Tests\Browser\Admin;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Menu;
use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
class LogonTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -26,9 +23,9 @@
*/
public function testLogonMenu(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->with(new Menu(), function ($browser) {
+ ->with(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
})
->assertMissing('@second-factor-input')
@@ -41,7 +38,7 @@
*/
public function testLogonRedirect(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/dashboard');
// Checks if we're really on the login page
@@ -55,7 +52,7 @@
*/
public function testLogonWrongCredentials(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('jeroen@jeroen.jeroen', 'wrong')
// Error message
@@ -70,13 +67,13 @@
*/
public function testLogonSuccessful(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true);
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true);
// Checks if we're really on Dashboard page
$browser->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']);
})
->assertUser('jeroen@jeroen.jeroen');
@@ -94,11 +91,11 @@
*/
public function testLogout(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new Dashboard());
// Click the Logout button
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
@@ -107,7 +104,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
});
@@ -121,9 +118,9 @@
*/
public function testLogoutByURL(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true);
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true);
// Checks if we're really on Dashboard page
$browser->on(new Dashboard());
@@ -134,7 +131,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
});
diff --git a/src/tests/Browser/Admin/ResourceTest.php b/src/tests/Browser/Admin/ResourceTest.php
--- a/src/tests/Browser/Admin/ResourceTest.php
+++ b/src/tests/Browser/Admin/ResourceTest.php
@@ -3,9 +3,9 @@
namespace Tests\Browser\Admin;
use App\Resource;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Admin\Resource as ResourcePage;
use Tests\Browser\Pages\Admin\User as UserPage;
use Tests\Browser\Pages\Dashboard;
@@ -14,19 +14,13 @@
class ResourceTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -65,7 +59,7 @@
// Goto the resource page
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -74,7 +68,7 @@
->click('@user-resources table tbody tr:first-child td:first-child a')
->on($resource_page)
->assertSeeIn('@resource-info .card-title', $resource->email)
- ->with('@resource-info form', function (Browser $browser) use ($resource) {
+ ->with('@resource-info form', static function (Browser $browser) use ($resource) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #resourceid', "{$resource->id} ({$resource->created_at})")
@@ -85,7 +79,7 @@
})
->assertElementsCount('ul.nav-tabs', 1)
->assertSeeIn('ul.nav-tabs .nav-link', 'Settings')
- ->with('@resource-settings form', function (Browser $browser) {
+ ->with('@resource-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Invitation policy')
->assertSeeIn('.row:nth-child(1) #invitation_policy', 'accept');
diff --git a/src/tests/Browser/Admin/SharedFolderTest.php b/src/tests/Browser/Admin/SharedFolderTest.php
--- a/src/tests/Browser/Admin/SharedFolderTest.php
+++ b/src/tests/Browser/Admin/SharedFolderTest.php
@@ -3,9 +3,9 @@
namespace Tests\Browser\Admin;
use App\SharedFolder;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Admin\SharedFolder as SharedFolderPage;
use Tests\Browser\Pages\Admin\User as UserPage;
use Tests\Browser\Pages\Dashboard;
@@ -14,19 +14,13 @@
class SharedFolderTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -66,7 +60,7 @@
// Goto the folder page
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -75,7 +69,7 @@
->click('@user-folders table tbody tr:first-child td:first-child a')
->on($folder_page)
->assertSeeIn('@folder-info .card-title', $folder->email)
- ->with('@folder-info form', function (Browser $browser) use ($folder) {
+ ->with('@folder-info form', static function (Browser $browser) use ($folder) {
$browser->assertElementsCount('.row', 4)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #folderid', "{$folder->id} ({$folder->created_at})")
@@ -88,7 +82,7 @@
})
->assertElementsCount('ul.nav-tabs .nav-item', 2)
->assertSeeIn('ul.nav-tabs .nav-item:nth-child(1) .nav-link', 'Settings')
- ->with('@folder-settings form', function (Browser $browser) {
+ ->with('@folder-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Access rights')
->assertSeeIn('.row:nth-child(1) #acl', 'anyone: read-only')
@@ -96,7 +90,7 @@
})
->assertSeeIn('ul.nav-tabs .nav-item:nth-child(2) .nav-link', 'Email Aliases (2)')
->click('ul.nav-tabs .nav-item:nth-child(2) .nav-link')
- ->with('@folder-aliases table', function (Browser $browser) {
+ ->with('@folder-aliases table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1) td', 'folder-alias1@kolab.org')
->assertSeeIn('tbody tr:nth-child(2) td', 'folder-alias2@kolab.org');
diff --git a/src/tests/Browser/Admin/StatsTest.php b/src/tests/Browser/Admin/StatsTest.php
--- a/src/tests/Browser/Admin/StatsTest.php
+++ b/src/tests/Browser/Admin/StatsTest.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Admin;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Pages\Admin\Stats;
use Tests\Browser\Pages\Dashboard;
@@ -10,10 +11,7 @@
class StatsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -24,9 +22,9 @@
*/
public function testStats(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertSeeIn('@links .link-stats', 'Stats')
->click('@links .link-stats')
diff --git a/src/tests/Browser/Admin/UserFinancesTest.php b/src/tests/Browser/Admin/UserFinancesTest.php
--- a/src/tests/Browser/Admin/UserFinancesTest.php
+++ b/src/tests/Browser/Admin/UserFinancesTest.php
@@ -4,7 +4,7 @@
use App\Discount;
use App\Transaction;
-use App\User;
+use App\Utils;
use App\Wallet;
use Carbon\Carbon;
use Tests\Browser;
@@ -17,10 +17,7 @@
class UserFinancesTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -47,16 +44,16 @@
$page = new UserPage($jack->id);
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($page)
->on($page)
->assertSeeIn('@nav #tab-finances', 'Finances')
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 2)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', 'none')
@@ -64,7 +61,7 @@
->assertSeeIn('.row:nth-child(2) a', 'abc');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertMissing('tbody')
->assertSeeIn('tfoot td', "There are no transactions for this account.");
})
@@ -85,12 +82,12 @@
// Create test transactions
$transaction = Transaction::create([
- 'user_email' => 'jeroen@jeroen.jeroen',
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_CREDIT,
- 'amount' => 100,
- 'description' => 'Payment',
+ 'user_email' => 'jeroen@jeroen.jeroen',
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_CREDIT,
+ 'amount' => 100,
+ 'description' => 'Payment',
]);
$transaction->created_at = Carbon::now()->subMonth();
$transaction->save();
@@ -98,17 +95,17 @@
// Click the managed-by link on Jack's page
$browser->click('@user-info #manager a')
->on($page)
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-danger', '-20,10 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', '10% - Test voucher');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertMissing('tfoot');
@@ -130,17 +127,17 @@
$browser->click('@nav #tab-users')
->click('@user-users tbody tr:nth-child(4) td:first-child a')
->on($page)
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', 'none');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertMissing('tbody')
->assertSeeIn('tfoot td', "There are no transactions for this account.");
})
@@ -164,7 +161,7 @@
->waitUntilMissing('@user-finances .app-loader')
->click('@user-finances #discount button')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Account discount')
->assertFocused('@body select')
->assertSelected('@body select', '')
@@ -175,7 +172,7 @@
->assertMissing('#discount-dialog')
->click('@user-finances #discount button')
// Change the discount
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->click('@body select')
->click('@body select option:nth-child(2)')
->click('@button-action');
@@ -183,7 +180,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.')
->assertSeeIn('#discount span', '10% - Test voucher')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹')
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,41 CHF/month¹')
@@ -192,7 +189,7 @@
// Change back to 'none'
->click('@nav #tab-finances')
->click('@user-finances #discount button')
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->click('@body select')
->click('@body select option:nth-child(1)')
->click('@button-action');
@@ -200,7 +197,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.')
->assertSeeIn('#discount span', 'none')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF/month')
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month')
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,90 CHF/month')
@@ -223,7 +220,7 @@
->waitFor('@user-finances #button-award')
->click('@user-finances #button-award')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Add a bonus to the wallet')
->assertFocused('@body input#oneoff_amount')
->assertSeeIn('@body label[for="oneoff_amount"]', 'Amount')
@@ -238,7 +235,7 @@
// Test bonus
$browser->click('@user-finances #button-award')
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
// Test input validation for a bonus
$browser->type('@body #oneoff_amount', 'aaa')
->type('@body #oneoff_description', '')
@@ -264,7 +261,7 @@
->assertMissing('#oneoff-dialog')
->assertSeeIn('@user-finances .card-title span.text-success', '12,34 CHF')
->waitUntilMissing('.app-loader')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 3)
->assertMissing('tfoot')
->assertSeeIn('tbody tr:first-child td.description', 'Bonus: Test bonus')
@@ -280,7 +277,7 @@
// Test penalty
$browser->click('@user-finances #button-penalty')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Add a penalty to the wallet')
->assertFocused('@body input#oneoff_amount')
->assertSeeIn('@body label[for="oneoff_amount"]', 'Amount')
@@ -293,7 +290,7 @@
})
->assertMissing('#oneoff-dialog')
->click('@user-finances #button-penalty')
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
// Test input validation for a penalty
$browser->type('@body #oneoff_amount', '')
->type('@body #oneoff_description', '')
diff --git a/src/tests/Browser/Admin/UserTest.php b/src/tests/Browser/Admin/UserTest.php
--- a/src/tests/Browser/Admin/UserTest.php
+++ b/src/tests/Browser/Admin/UserTest.php
@@ -8,6 +8,7 @@
use App\EventLog;
use App\Sku;
use App\User;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -15,22 +16,18 @@
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
class UserTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
$john = $this->getTestUser('john@kolab.org');
$john->setSettings([
- 'phone' => '+48123123123',
- 'external_email' => 'john.doe.external@gmail.com',
+ 'phone' => '+48123123123',
+ 'external_email' => 'john.doe.external@gmail.com',
]);
if ($john->isSuspended()) {
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]);
@@ -40,21 +37,18 @@
$wallet->save();
Entitlement::where('cost', '>=', 5000)->delete();
- Eventlog::query()->delete();
+ EventLog::query()->delete();
$this->deleteTestGroup('group-test@kolab.org');
$this->deleteTestUser('userstest1@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$john = $this->getTestUser('john@kolab.org');
$john->setSettings([
- 'phone' => null,
- 'external_email' => 'john.doe.external@gmail.com',
+ 'phone' => null,
+ 'external_email' => 'john.doe.external@gmail.com',
]);
if ($john->isSuspended()) {
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]);
@@ -64,7 +58,7 @@
$wallet->save();
Entitlement::where('cost', '>=', 5000)->delete();
- Eventlog::query()->delete();
+ EventLog::query()->delete();
$this->deleteTestGroup('group-test@kolab.org');
$this->deleteTestUser('userstest1@kolabnow.com');
@@ -92,9 +86,9 @@
$this->browse(function (Browser $browser) {
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSettings([
- 'limit_geo' => null,
- 'organization' => null,
- 'guam_enabled' => null,
+ 'limit_geo' => null,
+ 'organization' => null,
+ 'guam_enabled' => null,
]);
$event1 = EventLog::createFor($jack, EventLog::TYPE_SUSPENDED, 'Event 1');
@@ -109,14 +103,14 @@
$page = new UserPage($jack->id);
$browser->visit(new Home())
- ->submitLogon('jeroen@jeroen.jeroen', \App\Utils::generatePassphrase(), true)
+ ->submitLogon('jeroen@jeroen.jeroen', Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($page)
->on($page);
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $jack->email)
- ->with('@user-info form', function (Browser $browser) use ($jack) {
+ ->with('@user-info form', static function (Browser $browser) use ($jack) {
$browser->assertElementsCount('.row', 7)
->assertSeeIn('.row:nth-child(1) label', 'Managed by')
->assertSeeIn('.row:nth-child(1) #manager a', 'john@kolab.org')
@@ -145,7 +139,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 1)
->assertSeeIn('table tbody tr:first-child td:first-child', 'jack.daniels@kolab.org')
->assertMissing('table tfoot');
@@ -154,7 +148,7 @@
// Assert Subscriptions tab
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 3)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF')
@@ -169,7 +163,7 @@
// Assert Domains tab
$browser->assertSeeIn('@nav #tab-domains', 'Domains (0)')
->click('@nav #tab-domains')
- ->with('@user-domains', function (Browser $browser) {
+ ->with('@user-domains', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no domains in this account.');
});
@@ -177,7 +171,7 @@
// Assert Users tab
$browser->assertSeeIn('@nav #tab-users', 'Users (0)')
->click('@nav #tab-users')
- ->with('@user-users', function (Browser $browser) {
+ ->with('@user-users', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no users in this account.');
});
@@ -185,7 +179,7 @@
// Assert Distribution lists tab
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)')
->click('@nav #tab-distlists')
- ->with('@user-distlists', function (Browser $browser) {
+ ->with('@user-distlists', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.');
});
@@ -193,7 +187,7 @@
// Assert Resources tab
$browser->assertSeeIn('@nav #tab-resources', 'Resources (0)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no resources in this account.');
});
@@ -201,7 +195,7 @@
// Assert Shared folders tab
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (0)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no shared folders in this account.');
});
@@ -209,7 +203,7 @@
// Assert Settings tab
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->whenAvailable('@user-settings form', function (Browser $browser) {
+ ->whenAvailable('@user-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:first-child label', 'Greylisting')
->assertSeeIn('.row:first-child .text-success', 'enabled')
@@ -223,7 +217,7 @@
// Assert History tab
$browser->assertSeeIn('@nav #tab-history', 'History')
->click('@nav #tab-history')
- ->whenAvailable('@user-history table', function (Browser $browser) use ($event1, $event2) {
+ ->whenAvailable('@user-history table', static function (Browser $browser) use ($event1, $event2) {
$browser->waitFor('tbody tr')->assertElementsCount('tbody tr', 2)
// row 1
->assertSeeIn('tr:nth-child(1) td:nth-child(1)', $event2->created_at->toDateTimeString())
@@ -276,7 +270,7 @@
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $john->email)
- ->with('@user-info form', function (Browser $browser) use ($john) {
+ ->with('@user-info form', static function (Browser $browser) use ($john) {
$ext_email = $john->getSetting('external_email');
$browser->assertElementsCount('.row', 9)
@@ -294,7 +288,7 @@
->assertSeeIn('.row:nth-child(6) #phone', $john->getSetting('phone'))
->assertSeeIn('.row:nth-child(7) label', 'External Email')
->assertSeeIn('.row:nth-child(7) #external_email a', $ext_email)
- ->assertAttribute('.row:nth-child(7) #external_email a', 'href', "mailto:$ext_email")
+ ->assertAttribute('.row:nth-child(7) #external_email a', 'href', "mailto:{$ext_email}")
->assertSeeIn('.row:nth-child(8) label', 'Address')
->assertSeeIn('.row:nth-child(8) #billing_address', $john->getSetting('billing_address'))
->assertSeeIn('.row:nth-child(9) label', 'Country')
@@ -311,7 +305,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 1)
->assertSeeIn('table tbody tr:first-child td:first-child', 'john.doe@kolab.org')
->assertMissing('table tfoot');
@@ -320,7 +314,7 @@
// Assert Subscriptions tab
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 3)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
@@ -335,7 +329,7 @@
// Assert Domains tab
$browser->assertSeeIn('@nav #tab-domains', 'Domains (1)')
->click('@nav #tab-domains')
- ->with('@user-domains table', function (Browser $browser) {
+ ->with('@user-domains table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'kolab.org')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success')
@@ -345,7 +339,7 @@
// Assert Users tab
$browser->assertSeeIn('@nav #tab-users', 'Users (4)')
->click('@nav #tab-users')
- ->with('@user-users table', function (Browser $browser) {
+ ->with('@user-users table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 4)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'jack@kolab.org')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success')
@@ -361,7 +355,7 @@
// Assert Distribution lists tab
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (1)')
->click('@nav #tab-distlists')
- ->with('@user-distlists table', function (Browser $browser) {
+ ->with('@user-distlists table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'Test Group')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-danger')
@@ -372,7 +366,7 @@
// Assert Resources tab
$browser->assertSeeIn('@nav #tab-resources', 'Resources (2)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 2)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'Conference Room #1')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', 'resource-test1@kolab.org')
@@ -384,7 +378,7 @@
// Assert Shared folders tab
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (2)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 2)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'Calendar')
->assertSeeIn('table tbody tr:nth-child(1) td:nth-child(2)', 'Calendar')
@@ -398,7 +392,7 @@
// Assert History tab
$browser->assertSeeIn('@nav #tab-history', 'History')
->click('@nav #tab-history')
- ->whenAvailable('@user-history table', function (Browser $browser) {
+ ->whenAvailable('@user-history table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 0)
->assertSeeIn('tfoot tr td', "There's no events in the log");
});
@@ -413,18 +407,18 @@
// Add an extra storage and beta entitlement with different prices
Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $beta_sku->id,
- 'cost' => 5010,
- 'entitleable_id' => $ned->id,
- 'entitleable_type' => User::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $beta_sku->id,
+ 'cost' => 5010,
+ 'entitleable_id' => $ned->id,
+ 'entitleable_type' => User::class,
]);
Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $storage_sku->id,
- 'cost' => 5000,
- 'entitleable_id' => $ned->id,
- 'entitleable_type' => User::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $storage_sku->id,
+ 'cost' => 5000,
+ 'entitleable_id' => $ned->id,
+ 'entitleable_type' => User::class,
]);
$page = new UserPage($ned->id);
@@ -436,7 +430,7 @@
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $ned->email)
- ->with('@user-info form', function (Browser $browser) use ($ned) {
+ ->with('@user-info form', static function (Browser $browser) use ($ned) {
$browser->assertSeeIn('.row:nth-child(2) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(2) #userid', "{$ned->id} ({$ned->created_at})");
});
@@ -451,7 +445,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (0)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'This user has no email aliases.');
});
@@ -459,7 +453,7 @@
// Assert Subscriptions tab, we expect John's discount here
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (6)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 6)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
@@ -482,7 +476,7 @@
// We don't expect John's domains here
$browser->assertSeeIn('@nav #tab-domains', 'Domains (0)')
->click('@nav #tab-domains')
- ->with('@user-domains', function (Browser $browser) {
+ ->with('@user-domains', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no domains in this account.');
});
@@ -490,7 +484,7 @@
// We don't expect John's users here
$browser->assertSeeIn('@nav #tab-users', 'Users (0)')
->click('@nav #tab-users')
- ->with('@user-users', function (Browser $browser) {
+ ->with('@user-users', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no users in this account.');
});
@@ -498,7 +492,7 @@
// We don't expect John's distribution lists here
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)')
->click('@nav #tab-distlists')
- ->with('@user-distlists', function (Browser $browser) {
+ ->with('@user-distlists', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.');
});
@@ -506,7 +500,7 @@
// We don't expect John's resources here
$browser->assertSeeIn('@nav #tab-resources', 'Resources (0)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no resources in this account.');
});
@@ -514,7 +508,7 @@
// We don't expect John's folders here
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (0)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no shared folders in this account.');
});
@@ -522,7 +516,7 @@
// Assert Settings tab
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->whenAvailable('@user-settings form', function (Browser $browser) {
+ ->whenAvailable('@user-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:first-child label', 'Greylisting')
->assertSeeIn('.row:first-child .text-danger', 'disabled');
@@ -544,7 +538,7 @@
->waitFor('@user-info #external_email button')
->click('@user-info #external_email button')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'External Email')
->assertFocused('@body input')
->assertValue('@body input', 'john.doe.external@gmail.com')
@@ -555,7 +549,7 @@
->assertMissing('#email-dialog')
->click('@user-info #external_email button')
// Test email validation error handling, and email update
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->type('@body input', 'test')
->click('@button-action')
->waitFor('@body input.is-invalid')
@@ -570,7 +564,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.')
->assertSeeIn('@user-info #external_email a', 'test@test.com')
->click('@user-info #external_email button')
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->assertValue('@body input', 'test@test.com')
->assertMissing('@body input.is-invalid')
->assertMissing('@body input + .invalid-feedback')
@@ -597,7 +591,7 @@
->assertVisible('@user-info #button-suspend')
->assertMissing('@user-info #button-unsuspend')
->click('@user-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -612,7 +606,7 @@
$this->assertSame('test suspend', $event->comment);
$browser->click('@user-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -624,7 +618,7 @@
->assertMissing('@user-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
+ $this->assertNull($event->comment);
});
}
@@ -658,13 +652,13 @@
$browser->visit(new UserPage($user->id))
->assertSeeIn('@user-info #status', 'Restricted')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) use ($sku2fa) {
+ ->with('@user-subscriptions', static function (Browser $browser) use ($sku2fa) {
$browser->waitFor('#reset2fa')
->assertVisible('#sku' . $sku2fa->id);
})
->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (1)')
->click('#reset2fa')
- ->with(new Dialog('#reset-2fa-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#reset-2fa-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', '2-Factor Authentication Reset')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Reset')
@@ -687,7 +681,7 @@
$browser->visit(new UserPage($user->id))
->click('@nav #tab-settings')
- ->whenAvailable('@user-settings form', function (Browser $browser) {
+ ->whenAvailable('@user-settings form', static function (Browser $browser) {
$browser->assertSeeIn('.row:nth-child(3) label', 'Geo-lockin')
->assertSeeIn('.row:nth-child(3) #limit_geo', 'Poland, Germany')
->assertSeeIn('#limit_geo + button', 'Reset')
diff --git a/src/tests/Browser/AuthorizeTest.php b/src/tests/Browser/AuthorizeTest.php
--- a/src/tests/Browser/AuthorizeTest.php
+++ b/src/tests/Browser/AuthorizeTest.php
@@ -2,9 +2,10 @@
namespace Tests\Browser;
+use App\Auth\PassportClient;
+use App\Utils;
use Illuminate\Support\Facades\Cache;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
@@ -12,22 +13,19 @@
{
private $client;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
// Create a client for tests
- $this->client = \App\Auth\PassportClient::firstOrCreate(
+ $this->client = PassportClient::firstOrCreate(
['id' => 'test'],
[
'user_id' => null,
'name' => 'Test',
'secret' => '123',
'provider' => 'users',
- 'redirect' => \App\Utils::serviceUrl('support'),
+ 'redirect' => Utils::serviceUrl('support'),
'personal_access_client' => 0,
'password_client' => 0,
'revoked' => false,
@@ -36,10 +34,7 @@
);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->client->delete();
@@ -54,11 +49,11 @@
$user = $this->getTestUser('john@kolab.org');
$url = '/oauth/authorize?' . http_build_query([
- 'client_id' => $this->client->id,
- 'response_type' => 'code',
- 'scope' => 'email auth.token',
- 'state' => 'state',
- 'redirect_uri' => $this->client->redirect,
+ 'client_id' => $this->client->id,
+ 'response_type' => 'code',
+ 'scope' => 'email auth.token',
+ 'state' => 'state',
+ 'redirect_uri' => $this->client->redirect,
]);
Cache::forget("oauth-seen-{$user->id}-{$this->client->id}");
@@ -84,26 +79,26 @@
// Click the "No, thanks" button
$browser->click('#auth-form button.btn-danger')
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?error=access_denied&state=state/) !== null");
+ ->assertScript("location.search.match(/^\\?error=access_denied&state=state/) !== null");
// Visit the page again and click the "Allow access" button
$browser->visit($url)
->waitFor('#auth-form button.btn-success')
->click('#auth-form button.btn-success')
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null")
+ ->assertScript("location.search.match(/^\\?code=[a-f0-9]+&state=state/) !== null")
->pause(1000); // let the Support page refresh the session tokens before we proceed
// Visit the page and expect an immediate redirect
$browser->visit($url)
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?code=[a-f0-9]+&state=state/) !== null")
+ ->assertScript("location.search.match(/^\\?code=[a-f0-9]+&state=state/) !== null")
->pause(1000); // let the Support page refresh the session token before we proceed
// Error handling (invalid response_type)
$browser->visit(str_replace('response_type=code', 'response_type=invalid', $url))
->waitForLocation('/support')
- ->assertScript("location.search.match(/^\?error=unsupported_response_type&state=state/) !== null");
+ ->assertScript("location.search.match(/^\\?error=unsupported_response_type&state=state/) !== null");
});
}
}
diff --git a/src/tests/Browser/Components/AclInput.php b/src/tests/Browser/Components/AclInput.php
--- a/src/tests/Browser/Components/AclInput.php
+++ b/src/tests/Browser/Components/AclInput.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class AclInput extends BaseComponent
{
protected $selector;
-
public function __construct($selector)
{
$this->selector = $selector;
@@ -28,9 +27,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -68,15 +65,15 @@
foreach ($list as $idx => $value) {
$selector = '.input-group:nth-child(' . ($idx + 2) . ')';
- list($ident, $acl) = preg_split('/\s*,\s*/', $value);
+ [$ident, $acl] = preg_split('/\s*,\s*/', $value);
$input = $ident == 'anyone' ? 'input:read-only' : 'input:not(:read-only)';
- $browser->assertVisible("$selector $input")
- ->assertVisible("$selector select")
- ->assertVisible("$selector a.btn")
- ->assertValue("$selector $input", $ident)
- ->assertSelected("$selector select", $acl);
+ $browser->assertVisible("{$selector} {$input}")
+ ->assertVisible("{$selector} select")
+ ->assertVisible("{$selector} a.btn")
+ ->assertValue("{$selector} {$input}", $ident)
+ ->assertSelected("{$selector} select", $acl);
}
}
@@ -85,7 +82,7 @@
*/
public function addAclEntry($browser, string $value)
{
- list($ident, $acl) = preg_split('/\s*,\s*/', $value);
+ [$ident, $acl] = preg_split('/\s*,\s*/', $value);
$browser->select('@mod-select', $ident == 'anyone' ? 'anyone' : 'user')
->select('@acl-select', $acl);
@@ -116,12 +113,12 @@
*/
public function updateAclEntry($browser, int $num, $value)
{
- list($ident, $acl) = preg_split('/\s*,\s*/', $value);
+ [$ident, $acl] = preg_split('/\s*,\s*/', $value);
$selector = '.input-group:nth-child(' . ($num + 1) . ')';
- $browser->select("$selector select.acl", $acl)
- ->type("$selector input", $ident);
+ $browser->select("{$selector} select.acl", $acl)
+ ->type("{$selector} input", $ident);
}
/**
diff --git a/src/tests/Browser/Components/CountrySelect.php b/src/tests/Browser/Components/CountrySelect.php
--- a/src/tests/Browser/Components/CountrySelect.php
+++ b/src/tests/Browser/Components/CountrySelect.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
use PHPUnit\Framework\Assert as PHPUnit;
@@ -10,7 +11,6 @@
protected $selector;
protected $countries;
-
public function __construct($selector)
{
$this->selector = $selector;
@@ -30,9 +30,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -61,7 +59,7 @@
if (empty($list)) {
$browser->assertSeeIn('@link', 'No restrictions')
->click('@link')
- ->with(new Dialog('@dialog'), function ($browser) {
+ ->with(new Dialog('@dialog'), static function ($browser) {
$browser->waitFor('.world-map > svg', 10);
$selected = $browser->elements('.world-map [aria-selected="true"]');
@@ -77,7 +75,7 @@
$browser->assertSeeIn('@link', $this->countriesText($list))
->click('@link')
- ->with(new Dialog('@dialog'), function ($browser) use ($list) {
+ ->with(new Dialog('@dialog'), static function ($browser) use ($list) {
$browser->waitFor('.world-map > svg', 10);
$selected = $browser->elements('.world-map [aria-selected="true"]');
@@ -99,7 +97,7 @@
public function setCountries($browser, array $list)
{
$browser->click('@link')
- ->with(new Dialog('@dialog'), function ($browser) use ($list) {
+ ->with(new Dialog('@dialog'), static function ($browser) use ($list) {
$browser->waitFor('.world-map > svg')
->execScript("\$('.world-map [cc]').attr('aria-selected', '')");
diff --git a/src/tests/Browser/Components/Dialog.php b/src/tests/Browser/Components/Dialog.php
--- a/src/tests/Browser/Components/Dialog.php
+++ b/src/tests/Browser/Components/Dialog.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class Dialog extends BaseComponent
{
protected $selector;
-
public function __construct($selector)
{
$this->selector = trim($selector);
@@ -28,9 +27,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
diff --git a/src/tests/Browser/Components/Error.php b/src/tests/Browser/Components/Error.php
--- a/src/tests/Browser/Components/Error.php
+++ b/src/tests/Browser/Components/Error.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
use PHPUnit\Framework\Assert as PHPUnit;
@@ -40,9 +41,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -69,9 +68,9 @@
$selector = $this->selector();
return [
- '@code' => "$selector .code",
- '@message' => "$selector .message",
- '@hint' => "$selector .hint",
+ '@code' => "{$selector} .code",
+ '@message' => "{$selector} .message",
+ '@hint' => "{$selector} .hint",
];
}
}
diff --git a/src/tests/Browser/Components/ListInput.php b/src/tests/Browser/Components/ListInput.php
--- a/src/tests/Browser/Components/ListInput.php
+++ b/src/tests/Browser/Components/ListInput.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class ListInput extends BaseComponent
{
protected $selector;
-
public function __construct($selector)
{
$this->selector = $selector;
@@ -28,9 +27,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
diff --git a/src/tests/Browser/Components/Menu.php b/src/tests/Browser/Components/Menu.php
--- a/src/tests/Browser/Components/Menu.php
+++ b/src/tests/Browser/Components/Menu.php
@@ -4,6 +4,7 @@
use Laravel\Dusk\Component as BaseComponent;
use PHPUnit\Framework\Assert as PHPUnit;
+use Tests\Browser;
class Menu extends BaseComponent
{
@@ -32,9 +33,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Tests\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -44,13 +43,11 @@
/**
* Assert that menu contains only specified menu items.
*
- * @param \Tests\Browser $browser
- * @param array $items List of menu items
- * @param string $active Expected active item
- *
- * @return void
+ * @param Browser $browser
+ * @param array $items List of menu items
+ * @param string $active Expected active item
*/
- public function assertMenuItems($browser, array $items, string $active = null)
+ public function assertMenuItems($browser, array $items, ?string $active = null)
{
// On mobile the links are not visible, show them first (wait for transition)
if (!$browser->isDesktop()) {
@@ -76,10 +73,8 @@
/**
* Click menu link.
*
- * @param \Tests\Browser $browser The browser object
- * @param string $name Menu item name
- *
- * @return void
+ * @param Browser $browser The browser object
+ * @param string $name Menu item name
*/
public function clickMenuItem($browser, string $name)
{
@@ -106,9 +101,9 @@
return [
'@list' => ".navbar-nav",
- '@brand' => ".navbar-brand",
+ '@brand' => ".navbar-brand",
'@toggler' => ".navbar-toggler",
- '@lang' => ".nav-link.link-lang",
+ '@lang' => ".nav-link.link-lang",
];
}
}
diff --git a/src/tests/Browser/Components/QuotaInput.php b/src/tests/Browser/Components/QuotaInput.php
--- a/src/tests/Browser/Components/QuotaInput.php
+++ b/src/tests/Browser/Components/QuotaInput.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class QuotaInput extends BaseComponent
{
protected $selector;
-
public function __construct($selector)
{
$this->selector = trim($selector);
@@ -28,9 +27,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -40,15 +37,13 @@
/**
* Assert input value
*
- * @param \Laravel\Dusk\Browser $browser The browser
- * @param int $value Value in GB
- *
- * @return void
+ * @param Browser $browser The browser
+ * @param int $value Value in GB
*/
public function assertQuotaValue($browser, $value)
{
$browser->assertValue('@input', (string) $value)
- ->assertSeeIn('@label', "$value GB");
+ ->assertSeeIn('@label', "{$value} GB");
}
/**
@@ -67,10 +62,8 @@
/**
* Set input value
*
- * @param \Laravel\Dusk\Browser $browser The browser
- * @param int $value Value in GB
- *
- * @return void
+ * @param Browser $browser The browser
+ * @param int $value Value in GB
*/
public function setQuotaValue($browser, $value)
{
@@ -83,6 +76,6 @@
$num--;
}
- $browser->assertSeeIn('@label', "$value GB");
+ $browser->assertSeeIn('@label', "{$value} GB");
}
}
diff --git a/src/tests/Browser/Components/Status.php b/src/tests/Browser/Components/Status.php
--- a/src/tests/Browser/Components/Status.php
+++ b/src/tests/Browser/Components/Status.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
class Status extends BaseComponent
@@ -19,9 +20,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -37,7 +36,7 @@
{
return [
'@body' => "#status-body",
- '@progress-bar' => ".progress-bar",
+ '@progress-bar' => ".progress-bar",
'@progress-label' => ".progress-label",
'@refresh-button' => "#status-refresh",
'@refresh-text' => "#refresh-text",
@@ -52,7 +51,7 @@
$browser->assertVisible('@progress-bar')
->assertAttribute('@progress-bar', 'aria-valuenow', $percent)
->assertSeeIn('@progress-label', $label)
- ->withinBody(function ($browser) use ($class) {
+ ->withinBody(static function ($browser) use ($class) {
$browser->assertVisible('#status-box.process-' . $class);
});
}
diff --git a/src/tests/Browser/Components/SubscriptionSelect.php b/src/tests/Browser/Components/SubscriptionSelect.php
--- a/src/tests/Browser/Components/SubscriptionSelect.php
+++ b/src/tests/Browser/Components/SubscriptionSelect.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Components;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class SubscriptionSelect extends BaseComponent
{
protected $selector;
-
public function __construct($selector)
{
$this->selector = $selector;
@@ -28,9 +27,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser
- *
- * @return void
+ * @param Browser $browser
*/
public function assert($browser)
{
@@ -42,17 +39,17 @@
*/
public function assertSubscription($browser, int $idx, $name, $title = null, $price = null)
{
- $idx += 1; // index starts with 1 in css
- $row = "tbody tr:nth-child($idx)";
+ $idx++; // index starts with 1 in css
+ $row = "tbody tr:nth-child({$idx})";
- $browser->assertSeeIn("$row td.name label", $name);
+ $browser->assertSeeIn("{$row} td.name label", $name);
if ($title !== null) {
- $browser->assertTip("$row td.buttons button", $title);
+ $browser->assertTip("{$row} td.buttons button", $title);
}
if ($price !== null) {
- $browser->assertSeeIn("$row td.price", $price);
+ $browser->assertSeeIn("{$row} td.price", $price);
}
}
@@ -61,9 +58,9 @@
*/
public function assertSubscriptionState($browser, int $idx, bool $enabled)
{
- $idx += 1; // index starts with 1 in css
- $row = "tbody tr:nth-child($idx)";
- $browser->{$enabled ? 'assertChecked' : 'assertNotChecked'}("$row td.selection input");
+ $idx++; // index starts with 1 in css
+ $row = "tbody tr:nth-child({$idx})";
+ $browser->{$enabled ? 'assertChecked' : 'assertNotChecked'}("{$row} td.selection input");
}
/**
@@ -71,8 +68,8 @@
*/
public function clickSubscription($browser, int $idx)
{
- $idx += 1; // index starts with 1 in css
- $row = "tbody tr:nth-child($idx)";
- $browser->click("$row td.selection input");
+ $idx++; // index starts with 1 in css
+ $row = "tbody tr:nth-child({$idx})";
+ $browser->click("{$row} td.selection input");
}
}
diff --git a/src/tests/Browser/Components/Toast.php b/src/tests/Browser/Components/Toast.php
--- a/src/tests/Browser/Components/Toast.php
+++ b/src/tests/Browser/Components/Toast.php
@@ -3,8 +3,8 @@
namespace Tests\Browser\Components;
use Facebook\WebDriver\WebDriverBy;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Component as BaseComponent;
-use PHPUnit\Framework\Assert as PHPUnit;
class Toast extends BaseComponent
{
@@ -17,7 +17,6 @@
protected $type;
protected $element;
-
public function __construct($type)
{
$this->type = $type;
@@ -36,9 +35,7 @@
/**
* Assert that the browser page contains the component.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -55,14 +52,14 @@
{
return [
'@title' => ".toast-header > strong",
- '@message' => ".toast-body",
+ '@message' => ".toast-body",
];
}
/**
* Assert title of the toast element
*/
- public function assertToastTitle($browser, string $title = null)
+ public function assertToastTitle($browser, ?string $title = null)
{
if (empty($title)) {
switch ($this->type) {
diff --git a/src/tests/Browser/DegradedAccountTest.php b/src/tests/Browser/DegradedAccountTest.php
--- a/src/tests/Browser/DegradedAccountTest.php
+++ b/src/tests/Browser/DegradedAccountTest.php
@@ -8,17 +8,14 @@
use Tests\Browser\Pages\DistlistList;
use Tests\Browser\Pages\DomainList;
use Tests\Browser\Pages\Home;
-use Tests\Browser\Pages\UserList;
use Tests\Browser\Pages\ResourceList;
use Tests\Browser\Pages\SharedFolderList;
+use Tests\Browser\Pages\UserList;
use Tests\TestCaseDusk;
class DegradedAccountTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -32,10 +29,7 @@
$this->clearBetaEntitlements();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$john = $this->getTestUser('john@kolab.org');
@@ -58,7 +52,7 @@
$john = $this->getTestUser('john@kolab.org');
$this->addBetaEntitlement($john);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
@@ -69,7 +63,7 @@
$browser->visit(new UserList())
->assertSeeIn('#status-degraded p.alert', 'The account is degraded')
->assertSeeIn('#status-degraded p.alert', 'Please, make a payment')
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-warning') // Jack
->assertText('tbody tr:nth-child(2) td:first-child svg.text-warning title', 'Degraded')
@@ -114,7 +108,7 @@
*/
public function testDegradedAccountUser(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
->on(new Dashboard())
diff --git a/src/tests/Browser/DistlistTest.php b/src/tests/Browser/DistlistTest.php
--- a/src/tests/Browser/DistlistTest.php
+++ b/src/tests/Browser/DistlistTest.php
@@ -8,27 +8,21 @@
use Tests\Browser\Components\Status;
use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
-use Tests\Browser\Pages\Home;
use Tests\Browser\Pages\DistlistInfo;
use Tests\Browser\Pages\DistlistList;
+use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
class DistlistTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
@@ -41,7 +35,7 @@
public function testInfoUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/distlist/abc')->on(new Home());
});
}
@@ -52,7 +46,7 @@
public function testListUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/distlists')->on(new Home());
});
}
@@ -68,14 +62,14 @@
$group->assignToWallet($john->wallets->first());
// Log on the user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
->assertSeeIn('@links .link-distlists', 'Distribution lists')
->click('@links .link-distlists')
->on(new DistlistList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertSeeIn('thead tr th:nth-child(1)', 'Name')
->assertSeeIn('thead tr th:nth-child(2)', 'Email')
@@ -104,7 +98,7 @@
->assertSeeIn('#distlist-info .card-title', 'New distribution list')
->assertSeeIn('@nav #tab-general', 'General')
->assertMissing('@nav #tab-settings')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertMissing('#status')
->assertFocused('#name')
@@ -114,12 +108,12 @@
->assertValue('div.row:nth-child(2) input[type=text]', '')
->assertSeeIn('div.row:nth-child(3) label', 'Recipients')
->assertVisible('div.row:nth-child(3) .list-input')
- ->with(new ListInput('#members'), function (Browser $browser) {
+ ->with(new ListInput('#members'), static function (Browser $browser) {
$browser->assertListInputValue([])
->assertValue('@input', '');
})
->assertSeeIn('div.row:nth-child(4) label', 'Subscriptions')
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Distribution list')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,00 CHF/month')
@@ -145,7 +139,7 @@
// Test successful group creation
->type('#name', 'Test Group')
->type('#email', 'group-test@kolab.org')
- ->with(new ListInput('#members'), function (Browser $browser) {
+ ->with(new ListInput('#members'), static function (Browser $browser) {
$browser->addListEntry('test1@gmail.com')
->addListEntry('test2@gmail.com');
})
@@ -158,7 +152,7 @@
$browser->click('@table tr:nth-child(1) td:first-child a')
->on(new DistlistInfo())
->assertSeeIn('#distlist-info .card-title', 'Distribution list')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertFocused('#name')
->assertSeeIn('div.row:nth-child(1) label', 'Status')
@@ -169,12 +163,12 @@
->assertValue('div.row:nth-child(3) input[type=text]:disabled', 'group-test@kolab.org')
->assertSeeIn('div.row:nth-child(4) label', 'Recipients')
->assertVisible('div.row:nth-child(4) .list-input')
- ->with(new ListInput('#members'), function (Browser $browser) {
+ ->with(new ListInput('#members'), static function (Browser $browser) {
$browser->assertListInputValue(['test1@gmail.com', 'test2@gmail.com'])
->assertValue('@input', '');
})
->assertSeeIn('div.row:nth-child(5) label', 'Subscriptions')
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Distribution list')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,00 CHF/month')
@@ -188,7 +182,7 @@
->assertSeeIn('button[type=submit]', 'Submit');
})
// Test error handling
- ->with(new ListInput('#members'), function (Browser $browser) {
+ ->with(new ListInput('#members'), static function (Browser $browser) {
$browser->addListEntry('invalid address');
})
->click('@general button[type=submit]')
@@ -197,7 +191,7 @@
->assertVisible('#members .input-group:nth-child(4) input.is-invalid')
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
// Test successful update
- ->with(new ListInput('#members'), function (Browser $browser) {
+ ->with(new ListInput('#members'), static function (Browser $browser) {
$browser->removeListEntry(3)->removeListEntry(2);
})
->click('@general button[type=submit]')
@@ -242,11 +236,11 @@
$this->assertFalse($group->isLdapReady());
- $this->browse(function ($browser) use ($group) {
+ $this->browse(static function ($browser) use ($group) {
// Test auto-refresh
$browser->visit('/distlist/' . $group->id)
->on(new DistlistInfo())
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertSeeIn('@body', 'We are preparing the distribution list')
->assertProgress(83, 'Creating a distribution list...', 'pending')
->assertMissing('@refresh-button')
@@ -276,25 +270,25 @@
$group->status = Group::STATUS_NEW | Group::STATUS_ACTIVE;
$group->save();
- $this->browse(function ($browser) use ($group) {
+ $this->browse(static function ($browser) use ($group) {
// Test auto-refresh
$browser->visit('/distlist/' . $group->id)
->on(new DistlistInfo())
->assertSeeIn('@nav #tab-general', 'General')
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('@settings form', function (Browser $browser) {
+ ->with('@settings form', static function (Browser $browser) {
// Assert form content
$browser->assertSeeIn('div.row:nth-child(1) label', 'Sender Access List')
->assertVisible('div.row:nth-child(1) .list-input')
- ->with(new ListInput('#sender-policy'), function (Browser $browser) {
+ ->with(new ListInput('#sender-policy'), static function (Browser $browser) {
$browser->assertListInputValue([])
->assertValue('@input', '');
})
->assertSeeIn('button[type=submit]', 'Submit');
})
// Test error handling
- ->with(new ListInput('#sender-policy'), function (Browser $browser) {
+ ->with(new ListInput('#sender-policy'), static function (Browser $browser) {
$browser->addListEntry('test.com');
})
->click('@settings button[type=submit]')
@@ -303,8 +297,8 @@
->refresh()
->on(new DistlistInfo())
->click('@nav #tab-settings')
- ->with('@settings form', function (Browser $browser) {
- $browser->with(new ListInput('#sender-policy'), function (Browser $browser) {
+ ->with('@settings form', static function (Browser $browser) {
+ $browser->with(new ListInput('#sender-policy'), static function (Browser $browser) {
$browser->assertListInputValue(['test.com'])
->assertValue('@input', '');
});
diff --git a/src/tests/Browser/DomainTest.php b/src/tests/Browser/DomainTest.php
--- a/src/tests/Browser/DomainTest.php
+++ b/src/tests/Browser/DomainTest.php
@@ -3,6 +3,7 @@
namespace Tests\Browser;
use App\Domain;
+use App\Package;
use App\Plan;
use App\User;
use Tests\Browser;
@@ -17,10 +18,7 @@
class DomainTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -28,10 +26,7 @@
$this->deleteTestUser('testuserdomain@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('testdomain.com');
$this->deleteTestUser('testuserdomain@' . \config('app.domain'));
@@ -45,7 +40,7 @@
public function testDomainInfoUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$browser->visit('/domain/123')->on(new Home());
});
}
@@ -56,18 +51,19 @@
public function testDomainListUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$browser->visit('/domains')->on(new Home());
});
}
/**
* Test domain info page (non-existing domain id)
+ *
* @group skipci
*/
public function testDomainInfo404(): void
{
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
// FIXME: I couldn't make loginAs() method working
// Note: Here we're also testing that unauthenticated request
@@ -83,11 +79,12 @@
* Test domain info page (existing domain)
*
* @depends testDomainInfo404
+ *
* @group skipci
*/
public function testDomainInfo(): void
{
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
// Unconfirmed domain
$domain = Domain::where('namespace', 'kolab.org')->first();
if ($domain->isConfirmed()) {
@@ -100,14 +97,14 @@
$browser->visit('/domain/' . $domain->id)
->on(new DomainInfo())
->assertSeeIn('.card-title', 'Domain')
- ->whenAvailable('@general', function ($browser) use ($domain) {
+ ->whenAvailable('@general', static function ($browser) use ($domain) {
$browser->assertSeeIn('form div:nth-child(1) label', 'Status')
->assertSeeIn('form div:nth-child(1) #status.text-danger', 'Not Ready')
->assertSeeIn('form div:nth-child(2) label', 'Name')
->assertValue('form div:nth-child(2) input:disabled', $domain->namespace)
->assertSeeIn('form div:nth-child(3) label', 'Subscriptions');
})
- ->whenAvailable('@general form div:nth-child(3) table', function ($browser) {
+ ->whenAvailable('@general form div:nth-child(3) table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertVisible('tbody tr td.selection input:checked:disabled')
->assertSeeIn('tbody tr td.name', 'External Domain')
@@ -117,16 +114,16 @@
'Host a domain that is externally registered'
);
})
- ->whenAvailable('@confirm', function ($browser) use ($domain) {
+ ->whenAvailable('@confirm', static function ($browser) use ($domain) {
$browser->assertSeeIn('pre', $domain->namespace)
->assertSeeIn('pre', $domain->hash())
->scrollTo('button')->pause(500)
->click('button')
->assertToast(Toast::TYPE_SUCCESS, 'Domain ownership confirmed successfully.');
- // TODO: Test scenario when a domain confirmation failed
+ // TODO: Test scenario when a domain confirmation failed
})
- ->whenAvailable('@config', function ($browser) use ($domain) {
+ ->whenAvailable('@config', static function ($browser) use ($domain) {
$browser->assertSeeIn('pre', $domain->namespace);
})
->assertMissing('@general button[type=submit]')
@@ -142,11 +139,12 @@
/**
* Test domain settings
+ *
* @group skipci
*/
public function testDomainSettings(): void
{
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$domain = Domain::where('namespace', 'kolab.org')->first();
$domain->setSetting('spf_whitelist', \json_encode(['.test.com']));
@@ -156,20 +154,20 @@
->assertSeeIn('@nav #tab-general', 'General')
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('#settings form', function (Browser $browser) {
+ ->with('#settings form', static function (Browser $browser) {
// Test whitelist widget
$widget = new ListInput('#spf_whitelist');
$browser->assertSeeIn('div.row:nth-child(1) label', 'SPF Whitelist')
->assertVisible('div.row:nth-child(1) .list-input')
- ->with($widget, function (Browser $browser) {
+ ->with($widget, static function (Browser $browser) {
$browser->assertListInputValue(['.test.com'])
->assertValue('@input', '')
->addListEntry('invalid domain');
})
->click('button[type=submit]')
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->with($widget, function (Browser $browser) {
+ ->with($widget, static function (Browser $browser) {
$err = 'The entry format is invalid. Expected a domain name starting with a dot.';
$browser->assertFormError(2, $err, false)
->removeListEntry(2)
@@ -186,11 +184,12 @@
* Test domains list page
*
* @depends testDomainListUnauth
+ *
* @group skipci
*/
public function testDomainList(): void
{
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
// Login the user
$browser->visit('/login')
->on(new Home())
@@ -209,7 +208,7 @@
->click('@table tbody tr:first-child td:first-child a')
// On Domain Info page verify that's the clicked domain
->on(new DomainInfo())
- ->whenAvailable('@config', function ($browser) {
+ ->whenAvailable('@config', static function ($browser) {
$browser->assertSeeIn('pre', 'kolab.org');
});
});
@@ -223,7 +222,7 @@
public function testDomainListEmpty(): void
{
// User is not a wallet controller
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$browser->visit('/login')
->on(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
@@ -239,7 +238,7 @@
$plan = Plan::withObjectTenantContext($user)->where('title', 'group')->first();
$user->setSetting('plan_id', $plan->id);
- $this->browse(function ($browser) use ($user) {
+ $this->browse(static function ($browser) use ($user) {
$browser->visit('/login')
->on(new Home())
->submitLogon($user->email, 'simple123', true)
@@ -267,7 +266,7 @@
->on(new DomainInfo())
->waitFor('button.button-delete')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function ($browser) {
+ ->with(new Dialog('#delete-warning'), static function ($browser) {
$browser->click('@button-action');
})
->waitUntilMissing('#delete-warning')
@@ -282,11 +281,12 @@
/**
* Test domain creation page
+ *
* @group skipci
*/
public function testDomainCreate(): void
{
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$browser->visit('/login')
->on(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
@@ -298,14 +298,14 @@
->assertSeeIn('.card-title', 'New domain')
->assertElementsCount('@nav li', 1)
->assertSeeIn('@nav li:first-child', 'General')
- ->whenAvailable('@general', function ($browser) {
+ ->whenAvailable('@general', static function ($browser) {
$browser->assertSeeIn('form div:nth-child(1) label', 'Name')
->assertValue('form div:nth-child(1) input:not(:disabled)', '')
->assertFocused('form div:nth-child(1) input')
->assertSeeIn('form div:nth-child(2) label', 'Package')
->assertMissing('form div:nth-child(3)');
})
- ->whenAvailable('@general form div:nth-child(2) table', function ($browser) {
+ ->whenAvailable('@general form div:nth-child(2) table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertVisible('tbody tr td.selection input:checked[readonly]')
->assertSeeIn('tbody tr td.name', 'Domain Hosting')
@@ -343,6 +343,7 @@
/**
* Test domain deletion
+ *
* @group skipci
*/
public function testDomainDelete(): void
@@ -350,10 +351,10 @@
// Create the domain to delete
$john = $this->getTestUser('john@kolab.org');
$domain = $this->getTestDomain('testdomain.com', ['type' => Domain::TYPE_EXTERNAL]);
- $packageDomain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $packageDomain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$domain->assignPackage($packageDomain, $john);
- $this->browse(function ($browser) {
+ $this->browse(static function ($browser) {
$browser->visit('/login')
->on(new Home())
->submitLogon('john@kolab.org', 'simple123')
@@ -366,7 +367,7 @@
->waitFor('button.button-delete')
->assertSeeIn('button.button-delete', 'Delete domain')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function ($browser) {
+ ->with(new Dialog('#delete-warning'), static function ($browser) {
$browser->assertSeeIn('@title', 'Delete testdomain.com')
->assertFocused('@button-cancel')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -375,7 +376,7 @@
})
->waitUntilMissing('#delete-warning')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function (Browser $browser) {
+ ->with(new Dialog('#delete-warning'), static function (Browser $browser) {
$browser->click('@button-action');
})
->waitUntilMissing('#delete-warning')
@@ -389,7 +390,7 @@
->on(new DomainInfo())
->waitFor('button.button-delete')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function ($browser) {
+ ->with(new Dialog('#delete-warning'), static function ($browser) {
$browser->click('@button-action');
})
->assertToast(Toast::TYPE_ERROR, $err);
diff --git a/src/tests/Browser/ErrorTest.php b/src/tests/Browser/ErrorTest.php
--- a/src/tests/Browser/ErrorTest.php
+++ b/src/tests/Browser/ErrorTest.php
@@ -9,12 +9,10 @@
{
/**
* Test error 404 page on unknown route
- *
- * @return void
*/
public function testError404Page()
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/unknown')
->waitFor('#app > #error-page')
->assertVisible('#app > #header-menu')
@@ -22,7 +20,7 @@
->assertErrorPage(404);
});
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/login/unknown')
->waitFor('#app > #error-page')
->assertVisible('#app > #header-menu')
diff --git a/src/tests/Browser/FaqTest.php b/src/tests/Browser/FaqTest.php
--- a/src/tests/Browser/FaqTest.php
+++ b/src/tests/Browser/FaqTest.php
@@ -13,9 +13,9 @@
*/
public function testFaq(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup())
- ->whenAvailable('#faq', function ($browser) {
+ ->whenAvailable('#faq', static function ($browser) {
$browser->assertSeeIn('h5', 'FAQ')
->assertElementsCount('ul > li', 1)
->assertSeeIn('li:last-child a', 'Need support?')
diff --git a/src/tests/Browser/LogonTest.php b/src/tests/Browser/LogonTest.php
--- a/src/tests/Browser/LogonTest.php
+++ b/src/tests/Browser/LogonTest.php
@@ -2,6 +2,7 @@
namespace Tests\Browser;
+use App\Auth\SecondFactor;
use Tests\Browser;
use Tests\Browser\Components\Menu;
use Tests\Browser\Components\Toast;
@@ -16,16 +17,16 @@
*/
public function testLogonMenu(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['signup', 'support', 'login', 'lang'])
->assertSeeIn('#footer-copyright', \config('app.company.copyright'))
->assertSeeIn('#footer-copyright', date('Y'));
});
if ($browser->isDesktop()) {
- $browser->within(new Menu('footer'), function ($browser) {
+ $browser->within(new Menu('footer'), static function ($browser) {
$browser->assertMenuItems(['signup', 'support', 'login']);
});
} else {
@@ -49,12 +50,12 @@
$browser->visit(new Home())
// ->plainCookie('language', '')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertSeeIn('@lang', 'EN')
->click('@lang');
})
// Switch English -> German
- ->whenAvailable('nav .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('nav .dropdown-menu', static function (Browser $browser) {
$browser->assertElementsCount('a', 3)
->assertSeeIn('a:nth-child(1)', 'EN - English')
->assertSeeIn('a:nth-child(2)', 'DE - German')
@@ -62,7 +63,7 @@
->click('a:nth-child(2)');
})
->waitUntilMissing('nav .dropdown-menu')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertSeeIn('@lang', 'DE');
})
->waitForTextIn('#header-menu .link-login', 'EINLOGGEN')
@@ -73,17 +74,17 @@
->waitForTextIn('#header-menu .link-login', 'EINLOGGEN')
->assertSeeIn('#footer-menu .link-login', 'Einloggen')
->assertSeeIn('@logon-button', 'Anmelden')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertSeeIn('@lang', 'DE')
->click('@lang');
})
// Switch German -> English
- ->whenAvailable('nav .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('nav .dropdown-menu', static function (Browser $browser) {
$browser->assertSeeIn('a:nth-child(1)', 'Englisch')
->click('a:nth-child(1)');
})
->waitUntilMissing('nav .dropdown-menu')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertSeeIn('@lang', 'EN');
})
->waitForTextIn('#header-menu .link-login', 'LOGIN');
@@ -95,7 +96,7 @@
*/
public function testRequiredAuth(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/dashboard');
// Checks if we're really on the login page
@@ -109,7 +110,7 @@
*/
public function testLogonWrongCredentials(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'wrong');
@@ -126,7 +127,7 @@
*/
public function testLogonSuccessful(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
// Checks if we're really on Dashboard page
@@ -136,12 +137,12 @@
->assertVisible('@links a.link-users')
->assertVisible('@links a.link-wallet')
->assertVisible('@links a.link-webmail')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']);
});
if ($browser->isDesktop()) {
- $browser->within(new Menu('footer'), function ($browser) {
+ $browser->within(new Menu('footer'), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout']);
});
} else {
@@ -175,11 +176,11 @@
*/
public function testLogout(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new Dashboard());
// Click the Logout button
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
@@ -188,7 +189,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['signup', 'support', 'login', 'lang']);
});
@@ -202,7 +203,7 @@
*/
public function testLogoutByURL(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true);
@@ -215,7 +216,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['signup', 'support', 'login', 'lang']);
});
@@ -231,7 +232,7 @@
*/
public function test2FA(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
// Test missing 2fa code
$browser->on(new Home())
->type('@email-input', 'ned@kolab.org')
@@ -257,7 +258,7 @@
->assertFocused('@second-factor-input')
->assertToast(Toast::TYPE_ERROR, 'Form validation error');
- $code = \App\Auth\SecondFactor::code('ned@kolab.org');
+ $code = SecondFactor::code('ned@kolab.org');
// Test valid (TOTP) code
$browser->type('@second-factor-input', $code)
@@ -275,7 +276,7 @@
*/
public function testAfterLogonRedirect(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
// User is logged in, invalidate the session token and visit /settings page
$browser->execScript("localStorage.setItem('token', '123')")
->visit('/settings')
diff --git a/src/tests/Browser/Meet/RoomControlsTest.php b/src/tests/Browser/Meet/RoomControlsTest.php
--- a/src/tests/Browser/Meet/RoomControlsTest.php
+++ b/src/tests/Browser/Meet/RoomControlsTest.php
@@ -9,16 +9,13 @@
class RoomControlsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -33,44 +30,44 @@
{
// TODO: This test does not work in headless mode
$this->markTestIncomplete();
-/*
- $this->browse(function (Browser $browser) {
- // Join the room as an owner (authenticate)
- $browser->visit(new RoomPage('john'))
- ->click('@setup-button')
- ->assertMissing('@toolbar')
- ->assertMissing('@menu')
- ->assertMissing('@session')
- ->assertMissing('@chat')
- ->assertMissing('@setup-form')
- ->assertVisible('@login-form')
- ->submitLogon('john@kolab.org', 'simple123')
- ->waitFor('@setup-form')
- ->assertMissing('@login-form')
- ->waitUntilMissing('@setup-status-message.loading')
- ->click('@setup-button')
- ->waitFor('@session')
-
- // Test fullscreen for the whole room
- ->click('@menu button.link-fullscreen.closed')
- ->assertVisible('@toolbar')
- ->assertVisible('@session')
- ->assertMissing('nav')
- ->assertMissing('@menu button.link-fullscreen.closed')
- ->click('@menu button.link-fullscreen.open')
- ->assertVisible('nav')
-
- // Test fullscreen for the participant video
- ->click('@session button.link-fullscreen.closed')
- ->assertVisible('@session')
- ->assertMissing('@toolbar')
- ->assertMissing('nav')
- ->assertMissing('@session button.link-fullscreen.closed')
- ->click('@session button.link-fullscreen.open')
- ->assertVisible('nav')
- ->assertVisible('@toolbar');
- });
-*/
+ /*
+ $this->browse(function (Browser $browser) {
+ // Join the room as an owner (authenticate)
+ $browser->visit(new RoomPage('john'))
+ ->click('@setup-button')
+ ->assertMissing('@toolbar')
+ ->assertMissing('@menu')
+ ->assertMissing('@session')
+ ->assertMissing('@chat')
+ ->assertMissing('@setup-form')
+ ->assertVisible('@login-form')
+ ->submitLogon('john@kolab.org', 'simple123')
+ ->waitFor('@setup-form')
+ ->assertMissing('@login-form')
+ ->waitUntilMissing('@setup-status-message.loading')
+ ->click('@setup-button')
+ ->waitFor('@session')
+
+ // Test fullscreen for the whole room
+ ->click('@menu button.link-fullscreen.closed')
+ ->assertVisible('@toolbar')
+ ->assertVisible('@session')
+ ->assertMissing('nav')
+ ->assertMissing('@menu button.link-fullscreen.closed')
+ ->click('@menu button.link-fullscreen.open')
+ ->assertVisible('nav')
+
+ // Test fullscreen for the participant video
+ ->click('@session button.link-fullscreen.closed')
+ ->assertVisible('@session')
+ ->assertMissing('@toolbar')
+ ->assertMissing('nav')
+ ->assertMissing('@session button.link-fullscreen.closed')
+ ->click('@session button.link-fullscreen.open')
+ ->assertVisible('nav')
+ ->assertVisible('@toolbar');
+ });
+ */
}
/**
@@ -80,7 +77,7 @@
*/
public function testNicknameAndMuting(): void
{
- $this->browse(function (Browser $owner, Browser $guest) {
+ $this->browse(static function (Browser $owner, Browser $guest) {
// Join the room as an owner (authenticate)
$owner->visit(new RoomPage('john'))
->click('@setup-button')
@@ -99,21 +96,21 @@
->assertSeeIn('@setup-button', "JOIN")
// Join the room, disable cam/mic
->select('@setup-mic-select', '')
- //->select('@setup-cam-select', '')
+ // ->select('@setup-cam-select', '')
->clickWhenEnabled('@setup-button')
->waitFor('@session');
// Assert current UI state
$owner->assertToolbar([
- 'audio' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'video' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'screen' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'chat' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'fullscreen' => RoomPage::BUTTON_ENABLED,
- 'options' => RoomPage::BUTTON_ENABLED,
- 'logout' => RoomPage::BUTTON_ENABLED,
- ])
- ->whenAvailable('div.meet-video.self', function (Browser $browser) {
+ 'audio' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'video' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'screen' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'chat' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'fullscreen' => RoomPage::BUTTON_ENABLED,
+ 'options' => RoomPage::BUTTON_ENABLED,
+ 'logout' => RoomPage::BUTTON_ENABLED,
+ ])
+ ->whenAvailable('div.meet-video.self', static function (Browser $browser) {
$browser->waitFor('video')
->assertAudioMuted('video', true)
->assertSeeIn('.meet-nickname', 'john')
@@ -122,7 +119,7 @@
->assertMissing('.status .status-audio')
->assertMissing('.status .status-video');
})
- ->whenAvailable('div.meet-video:not(.self)', function (Browser $browser) {
+ ->whenAvailable('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitFor('video')
->assertVisible('.meet-nickname')
->assertVisible('.controls button.link-fullscreen')
@@ -134,14 +131,14 @@
// Assert current UI state
$guest->assertToolbar([
- 'audio' => RoomPage::BUTTON_ACTIVE | RoomPage::BUTTON_ENABLED,
- 'video' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'screen' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'chat' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
- 'fullscreen' => RoomPage::BUTTON_ENABLED,
- 'logout' => RoomPage::BUTTON_ENABLED,
- ])
- ->whenAvailable('div.meet-video:not(.self)', function (Browser $browser) {
+ 'audio' => RoomPage::BUTTON_ACTIVE | RoomPage::BUTTON_ENABLED,
+ 'video' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'screen' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'chat' => RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED,
+ 'fullscreen' => RoomPage::BUTTON_ENABLED,
+ 'logout' => RoomPage::BUTTON_ENABLED,
+ ])
+ ->whenAvailable('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitFor('video')
->assertSeeIn('.meet-nickname', 'john')
->assertVisible('.controls button.link-fullscreen')
@@ -149,7 +146,7 @@
->assertMissing('.status .status-audio')
->assertMissing('.status .status-video');
})
- ->whenAvailable('div.meet-video.self', function (Browser $browser) {
+ ->whenAvailable('div.meet-video.self', static function (Browser $browser) {
$browser->waitFor('video')
->assertVisible('.controls button.link-fullscreen')
->assertMissing('.controls button.link-audio')
@@ -213,7 +210,7 @@
$guest->waitUntilMissing('div.meet-video:not(.self) .status .status-video');
// Test muting other user
- $guest->with('div.meet-video:not(.self)', function (Browser $browser) {
+ $guest->with('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->click('.controls button.link-audio')
->assertAudioMuted('video', true)
->assertVisible('.controls button.link-audio.text-danger')
@@ -224,7 +221,7 @@
// Test volume control
$guest->mouseover('@menu')
- ->with('div.meet-video:not(.self)', function (Browser $browser) {
+ ->with('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitUntilMissing('.volume')
->mouseover('.controls button.link-audio')
->waitFor('.volume')
@@ -265,7 +262,7 @@
*/
public function testChat(): void
{
- $this->browse(function (Browser $owner, Browser $guest) {
+ $this->browse(static function (Browser $owner, Browser $guest) {
// Join the room as an owner
$owner->visit(new RoomPage('john'))
->waitFor('@setup-form')
@@ -360,7 +357,7 @@
*/
public function testShareScreen(): void
{
- $this->browse(function (Browser $owner, Browser $guest) {
+ $this->browse(static function (Browser $owner, Browser $guest) {
// Join the room as an owner
$owner->visit(new RoomPage('john'))
->waitFor('@setup-form')
@@ -383,7 +380,7 @@
$owner->assertToolbarButtonState('screen', RoomPage::BUTTON_INACTIVE | RoomPage::BUTTON_ENABLED)
->assertElementsCount('@session div.meet-video', 1)
->click('@menu button.link-screen')
- ->whenAvailable('div.meet-video:not(.self)', function (Browser $browser) {
+ ->whenAvailable('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitFor('video')
->assertSeeIn('.meet-nickname', 'john')
->assertVisible('.controls button.link-fullscreen')
@@ -396,7 +393,7 @@
->assertToolbarButtonState('screen', RoomPage::BUTTON_ACTIVE | RoomPage::BUTTON_ENABLED);
$guest
- ->whenAvailable('div.meet-video.screen', function (Browser $browser) {
+ ->whenAvailable('div.meet-video.screen', static function (Browser $browser) {
$browser->waitFor('video')
->assertSeeIn('.meet-nickname', 'john')
->assertVisible('.controls button.link-fullscreen')
diff --git a/src/tests/Browser/Meet/RoomInterpretersTest.php b/src/tests/Browser/Meet/RoomInterpretersTest.php
--- a/src/tests/Browser/Meet/RoomInterpretersTest.php
+++ b/src/tests/Browser/Meet/RoomInterpretersTest.php
@@ -9,16 +9,13 @@
class RoomInterpretersTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -31,7 +28,7 @@
*/
public function testInterpreters(): void
{
- $this->browse(function (Browser $owner, Browser $interpreter, Browser $guest) {
+ $this->browse(static function (Browser $owner, Browser $interpreter, Browser $guest) {
$page = new RoomPage('john');
// Join the room as an owner (authenticate)
$owner->visit($page)
@@ -58,7 +55,7 @@
->waitFor('@session .meet-video:not(.self)')
->assertSeeIn('@session .meet-video:not(.self)', 'Interpreter')
->click('@session .meet-video:not(.self) .meet-nickname')
- ->whenAvailable('@session .meet-video:not(.self) .dropdown-menu', function ($browser) {
+ ->whenAvailable('@session .meet-video:not(.self) .dropdown-menu', static function ($browser) {
$browser->assertVisible('.interpreting')
->assertSeeIn('.interpreting h6', 'Language interpreter')
->select('.interpreting select', 'en');
@@ -100,7 +97,7 @@
->assertAudioMuted('@session .meet-subscriber:not(.self) video', true) // muted interpreter
// select a channel
->click('@menu button.link-channel')
- ->whenAvailable('#channel-select .dropdown-menu', function ($browser) {
+ ->whenAvailable('#channel-select .dropdown-menu', static function ($browser) {
$browser->assertSeeIn('a:first-child.active', '- none -')
->assertSeeIn('a:nth-child(2):not(.active)', 'English')
->assertMissing('a:nth-child(3)')
@@ -112,7 +109,7 @@
->assertAudioMuted('@session .meet-subscriber:not(.self) video', false) // unmuted interpreter
// Unselect a channel
->click('@menu button.link-channel')
- ->whenAvailable('#channel-select .dropdown-menu', function ($browser) {
+ ->whenAvailable('#channel-select .dropdown-menu', static function ($browser) {
$browser->assertVisible('a:first-child:not(.active)')
->assertVisible('a:nth-child(2).active')
->click('a:first-child');
@@ -130,7 +127,7 @@
->assertAudioMuted('@session .meet-subscriber:nth-child(1) video', true) // muted interpreter
// select a channel
->click('@menu button.link-channel')
- ->whenAvailable('#channel-select .dropdown-menu', function ($browser) {
+ ->whenAvailable('#channel-select .dropdown-menu', static function ($browser) {
$browser->assertSeeIn('a:first-child.active', '- none -')
->assertSeeIn('a:nth-child(2):not(.active)', 'English')
->assertMissing('a:nth-child(3)')
@@ -142,7 +139,7 @@
->assertAudioMuted('@session .meet-subscriber:nth-child(1) video', false) // unmuted interpreter
// Unselect a channel
->click('@menu button.link-channel')
- ->whenAvailable('#channel-select .dropdown-menu', function ($browser) {
+ ->whenAvailable('#channel-select .dropdown-menu', static function ($browser) {
$browser->assertVisible('a:first-child:not(.active)')
->assertVisible('a:nth-child(2).active')
->click('a:first-child');
@@ -153,7 +150,7 @@
// Remove interpreting role
$owner->click('@session .meet-subscriber:nth-child(1) .meet-nickname')
- ->whenAvailable('@session .meet-subscriber:nth-child(1) .dropdown-menu', function ($browser) {
+ ->whenAvailable('@session .meet-subscriber:nth-child(1) .dropdown-menu', static function ($browser) {
$browser->assertSelected('.interpreting select', 'en')
->select('.interpreting select', '');
})
diff --git a/src/tests/Browser/Meet/RoomModeratorTest.php b/src/tests/Browser/Meet/RoomModeratorTest.php
--- a/src/tests/Browser/Meet/RoomModeratorTest.php
+++ b/src/tests/Browser/Meet/RoomModeratorTest.php
@@ -4,23 +4,19 @@
use App\Meet\Room;
use Tests\Browser;
-use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Menu;
use Tests\Browser\Pages\Meet\Room as RoomPage;
use Tests\TestCaseDusk;
class RoomModeratorTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -33,7 +29,7 @@
*/
public function testModeratorPromotion(): void
{
- $this->browse(function (Browser $browser, Browser $guest1, Browser $guest2) {
+ $this->browse(static function (Browser $browser, Browser $guest1, Browser $guest2) {
// In one browser window join as a room owner
$browser->visit(new RoomPage('john'))
->click('@setup-button')
@@ -78,7 +74,7 @@
->assertMissing('@session div.meet-subscriber:not(.self) svg.user') // owner
->assertVisible('@session div.meet-subscriber:not(.self) svg.moderator') // owner
->click('@session div.meet-subscriber.self .meet-nickname')
- ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', static function (Browser $browser) {
$browser->assertMissing('.permissions');
})
->click('@session div.meet-subscriber:not(.self) .meet-nickname')
@@ -99,12 +95,12 @@
->assertMissing('@session div.meet-subscriber.self svg.user') // self
->assertVisible('@session div.meet-subscriber.self svg.moderator') // self
->click('@session div.meet-subscriber.self .meet-nickname')
- ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', static function (Browser $browser) {
$browser->assertChecked('.action-role-moderator input')
->assertDisabled('.action-role-moderator input');
})
->click('@session div.meet-subscriber:not(.self) .meet-nickname')
- ->whenAvailable('@session div.meet-subscriber:not(.self) .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session div.meet-subscriber:not(.self) .dropdown-menu', static function (Browser $browser) {
$browser->assertNotChecked('.action-role-moderator input')
->click('.action-role-moderator input');
});
@@ -122,7 +118,7 @@
->click('@session div.meet-subscriber:not(.self) .meet-nickname') // owner
->assertMissing('@session div.meet-subscriber:not(.self) .dropdown-menu')
->click('@session div.meet-subscriber.self .meet-nickname')
- ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session div.meet-subscriber.self .dropdown-menu', static function (Browser $browser) {
$browser->assertChecked('.action-role-moderator input')
->assertEnabled('.action-role-moderator input')
->assertNotChecked('.action-role-publisher input')
@@ -134,7 +130,7 @@
// Check if a moderator can unpublish another user
$guest1->click('@session div.meet-video .meet-nickname')
- ->whenAvailable('@session div.meet-video .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session div.meet-video .dropdown-menu', static function (Browser $browser) {
$browser->assertNotChecked('.action-role-moderator input')
->assertEnabled('.action-role-moderator input')
->assertChecked('.action-role-publisher input')
@@ -149,7 +145,7 @@
$browser->waitFor('@session div.meet-subscriber:nth-child(3)')
->click('@session') // somehow needed to make the next line invoke the menu
->click('@session div.meet-subscriber:nth-child(2) .meet-nickname')
- ->whenAvailable('@session div.meet-subscriber:nth-child(2) .dropdown-menu', function ($browser) {
+ ->whenAvailable('@session div.meet-subscriber:nth-child(2) .dropdown-menu', static function ($browser) {
$browser->assertChecked('.action-role-moderator input')
->click('.action-role-moderator input');
})
@@ -159,7 +155,7 @@
$guest1->waitFor('@session div.meet-subscriber.self svg.user')
->assertMissing('@session div.meet-subscriber.self svg.moderator')
->click('@session div.meet-subscriber.self .meet-nickname')
- ->whenAvailable('@session .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .dropdown-menu', static function (Browser $browser) {
$browser->assertMissing('.permissions');
});
});
diff --git a/src/tests/Browser/Meet/RoomOptionsTest.php b/src/tests/Browser/Meet/RoomOptionsTest.php
--- a/src/tests/Browser/Meet/RoomOptionsTest.php
+++ b/src/tests/Browser/Meet/RoomOptionsTest.php
@@ -11,16 +11,13 @@
class RoomOptionsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -109,7 +106,7 @@
->assertElementsCount('#password-input button', 1)
->click('@button-cancel');
- $this->assertSame(null, $room->fresh()->getSetting('password'));
+ $this->assertNull($room->fresh()->getSetting('password'));
});
});
}
@@ -172,7 +169,7 @@
// Test denying the request (this will also test custom toasts)
$owner
- ->whenAvailable(new Toast(Toast::TYPE_CUSTOM), function ($browser) {
+ ->whenAvailable(new Toast(Toast::TYPE_CUSTOM), static function ($browser) {
$browser->assertToastTitle('Join request')
->assertVisible('.toast-header svg.fa-user')
->assertSeeIn('@message', 'Guest<p> requested to join.')
@@ -232,7 +229,7 @@
->assertButtonDisabled('@setup-button');
$owner
- ->whenAvailable(new Toast(Toast::TYPE_CUSTOM), function ($browser) {
+ ->whenAvailable(new Toast(Toast::TYPE_CUSTOM), static function ($browser) {
$browser->assertToastTitle('Join request')
->assertSeeIn('@message', 'guest requested to join.')
->click('@message button.accept');
@@ -257,11 +254,11 @@
->waitUntilMissing('@session .meet-video:not(.self)');
// Expect a "end of session" dialog on the participant side
- $guest->with(new Dialog('#leave-dialog'), function (Browser $browser) {
- $browser->assertSeeIn('@title', 'Room closed')
- ->assertSeeIn('@body', "The session has been closed by the room owner.")
- ->assertMissing('@button-action')
- ->assertSeeIn('@button-cancel', 'Close');
+ $guest->with(new Dialog('#leave-dialog'), static function (Browser $browser) {
+ $browser->assertSeeIn('@title', 'Room closed')
+ ->assertSeeIn('@body', "The session has been closed by the room owner.")
+ ->assertMissing('@button-action')
+ ->assertSeeIn('@button-cancel', 'Close');
});
});
}
@@ -319,7 +316,7 @@
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.")
->click('@button-cancel');
- $this->assertSame(null, $room->fresh()->getSetting('nomedia'));
+ $this->assertNull($room->fresh()->getSetting('nomedia'));
});
});
}
diff --git a/src/tests/Browser/Meet/RoomQATest.php b/src/tests/Browser/Meet/RoomQATest.php
--- a/src/tests/Browser/Meet/RoomQATest.php
+++ b/src/tests/Browser/Meet/RoomQATest.php
@@ -9,16 +9,13 @@
class RoomQATest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -31,7 +28,7 @@
*/
public function testQA(): void
{
- $this->browse(function (Browser $owner, Browser $guest1, Browser $guest2) {
+ $this->browse(static function (Browser $owner, Browser $guest1, Browser $guest2) {
// Join the room as an owner (authenticate)
$owner->visit(new RoomPage('john'))
->click('@setup-button')
@@ -95,7 +92,7 @@
// Demote the guest (2) to subscriber, assert Hand button in toolbar
$owner->click('@session div.meet-video .meet-nickname')
- ->whenAvailable('@session div.meet-video .dropdown-menu', function ($browser) {
+ ->whenAvailable('@session div.meet-video .dropdown-menu', static function ($browser) {
$browser->click('.action-role-publisher input');
});
@@ -111,7 +108,7 @@
$owner->waitFor('@queue .dropdown:not(.self)')
->pause(8000) // wait until it's not moving, otherwise click() will fail
->click('@queue .dropdown:not(.self)')
- ->whenAvailable('@queue .dropdown:not(.self) .dropdown-menu', function ($browser) {
+ ->whenAvailable('@queue .dropdown:not(.self) .dropdown-menu', static function ($browser) {
$browser->click('.action-role-publisher input');
})
->waitUntilMissing('@queue .dropdown:not(.self)')
@@ -126,7 +123,7 @@
// Finally, do the same with the owner (last in the queue)
$owner->click('@queue .dropdown.self')
- ->whenAvailable('@queue .dropdown.self .dropdown-menu', function ($browser) {
+ ->whenAvailable('@queue .dropdown.self .dropdown-menu', static function ($browser) {
$browser->click('.action-role-publisher input');
})
->waitUntilMissing('@queue')
diff --git a/src/tests/Browser/Meet/RoomSetupTest.php b/src/tests/Browser/Meet/RoomSetupTest.php
--- a/src/tests/Browser/Meet/RoomSetupTest.php
+++ b/src/tests/Browser/Meet/RoomSetupTest.php
@@ -11,16 +11,13 @@
class RoomSetupTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->resetTestRoom();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->resetTestRoom();
parent::tearDown();
@@ -33,14 +30,14 @@
*/
public function testRoomNonExistingRoom(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new RoomPage('unknown'))
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login', 'lang']);
});
if ($browser->isDesktop()) {
- $browser->within(new Menu('footer'), function ($browser) {
+ $browser->within(new Menu('footer'), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login']);
});
} else {
@@ -67,14 +64,14 @@
*/
public function testRoomSetup(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new RoomPage('john'))
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login', 'lang']);
});
if ($browser->isDesktop()) {
- $browser->within(new Menu('footer'), function ($browser) {
+ $browser->within(new Menu('footer'), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login']);
});
} else {
@@ -117,11 +114,12 @@
* Test two users in a room (joining/leaving and some basic functionality)
*
* @group meet
+ *
* @depends testRoomSetup
*/
public function testTwoUsersInARoom(): void
{
- $this->browse(function (Browser $browser, Browser $guest) {
+ $this->browse(static function (Browser $browser, Browser $guest) {
// In one browser window act as a guest
$guest->visit(new RoomPage('john'))
->assertMissing('@toolbar')
@@ -149,12 +147,12 @@
->assertVisible('@login-form')
->submitLogon('john@kolab.org', 'simple123')
->waitFor('@setup-form')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']);
});
if ($browser->isDesktop()) {
- $browser->within(new Menu('footer'), function ($browser) {
+ $browser->within(new Menu('footer'), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout']);
});
}
@@ -168,7 +166,7 @@
->clickWhenEnabled('@setup-button')
->waitFor('@session')
->assertMissing('@setup-form')
- ->whenAvailable('div.meet-video.self', function (Browser $browser) {
+ ->whenAvailable('div.meet-video.self', static function (Browser $browser) {
$browser->waitFor('video')
->assertSeeIn('.meet-nickname', 'john')
->assertVisible('.controls button.link-fullscreen')
@@ -190,11 +188,11 @@
->assertSeeIn('@setup-button', "JOIN")
// Join the room, disable cam/mic
->select('@setup-mic-select', '')
- //->select('@setup-cam-select', '')
+ // ->select('@setup-cam-select', '')
->clickWhenEnabled('@setup-button')
->waitFor('@session')
->assertMissing('@setup-form')
- ->whenAvailable('div.meet-video.self', function (Browser $browser) {
+ ->whenAvailable('div.meet-video.self', static function (Browser $browser) {
$browser->waitFor('video')
->assertVisible('.meet-nickname')
->assertVisible('.controls button.link-fullscreen')
@@ -202,7 +200,7 @@
->assertVisible('.status .status-audio')
->assertMissing('.status .status-video');
})
- ->whenAvailable('div.meet-video:not(.self)', function (Browser $browser) {
+ ->whenAvailable('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitFor('video')
->assertSeeIn('.meet-nickname', 'john')
->assertVisible('.controls button.link-fullscreen')
@@ -215,7 +213,7 @@
// Check guest's elements in the owner's window
$browser
- ->whenAvailable('div.meet-video:not(.self)', function (Browser $browser) {
+ ->whenAvailable('div.meet-video:not(.self)', static function (Browser $browser) {
$browser->waitFor('video')
->assertVisible('.meet-nickname')
->assertVisible('.controls button.link-fullscreen')
@@ -250,7 +248,7 @@
->assertSeeIn('@setup-button', "JOIN")
// Join the room, disable cam/mic
->select('@setup-mic-select', '')
- //->select('@setup-cam-select', '')
+ // ->select('@setup-cam-select', '')
->clickWhenEnabled('@setup-button')
->waitFor('@session');
@@ -261,11 +259,11 @@
->waitForLocation('/dashboard');
// Expect other participants be informed about the end of the session
- $guest->with(new Dialog('#leave-dialog'), function (Browser $browser) {
- $browser->assertSeeIn('@title', 'Room closed')
- ->assertSeeIn('@body', "The session has been closed by the room owner.")
- ->assertSeeIn('@button-cancel', 'Close')
- ->click('@button-cancel');
+ $guest->with(new Dialog('#leave-dialog'), static function (Browser $browser) {
+ $browser->assertSeeIn('@title', 'Room closed')
+ ->assertSeeIn('@body', "The session has been closed by the room owner.")
+ ->assertSeeIn('@button-cancel', 'Close')
+ ->click('@button-cancel');
})
->assertMissing('#leave-dialog')
->waitForLocation('/login');
@@ -276,11 +274,12 @@
* Test two subscribers-only users in a room
*
* @group meet
+ *
* @depends testTwoUsersInARoom
*/
public function testSubscribers(): void
{
- $this->browse(function (Browser $browser, Browser $guest) {
+ $this->browse(static function (Browser $browser, Browser $guest) {
// Join the room as the owner
$browser->visit(new RoomPage('john'))
->waitFor('@setup-form')
@@ -292,7 +291,7 @@
->clickWhenEnabled('@setup-button')
->waitFor('@session')
->assertMissing('@setup-form')
- ->whenAvailable('@subscribers .meet-subscriber.self', function (Browser $browser) {
+ ->whenAvailable('@subscribers .meet-subscriber.self', static function (Browser $browser) {
$browser->assertSeeIn('.meet-nickname', 'john');
})
->assertElementsCount('@session div.meet-video', 0)
@@ -320,10 +319,10 @@
->clickWhenEnabled('@setup-button')
->waitFor('@session')
->assertMissing('@setup-form')
- ->whenAvailable('@subscribers .meet-subscriber.self', function (Browser $browser) {
+ ->whenAvailable('@subscribers .meet-subscriber.self', static function (Browser $browser) {
$browser->assertVisible('.meet-nickname');
})
- ->whenAvailable('@subscribers .meet-subscriber:not(.self)', function (Browser $browser) {
+ ->whenAvailable('@subscribers .meet-subscriber:not(.self)', static function (Browser $browser) {
$browser->assertSeeIn('.meet-nickname', 'john');
})
->assertElementsCount('@session div.meet-video', 0)
@@ -342,7 +341,7 @@
// Check guest's elements in the owner's window
$browser
- ->whenAvailable('@subscribers .meet-subscriber:not(.self)', function (Browser $browser) {
+ ->whenAvailable('@subscribers .meet-subscriber:not(.self)', static function (Browser $browser) {
$browser->assertVisible('.meet-nickname');
})
->assertElementsCount('@session div.meet-video', 0)
@@ -365,11 +364,12 @@
* Test demoting publisher to a subscriber
*
* @group meet
+ *
* @depends testSubscribers
*/
public function testDemoteToSubscriber(): void
{
- $this->browse(function (Browser $browser, Browser $guest1, Browser $guest2) {
+ $this->browse(static function (Browser $browser, Browser $guest1, Browser $guest2) {
// Join the room as the owner
$browser->visit(new RoomPage('john'))
->waitFor('@setup-form')
@@ -395,7 +395,7 @@
->assertElementsCount('@session div.meet-subscriber', 0)
// assert there's no moderator-related features for this guess available
->click('@session .meet-video.self .meet-nickname')
- ->whenAvailable('@session .meet-video.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .meet-video.self .dropdown-menu', static function (Browser $browser) {
$browser->assertMissing('.permissions');
})
->click('@session .meet-video:not(.self) .meet-nickname')
@@ -410,7 +410,7 @@
->assertElementsCount('@session video', 2)
->assertElementsCount('@session .meet-subscriber', 0)
->click('@session .meet-video:not(.self) .meet-nickname')
- ->whenAvailable('@session .meet-video:not(.self) .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .meet-video:not(.self) .dropdown-menu', static function (Browser $browser) {
$browser->assertSeeIn('.action-role-publisher', 'Audio & Video publishing')
->click('.action-role-publisher')
->waitUntilMissing('.dropdown-menu');
@@ -446,7 +446,7 @@
// Promote the guest back to a publisher
$browser
->click('@session .meet-subscriber .meet-nickname')
- ->whenAvailable('@session .meet-subscriber .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .meet-subscriber .dropdown-menu', static function (Browser $browser) {
$browser->assertSeeIn('.action-role-publisher', 'Audio & Video publishing')
->assertNotChecked('.action-role-publisher input')
->click('.action-role-publisher')
@@ -458,7 +458,7 @@
->assertElementsCount('@session div.meet-subscriber', 0);
$guest1
- ->with(new Dialog('#media-setup-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#media-setup-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Media setup')
->click('@button-cancel');
})
@@ -470,7 +470,7 @@
// Demote the owner to a subscriber
$browser
->click('@session .meet-video.self .meet-nickname')
- ->whenAvailable('@session .meet-video.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .meet-video.self .dropdown-menu', static function (Browser $browser) {
$browser->assertSeeIn('.action-role-publisher', 'Audio & Video publishing')
->assertChecked('.action-role-publisher input')
->click('.action-role-publisher')
@@ -485,14 +485,14 @@
// Promote the owner to a publisher
$browser
->click('@session .meet-subscriber.self .meet-nickname')
- ->whenAvailable('@session .meet-subscriber.self .dropdown-menu', function (Browser $browser) {
+ ->whenAvailable('@session .meet-subscriber.self .dropdown-menu', static function (Browser $browser) {
$browser->assertSeeIn('.action-role-publisher', 'Audio & Video publishing')
->assertNotChecked('.action-role-publisher input')
->click('.action-role-publisher')
->waitUntilMissing('.dropdown-menu');
})
->waitUntilMissing('@session .meet-subscriber.self')
- ->with(new Dialog('#media-setup-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#media-setup-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Media setup')
->click('@button-cancel');
})
@@ -507,11 +507,12 @@
* Test the media setup dialog
*
* @group meet
+ *
* @depends testDemoteToSubscriber
*/
public function testMediaSetupDialog(): void
{
- $this->browse(function (Browser $browser, $guest) {
+ $this->browse(static function (Browser $browser, $guest) {
// Join the room as the owner
$browser->visit(new RoomPage('john'))
->waitFor('@setup-form')
@@ -534,7 +535,7 @@
$browser->waitFor('@session video')
->click('.controls button.link-setup')
- ->with(new Dialog('#media-setup-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#media-setup-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Media setup')
->assertVisible('form video')
->assertVisible('form > div:nth-child(1) video')
@@ -551,7 +552,7 @@
->assertMissing('#media-setup-dialog')
// Test mute audio and video
->click('.controls button.link-setup')
- ->with(new Dialog('#media-setup-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#media-setup-dialog'), static function (Browser $browser) {
$browser->select('form > div:nth-child(2) select', '')
->select('form > div:nth-child(3) select', '')
->click('@button-cancel');
diff --git a/src/tests/Browser/Meet/RoomsTest.php b/src/tests/Browser/Meet/RoomsTest.php
--- a/src/tests/Browser/Meet/RoomsTest.php
+++ b/src/tests/Browser/Meet/RoomsTest.php
@@ -11,25 +11,18 @@
use Tests\Browser\Pages\Meet\Room as RoomPage;
use Tests\Browser\Pages\Meet\RoomInfo;
use Tests\Browser\Pages\Meet\RoomList;
-use Tests\Browser\Pages\UserInfo;
use Tests\TestCaseDusk;
class RoomsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
$room = $this->resetTestRoom('shared', ['acl' => ['jack@kolab.org, full']]);
@@ -43,7 +36,7 @@
public function testRoomsUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/rooms')
->on(new Home())
->submitLogon('john@kolab.org', 'simple123', false)
@@ -69,17 +62,17 @@
// Test Video chat page
->click('@links a.link-chat')
->on(new RoomList())
- ->whenAvailable('@table', function ($browser) {
+ ->whenAvailable('@table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertElementsCount('thead th', 3)
- ->with('tbody tr:nth-child(1)', function ($browser) {
+ ->with('tbody tr:nth-child(1)', static function ($browser) {
$browser->assertSeeIn('td:nth-child(1) a', 'john')
->assertSeeIn('td:nth-child(2) a', "Standard room")
->assertElementsCount('td.buttons button', 2)
->assertAttribute('td.buttons button:nth-child(1)', 'title', 'Copy room location')
->assertAttribute('td.buttons button:nth-child(2)', 'title', 'Enter the room');
})
- ->with('tbody tr:nth-child(2)', function ($browser) {
+ ->with('tbody tr:nth-child(2)', static function ($browser) {
$browser->assertSeeIn('td:nth-child(1) a', 'shared')
->assertSeeIn('td:nth-child(2) a', "Shared room")
->assertElementsCount('td.buttons button', 2)
@@ -124,11 +117,11 @@
->assertVisible('@intro p')
->assertElementsCount('@nav li', 1)
->assertSeeIn('@nav li a', 'General')
- ->with('@general form', function ($browser) {
+ ->with('@general form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Description')
->assertFocused('.row:nth-child(1) input')
->assertSeeIn('.row:nth-child(2) label', 'Subscriptions')
- ->with(new SubscriptionSelect('@skus'), function ($browser) {
+ ->with(new SubscriptionSelect('@skus'), static function ($browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSubscription(
0,
@@ -153,7 +146,7 @@
->click('@general button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, "Room created successfully.")
->on(new RoomList())
- ->whenAvailable('@table', function ($browser) {
+ ->whenAvailable('@table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 3);
});
@@ -169,12 +162,12 @@
->assertVisible("@intro a[href=\"/meet/{$room->name}\"]")
->assertElementsCount('@nav li', 2)
->assertSeeIn('@nav li:first-child a', 'General')
- ->with('@general form', function ($browser) {
+ ->with('@general form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Description')
->assertFocused('.row:nth-child(1) input')
->type('.row:nth-child(1) input', 'test321')
->assertSeeIn('.row:nth-child(2) label', 'Subscriptions')
- ->with(new SubscriptionSelect('@skus'), function ($browser) {
+ ->with(new SubscriptionSelect('@skus'), static function ($browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSubscription(
0,
@@ -206,12 +199,12 @@
// Test room deleting
$browser->visit('/room/' . $room->id)
- ->on(new Roominfo())
+ ->on(new RoomInfo())
->assertSeeIn('button.button-delete', 'Delete room')
->click('button.button-delete')
->assertToast(Toast::TYPE_SUCCESS, "Room deleted successfully.")
->on(new RoomList())
- ->whenAvailable('@table', function ($browser) {
+ ->whenAvailable('@table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 2);
});
});
@@ -231,7 +224,7 @@
->on(new RoomInfo())
->assertSeeIn('@nav li:last-child a', 'Settings')
->click('@nav li:last-child a')
- ->with('@settings form', function ($browser) {
+ ->with('@settings form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Password')
->assertValue('.row:nth-child(1) input', '')
->assertVisible('.row:nth-child(1) .form-text')
@@ -252,7 +245,7 @@
->on(new RoomInfo())
->assertSeeIn('@nav li:last-child a', 'Settings')
->click('@nav li:last-child a')
- ->with('@settings form', function ($browser) {
+ ->with('@settings form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(4) label', 'Moderators')
->assertVisible('.row:nth-child(4) .form-text')
->type('#acl .input-group:first-child input', 'jack')
@@ -261,7 +254,7 @@
->click('@settings button[type=submit]')
->assertToast(Toast::TYPE_ERROR, "Form validation error")
->assertSeeIn('#acl + .invalid-feedback', "The specified email address is invalid.")
- ->with('@settings form', function ($browser) {
+ ->with('@settings form', static function ($browser) {
$browser->type('.row:nth-child(1) input', 'pass')
->click('.row:nth-child(2) input')
->click('.row:nth-child(3) input')
@@ -275,8 +268,8 @@
$config = $room->getConfig();
$this->assertSame('pass', $config['password']);
- $this->assertSame(true, $config['locked']);
- $this->assertSame(true, $config['nomedia']);
+ $this->assertTrue($config['locked']);
+ $this->assertTrue($config['nomedia']);
$this->assertSame(['jack@kolab.org, full'], $config['acl']);
});
}
@@ -291,11 +284,11 @@
$jack = $this->getTestUser('jack@kolab.org');
$john = $this->getTestUser('john@kolab.org');
$room = $this->resetTestRoom('shared', [
- 'password' => 'pass',
- 'locked' => true,
- 'nomedia' => true,
- 'acl' => ['jack@kolab.org, full']
- ]);
+ 'password' => 'pass',
+ 'locked' => true,
+ 'nomedia' => true,
+ 'acl' => ['jack@kolab.org, full'],
+ ]);
$this->browse(function (Browser $browser) use ($room, $jack) {
$browser->visit(new Home())
@@ -304,7 +297,7 @@
->click('@links a.link-chat')
->on(new RoomList())
->assertMissing('button.room-new')
- ->whenAvailable('@table', function ($browser) {
+ ->whenAvailable('@table', static function ($browser) {
$browser->assertElementsCount('tbody tr', 2); // one shared room, one owned room
});
@@ -317,26 +310,26 @@
->assertVisible("@intro a[href=\"/meet/{$owned->name}\"]")
->assertMissing('button.button-delete')
->assertElementsCount('@nav li', 2)
- ->with('@general form', function ($browser) {
+ ->with('@general form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Description')
->assertFocused('.row:nth-child(1) input')
->assertMissing('.row:nth-child(2)');
- /*
- ->assertSeeIn('.row:nth-child(2) label', 'Subscriptions')
- ->with(new SubscriptionSelect('@skus'), function ($browser) {
- $browser->assertElementsCount('tbody tr', 1)
- ->assertSubscription(
- 0,
- "Standard conference room",
- "Audio & video conference room",
- "0,00 CHF/month"
- )
- ->assertSubscriptionState(0, true);
- });
- */
+ /*
+ ->assertSeeIn('.row:nth-child(2) label', 'Subscriptions')
+ ->with(new SubscriptionSelect('@skus'), function ($browser) {
+ $browser->assertElementsCount('tbody tr', 1)
+ ->assertSubscription(
+ 0,
+ "Standard conference room",
+ "Audio & video conference room",
+ "0,00 CHF/month"
+ )
+ ->assertSubscriptionState(0, true);
+ });
+ */
})
->click('@nav li:last-child a')
- ->with('@settings form', function ($browser) {
+ ->with('@settings form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Password')
->assertValue('.row:nth-child(1) input', '')
->assertSeeIn('.row:nth-child(2) label', 'Locked room')
@@ -356,7 +349,7 @@
->assertElementsCount('@nav li', 1)
// Test room settings
->assertSeeIn('@nav li:last-child a', 'Settings')
- ->with('@settings form', function ($browser) {
+ ->with('@settings form', static function ($browser) {
$browser->assertSeeIn('.row:nth-child(1) label', 'Password')
->assertValue('.row:nth-child(1) input', 'pass')
->assertSeeIn('.row:nth-child(2) label', 'Locked room')
@@ -374,8 +367,8 @@
$config = $room->getConfig();
$this->assertSame('pass123', $config['password']);
- $this->assertSame(false, $config['locked']);
- $this->assertSame(false, $config['nomedia']);
+ $this->assertFalse($config['locked']);
+ $this->assertFalse($config['nomedia']);
$this->assertSame(['jack@kolab.org, full'], $config['acl']);
$browser->click("@intro a[href=\"/meet/shared\"]")
diff --git a/src/tests/Browser/Pages/Admin/Distlist.php b/src/tests/Browser/Pages/Admin/Distlist.php
--- a/src/tests/Browser/Pages/Admin/Distlist.php
+++ b/src/tests/Browser/Pages/Admin/Distlist.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Distlist extends Page
@@ -20,8 +21,6 @@
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -31,9 +30,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -44,8 +41,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Admin/Domain.php b/src/tests/Browser/Pages/Admin/Domain.php
--- a/src/tests/Browser/Pages/Admin/Domain.php
+++ b/src/tests/Browser/Pages/Admin/Domain.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Domain extends Page
@@ -20,8 +21,6 @@
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -31,9 +30,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -44,8 +41,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Admin/Resource.php b/src/tests/Browser/Pages/Admin/Resource.php
--- a/src/tests/Browser/Pages/Admin/Resource.php
+++ b/src/tests/Browser/Pages/Admin/Resource.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Resource extends Page
@@ -20,8 +21,6 @@
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -31,9 +30,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -44,8 +41,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Admin/SharedFolder.php b/src/tests/Browser/Pages/Admin/SharedFolder.php
--- a/src/tests/Browser/Pages/Admin/SharedFolder.php
+++ b/src/tests/Browser/Pages/Admin/SharedFolder.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class SharedFolder extends Page
@@ -20,8 +21,6 @@
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -31,9 +30,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -44,8 +41,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Admin/Stats.php b/src/tests/Browser/Pages/Admin/Stats.php
--- a/src/tests/Browser/Pages/Admin/Stats.php
+++ b/src/tests/Browser/Pages/Admin/Stats.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Stats extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Admin/User.php b/src/tests/Browser/Pages/Admin/User.php
--- a/src/tests/Browser/Pages/Admin/User.php
+++ b/src/tests/Browser/Pages/Admin/User.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages\Admin;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class User extends Page
@@ -20,8 +21,6 @@
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -31,9 +30,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser): void
{
@@ -44,8 +41,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Dashboard.php b/src/tests/Browser/Pages/Dashboard.php
--- a/src/tests/Browser/Pages/Dashboard.php
+++ b/src/tests/Browser/Pages/Dashboard.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Dashboard extends Page
@@ -19,9 +20,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -33,8 +32,8 @@
/**
* Assert logged-in user
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- * @param string $user User email
+ * @param Browser $browser The browser object
+ * @param string $user User email
*/
public function assertUser($browser, $user)
{
diff --git a/src/tests/Browser/Pages/DistlistInfo.php b/src/tests/Browser/Pages/DistlistInfo.php
--- a/src/tests/Browser/Pages/DistlistInfo.php
+++ b/src/tests/Browser/Pages/DistlistInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class DistlistInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/DistlistList.php b/src/tests/Browser/Pages/DistlistList.php
--- a/src/tests/Browser/Pages/DistlistList.php
+++ b/src/tests/Browser/Pages/DistlistList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class DistlistList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/DomainInfo.php b/src/tests/Browser/Pages/DomainInfo.php
--- a/src/tests/Browser/Pages/DomainInfo.php
+++ b/src/tests/Browser/Pages/DomainInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class DomainInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -30,8 +27,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/DomainList.php b/src/tests/Browser/Pages/DomainList.php
--- a/src/tests/Browser/Pages/DomainList.php
+++ b/src/tests/Browser/Pages/DomainList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class DomainList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Home.php b/src/tests/Browser/Pages/Home.php
--- a/src/tests/Browser/Pages/Home.php
+++ b/src/tests/Browser/Pages/Home.php
@@ -2,7 +2,9 @@
namespace Tests\Browser\Pages;
+use App\Auth\SecondFactor;
use Laravel\Dusk\Page;
+use Tests\Browser;
class Home extends Page
{
@@ -20,8 +22,6 @@
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
*/
public function assert($browser)
{
@@ -42,20 +42,18 @@
'@email-input' => '#inputEmail',
'@password-input' => '#inputPassword',
'@second-factor-input' => '#secondfactor',
- '@logon-button' => '#logon-form button.btn-primary'
+ '@logon-button' => '#logon-form button.btn-primary',
];
}
/**
* Submit logon form.
*
- * @param \Tests\Browser $browser The browser object
- * @param string $username User name
- * @param string $password User password
- * @param bool $wait_for_dashboard
- * @param array $config Client-site config
- *
- * @return void
+ * @param Browser $browser The browser object
+ * @param string $username User name
+ * @param string $password User password
+ * @param bool $wait_for_dashboard
+ * @param array $config Client-site config
*/
public function submitLogon(
$browser,
@@ -69,7 +67,7 @@
->type('@password-input', $password);
if ($username == 'ned@kolab.org') {
- $code = \App\Auth\SecondFactor::code('ned@kolab.org');
+ $code = SecondFactor::code('ned@kolab.org');
$browser->type('@second-factor-input', $code);
}
diff --git a/src/tests/Browser/Pages/Meet/Room.php b/src/tests/Browser/Pages/Meet/Room.php
--- a/src/tests/Browser/Pages/Meet/Room.php
+++ b/src/tests/Browser/Pages/Meet/Room.php
@@ -2,8 +2,10 @@
namespace Tests\Browser\Pages\Meet;
+use App\Auth\SecondFactor;
use Laravel\Dusk\Page;
use PHPUnit\Framework\Assert;
+use Tests\Browser;
class Room extends Page
{
@@ -42,8 +44,6 @@
* Assert that the browser is on the page.
*
* @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
*/
public function assert($browser)
{
@@ -99,8 +99,8 @@
/**
* Assert menu state.
*
- * @param \Tests\Browser $browser The browser object
- * @param array $menu Menu items/state
+ * @param Browser $browser The browser object
+ * @param array $menu Menu items/state
*/
public function assertToolbar($browser, array $menu): void
{
@@ -114,9 +114,9 @@
/**
* Assert menu button state.
*
- * @param \Tests\Browser $browser The browser object
- * @param string $button Button name
- * @param int $state Expected button state (sum of BUTTON_* consts)
+ * @param Browser $browser The browser object
+ * @param string $button Button name
+ * @param int $state Expected button state (sum of BUTTON_* consts)
*/
public function assertToolbarButtonState($browser, $button, $state): void
{
@@ -144,16 +144,16 @@
/**
* Assert the <video> element's 'muted' property state
*
- * @param \Tests\Browser $browser The browser object
- * @param string $selector Video element selector
- * @param bool $state Expected state
+ * @param Browser $browser The browser object
+ * @param string $selector Video element selector
+ * @param bool $state Expected state
*/
public function assertAudioMuted($browser, $selector, $state): void
{
$selector = addslashes($browser->resolver->format($selector));
$result = $browser->script(
- "var video = document.querySelector('$selector'); return video.muted"
+ "var video = document.querySelector('{$selector}'); return video.muted"
);
Assert::assertSame((bool) $result[0], $state);
@@ -162,9 +162,9 @@
/**
* Assert the participant icon type
*
- * @param \Tests\Browser $browser The browser object
- * @param string $selector Element selector
- * @param string $type Participant icon type
+ * @param Browser $browser The browser object
+ * @param string $selector Element selector
+ * @param string $type Participant icon type
*/
public function assertUserIcon($browser, $selector, $type): void
{
@@ -175,23 +175,23 @@
/**
* Set the nickname for the participant
*
- * @param \Tests\Browser $browser The browser object
- * @param string $selector Participant element selector
- * @param string $nickname Nickname
+ * @param Browser $browser The browser object
+ * @param string $selector Participant element selector
+ * @param string $nickname Nickname
*/
public function setNickname($browser, $selector, $nickname): void
{
- $element = "$selector .meet-nickname .content";
+ $element = "{$selector} .meet-nickname .content";
- $browser->click("$selector .meet-nickname")
- ->waitFor("$selector .dropdown-menu")
- ->assertSeeIn("$selector .dropdown-menu > .action-nickname", 'Nickname')
- ->click("$selector .dropdown-menu > .action-nickname")
+ $browser->click("{$selector} .meet-nickname")
+ ->waitFor("{$selector} .dropdown-menu")
+ ->assertSeeIn("{$selector} .dropdown-menu > .action-nickname", 'Nickname')
+ ->click("{$selector} .dropdown-menu > .action-nickname")
->waitUntilMissing('.dropdown-menu')
// Use script() because type() does not work with this contenteditable widget
->script(
- "var element = document.querySelector('$element');"
- . "element.innerText = '$nickname';"
+ "var element = document.querySelector('{$element}');"
+ . "element.innerText = '{$nickname}';"
. "element.dispatchEvent(new KeyboardEvent('keydown', { keyCode: 27 }))"
);
}
@@ -199,10 +199,10 @@
/**
* Submit logon form.
*
- * @param \Tests\Browser $browser The browser object
- * @param string $username User name
- * @param string $password User password
- * @param array $config Client-site config
+ * @param Browser $browser The browser object
+ * @param string $username User name
+ * @param string $password User password
+ * @param array $config Client-site config
*/
public function submitLogon($browser, $username, $password, $config = []): void
{
@@ -210,7 +210,7 @@
->type('@login-password-input', $password);
if ($username == 'ned@kolab.org') {
- $code = \App\Auth\SecondFactor::code('ned@kolab.org');
+ $code = SecondFactor::code('ned@kolab.org');
$browser->type('@login-second-factor-input', $code);
}
diff --git a/src/tests/Browser/Pages/Meet/RoomInfo.php b/src/tests/Browser/Pages/Meet/RoomInfo.php
--- a/src/tests/Browser/Pages/Meet/RoomInfo.php
+++ b/src/tests/Browser/Pages/Meet/RoomInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages\Meet;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class RoomInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -30,8 +27,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Meet/RoomList.php b/src/tests/Browser/Pages/Meet/RoomList.php
--- a/src/tests/Browser/Pages/Meet/RoomList.php
+++ b/src/tests/Browser/Pages/Meet/RoomList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages\Meet;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class RoomList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/PasswordReset.php b/src/tests/Browser/Pages/PasswordReset.php
--- a/src/tests/Browser/Pages/PasswordReset.php
+++ b/src/tests/Browser/Pages/PasswordReset.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class PasswordReset extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -30,8 +27,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/PaymentMollie.php b/src/tests/Browser/Pages/PaymentMollie.php
--- a/src/tests/Browser/Pages/PaymentMollie.php
+++ b/src/tests/Browser/Pages/PaymentMollie.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class PaymentMollie extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,19 +18,15 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
- $browser->waitFor('form')->waitFor('@title');
+ $browser->waitFor('form#body')->waitFor('@title');
}
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
@@ -44,36 +39,21 @@
/**
* Submit payment form.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- * @param string $status Test payment status (paid, open, failed, expired)
- *
- * @return void
+ * @param Browser $browser The browser object
+ * @param string $status Test payment status (paid, open, failed, expired)
*/
public function submitPayment($browser, $status = 'paid')
{
// https://docs.mollie.com/overview/testing
// https://docs.mollie.com/components/testing
$browser
- ->withinFrame('#card-number iframe', function ($browser) {
- $browser->waitFor('#cardNumber')
- ->type('#cardNumber', '2223 0000 1047 9399'); // Mastercard
- })
- ->withinFrame('#card-holder-name iframe', function ($browser) {
- $browser->waitFor('#cardHolder')
- ->type('#cardHolder', 'Test');
- })
- ->click('#expiry-date iframe')
- ->withinFrame('#expiry-date iframe', function ($browser) {
- $browser->waitFor('#expiryDate')
- ->type('#expiryDate', '12/' . (date('y') + 1));
- })
- ->click('#cvv iframe')
- ->withinFrame('#cvv iframe', function ($browser) {
- $browser->waitFor('#verificationCode')
- ->click('#verificationCode')
- ->type('#verificationCode', '123');
+ ->withinFrame('form#body iframe', static function ($browser) {
+ $browser->waitFor('#cardNumber')->type('#cardNumber', '2223 0000 1047 9399'); // Mastercard
+ $browser->waitFor('#cardHolder')->type('#cardHolder', 'Test');
+ $browser->waitFor('#cardExpiryDate')->type('#cardExpiryDate', '12/' . (date('y') + 1));
+ $browser->waitFor('#cardCvv')->type('#cardCvv', '123')
+ ->click('button[type=submit]');
})
- ->click('#submit-button')
->waitFor('input[value="' . $status . '"]')
->click('input[value="' . $status . '"]')
->click('button.form__button');
diff --git a/src/tests/Browser/Pages/PaymentStatus.php b/src/tests/Browser/Pages/PaymentStatus.php
--- a/src/tests/Browser/Pages/PaymentStatus.php
+++ b/src/tests/Browser/Pages/PaymentStatus.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class PaymentStatus extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/PaymentStripe.php b/src/tests/Browser/Pages/PaymentStripe.php
--- a/src/tests/Browser/Pages/PaymentStripe.php
+++ b/src/tests/Browser/Pages/PaymentStripe.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class PaymentStripe extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -30,38 +27,48 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
return [
- '@form' => '.App-Payment > form',
- '@title' => '.App-Overview .ProductSummary',
- '@amount' => '#ProductSummary-totalAmount',
- '@description' => '#ProductSummary-Description',
+ '@form' => '.App-Payment form',
+ '@amount' => '.OrderDetails .CurrencyAmount',
+ '@description' => '.OrderDetails .LineItem-productName',
'@email' => '.App-Payment .ReadOnlyFormField-email .ReadOnlyFormField-content',
'@cardnumber-input' => '.App-Payment #cardNumber',
'@cardexpiry-input' => '.App-Payment #cardExpiry',
'@cardcvc-input' => '.App-Payment #cardCvc',
'@name-input' => '.App-Payment #billingName',
- '@submit-button' => '.App-Payment form button.SubmitButton',
+ '@submit-button' => '.App-Payment .ConfirmPayment button',
];
}
/**
- * Submit payment form.
+ * Assert payment details.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
+ * @param Browser $browser The browser object
+ */
+ public function assertDetails($browser, $description, $amount)
+ {
+ // Currency selection, choose CHF
+ $browser->click('.SideToSideCurrencyToggle-toggle:nth-child(2) button')
+ ->pause(1000)
+ ->assertSeeIn('@description', $description)
+ ->assertSeeIn('@amount', $amount);
+ }
+
+ /**
+ * Submit payment form.
*
- * @return void
+ * @param Browser $browser The browser object
*/
public function submitValidCreditCard($browser)
{
$browser->type('@name-input', 'Test')
->typeSlowly('@cardnumber-input', '4242424242424242', 50)
- ->type('@cardexpiry-input', '12/' . (intval(date('y')) + 1))
+ ->type('@cardexpiry-input', '12/' . ((int) date('y') + 1))
->type('@cardcvc-input', '123')
+ ->scrollTo('@submit-button')->pause(200)
->press('@submit-button');
}
}
diff --git a/src/tests/Browser/Pages/Policies.php b/src/tests/Browser/Pages/Policies.php
--- a/src/tests/Browser/Pages/Policies.php
+++ b/src/tests/Browser/Pages/Policies.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Policies extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Reseller/Invitations.php b/src/tests/Browser/Pages/Reseller/Invitations.php
--- a/src/tests/Browser/Pages/Reseller/Invitations.php
+++ b/src/tests/Browser/Pages/Reseller/Invitations.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages\Reseller;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Invitations extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/ResourceInfo.php b/src/tests/Browser/Pages/ResourceInfo.php
--- a/src/tests/Browser/Pages/ResourceInfo.php
+++ b/src/tests/Browser/Pages/ResourceInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class ResourceInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/ResourceList.php b/src/tests/Browser/Pages/ResourceList.php
--- a/src/tests/Browser/Pages/ResourceList.php
+++ b/src/tests/Browser/Pages/ResourceList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class ResourceList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/SharedFolderInfo.php b/src/tests/Browser/Pages/SharedFolderInfo.php
--- a/src/tests/Browser/Pages/SharedFolderInfo.php
+++ b/src/tests/Browser/Pages/SharedFolderInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class SharedFolderInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/SharedFolderList.php b/src/tests/Browser/Pages/SharedFolderList.php
--- a/src/tests/Browser/Pages/SharedFolderList.php
+++ b/src/tests/Browser/Pages/SharedFolderList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class SharedFolderList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Signup.php b/src/tests/Browser/Pages/Signup.php
--- a/src/tests/Browser/Pages/Signup.php
+++ b/src/tests/Browser/Pages/Signup.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Signup extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -35,8 +32,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/UserInfo.php b/src/tests/Browser/Pages/UserInfo.php
--- a/src/tests/Browser/Pages/UserInfo.php
+++ b/src/tests/Browser/Pages/UserInfo.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class UserInfo extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -31,8 +28,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/UserList.php b/src/tests/Browser/Pages/UserList.php
--- a/src/tests/Browser/Pages/UserList.php
+++ b/src/tests/Browser/Pages/UserList.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class UserList extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/Pages/Wallet.php b/src/tests/Browser/Pages/Wallet.php
--- a/src/tests/Browser/Pages/Wallet.php
+++ b/src/tests/Browser/Pages/Wallet.php
@@ -2,14 +2,13 @@
namespace Tests\Browser\Pages;
+use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Wallet extends Page
{
/**
* Get the URL for the page.
- *
- * @return string
*/
public function url(): string
{
@@ -19,9 +18,7 @@
/**
* Assert that the browser is on the page.
*
- * @param \Laravel\Dusk\Browser $browser The browser object
- *
- * @return void
+ * @param Browser $browser The browser object
*/
public function assert($browser)
{
@@ -32,8 +29,6 @@
/**
* Get the element shortcuts for the page.
- *
- * @return array
*/
public function elements(): array
{
diff --git a/src/tests/Browser/PasswordResetTest.php b/src/tests/Browser/PasswordResetTest.php
--- a/src/tests/Browser/PasswordResetTest.php
+++ b/src/tests/Browser/PasswordResetTest.php
@@ -13,20 +13,14 @@
class PasswordResetTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('passwordresettestdusk@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('passwordresettestdusk@' . \config('app.domain'));
@@ -38,7 +32,7 @@
*/
public function testLinkOnLogon(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->assertSeeLink('Forgot password?')
->clickLink('Forgot password?')
@@ -55,27 +49,27 @@
$user = $this->getTestUser('passwordresettestdusk@' . \config('app.domain'));
$user->setSetting('external_email', 'external@domain.tld');
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new PasswordReset());
$browser->assertVisible('@step1');
// Here we expect email input and submit button
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->assertVisible('#reset_email');
$step->assertFocused('#reset_email');
$step->assertVisible('[type=submit]');
});
// Submit empty form
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->click('[type=submit]');
$step->assertFocused('#reset_email');
});
// Submit invalid email
// We expect email input to have is-invalid class added, with .invalid-feedback element
- $browser->with('@step1', function ($step) use ($browser) {
+ $browser->with('@step1', static function ($step) use ($browser) {
$step->type('#reset_email', '@test');
$step->click('[type=submit]');
@@ -86,7 +80,7 @@
});
// Submit valid data
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#reset_email', 'passwordresettestdusk@' . \config('app.domain'));
$step->click('[type=submit]');
@@ -114,7 +108,7 @@
$browser->assertVisible('@step2');
// Here we expect one text input, Back and Continue buttons
- $browser->with('@step2', function ($step) {
+ $browser->with('@step2', static function ($step) {
$step->assertVisible('#reset_short_code');
$step->assertFocused('#reset_short_code');
$step->assertVisible('[type=button]');
@@ -128,7 +122,7 @@
$browser->assertMissing('@step2');
// Submit valid Step 1 data (again)
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#reset_email', 'passwordresettestdusk@' . \config('app.domain'));
$step->click('[type=submit]');
});
@@ -138,7 +132,7 @@
// Submit invalid code
// We expect code input to have is-invalid class added, with .invalid-feedback element
- $browser->with('@step2', function ($step) use ($browser) {
+ $browser->with('@step2', static function ($step) use ($browser) {
$step->type('#reset_short_code', 'XXXXX');
$step->click('[type=submit]');
@@ -191,7 +185,7 @@
->clearToasts();
// Here we expect 2 text inputs, Back and Continue buttons
- $browser->with('@step3', function (Browser $step) {
+ $browser->with('@step3', static function (Browser $step) {
$step->assertVisible('#reset_password')
->assertVisible('#reset_password_confirmation')
->assertVisible('[type=button]')
@@ -217,7 +211,7 @@
->assertMissing('@step2');
// Submit valid data
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#reset_email', 'passwordresettestdusk@' . \config('app.domain'));
$step->click('[type=submit]');
});
@@ -240,9 +234,9 @@
$browser->waitFor('@step3');
// Submit invalid data
- $browser->with('@step3', function ($step) use ($browser) {
+ $browser->with('@step3', static function ($step) use ($browser) {
$step->assertFocused('#reset_password')
- ->whenAvailable('#reset_password_policy', function (Browser $browser) {
+ ->whenAvailable('#reset_password_policy', static function (Browser $browser) {
$browser->assertElementsCount('li', 2)
->assertMissing('li:first-child svg.text-success')
->assertSeeIn('li:first-child small', "Password contains an upper-case character")
@@ -251,7 +245,7 @@
})
->type('#reset_password', 'A2345678')
->type('#reset_password_confirmation', '123456789')
- ->with('#reset_password_policy', function (Browser $browser) {
+ ->with('#reset_password_policy', static function (Browser $browser) {
$browser->waitFor('li:first-child svg.text-success')
->waitFor('li:last-child svg.text-success');
});
@@ -268,7 +262,7 @@
});
// Submit valid data
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#reset_password_confirmation', 'A2345678')
->click('[type=submit]');
});
@@ -300,7 +294,7 @@
->waitFor('@step3')
->assertMissing('@step1')
->assertMissing('@step2')
- ->with('@step3', function ($step) {
+ ->with('@step3', static function ($step) {
$step->type('#reset_password', 'A2345678')
->type('#reset_password_confirmation', 'A2345678')
->click('[type=submit]');
@@ -308,7 +302,7 @@
->waitUntilMissing('@step3')
// At this point we should be auto-logged-in to dashboard
->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
diff --git a/src/tests/Browser/PaymentCoinbaseTest.php b/src/tests/Browser/PaymentCoinbaseTest.php
--- a/src/tests/Browser/PaymentCoinbaseTest.php
+++ b/src/tests/Browser/PaymentCoinbaseTest.php
@@ -2,7 +2,6 @@
namespace Tests\Browser;
-use App\Wallet;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -13,10 +12,7 @@
class PaymentCoinbaseTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -27,10 +23,7 @@
$this->deleteTestUser('payment-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.coinbase.key')) {
$this->deleteTestUser('payment-test@kolabnow.com');
@@ -47,7 +40,7 @@
public function testPayment(): void
{
$user = $this->getTestUser('payment-test@kolabnow.com', [
- 'password' => 'simple123',
+ 'password' => 'simple123',
]);
$this->browse(function (Browser $browser) use ($user) {
@@ -58,12 +51,12 @@
->on(new WalletPage())
->assertSeeIn('@main button', 'Add credit')
->click('@main button')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->waitFor('#payment-method-selection .link-bitcoin svg')
->click('#payment-method-selection .link-bitcoin');
})
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->assertFocused('#amount')
->assertSeeIn('@button-cancel', 'Cancel')
diff --git a/src/tests/Browser/PaymentMollieTest.php b/src/tests/Browser/PaymentMollieTest.php
--- a/src/tests/Browser/PaymentMollieTest.php
+++ b/src/tests/Browser/PaymentMollieTest.php
@@ -15,10 +15,7 @@
class PaymentMollieTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -29,10 +26,7 @@
$this->deleteTestUser('payment-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.mollie.key')) {
$this->deleteTestUser('payment-test@kolabnow.com');
@@ -49,7 +43,7 @@
public function testPayment(): void
{
$user = $this->getTestUser('payment-test@kolabnow.com', [
- 'password' => 'simple123',
+ 'password' => 'simple123',
]);
$this->browse(function (Browser $browser) use ($user) {
@@ -61,14 +55,14 @@
->on(new WalletPage())
->assertSeeIn('@main button', 'Add credit')
->click('@main button')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->waitFor('#payment-method-selection .link-creditcard svg')
->waitFor('#payment-method-selection .link-paypal svg')
->waitFor('#payment-method-selection .link-banktransfer svg')
->click('#payment-method-selection .link-creditcard');
})
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->assertFocused('#amount')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -90,8 +84,8 @@
->submitPayment()
->waitForLocation('/wallet')
->on(new WalletPage());
- // Note: This depends on Mollie to Cockcpit communication (webhook)
- // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
+ // Note: This depends on Mollie to Cockcpit communication (webhook)
+ // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
$this->assertSame(1, $user->wallets()->first()->payments()->count());
});
@@ -105,7 +99,7 @@
public function testAutoPaymentSetup(): void
{
$user = $this->getTestUser('payment-test@kolabnow.com', [
- 'password' => 'simple123',
+ 'password' => 'simple123',
]);
$this->browse(function (Browser $browser) use ($user) {
@@ -126,11 +120,11 @@
->click('#payment-method-selection .link-creditcard');
})
*/
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Set up auto-payment')
->waitFor('@body #mandate_amount')
->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by')
- ->assertValue('@body #mandate_amount', strval(Payment::MIN_AMOUNT / 100))
+ ->assertValue('@body #mandate_amount', (string) (Payment::MIN_AMOUNT / 100))
->assertSeeIn('@body label[for="mandate_balance"]', 'when account balance is below') // phpcs:ignore
->assertValue('@body #mandate_balance', '0')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -188,7 +182,7 @@
});
// Test updating (disabled) auto-payment
- $this->browse(function (Browser $browser) use ($user) {
+ $this->browse(static function (Browser $browser) use ($user) {
$wallet = $user->wallets()->first();
$wallet->setSetting('mandate_disabled', 1);
@@ -201,25 +195,25 @@
)
->assertSeeIn('#mandate-info button.btn-primary', 'Change auto-payment')
->click('#mandate-info button.btn-primary')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Update auto-payment')
- ->assertSeeIn(
- '@body form .disabled-mandate',
- 'The auto-payment is disabled.'
- )
- ->assertValue('@body #mandate_amount', '100')
- ->assertValue('@body #mandate_balance', '0')
- ->assertSeeIn('@button-cancel', 'Cancel')
- ->assertSeeIn('@button-action', 'Submit')
+ ->assertSeeIn(
+ '@body form .disabled-mandate',
+ 'The auto-payment is disabled.'
+ )
+ ->assertValue('@body #mandate_amount', '100')
+ ->assertValue('@body #mandate_balance', '0')
+ ->assertSeeIn('@button-cancel', 'Cancel')
+ ->assertSeeIn('@button-action', 'Submit')
// Test error handling
- ->type('@body #mandate_amount', 'aaa')
- ->click('@button-action')
- ->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->assertVisible('@body #mandate_amount.is-invalid')
- ->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.')
+ ->type('@body #mandate_amount', 'aaa')
+ ->click('@button-action')
+ ->assertToast(Toast::TYPE_ERROR, 'Form validation error')
+ ->assertVisible('@body #mandate_amount.is-invalid')
+ ->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.')
// Submit valid data
- ->type('@body #mandate_amount', '50')
- ->click('@button-action');
+ ->type('@body #mandate_amount', '50')
+ ->click('@button-action');
})
->waitUntilMissing('#payment-dialog')
->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been updated.')
@@ -231,19 +225,19 @@
});
// Test deleting auto-payment
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new WalletPage())
- ->waitFor('#mandate-info')
- ->assertSeeIn('#mandate-info * button.btn-danger', 'Cancel auto-payment')
- ->assertVisible('#mandate-info * button.btn-danger')
- ->click('#mandate-info * button.btn-danger')
- ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.')
- ->assertVisible('#mandate-form')
- ->assertMissing('#mandate-info');
+ ->waitFor('#mandate-info')
+ ->assertSeeIn('#mandate-info * button.btn-danger', 'Cancel auto-payment')
+ ->assertVisible('#mandate-info * button.btn-danger')
+ ->click('#mandate-info * button.btn-danger')
+ ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.')
+ ->assertVisible('#mandate-form')
+ ->assertMissing('#mandate-info');
});
// Test pending and failed mandate
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new WalletPage())
->assertMissing('@body #mandate-form .alert')
->click('@main #mandate-form button')
@@ -254,7 +248,7 @@
->click('#payment-method-selection .link-creditcard');
})
*/
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Set up auto-payment')
->waitFor('@body #mandate_amount')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -288,7 +282,7 @@
->click('#payment-method-selection .link-creditcard');
})
*/
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Set up auto-payment')
->waitFor('@body #mandate_amount')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -310,7 +304,7 @@
'The setup of automatic payments failed. Restart the process to enable'
)
->click('@main button')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->waitFor('#mandate-form')
->assertMissing('#mandate-info');
});
diff --git a/src/tests/Browser/PaymentStripeTest.php b/src/tests/Browser/PaymentStripeTest.php
--- a/src/tests/Browser/PaymentStripeTest.php
+++ b/src/tests/Browser/PaymentStripeTest.php
@@ -15,10 +15,7 @@
class PaymentStripeTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -29,10 +26,7 @@
$this->deleteTestUser('payment-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.stripe.key')) {
$this->deleteTestUser('payment-test@kolabnow.com');
@@ -49,7 +43,7 @@
public function testPayment(): void
{
$user = $this->getTestUser('payment-test@kolabnow.com', [
- 'password' => 'simple123',
+ 'password' => 'simple123',
]);
$this->browse(function (Browser $browser) use ($user) {
@@ -61,14 +55,14 @@
->on(new WalletPage())
->assertSeeIn('@main button', 'Add credit')
->click('@main button')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->waitFor('#payment-method-selection .link-creditcard svg')
->waitFor('#payment-method-selection .link-paypal svg')
->assertMissing('#payment-method-selection .link-banktransfer svg')
->click('#payment-method-selection .link-creditcard');
})
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->assertFocused('#amount')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -85,8 +79,7 @@
->click('@button-action');
})
->on(new PaymentStripe())
- ->assertSeeIn('@title', $user->tenant->title . ' Payment')
- ->assertSeeIn('@amount', 'CHF 12.34')
+ ->assertDetails($user->tenant->title . ' Payment', 'CHF 12.34')
->assertSeeIn('@email', $user->email)
->submitValidCreditCard();
@@ -112,7 +105,7 @@
public function testAutoPaymentSetup(): void
{
$user = $this->getTestUser('payment-test@kolabnow.com', [
- 'password' => 'simple123',
+ 'password' => 'simple123',
]);
// Test creating auto-payment
@@ -134,11 +127,11 @@
->click('#payment-method-selection .link-creditcard');
})
*/
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Set up auto-payment')
->waitFor('@body #mandate_amount')
->assertSeeIn('@body label[for="mandate_amount"]', 'Fill up by')
- ->assertValue('@body #mandate_amount', strval(Payment::MIN_AMOUNT / 100))
+ ->assertValue('@body #mandate_amount', (string) (Payment::MIN_AMOUNT / 100))
->assertSeeIn('@body label[for="mandate_balance"]', 'when account balance is below') // phpcs:ignore
->assertValue('@body #mandate_balance', '0')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -168,7 +161,7 @@
->click('@button-action');
})
->on(new PaymentStripe())
- ->assertMissing('@title')
+ ->assertMissing('@description')
->assertMissing('@amount')
->assertSeeIn('@email', $user->email)
->submitValidCreditCard()
@@ -194,7 +187,7 @@
});
// Test updating (disabled) auto-payment
- $this->browse(function (Browser $browser) use ($user) {
+ $this->browse(static function (Browser $browser) use ($user) {
$wallet = $user->wallets()->first();
$wallet->setSetting('mandate_disabled', 1);
@@ -207,25 +200,25 @@
)
->assertSeeIn('#mandate-info button.btn-primary', 'Change auto-payment')
->click('#mandate-info button.btn-primary')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Update auto-payment')
- ->assertSeeIn(
- '@body form .disabled-mandate',
- 'The auto-payment is disabled.'
- )
- ->assertValue('@body #mandate_amount', '100')
- ->assertValue('@body #mandate_balance', '0')
- ->assertSeeIn('@button-cancel', 'Cancel')
- ->assertSeeIn('@button-action', 'Submit')
+ ->assertSeeIn(
+ '@body form .disabled-mandate',
+ 'The auto-payment is disabled.'
+ )
+ ->assertValue('@body #mandate_amount', '100')
+ ->assertValue('@body #mandate_balance', '0')
+ ->assertSeeIn('@button-cancel', 'Cancel')
+ ->assertSeeIn('@button-action', 'Submit')
// Test error handling
- ->type('@body #mandate_amount', 'aaa')
- ->click('@button-action')
- ->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->assertVisible('@body #mandate_amount.is-invalid')
- ->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.')
+ ->type('@body #mandate_amount', 'aaa')
+ ->click('@button-action')
+ ->assertToast(Toast::TYPE_ERROR, 'Form validation error')
+ ->assertVisible('@body #mandate_amount.is-invalid')
+ ->assertSeeIn('#mandate_amount + span + .invalid-feedback', 'The amount must be a number.')
// Submit valid data
- ->type('@body #mandate_amount', '50')
- ->click('@button-action');
+ ->type('@body #mandate_amount', '50')
+ ->click('@button-action');
})
->waitUntilMissing('#payment-dialog')
->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been updated.')
@@ -237,15 +230,15 @@
});
// Test deleting auto-payment
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new WalletPage())
- ->waitFor('#mandate-info')
- ->assertSeeIn('#mandate-info * button.btn-danger', 'Cancel auto-payment')
- ->assertVisible('#mandate-info * button.btn-danger')
- ->click('#mandate-info * button.btn-danger')
- ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.')
- ->assertVisible('#mandate-form')
- ->assertMissing('#mandate-info');
+ ->waitFor('#mandate-info')
+ ->assertSeeIn('#mandate-info * button.btn-danger', 'Cancel auto-payment')
+ ->assertVisible('#mandate-info * button.btn-danger')
+ ->click('#mandate-info * button.btn-danger')
+ ->assertToast(Toast::TYPE_SUCCESS, 'The auto-payment has been removed.')
+ ->assertVisible('#mandate-form')
+ ->assertMissing('#mandate-info');
});
}
}
diff --git a/src/tests/Browser/PoliciesTest.php b/src/tests/Browser/PoliciesTest.php
--- a/src/tests/Browser/PoliciesTest.php
+++ b/src/tests/Browser/PoliciesTest.php
@@ -18,7 +18,7 @@
public function testPoliciesUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/policies')->on(new Home());
});
}
@@ -28,7 +28,7 @@
*/
public function testDashboard(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
// Test a user that is not an account owner
$browser->visit(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
@@ -36,7 +36,7 @@
->assertMissing('@links .link-policies')
->visit('/policies')
->assertErrorPage(403)
- ->within(new Menu(), function (Browser $browser) {
+ ->within(new Menu(), static function (Browser $browser) {
$browser->clickMenuItem('logout');
});
@@ -60,13 +60,13 @@
$john->setSetting('password_policy', 'min:5,max:100,lower');
$john->setSetting('max_password_age', null);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->click('@links .link-policies')
->on(new Policies())
->assertSeeIn('#policies .card-title', 'Policies')
// Password policy
->assertSeeIn('@form .row:nth-child(1) > label', 'Password Policy')
- ->with('@form #password_policy', function (Browser $browser) {
+ ->with('@form #password_policy', static function (Browser $browser) {
$browser->assertElementsCount('li', 7)
->assertSeeIn('li:nth-child(1) label', 'Minimum password length')
->assertChecked('li:nth-child(1) input[type=checkbox]')
@@ -92,7 +92,7 @@
->assertNotChecked('li:nth-child(7) input[type=checkbox]')
->assertMissing('li:nth-child(7) input[type=text]')
->assertSelected('li:nth-child(7) select', 3)
- ->assertSelectHasOptions('li:nth-child(7) select', [1,2,3,4,5,6])
+ ->assertSelectHasOptions('li:nth-child(7) select', [1, 2, 3, 4, 5, 6])
// Change the policy
->type('li:nth-child(1) input[type=text]', '11')
->type('li:nth-child(2) input[type=text]', '120')
@@ -100,7 +100,7 @@
->click('li:nth-child(4) input[type=checkbox]');
})
->assertSeeIn('@form .row:nth-child(2) > label', 'Password Retention')
- ->with('@form #password_retention', function (Browser $browser) {
+ ->with('@form #password_retention', static function (Browser $browser) {
$browser->assertElementsCount('li', 1)
->assertSeeIn('li:nth-child(1) label', 'Require a password change every')
->assertNotChecked('li:nth-child(1) input[type=checkbox]')
diff --git a/src/tests/Browser/Reseller/DashboardTest.php b/src/tests/Browser/Reseller/DashboardTest.php
--- a/src/tests/Browser/Reseller/DashboardTest.php
+++ b/src/tests/Browser/Reseller/DashboardTest.php
@@ -2,6 +2,9 @@
namespace Tests\Browser\Reseller;
+use App\Domain;
+use App\Plan;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
use Tests\Browser\Components\Toast;
@@ -11,10 +14,7 @@
class DashboardTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -26,10 +26,7 @@
$this->deleteTestDomain('testsearch.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSetting('external_email', null);
@@ -47,7 +44,7 @@
{
$this->browse(function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertFocused('@search input')
->assertMissing('@search table');
@@ -66,9 +63,9 @@
$browser->type('@search input', 'john.doe.external@gmail.com')
->click('@search form button')
->assertToast(Toast::TYPE_INFO, '2 user accounts have been found.')
- ->whenAvailable('@search table', function (Browser $browser) use ($john, $jack) {
+ ->whenAvailable('@search table', static function (Browser $browser) use ($john, $jack) {
$browser->assertElementsCount('tbody tr', 2)
- ->with('tbody tr:first-child', function (Browser $browser) use ($jack) {
+ ->with('tbody tr:first-child', static function (Browser $browser) use ($jack) {
$browser->assertSeeIn('td:nth-child(1) a', $jack->email)
->assertSeeIn('td:nth-child(2) a', $jack->id);
@@ -81,7 +78,7 @@
->assertText('td:nth-child(4)', '');
}
})
- ->with('tbody tr:last-child', function (Browser $browser) use ($john) {
+ ->with('tbody tr:last-child', static function (Browser $browser) use ($john) {
$browser->assertSeeIn('td:nth-child(1) a', $john->email)
->assertSeeIn('td:nth-child(2) a', $john->id);
@@ -102,7 +99,7 @@
->assertMissing('@search table')
->waitForLocation('/user/' . $john->id)
->waitUntilMissing('.app-loader')
- ->whenAvailable('#user-info', function (Browser $browser) use ($john) {
+ ->whenAvailable('#user-info', static function (Browser $browser) use ($john) {
$browser->assertSeeIn('.card-title', $john->email);
});
});
@@ -115,15 +112,15 @@
{
$this->browse(function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertFocused('@search input')
->assertMissing('@search table');
// Deleted users/domains
- $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]);
+ $domain = $this->getTestDomain('testsearch.com', ['type' => Domain::TYPE_EXTERNAL]);
$user = $this->getTestUser('test@testsearch.com');
- $plan = \App\Plan::where('title', 'group')->first();
+ $plan = Plan::where('title', 'group')->first();
$user->assignPlan($plan, $domain);
$user->setAliases(['alias@testsearch.com']);
Queue::fake();
@@ -133,10 +130,10 @@
$browser->type('@search input', 'testsearch.com')
->click('@search form button')
->assertToast(Toast::TYPE_INFO, '1 user accounts have been found.')
- ->whenAvailable('@search table', function (Browser $browser) use ($user) {
+ ->whenAvailable('@search table', static function (Browser $browser) use ($user) {
$browser->assertElementsCount('tbody tr', 1)
->assertVisible('tbody tr:first-child.text-secondary')
- ->with('tbody tr:first-child', function (Browser $browser) use ($user) {
+ ->with('tbody tr:first-child', static function (Browser $browser) use ($user) {
$browser->assertSeeIn('td:nth-child(1) span', $user->email)
->assertSeeIn('td:nth-child(2) span', $user->id);
diff --git a/src/tests/Browser/Reseller/DistlistTest.php b/src/tests/Browser/Reseller/DistlistTest.php
--- a/src/tests/Browser/Reseller/DistlistTest.php
+++ b/src/tests/Browser/Reseller/DistlistTest.php
@@ -4,6 +4,7 @@
use App\EventLog;
use App\Group;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
@@ -16,25 +17,19 @@
class DistlistTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
$this->deleteTestGroup('group-test@kolab.org');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
parent::tearDown();
}
@@ -74,7 +69,7 @@
// Goto the distlist page
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -83,7 +78,7 @@
->click('@user-distlists table tbody tr:first-child td a')
->on($distlist_page)
->assertSeeIn('@distlist-info .card-title', $group->email)
- ->with('@distlist-info form', function (Browser $browser) use ($group) {
+ ->with('@distlist-info form', static function (Browser $browser) use ($group) {
$browser->assertElementsCount('.row', 4)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #distlistid', "{$group->id} ({$group->created_at})")
@@ -97,7 +92,7 @@
})
->assertElementsCount('ul.nav-tabs li', 2)
->assertSeeIn('ul.nav-tabs #tab-settings', 'Settings')
- ->with('@distlist-settings form', function (Browser $browser) {
+ ->with('@distlist-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Sender Access List')
->assertSeeIn('.row:nth-child(1) #sender_policy', 'test1.com, test2.com');
@@ -117,7 +112,7 @@
public function testSuspendAndUnsuspend(): void
{
Queue::fake();
- Eventlog::query()->delete();
+ EventLog::query()->delete();
$this->browse(function (Browser $browser) {
$user = $this->getTestUser('john@kolab.org');
@@ -131,7 +126,7 @@
->assertMissing('@distlist-info #button-unsuspend')
->assertSeeIn('@distlist-info #status.text-success', 'Active')
->click('@distlist-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -144,10 +139,10 @@
$event = EventLog::where('type', EventLog::TYPE_SUSPENDED)->first();
$this->assertSame('test suspend', $event->comment);
- $this->assertEquals($group->id, $event->object_id);
+ $this->assertSame((string) $group->id, (string) $event->object_id);
$browser->click('@distlist-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -159,8 +154,8 @@
->assertMissing('@distlist-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
- $this->assertEquals($group->id, $event->object_id);
+ $this->assertNull($event->comment);
+ $this->assertSame((string) $group->id, (string) $event->object_id);
});
}
}
diff --git a/src/tests/Browser/Reseller/DomainTest.php b/src/tests/Browser/Reseller/DomainTest.php
--- a/src/tests/Browser/Reseller/DomainTest.php
+++ b/src/tests/Browser/Reseller/DomainTest.php
@@ -3,7 +3,10 @@
namespace Tests\Browser\Reseller;
use App\Domain;
+use App\Entitlement;
use App\EventLog;
+use App\Sku;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -12,34 +15,27 @@
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
class DomainTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
- Eventlog::query()->delete();
+ EventLog::query()->delete();
parent::tearDown();
}
@@ -70,7 +66,7 @@
// Goto the domain page
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -80,7 +76,7 @@
$browser->on($domain_page)
->assertSeeIn('@domain-info .card-title', 'kolab.org')
- ->with('@domain-info form', function (Browser $browser) use ($domain) {
+ ->with('@domain-info form', static function (Browser $browser) use ($domain) {
$browser->assertElementsCount('.row', 2)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #domainid', "{$domain->id} ({$domain->created_at})")
@@ -96,7 +92,7 @@
// Assert Configuration tab
$browser->assertSeeIn('@nav #tab-config', 'Configuration')
- ->with('@domain-config', function (Browser $browser) {
+ ->with('@domain-config', static function (Browser $browser) {
$browser->assertSeeIn('pre#dns-confirm', 'kolab-verify.kolab.org.')
->assertSeeIn('pre#dns-config', 'kolab.org.');
});
@@ -113,27 +109,27 @@
EventLog::query()->delete();
$this->browse(function (Browser $browser) {
- $sku_domain = \App\Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $sku_domain = Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user = $this->getTestUser('test1@domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE
- | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED
- | Domain::STATUS_VERIFIED,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE
+ | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED
+ | Domain::STATUS_VERIFIED,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- \App\Entitlement::create([
+ Entitlement::create([
'wallet_id' => $user->wallets()->first()->id,
'sku_id' => $sku_domain->id,
'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'entitleable_type' => Domain::class,
]);
$browser->visit(new DomainPage($domain->id))
->assertVisible('@domain-info #button-suspend')
->assertMissing('@domain-info #button-unsuspend')
->click('@domain-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -146,10 +142,10 @@
$event = EventLog::where('type', EventLog::TYPE_SUSPENDED)->first();
$this->assertSame('test suspend', $event->comment);
- $this->assertEquals($domain->id, $event->object_id);
+ $this->assertSame((string) $domain->id, (string) $event->object_id);
$browser->click('@domain-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -161,8 +157,8 @@
->assertMissing('@domain-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
- $this->assertEquals($domain->id, $event->object_id);
+ $this->assertNull($event->comment);
+ $this->assertSame((string) $domain->id, (string) $event->object_id);
});
}
}
diff --git a/src/tests/Browser/Reseller/InvitationsTest.php b/src/tests/Browser/Reseller/InvitationsTest.php
--- a/src/tests/Browser/Reseller/InvitationsTest.php
+++ b/src/tests/Browser/Reseller/InvitationsTest.php
@@ -3,10 +3,10 @@
namespace Tests\Browser\Reseller;
use App\SignupInvitation;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
-use Tests\Browser\Components\Menu;
use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
@@ -15,10 +15,7 @@
class InvitationsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -31,7 +28,7 @@
public function testInvitationsUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/invitations')->on(new Home());
});
}
@@ -41,11 +38,11 @@
*/
public function testInvitationCreate(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$date_regexp = '/^20[0-9]{2}-/';
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertSeeIn('@links .link-invitations', 'Invitations')
->click('@links .link-invitations')
@@ -57,7 +54,7 @@
// Create a single invite with email address input
$browser->click('@create-button')
- ->with(new Dialog('#invite-create'), function (Browser $browser) {
+ ->with(new Dialog('#invite-create'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Invite for a signup')
->assertFocused('@body input#email')
->assertValue('@body input#email', '')
@@ -88,7 +85,7 @@
// Create invites from a file
$browser->click('@create-button')
- ->with(new Dialog('#invite-create'), function (Browser $browser) {
+ ->with(new Dialog('#invite-create'), static function (Browser $browser) {
$browser->assertFocused('@body input#email')
->assertValue('@body input#email', '')
->assertMissing('@body input#email.is-invalid')
@@ -119,7 +116,7 @@
*/
public function testInvitationDeleteAndResend(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
Queue::fake();
$i1 = SignupInvitation::create(['email' => 'test1@domain.org']);
$i2 = SignupInvitation::create(['email' => 'test2@domain.org']);
@@ -150,7 +147,7 @@
*/
public function testInvitationsList(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
Queue::fake();
$i1 = SignupInvitation::create(['email' => 'email1@ext.com']);
$i2 = SignupInvitation::create(['email' => 'email2@ext.com']);
@@ -178,7 +175,7 @@
// ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
->assertElementsCount('@table tbody tr', 10)
->assertSeeIn('.more-loader button', 'Load more')
- ->with('@table tbody', function ($browser) use ($i1, $i2, $i3) {
+ ->with('@table tbody', static function ($browser) use ($i1, $i2, $i3) {
$browser->assertSeeIn('tr:nth-child(1) td.email', $i1->email)
->assertText('tr:nth-child(1) td.email svg.text-danger title', 'Sending failed')
->assertVisible('tr:nth-child(1) td.buttons button.button-delete')
@@ -196,7 +193,7 @@
->assertVisible('tr:nth-child(4) td.buttons button.button-resend:disabled');
})
->click('.more-loader button')
- ->whenAvailable('@table tbody tr:nth-child(11)', function ($browser) use ($i11) {
+ ->whenAvailable('@table tbody tr:nth-child(11)', static function ($browser) use ($i11) {
$browser->assertSeeIn('td.email', $i11->email);
})
->assertMissing('.more-loader button');
diff --git a/src/tests/Browser/Reseller/LogonTest.php b/src/tests/Browser/Reseller/LogonTest.php
--- a/src/tests/Browser/Reseller/LogonTest.php
+++ b/src/tests/Browser/Reseller/LogonTest.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Reseller;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Menu;
use Tests\Browser\Components\Toast;
@@ -11,10 +12,7 @@
class LogonTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -25,9 +23,9 @@
*/
public function testLogonMenu(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->with(new Menu(), function ($browser) {
+ ->with(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
})
->assertMissing('@second-factor-input')
@@ -40,7 +38,7 @@
*/
public function testLogonRedirect(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/dashboard');
// Checks if we're really on the login page
@@ -54,7 +52,7 @@
*/
public function testLogonWrongCredentials(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('reseller@' . \config('app.domain'), 'wrong')
// Error message
@@ -69,13 +67,13 @@
*/
public function testLogonSuccessful(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true);
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true);
// Checks if we're really on Dashboard page
$browser->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'dashboard', 'logout', 'lang']);
})
->assertUser('reseller@' . \config('app.domain'));
@@ -93,11 +91,11 @@
*/
public function testLogout(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new Dashboard());
// Click the Logout button
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
@@ -106,7 +104,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
});
@@ -120,9 +118,9 @@
*/
public function testLogoutByURL(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true);
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true);
// Checks if we're really on Dashboard page
$browser->on(new Dashboard());
@@ -133,7 +131,7 @@
->on(new Home());
// with default menu
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'login', 'lang']);
});
diff --git a/src/tests/Browser/Reseller/PaymentMollieTest.php b/src/tests/Browser/Reseller/PaymentMollieTest.php
--- a/src/tests/Browser/Reseller/PaymentMollieTest.php
+++ b/src/tests/Browser/Reseller/PaymentMollieTest.php
@@ -2,7 +2,7 @@
namespace Tests\Browser\Reseller;
-use App\Wallet;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -14,10 +14,7 @@
class PaymentMollieTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -28,10 +25,7 @@
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.mollie.key')) {
$user = $this->getTestUser('reseller@' . \config('app.domain'));
@@ -60,20 +54,20 @@
$browser->withConfig(['services.payment_provider' => 'mollie'])
->visit(new Home())
- ->submitLogon($user->email, \App\Utils::generatePassphrase(), true)
+ ->submitLogon($user->email, Utils::generatePassphrase(), true)
->on(new Dashboard())
->click('@links .link-wallet')
->on(new WalletPage())
->assertSeeIn('@main button', 'Add credit')
->click('@main button')
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->waitFor('#payment-method-selection .link-creditcard svg')
->waitFor('#payment-method-selection .link-paypal svg')
->waitFor('#payment-method-selection .link-banktransfer svg')
->click('#payment-method-selection .link-creditcard');
})
- ->with(new Dialog('@payment-dialog'), function (Browser $browser) {
+ ->with(new Dialog('@payment-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Top up your wallet')
->assertFocused('#amount')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -95,8 +89,8 @@
->submitPayment()
->waitForLocation('/wallet')
->on(new WalletPage());
- // Note: This depends on Mollie to Cockcpit communication (webhook)
- // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
+ // Note: This depends on Mollie to Cockcpit communication (webhook)
+ // $browser->assertSeeIn('@main .card-title', 'Account balance 12,34 CHF');
$this->assertSame(1, $wallet->payments()->count());
});
diff --git a/src/tests/Browser/Reseller/ResourceTest.php b/src/tests/Browser/Reseller/ResourceTest.php
--- a/src/tests/Browser/Reseller/ResourceTest.php
+++ b/src/tests/Browser/Reseller/ResourceTest.php
@@ -3,9 +3,9 @@
namespace Tests\Browser\Reseller;
use App\Resource;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Admin\Resource as ResourcePage;
use Tests\Browser\Pages\Admin\User as UserPage;
use Tests\Browser\Pages\Dashboard;
@@ -14,19 +14,13 @@
class ResourceTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -65,7 +59,7 @@
// Goto the distlist page
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -74,7 +68,7 @@
->click('@user-resources table tbody tr:first-child td:first-child a')
->on($resource_page)
->assertSeeIn('@resource-info .card-title', $resource->email)
- ->with('@resource-info form', function (Browser $browser) use ($resource) {
+ ->with('@resource-info form', static function (Browser $browser) use ($resource) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #resourceid', "{$resource->id} ({$resource->created_at})")
@@ -85,7 +79,7 @@
})
->assertElementsCount('ul.nav-tabs', 1)
->assertSeeIn('ul.nav-tabs .nav-link', 'Settings')
- ->with('@resource-settings form', function (Browser $browser) {
+ ->with('@resource-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Invitation policy')
->assertSeeIn('.row:nth-child(1) #invitation_policy', 'accept');
diff --git a/src/tests/Browser/Reseller/SharedFolderTest.php b/src/tests/Browser/Reseller/SharedFolderTest.php
--- a/src/tests/Browser/Reseller/SharedFolderTest.php
+++ b/src/tests/Browser/Reseller/SharedFolderTest.php
@@ -3,9 +3,9 @@
namespace Tests\Browser\Reseller;
use App\SharedFolder;
+use App\Utils;
use Illuminate\Support\Facades\Queue;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Admin\SharedFolder as SharedFolderPage;
use Tests\Browser\Pages\Admin\User as UserPage;
use Tests\Browser\Pages\Dashboard;
@@ -14,19 +14,13 @@
class SharedFolderTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -66,7 +60,7 @@
// Goto the folder page
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($user_page)
->on($user_page)
@@ -75,7 +69,7 @@
->click('@user-folders table tbody tr:first-child td:first-child a')
->on($folder_page)
->assertSeeIn('@folder-info .card-title', $folder->email)
- ->with('@folder-info form', function (Browser $browser) use ($folder) {
+ ->with('@folder-info form', static function (Browser $browser) use ($folder) {
$browser->assertElementsCount('.row', 4)
->assertSeeIn('.row:nth-child(1) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(1) #folderid', "{$folder->id} ({$folder->created_at})")
@@ -88,7 +82,7 @@
})
->assertElementsCount('ul.nav-tabs .nav-item', 2)
->assertSeeIn('ul.nav-tabs .nav-item:nth-child(1) .nav-link', 'Settings')
- ->with('@folder-settings form', function (Browser $browser) {
+ ->with('@folder-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Access rights')
->assertSeeIn('.row:nth-child(1) #acl', 'anyone: read-only')
@@ -96,7 +90,7 @@
})
->assertSeeIn('ul.nav-tabs .nav-item:nth-child(2) .nav-link', 'Email Aliases (2)')
->click('ul.nav-tabs .nav-item:nth-child(2) .nav-link')
- ->with('@folder-aliases table', function (Browser $browser) {
+ ->with('@folder-aliases table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1) td', 'folder-alias1@kolab.org')
->assertSeeIn('tbody tr:nth-child(2) td', 'folder-alias2@kolab.org');
diff --git a/src/tests/Browser/Reseller/StatsTest.php b/src/tests/Browser/Reseller/StatsTest.php
--- a/src/tests/Browser/Reseller/StatsTest.php
+++ b/src/tests/Browser/Reseller/StatsTest.php
@@ -2,6 +2,7 @@
namespace Tests\Browser\Reseller;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Pages\Admin\Stats;
use Tests\Browser\Pages\Dashboard;
@@ -10,10 +11,7 @@
class StatsTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -25,7 +23,7 @@
public function testStatsUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/stats')->on(new Home());
});
}
@@ -35,9 +33,9 @@
*/
public function testStats(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertSeeIn('@links .link-stats', 'Stats')
->click('@links .link-stats')
diff --git a/src/tests/Browser/Reseller/UserFinancesTest.php b/src/tests/Browser/Reseller/UserFinancesTest.php
--- a/src/tests/Browser/Reseller/UserFinancesTest.php
+++ b/src/tests/Browser/Reseller/UserFinancesTest.php
@@ -4,7 +4,7 @@
use App\Discount;
use App\Transaction;
-use App\User;
+use App\Utils;
use App\Wallet;
use Carbon\Carbon;
use Tests\Browser;
@@ -17,10 +17,7 @@
class UserFinancesTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -47,16 +44,16 @@
$page = new UserPage($jack->id);
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($page)
->on($page)
->assertSeeIn('@nav #tab-finances', 'Finances')
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 2)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', 'none')
@@ -64,7 +61,7 @@
->assertSeeIn('.row:nth-child(2) a', 'abc');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertMissing('tbody')
->assertSeeIn('tfoot td', "There are no transactions for this account.");
})
@@ -85,12 +82,12 @@
// Create test transactions
$transaction = Transaction::create([
- 'user_email' => 'jeroen@jeroen.jeroen',
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_CREDIT,
- 'amount' => 100,
- 'description' => 'Payment',
+ 'user_email' => 'jeroen@jeroen.jeroen',
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_CREDIT,
+ 'amount' => 100,
+ 'description' => 'Payment',
]);
$transaction->created_at = Carbon::now()->subMonth();
$transaction->save();
@@ -98,17 +95,17 @@
// Click the managed-by link on Jack's page
$browser->click('@user-info #manager a')
->on($page)
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-danger', '-20,10 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', '10% - Test voucher');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertMissing('tfoot');
@@ -130,17 +127,17 @@
$browser->click('@nav #tab-users')
->click('@user-users tbody tr:nth-child(4) td:first-child a')
->on($page)
- ->with('@user-finances', function (Browser $browser) {
+ ->with('@user-finances', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('.card-title:first-child', 'Account balance')
->assertSeeIn('.card-title:first-child .text-success', '0,00 CHF')
- ->with('form', function (Browser $browser) {
+ ->with('form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 1)
->assertSeeIn('.row:nth-child(1) label', 'Discount')
->assertSeeIn('.row:nth-child(1) #discount span', 'none');
})
->assertSeeIn('h2:nth-of-type(2)', 'Transactions')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertMissing('tbody')
->assertSeeIn('tfoot td', "There are no transactions for this account.");
})
@@ -164,7 +161,7 @@
->waitUntilMissing('@user-finances .app-loader')
->click('@user-finances #discount button')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Account discount')
->assertFocused('@body select')
->assertSelected('@body select', '')
@@ -175,7 +172,7 @@
->assertMissing('#discount-dialog')
->click('@user-finances #discount button')
// Change the discount
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->click('@body select')
->click('@body select option:nth-child(2)')
->click('@button-action');
@@ -183,7 +180,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.')
->assertSeeIn('#discount span', '10% - Test voucher')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month¹')
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,41 CHF/month¹')
@@ -192,7 +189,7 @@
// Change back to 'none'
->click('@nav #tab-finances')
->click('@user-finances #discount button')
- ->with(new Dialog('#discount-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#discount-dialog'), static function (Browser $browser) {
$browser->click('@body select')
->click('@body select option:nth-child(1)')
->click('@button-action');
@@ -200,7 +197,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User wallet updated successfully.')
->assertSeeIn('#discount span', 'none')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF/month')
->assertSeeIn('table tbody tr:nth-child(2) td:last-child', '0,00 CHF/month')
->assertSeeIn('table tbody tr:nth-child(3) td:last-child', '4,90 CHF/month')
@@ -223,7 +220,7 @@
->waitFor('@user-finances #button-award')
->click('@user-finances #button-award')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Add a bonus to the wallet')
->assertFocused('@body input#oneoff_amount')
->assertSeeIn('@body label[for="oneoff_amount"]', 'Amount')
@@ -238,7 +235,7 @@
// Test bonus
$browser->click('@user-finances #button-award')
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
// Test input validation for a bonus
$browser->type('@body #oneoff_amount', 'aaa')
->type('@body #oneoff_description', '')
@@ -264,7 +261,7 @@
->assertMissing('#oneoff-dialog')
->assertSeeIn('@user-finances .card-title span.text-success', '12,34 CHF')
->waitUntilMissing('.app-loader')
- ->with('table', function (Browser $browser) {
+ ->with('table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 3)
->assertMissing('tfoot')
->assertSeeIn('tbody tr:first-child td.description', 'Bonus: Test bonus')
@@ -280,7 +277,7 @@
// Test penalty
$browser->click('@user-finances #button-penalty')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Add a penalty to the wallet')
->assertFocused('@body input#oneoff_amount')
->assertSeeIn('@body label[for="oneoff_amount"]', 'Amount')
@@ -293,7 +290,7 @@
})
->assertMissing('#oneoff-dialog')
->click('@user-finances #button-penalty')
- ->with(new Dialog('#oneoff-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#oneoff-dialog'), static function (Browser $browser) {
// Test input validation for a penalty
$browser->type('@body #oneoff_amount', '')
->type('@body #oneoff_description', '')
diff --git a/src/tests/Browser/Reseller/UserTest.php b/src/tests/Browser/Reseller/UserTest.php
--- a/src/tests/Browser/Reseller/UserTest.php
+++ b/src/tests/Browser/Reseller/UserTest.php
@@ -7,6 +7,7 @@
use App\EventLog;
use App\Sku;
use App\User;
+use App\Utils;
use Tests\Browser;
use Tests\Browser\Components\Dialog;
use Tests\Browser\Components\Toast;
@@ -14,22 +15,18 @@
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\TestCaseDusk;
-use Illuminate\Foundation\Testing\DatabaseMigrations;
class UserTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
$john = $this->getTestUser('john@kolab.org');
$john->setSettings([
- 'phone' => '+48123123123',
- 'external_email' => 'john.doe.external@gmail.com',
+ 'phone' => '+48123123123',
+ 'external_email' => 'john.doe.external@gmail.com',
]);
if ($john->isSuspended()) {
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]);
@@ -42,15 +39,12 @@
$this->deleteTestUser('userstest1@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$john = $this->getTestUser('john@kolab.org');
$john->setSettings([
- 'phone' => null,
- 'external_email' => 'john.doe.external@gmail.com',
+ 'phone' => null,
+ 'external_email' => 'john.doe.external@gmail.com',
]);
if ($john->isSuspended()) {
User::where('email', $john->email)->update(['status' => $john->status - User::STATUS_SUSPENDED]);
@@ -85,20 +79,20 @@
$this->browse(function (Browser $browser) {
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSettings([
- 'limit_geo' => null,
- 'organization' => null,
+ 'limit_geo' => null,
+ 'organization' => null,
]);
$page = new UserPage($jack->id);
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->visit($page)
->on($page);
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $jack->email)
- ->with('@user-info form', function (Browser $browser) use ($jack) {
+ ->with('@user-info form', static function (Browser $browser) use ($jack) {
$browser->assertElementsCount('.row', 7)
->assertSeeIn('.row:nth-child(1) label', 'Managed by')
->assertSeeIn('.row:nth-child(1) #manager a', 'john@kolab.org')
@@ -126,7 +120,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 1)
->assertSeeIn('table tbody tr:first-child td:first-child', 'jack.daniels@kolab.org')
->assertMissing('table tfoot');
@@ -135,7 +129,7 @@
// Assert Subscriptions tab
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 3)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '5,00 CHF/month')
@@ -150,7 +144,7 @@
// Assert Domains tab
$browser->assertSeeIn('@nav #tab-domains', 'Domains (0)')
->click('@nav #tab-domains')
- ->with('@user-domains', function (Browser $browser) {
+ ->with('@user-domains', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no domains in this account.');
});
@@ -158,7 +152,7 @@
// Assert Users tab
$browser->assertSeeIn('@nav #tab-users', 'Users (0)')
->click('@nav #tab-users')
- ->with('@user-users', function (Browser $browser) {
+ ->with('@user-users', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no users in this account.');
});
@@ -166,7 +160,7 @@
// Assert Distribution lists tab
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)')
->click('@nav #tab-distlists')
- ->with('@user-distlists', function (Browser $browser) {
+ ->with('@user-distlists', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.');
});
@@ -174,7 +168,7 @@
// Assert Resources tab
$browser->assertSeeIn('@nav #tab-resources', 'Resources (0)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no resources in this account.');
});
@@ -182,7 +176,7 @@
// Assert Shared folders tab
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (0)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no shared folders in this account.');
});
@@ -190,7 +184,7 @@
// Assert Settings tab
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->whenAvailable('@user-settings form', function (Browser $browser) {
+ ->whenAvailable('@user-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:first-child label', 'Greylisting')
->assertSeeIn('.row:first-child .text-success', 'enabled')
@@ -227,7 +221,7 @@
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $john->email)
- ->with('@user-info form', function (Browser $browser) use ($john) {
+ ->with('@user-info form', static function (Browser $browser) use ($john) {
$ext_email = $john->getSetting('external_email');
$browser->assertElementsCount('.row', 9)
@@ -245,7 +239,7 @@
->assertSeeIn('.row:nth-child(6) #phone', $john->getSetting('phone'))
->assertSeeIn('.row:nth-child(7) label', 'External Email')
->assertSeeIn('.row:nth-child(7) #external_email a', $ext_email)
- ->assertAttribute('.row:nth-child(7) #external_email a', 'href', "mailto:$ext_email")
+ ->assertAttribute('.row:nth-child(7) #external_email a', 'href', "mailto:{$ext_email}")
->assertSeeIn('.row:nth-child(8) label', 'Address')
->assertSeeIn('.row:nth-child(8) #billing_address', $john->getSetting('billing_address'))
->assertSeeIn('.row:nth-child(9) label', 'Country')
@@ -262,7 +256,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (1)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 1)
->assertSeeIn('table tbody tr:first-child td:first-child', 'john.doe@kolab.org')
->assertMissing('table tfoot');
@@ -271,7 +265,7 @@
// Assert Subscriptions tab
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (3)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 3)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
@@ -286,7 +280,7 @@
// Assert Users tab
$browser->assertSeeIn('@nav #tab-users', 'Users (4)')
->click('@nav #tab-users')
- ->with('@user-users table', function (Browser $browser) {
+ ->with('@user-users table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 4)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'jack@kolab.org')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success')
@@ -302,7 +296,7 @@
// Assert Domains tab
$browser->assertSeeIn('@nav #tab-domains', 'Domains (1)')
->click('@nav #tab-domains')
- ->with('@user-domains table', function (Browser $browser) {
+ ->with('@user-domains table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'kolab.org')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-success')
@@ -312,7 +306,7 @@
// Assert Distribution lists tab
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (1)')
->click('@nav #tab-distlists')
- ->with('@user-distlists table', function (Browser $browser) {
+ ->with('@user-distlists table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td:first-child a', 'Test Group')
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-danger')
@@ -323,7 +317,7 @@
// Assert Resources tab
$browser->assertSeeIn('@nav #tab-resources', 'Resources (2)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 2)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'Conference Room #1')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', 'resource-test1@kolab.org')
@@ -335,7 +329,7 @@
// Assert Shared folders tab
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (2)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 2)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'Calendar')
->assertSeeIn('table tbody tr:nth-child(1) td:nth-child(2)', 'Calendar')
@@ -362,7 +356,7 @@
// Assert main info box content
$browser->assertSeeIn('@user-info .card-title', $ned->email)
- ->with('@user-info form', function (Browser $browser) use ($ned) {
+ ->with('@user-info form', static function (Browser $browser) use ($ned) {
$browser->assertSeeIn('.row:nth-child(2) label', 'ID (Created)')
->assertSeeIn('.row:nth-child(2) #userid', "{$ned->id} ({$ned->created_at})");
});
@@ -377,7 +371,7 @@
// Assert Aliases tab
$browser->assertSeeIn('@nav #tab-aliases', 'Aliases (0)')
->click('@nav #tab-aliases')
- ->whenAvailable('@user-aliases', function (Browser $browser) {
+ ->whenAvailable('@user-aliases', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'This user has no email aliases.');
});
@@ -385,7 +379,7 @@
// Assert Subscriptions tab, we expect John's discount here
$browser->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (5)')
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) {
+ ->with('@user-subscriptions', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 5)
->assertSeeIn('table tbody tr:nth-child(1) td:first-child', 'User Mailbox')
->assertSeeIn('table tbody tr:nth-child(1) td:last-child', '4,50 CHF/month¹')
@@ -405,7 +399,7 @@
// We don't expect John's domains here
$browser->assertSeeIn('@nav #tab-domains', 'Domains (0)')
->click('@nav #tab-domains')
- ->with('@user-domains', function (Browser $browser) {
+ ->with('@user-domains', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no domains in this account.');
});
@@ -413,7 +407,7 @@
// We don't expect John's users here
$browser->assertSeeIn('@nav #tab-users', 'Users (0)')
->click('@nav #tab-users')
- ->with('@user-users', function (Browser $browser) {
+ ->with('@user-users', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no users in this account.');
});
@@ -421,7 +415,7 @@
// We don't expect John's distribution lists here
$browser->assertSeeIn('@nav #tab-distlists', 'Distribution lists (0)')
->click('@nav #tab-distlists')
- ->with('@user-distlists', function (Browser $browser) {
+ ->with('@user-distlists', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no distribution lists in this account.');
});
@@ -429,7 +423,7 @@
// Assert Resources tab
$browser->assertSeeIn('@nav #tab-resources', 'Resources (0)')
->click('@nav #tab-resources')
- ->with('@user-resources', function (Browser $browser) {
+ ->with('@user-resources', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no resources in this account.');
});
@@ -437,7 +431,7 @@
// Assert Shared folders tab
$browser->assertSeeIn('@nav #tab-folders', 'Shared folders (0)')
->click('@nav #tab-folders')
- ->with('@user-folders', function (Browser $browser) {
+ ->with('@user-folders', static function (Browser $browser) {
$browser->assertElementsCount('table tbody tr', 0)
->assertSeeIn('table tfoot tr td', 'There are no shared folders in this account.');
});
@@ -445,7 +439,7 @@
// Assert Settings tab
$browser->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->whenAvailable('@user-settings form', function (Browser $browser) {
+ ->whenAvailable('@user-settings form', static function (Browser $browser) {
$browser->assertElementsCount('.row', 3)
->assertSeeIn('.row:nth-child(1) label', 'Greylisting')
->assertSeeIn('.row:nth-child(1) .text-danger', 'disabled')
@@ -474,7 +468,7 @@
->waitFor('@user-info #external_email button')
->click('@user-info #external_email button')
// Test dialog content, and closing it with Cancel button
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'External Email')
->assertFocused('@body input')
->assertValue('@body input', 'john.doe.external@gmail.com')
@@ -485,7 +479,7 @@
->assertMissing('#email-dialog')
->click('@user-info #external_email button')
// Test email validation error handling, and email update
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->type('@body input', 'test')
->click('@button-action')
->waitFor('@body input.is-invalid')
@@ -500,7 +494,7 @@
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.')
->assertSeeIn('@user-info #external_email a', 'test@test.com')
->click('@user-info #external_email button')
- ->with(new Dialog('#email-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#email-dialog'), static function (Browser $browser) {
$browser->assertValue('@body input', 'test@test.com')
->assertMissing('@body input.is-invalid')
->assertMissing('@body input + .invalid-feedback')
@@ -529,7 +523,7 @@
->assertVisible('@user-info #button-suspend')
->assertMissing('@user-info #button-unsuspend')
->click('@user-info #button-suspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Suspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -544,7 +538,7 @@
$this->assertSame('test suspend', $event->comment);
$browser->click('@user-info #button-unsuspend')
- ->with(new Dialog('#suspend-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#suspend-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Unsuspend')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Submit')
@@ -556,7 +550,7 @@
->assertMissing('@user-info #button-unsuspend');
$event = EventLog::where('type', EventLog::TYPE_UNSUSPENDED)->first();
- $this->assertSame(null, $event->comment);
+ $this->assertNull($event->comment);
});
}
@@ -573,13 +567,13 @@
$browser->visit(new UserPage($user->id))
->click('@nav #tab-subscriptions')
- ->with('@user-subscriptions', function (Browser $browser) use ($sku2fa) {
+ ->with('@user-subscriptions', static function (Browser $browser) use ($sku2fa) {
$browser->waitFor('#reset2fa')
->assertVisible('#sku' . $sku2fa->id);
})
->assertSeeIn('@nav #tab-subscriptions', 'Subscriptions (1)')
->click('#reset2fa')
- ->with(new Dialog('#reset-2fa-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#reset-2fa-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', '2-Factor Authentication Reset')
->assertSeeIn('@button-cancel', 'Cancel')
->assertSeeIn('@button-action', 'Reset')
diff --git a/src/tests/Browser/Reseller/WalletTest.php b/src/tests/Browser/Reseller/WalletTest.php
--- a/src/tests/Browser/Reseller/WalletTest.php
+++ b/src/tests/Browser/Reseller/WalletTest.php
@@ -3,7 +3,9 @@
namespace Tests\Browser\Reseller;
use App\Payment;
+use App\Plan;
use App\Transaction;
+use App\Utils;
use App\Wallet;
use Carbon\Carbon;
use Tests\Browser;
@@ -14,19 +16,13 @@
class WalletTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$reseller = $this->getTestUser('reseller@' . \config('app.domain'));
$wallet = $reseller->wallets()->first();
@@ -44,7 +40,7 @@
public function testWalletUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/wallet')->on(new Home());
});
}
@@ -58,9 +54,9 @@
Wallet::where('user_id', $reseller->id)->update(['balance' => 125]);
// Positive balance
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
- ->submitLogon('reseller@' . \config('app.domain'), \App\Utils::generatePassphrase(), true)
+ ->submitLogon('reseller@' . \config('app.domain'), Utils::generatePassphrase(), true)
->on(new Dashboard())
->assertSeeIn('@links .link-wallet svg + span', 'Wallet')
->assertSeeIn('@links .link-wallet .badge.bg-success', '1,25 CHF');
@@ -69,7 +65,7 @@
Wallet::where('user_id', $reseller->id)->update(['balance' => -1234]);
// Negative balance
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Dashboard())
->assertSeeIn('@links .link-wallet svg + span', 'Wallet')
->assertSeeIn('@links .link-wallet .badge.bg-danger', '-12,34 CHF');
@@ -86,7 +82,7 @@
$reseller = $this->getTestUser('reseller@' . \config('app.domain'));
Wallet::where('user_id', $reseller->id)->update(['balance' => -1234]);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->click('@links .link-wallet')
->on(new WalletPage())
->assertSeeIn('#wallet .card-title', 'Account balance -12,34 CHF')
@@ -103,7 +99,7 @@
public function testReceipts(): void
{
$user = $this->getTestUser('reseller@' . \config('app.domain'));
- $plan = \App\Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
+ $plan = Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
$wallet = $user->wallets()->first();
$wallet->payments()->delete();
$user->assignPlan($plan);
@@ -111,13 +107,13 @@
$user->save();
// Assert Receipts tab content when there's no receipts available
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new WalletPage())
->assertSeeIn('#wallet .card-title', 'Account balance 0,00 CHF')
->assertSeeIn('#wallet .card-title .text-success', '0,00 CHF')
->assertSeeIn('#wallet .card-text', 'You are in your free trial period.') // TODO
->assertSeeIn('@nav #tab-receipts', 'Receipts')
- ->with('@receipts-tab', function (Browser $browser) {
+ ->with('@receipts-tab', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('tfoot td', 'There are no receipts for payments');
});
@@ -125,35 +121,35 @@
// Create some sample payments
$receipts = [];
- $date = Carbon::create(intval(date('Y')) - 1, 3, 30);
+ $date = Carbon::create((int) date('Y') - 1, 3, 30);
$payment = Payment::create([
- 'id' => 'AAA1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in March',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'currency_amount' => 1111,
- 'currency' => 'CHF',
+ 'id' => 'AAA1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in March',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'currency_amount' => 1111,
+ 'currency' => 'CHF',
]);
$payment->updated_at = $date;
$payment->save();
$receipts[] = $date->format('Y-m');
- $date = Carbon::create(intval(date('Y')) - 1, 4, 30);
+ $date = Carbon::create((int) date('Y') - 1, 4, 30);
$payment = Payment::create([
- 'id' => 'AAA2',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in April',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'currency_amount' => 1111,
- 'currency' => 'CHF',
+ 'id' => 'AAA2',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in April',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'currency_amount' => 1111,
+ 'currency' => 'CHF',
]);
$payment->updated_at = $date;
$payment->save();
@@ -197,13 +193,13 @@
// Create some sample transactions
$transactions = $this->createTestTransactions($wallet);
$transactions = array_reverse($transactions);
- $pages = array_chunk($transactions, 10 /* page size*/);
+ $pages = array_chunk($transactions, 10 /* page size */);
- $this->browse(function (Browser $browser) use ($pages) {
+ $this->browse(static function (Browser $browser) use ($pages) {
$browser->on(new WalletPage())
->assertSeeIn('@nav #tab-history', 'History')
->click('@nav #tab-history')
- ->with('@history-tab', function (Browser $browser) use ($pages) {
+ ->with('@history-tab', static function (Browser $browser) use ($pages) {
$browser->waitUntilMissing('.app-loader')
->assertElementsCount('table tbody tr', 10)
->assertMissing('table td.email')
@@ -212,9 +208,9 @@
foreach ($pages[0] as $idx => $transaction) {
$selector = 'table tbody tr:nth-child(' . ($idx + 1) . ')';
$priceStyle = $transaction->type == Transaction::WALLET_AWARD ? 'text-success' : 'text-danger';
- $browser->assertSeeIn("$selector td.description", $transaction->shortDescription())
- ->assertMissing("$selector td.selection button")
- ->assertVisible("$selector td.price.{$priceStyle}");
+ $browser->assertSeeIn("{$selector} td.description", $transaction->shortDescription())
+ ->assertMissing("{$selector} td.selection button")
+ ->assertVisible("{$selector} td.price.{$priceStyle}");
// TODO: Test more transaction details
}
@@ -228,12 +224,12 @@
foreach ($pages[1] as $idx => $transaction) {
$selector = 'table tbody tr:nth-child(' . ($idx + 1 + 10) . ')';
$priceStyle = $transaction->type == Transaction::WALLET_CREDIT ? 'text-success' : 'text-danger';
- $browser->assertSeeIn("$selector td.description", $transaction->shortDescription());
+ $browser->assertSeeIn("{$selector} td.description", $transaction->shortDescription());
if ($transaction->type == Transaction::WALLET_DEBIT) {
$debitEntry = $selector;
} else {
- $browser->assertMissing("$selector td.selection button");
+ $browser->assertMissing("{$selector} td.selection button");
}
}
});
diff --git a/src/tests/Browser/ResourceTest.php b/src/tests/Browser/ResourceTest.php
--- a/src/tests/Browser/ResourceTest.php
+++ b/src/tests/Browser/ResourceTest.php
@@ -2,7 +2,9 @@
namespace Tests\Browser;
+use App\Entitlement;
use App\Resource;
+use App\Sku;
use Tests\Browser;
use Tests\Browser\Components\Status;
use Tests\Browser\Components\Toast;
@@ -14,27 +16,21 @@
class ResourceTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->clearBetaEntitlements();
Resource::whereNotIn('email', ['resource-test1@kolab.org', 'resource-test2@kolab.org'])->delete();
// Remove leftover entitlements that might interfere with the tests
- \App\Entitlement::where('entitleable_type', 'App\\Resource')
+ Entitlement::where('entitleable_type', 'App\Resource')
->whereRaw('entitleable_id not in (select id from resources where deleted_at is null)')
->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
- \App\Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 0]);
+ Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 0]);
Resource::whereNotIn('email', ['resource-test1@kolab.org', 'resource-test2@kolab.org'])->delete();
$this->clearBetaEntitlements();
@@ -47,7 +43,7 @@
public function testInfoUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/resource/abc')->on(new Home());
});
}
@@ -58,7 +54,7 @@
public function testListUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/resources')->on(new Home());
});
}
@@ -69,7 +65,7 @@
public function testList(): void
{
// Log on the user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
@@ -77,7 +73,7 @@
});
// Test that Resources lists page is not accessible without the 'beta' entitlement
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/resources')
->assertErrorPage(403);
});
@@ -92,12 +88,12 @@
$resource->save();
// Test resources lists page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Dashboard())
->assertSeeIn('@links .link-resources', 'Resources')
->click('@links .link-resources')
->on(new ResourceList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertSeeIn('thead tr th:nth-child(1)', 'Name')
->assertSeeIn('thead tr th:nth-child(2)', 'Email Address')
@@ -118,7 +114,7 @@
public function testCreateUpdateDelete(): void
{
// Test that the page is not available accessible without the 'beta' entitlement
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/resource/new')
->assertErrorPage(403);
});
@@ -127,7 +123,7 @@
$john = $this->getTestUser('john@kolab.org');
$this->addBetaEntitlement($john);
- \App\Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 3]);
+ Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 3]);
$this->browse(function (Browser $browser) {
// Create a resource
@@ -138,7 +134,7 @@
->assertSeeIn('#resource-info .card-title', 'New resource')
->assertSeeIn('@nav #tab-general', 'General')
->assertMissing('@nav #tab-settings')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertMissing('#status')
->assertFocused('#name')
@@ -148,7 +144,7 @@
->assertSelectHasOptions('div.row:nth-child(2) select', ['kolab.org'])
->assertValue('div.row:nth-child(2) select', 'kolab.org')
->assertSeeIn('div.row:nth-child(3) label', 'Subscriptions')
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Resource')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,00 CHF/month') // one free unit left
@@ -179,7 +175,7 @@
$browser->click('@table tr:nth-child(3) td:first-child a')
->on(new ResourceInfo())
->assertSeeIn('#resource-info .card-title', 'Resource')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertFocused('#name')
->assertSeeIn('div.row:nth-child(1) label', 'Status')
@@ -192,7 +188,7 @@
'value',
'/^resource-[0-9]+@kolab\.org$/'
)
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Resource')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,00 CHF/month')
@@ -236,12 +232,12 @@
});
// Assert Subscription price for the case when there's no free units
- \App\Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 2]);
+ Sku::withEnvTenantContext()->where('title', 'resource')->update(['units_free' => 2]);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/resource/new')
->on(new ResourceInfo())
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Resource')
->assertSeeIn('tbody tr:nth-child(1) td.price', '1,01 CHF/month')
@@ -267,11 +263,11 @@
$this->assertFalse($resource->isImapReady());
- $this->browse(function ($browser) use ($resource) {
+ $this->browse(static function ($browser) use ($resource) {
// Test auto-refresh
$browser->visit('/resource/' . $resource->id)
->on(new ResourceInfo())
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertSeeIn('@body', 'We are preparing the resource')
->assertProgress(\config('app.with_ldap') ? 85 : 80, 'Creating a shared folder...', 'pending')
->assertMissing('@refresh-button')
@@ -300,14 +296,14 @@
$resource = $this->getTestResource('resource-test2@kolab.org');
$resource->setSetting('invitation_policy', null);
- $this->browse(function ($browser) use ($resource) {
+ $this->browse(static function ($browser) use ($resource) {
// Test auto-refresh
$browser->visit('/resource/' . $resource->id)
->on(new ResourceInfo())
->assertSeeIn('@nav #tab-general', 'General')
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('@settings form', function (Browser $browser) {
+ ->with('@settings form', static function (Browser $browser) {
// Assert form content
$browser->assertSeeIn('div.row:nth-child(1) label', 'Invitation policy')
->assertSelectHasOptions('div.row:nth-child(1) select', ['accept', 'manual', 'reject'])
@@ -336,7 +332,7 @@
->refresh()
->on(new ResourceInfo())
->click('@nav #tab-settings')
- ->with('@settings form', function (Browser $browser) {
+ ->with('@settings form', static function (Browser $browser) {
$browser->assertValue('div.row:nth-child(1) select', 'manual')
->assertVisible('div.row:nth-child(1) input')
->assertValue('div.row:nth-child(1) input', 'jack@kolab.org');
diff --git a/src/tests/Browser/SettingsTest.php b/src/tests/Browser/SettingsTest.php
--- a/src/tests/Browser/SettingsTest.php
+++ b/src/tests/Browser/SettingsTest.php
@@ -25,10 +25,7 @@
'organization' => 'Kolab Developers',
];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -36,10 +33,7 @@
$this->deleteTestUser('profile-delete@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
User::where('email', 'john@kolab.org')->first()->setSettings($this->profile);
$this->deleteTestUser('profile-delete@kolabnow.com');
@@ -53,7 +47,7 @@
public function testSettingsUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/settings')->on(new Home());
});
}
@@ -76,7 +70,7 @@
->assertSeeIn('#user-info button.button-delete', 'Delete account')
->assertSeeIn('#user-info .card-title', 'My account')
->assertSeeIn('@nav #tab-general', 'General')
- ->with('@general', function (Browser $browser) use ($user) {
+ ->with('@general', static function (Browser $browser) use ($user) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Status (Customer No.)')
->assertSeeIn('div.row:nth-child(1) #status', 'Active')
->assertSeeIn('div.row:nth-child(1) #userid', "({$user->id})")
@@ -85,7 +79,7 @@
->assertDisabled('div.row:nth-child(2) input[type=text]')
->assertSeeIn('div.row:nth-child(3) label', 'Email Aliases')
->assertVisible('div.row:nth-child(3) .list-input')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue(['john.doe@kolab.org'])
->assertValue('@input', '');
})
@@ -101,7 +95,7 @@
})
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('@settings', function (Browser $browser) {
+ ->with('@settings', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
->click('div.row:nth-child(1) input[type=checkbox]');
})
@@ -140,7 +134,7 @@
$user->setSetting('password_policy', 'min:10,upper,digit');
// Test acting as non-controller
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
->on(new Dashboard())
@@ -150,7 +144,7 @@
->assertMissing('#user-info button.button-delete')
->assertSeeIn('#user-info .card-title', 'My account')
->assertSeeIn('@nav #tab-general', 'General')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Email')
->assertValue('div.row:nth-child(1) input[type=text]', 'jack@kolab.org')
->assertSeeIn('div.row:nth-child(2) label', 'Password')
@@ -161,7 +155,7 @@
->assertMissing('div.row:nth-child(2) .btn-group')
->assertMissing('div.row:nth-child(2) #password-link')
->assertMissing('div.row:nth-child(3)')
- ->whenAvailable('#password_policy', function (Browser $browser) {
+ ->whenAvailable('#password_policy', static function (Browser $browser) {
$browser->assertElementsCount('li', 3)
->assertMissing('li:nth-child(1) svg.text-success')
->assertSeeIn('li:nth-child(1) small', "Minimum password length: 10 characters")
@@ -171,10 +165,9 @@
->assertSeeIn('li:nth-child(3) small', "Password contains a digit");
});
})
- ->assertMissing('@nav #tab-settings')
->assertSeeIn('@nav #tab-personal', 'Personal information')
->click('@nav #tab-personal')
- ->with('@personal', function (Browser $browser) {
+ ->with('@personal', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'First Name')
->assertValue('div.row:nth-child(1) input[type=text]', 'Jack')
->assertSeeIn('div.row:nth-child(2) label', 'Last Name')
@@ -186,21 +179,23 @@
->assertSeeIn('div.row:nth-child(7) label', 'Country')
->click('button[type=submit]');
})
- ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
+ ->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.')
+ // Settings tab is tested in another place
+ ->assertSeeIn('@nav #tab-settings', 'Settings');
});
$user = $this->getTestUser('profile-delete@kolabnow.com', ['password' => 'simple123']);
$oldpassword = $user->password;
// Test password change
- $this->browse(function (Browser $browser) use ($user) {
+ $this->browse(static function (Browser $browser) use ($user) {
$browser->visit(new Home())
->submitLogon($user->email, 'simple123', true)
->on(new Dashboard())
->click('@links .link-settings')
->on(new UserInfo())
->assertSeeIn('@nav #tab-general', 'General')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
$browser
->type('input#password', '12345678')
->type('input#password_confirmation', '12345678')
@@ -229,7 +224,7 @@
->on(new UserInfo())
->assertSeeIn('#user-info button.button-delete', 'Delete account')
->click('#user-info button.button-delete')
- ->with(new Dialog('#delete-warning'), function (Browser $browser) {
+ ->with(new Dialog('#delete-warning'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Delete this account?')
->assertSeeIn('@body', 'This will delete the account as well as all domains')
->assertSeeIn('@body strong', 'This operation is irreversible')
@@ -240,7 +235,7 @@
})
->waitUntilMissing('#delete-warning')
->click('#user-info button.button-delete')
- ->with(new Dialog('#delete-warning'), function (Browser $browser) {
+ ->with(new Dialog('#delete-warning'), static function (Browser $browser) {
$browser->click('@button-action');
})
->waitUntilMissing('#delete-warning')
diff --git a/src/tests/Browser/SharedFolderTest.php b/src/tests/Browser/SharedFolderTest.php
--- a/src/tests/Browser/SharedFolderTest.php
+++ b/src/tests/Browser/SharedFolderTest.php
@@ -16,20 +16,14 @@
class SharedFolderTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
SharedFolder::whereNotIn('email', ['folder-event@kolab.org', 'folder-contact@kolab.org'])->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
SharedFolder::whereNotIn('email', ['folder-event@kolab.org', 'folder-contact@kolab.org'])->delete();
@@ -42,7 +36,7 @@
public function testInfoUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/shared-folder/abc')->on(new Home());
});
}
@@ -53,7 +47,7 @@
public function testListUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/shared-folders')->on(new Home());
});
}
@@ -70,14 +64,14 @@
$folder->save();
// Log on the user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
->assertSeeIn('@links .link-shared-folders', 'Shared folders')
->click('@links .link-shared-folders')
->on(new SharedFolderList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertElementsCount('thead th', 2)
->assertSeeIn('thead tr th:nth-child(1)', 'Name')
@@ -109,7 +103,7 @@
->assertSeeIn('#folder-info .card-title', 'New shared folder')
->assertSeeIn('@nav #tab-general', 'General')
->assertMissing('@nav #tab-settings')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertMissing('#status')
->assertFocused('#name')
@@ -125,12 +119,12 @@
->assertSelectHasOptions('div.row:nth-child(3) select', ['kolab.org'])
->assertValue('div.row:nth-child(3) select', 'kolab.org')
->assertSeeIn('div.row:nth-child(4) label', 'Email Addresses')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue([])
->assertValue('@input', '');
})
->assertSeeIn('div.row:nth-child(5) label', 'Subscriptions')
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Shared Folder')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,89 CHF/month')
@@ -155,13 +149,13 @@
// Test error handling on aliases input
->type('#name', 'Test Folder')
->select('#type', 'mail')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->addListEntry('folder-alias@unknown');
})
->click('@general button[type=submit]')
->assertMissing('#name + .invalid-feedback')
->waitFor('#aliases + .invalid-feedback')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertFormError(1, "The specified domain is invalid.", true);
})
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
@@ -179,7 +173,7 @@
$browser->click('@table tr:nth-child(3) td:first-child a')
->on(new SharedFolderInfo())
->assertSeeIn('#folder-info .card-title', 'Shared folder')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertFocused('#name')
->assertSeeIn('div.row:nth-child(1) label', 'Status')
@@ -227,7 +221,7 @@
->click('button.shared-folder-new')
->on(new SharedFolderInfo())
->type('#name', 'Test Folder2')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->addListEntry('folder-alias1@kolab.org')
->addListEntry('folder-alias2@kolab.org');
})
@@ -246,16 +240,16 @@
// Test folder update
$browser->click('@table tr:nth-child(3) td:first-child a')
->on(new SharedFolderInfo())
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertFocused('#name')
->assertValue('div.row:nth-child(2) input[type=text]', 'Test Folder2')
->assertSelected('div.row:nth-child(3) select:disabled', 'mail')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue(['folder-alias1@kolab.org', 'folder-alias2@kolab.org'])
->assertValue('@input', '');
})
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 1)
->assertSeeIn('tbody tr:nth-child(1) td.name', 'Shared Folder')
->assertSeeIn('tbody tr:nth-child(1) td.price', '0,89 CHF/month')
@@ -269,7 +263,7 @@
})
// change folder name, and remove one alias
->type('#name', 'Test Folder Update2')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->removeListEntry(2);
})
->click('@general button[type=submit]')
@@ -295,11 +289,11 @@
$this->assertFalse($folder->isImapReady());
- $this->browse(function ($browser) use ($folder) {
+ $this->browse(static function ($browser) use ($folder) {
// Test auto-refresh
$browser->visit('/shared-folder/' . $folder->id)
->on(new SharedFolderInfo())
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertSeeIn('@body', 'We are preparing the shared folder')
->assertProgress(\config('app.with_ldap') ? 85 : 80, 'Creating a shared folder...', 'pending')
->assertMissing('@refresh-button')
@@ -326,7 +320,7 @@
$folder = $this->getTestSharedFolder('folder-event@kolab.org');
$folder->setSetting('acl', null);
- $this->browse(function ($browser) use ($folder) {
+ $this->browse(static function ($browser) use ($folder) {
$aclInput = new AclInput('@settings #acl');
// Test auto-refresh
$browser->visit('/shared-folder/' . $folder->id)
@@ -334,41 +328,41 @@
->assertSeeIn('@nav #tab-general', 'General')
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
- ->with('@settings form', function (Browser $browser) {
+ ->with('@settings form', static function (Browser $browser) {
// Assert form content
$browser->assertSeeIn('div.row:nth-child(1) label', 'Access rights')
->assertSeeIn('div.row:nth-child(1) #acl-hint', 'permissions')
->assertSeeIn('button[type=submit]', 'Submit');
})
// Test the AclInput widget
- ->with($aclInput, function (Browser $browser) {
+ ->with($aclInput, static function (Browser $browser) {
$browser->assertAclValue([])
->addAclEntry('anyone, read-only')
->addAclEntry('test, read-write')
->addAclEntry('john@kolab.org, full')
->assertAclValue([
- 'anyone, read-only',
- 'test, read-write',
- 'john@kolab.org, full',
+ 'anyone, read-only',
+ 'test, read-write',
+ 'john@kolab.org, full',
]);
})
// Test error handling
->click('@settings button[type=submit]')
- ->with($aclInput, function (Browser $browser) {
+ ->with($aclInput, static function (Browser $browser) {
$browser->assertFormError(2, 'The specified email address is invalid.');
})
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
// Test successful update
- ->with($aclInput, function (Browser $browser) {
+ ->with($aclInput, static function (Browser $browser) {
$browser->removeAclEntry(2)
->assertAclValue([
- 'anyone, read-only',
- 'john@kolab.org, full',
+ 'anyone, read-only',
+ 'john@kolab.org, full',
])
->updateAclEntry(2, 'jack@kolab.org, read-write')
->assertAclValue([
- 'anyone, read-only',
- 'jack@kolab.org, read-write',
+ 'anyone, read-only',
+ 'jack@kolab.org, read-write',
]);
})
->click('@settings button[type=submit]')
@@ -378,10 +372,10 @@
->refresh()
->on(new SharedFolderInfo())
->click('@nav #tab-settings')
- ->with($aclInput, function (Browser $browser) {
+ ->with($aclInput, static function (Browser $browser) {
$browser->assertAclValue([
- 'anyone, read-only',
- 'jack@kolab.org, read-write',
+ 'anyone, read-only',
+ 'jack@kolab.org, read-write',
]);
});
});
diff --git a/src/tests/Browser/SignupTest.php b/src/tests/Browser/SignupTest.php
--- a/src/tests/Browser/SignupTest.php
+++ b/src/tests/Browser/SignupTest.php
@@ -4,6 +4,7 @@
use App\Discount;
use App\Domain;
+use App\Payment;
use App\Plan;
use App\ReferralProgram;
use App\SignupCode;
@@ -14,7 +15,6 @@
use Tests\Browser\Components\Menu;
use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
-use Tests\Browser\Pages\Home;
use Tests\Browser\Pages\PaymentMollie;
use Tests\Browser\Pages\PaymentStatus;
use Tests\Browser\Pages\Signup;
@@ -22,10 +22,7 @@
class SignupTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -39,10 +36,7 @@
ReferralProgram::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('signuptestdusk@' . \config('app.domain'));
$this->deleteTestUser('admin@user-domain-signup.com');
@@ -63,7 +57,7 @@
public function testSignupCodeByLink(): void
{
// Test invalid code (invalid format)
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
// Register Signup page element selectors we'll be using
$browser->onWithoutAssert(new Signup());
@@ -80,7 +74,7 @@
});
// Test invalid code (valid format)
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/signup/XXXXX-code');
// FIXME: User will not be able to continue anyway, so we should
@@ -92,11 +86,11 @@
// Test valid code
$this->browse(function (Browser $browser) {
$code = SignupCode::create([
- 'email' => 'User@example.org',
- 'first_name' => 'User',
- 'last_name' => 'Name',
- 'plan' => 'individual',
- 'voucher' => '',
+ 'email' => 'User@example.org',
+ 'first_name' => 'User',
+ 'last_name' => 'Name',
+ 'plan' => 'individual',
+ 'voucher' => '',
]);
$browser->visit('/signup/' . $code->short_code . '-' . $code->code)
@@ -116,7 +110,7 @@
*/
public function testSignupStep0(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup());
$browser->assertVisible('@step0')
@@ -124,14 +118,14 @@
->assertMissing('@step2')
->assertMissing('@step3');
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login', 'lang'], 'signup');
});
$browser->waitFor('@step0 .plan-selector .card');
// Assert first plan box and press the button
- $browser->with('@step0 .plan-selector .plan-individual', function ($step) {
+ $browser->with('@step0 .plan-selector .plan-individual', static function ($step) {
$step->assertVisible('button')
->assertSeeIn('button', 'Individual Account')
->assertVisible('.plan-description')
@@ -149,10 +143,10 @@
// Click Back button
$browser->click('@step1 [type=button]')
->waitForLocation('/signup')
- ->assertVisible('@step0')
- ->assertMissing('@step1')
- ->assertMissing('@step2')
- ->assertMissing('@step3');
+ ->assertVisible('@step0')
+ ->assertMissing('@step1')
+ ->assertMissing('@step2')
+ ->assertMissing('@step3');
// Choose the group account plan
$browser->click('@step0 .plan-selector .plan-group button')
@@ -172,12 +166,12 @@
*/
public function testSignupStep1(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/signup/individual')
->onWithoutAssert(new Signup());
// Here we expect two text inputs and Back and Continue buttons
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->waitFor('#signup_last_name')
->assertSeeIn('.card-title', 'Sign Up - Step 1/3')
->assertVisible('#signup_first_name')
@@ -190,18 +184,18 @@
// Submit empty form
// Email is required, so after pressing Submit
// we expect focus to be moved to the email input
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->click('[type=submit]');
$step->assertFocused('#signup_email');
});
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->assertMenuItems(['support', 'signup', 'login', 'lang'], 'signup');
});
// Submit invalid email, and first_name
// We expect both inputs to have is-invalid class added, with .invalid-feedback element
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#signup_first_name', str_repeat('a', 250))
->type('#signup_email', '@test')
->click('[type=submit]')
@@ -214,7 +208,7 @@
// Submit valid data
// We expect error state on email input to be removed, and Step 2 form visible
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
@@ -244,7 +238,7 @@
->assertMissing('@step3');
// Here we expect one text input, Back and Continue buttons
- $browser->with('@step2', function ($step) {
+ $browser->with('@step2', static function ($step) {
$step->assertVisible('#signup_short_code')
->assertFocused('#signup_short_code')
->assertVisible('[type=button]')
@@ -258,7 +252,7 @@
->assertMissing('@step2');
// Submit valid Step 1 data (again)
- $browser->with('@step1', function ($step) {
+ $browser->with('@step1', static function ($step) {
$step->type('#signup_first_name', 'User')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
@@ -270,7 +264,7 @@
// Submit invalid code
// We expect code input to have is-invalid class added, with .invalid-feedback element
- $browser->with('@step2', function ($step) {
+ $browser->with('@step2', static function ($step) {
$step->type('#signup_short_code', 'XXXXX');
$step->click('[type=submit]');
@@ -314,7 +308,7 @@
$browser->assertVisible('@step3');
// Here we expect 3 text inputs, Back and Continue buttons
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$domains = Domain::getPublicDomains();
$domains_count = count($domains);
@@ -340,7 +334,7 @@
->assertValue('#signup_login', '')
->assertValue('#signup_password', '')
->assertValue('#signup_password_confirmation', '')
- ->with('#signup_password_policy', function (Browser $browser) {
+ ->with('#signup_password_policy', static function (Browser $browser) {
$browser->assertElementsCount('li', 2)
->assertMissing('li:first-child svg.text-success')
->assertSeeIn('li:first-child small', "Minimum password length: 6 characters")
@@ -374,12 +368,12 @@
$browser->waitFor('@step3');
// Submit invalid data
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->assertFocused('#signup_login')
->type('#signup_login', '*')
->type('#signup_password', '12345678')
->type('#signup_password_confirmation', '123456789')
- ->with('#signup_password_policy', function (Browser $browser) {
+ ->with('#signup_password_policy', static function (Browser $browser) {
$browser->waitFor('li:first-child svg.text-success')
->waitFor('li:last-child svg.text-success');
})
@@ -393,7 +387,7 @@
});
// Submit invalid data (valid login, invalid password)
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#signup_login', 'SignupTestDusk')
->click('[type=submit]')
->waitFor('#signup_password.is-invalid')
@@ -405,7 +399,7 @@
});
// Submit valid data
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#signup_password_confirmation', '12345678');
$step->click('[type=submit]');
@@ -422,7 +416,7 @@
->assertVisible('@links a.link-wallet');
// Logout the user
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -433,7 +427,7 @@
*/
public function testSignupGroup(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup());
// Choose the group account plan
@@ -442,7 +436,7 @@
// Submit valid data
// We expect error state on email input to be removed, and Step 2 form visible
- $browser->whenAvailable('@step1', function ($step) {
+ $browser->whenAvailable('@step1', static function ($step) {
$step->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
@@ -450,7 +444,7 @@
});
// Submit valid code
- $browser->whenAvailable('@step2', function ($step) {
+ $browser->whenAvailable('@step2', static function ($step) {
// Get the code and short_code from database
// FIXME: Find a nice way to read javascript data without using hidden inputs
$code = $step->value('#signup_code');
@@ -461,7 +455,7 @@
});
// Here we expect text inputs, as well as domain selector, and buttons
- $browser->whenAvailable('@step3', function ($step) {
+ $browser->whenAvailable('@step3', static function ($step) {
$domains = Domain::getPublicDomains();
$domains_count = count($domains);
@@ -489,7 +483,7 @@
});
// Submit invalid login and password data
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#signup_login', '*')
->type('#signup_domain', 'test.com')
->type('#signup_password', '12345678')
@@ -504,7 +498,7 @@
});
// Submit invalid domain
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#signup_login', 'admin')
->type('#signup_domain', 'aaa')
->type('#signup_password', '12345678')
@@ -519,7 +513,7 @@
});
// Submit invalid domain
- $browser->with('@step3', function ($step) {
+ $browser->with('@step3', static function ($step) {
$step->type('#signup_domain', 'user-domain-signup.com')
->click('[type=submit]');
});
@@ -534,7 +528,7 @@
->assertVisible('@links a.link-users')
->assertVisible('@links a.link-wallet');
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -550,11 +544,11 @@
$plan->hidden = true;
$plan->save();
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup());
// Submit valid data
- $browser->whenAvailable('@step1', function ($step) {
+ $browser->whenAvailable('@step1', static function ($step) {
$step->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
@@ -562,7 +556,7 @@
});
// Submit valid code
- $browser->whenAvailable('@step2', function ($step) {
+ $browser->whenAvailable('@step2', static function ($step) {
// Get the code and short_code from database
$code = $step->value('#signup_code');
$code = SignupCode::find($code);
@@ -572,7 +566,7 @@
});
// Here we expect text inputs, as well as domain selector, and buttons
- $browser->whenAvailable('@step3', function ($step) {
+ $browser->whenAvailable('@step3', static function ($step) {
$step->assertVisible('#signup_login')
->assertVisible('#signup_password')
->assertVisible('#signup_password_confirmation')
@@ -599,7 +593,7 @@
->assertMissing('@links a.link-shared-folders')
->assertMissing('@links a.link-resources');
- $browser->within(new Menu(), function ($browser) {
+ $browser->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -621,20 +615,20 @@
$plan->mode = Plan::MODE_MANDATE;
$plan->save();
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->withConfig(['services.payment_provider' => 'mollie'])
->visit(new Signup())
->waitFor('@step0 .plan-individual button')
->click('@step0 .plan-individual button')
// Test Back button
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$browser->click('button[type=button]');
})
- ->whenAvailable('@step0', function ($browser) {
+ ->whenAvailable('@step0', static function ($browser) {
$browser->click('.plan-individual button');
})
// Test submit
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$domains = Domain::getPublicDomains();
$domains_count = count($domains);
@@ -648,7 +642,7 @@
->type('#signup_password_confirmation', '12345678')
->click('[type=submit]');
})
- ->whenAvailable('@step4', function ($browser) {
+ ->whenAvailable('@step4', static function ($browser) {
$browser->assertSeeIn('h4', 'The account is about to be created!')
->assertSeeIn('h5', 'You are choosing a monthly subscription')
->assertVisible('#summary-content')
@@ -658,11 +652,11 @@
->assertSeeIn('button.btn-secondary', 'Back')
->click('button.btn-secondary');
})
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$browser->assertValue('#signup_login', 'signuptestdusk')
->click('[type=submit]');
})
- ->whenAvailable('@step4', function ($browser) {
+ ->whenAvailable('@step4', static function ($browser) {
$browser->click('button.btn-primary');
})
->on(new PaymentMollie())
@@ -690,12 +684,12 @@
// TODO: Move this to a separate tests file for PaymentStatus page
$payment = $user->wallets()->first()->payments()->first();
$payment->credit('Test');
- $payment->status = \App\Payment::STATUS_PAID;
+ $payment->status = Payment::STATUS_PAID;
$payment->save();
$this->assertTrue($user->fresh()->isActive());
$browser->waitForLocation('/dashboard', 10)
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -713,18 +707,18 @@
$plan->mode = Plan::MODE_MANDATE;
$plan->save();
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup())
->waitFor('@step0 .plan-individual button')
->click('@step0 .plan-individual button')
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$browser->type('#signup_login', 'signuptestdusk')
->type('#signup_password', '12345678')
->type('#signup_password_confirmation', '12345678')
->type('#signup_voucher', 'FREE')
->click('[type=submit]');
})
- ->whenAvailable('@step4', function ($browser) {
+ ->whenAvailable('@step4', static function ($browser) {
$browser->assertSeeIn('h4', 'The account is about to be created!')
->assertSeeIn('#summary-content', 'You are signing up for an account with 100% discount.')
->assertMissing('#summary-summary')
@@ -734,7 +728,7 @@
})
->waitUntilMissing('@step4')
->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -760,12 +754,12 @@
// Register a valid token
$plan->signupTokens()->create(['id' => '1234567890']);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup())
->waitFor('@step0 .plan-individual button')
->click('@step0 .plan-individual button')
// Step 1
- ->whenAvailable('@step1', function ($browser) {
+ ->whenAvailable('@step1', static function ($browser) {
$browser->assertSeeIn('.card-title', 'Sign Up - Step 1/2')
->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
@@ -782,7 +776,7 @@
->click('[type=submit]');
})
// Step 2
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$domains = Domain::getPublicDomains();
$domains_count = count($domains);
@@ -797,13 +791,13 @@
})
->waitUntilMissing('@step3')
->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
$user = User::where('email', 'signuptestdusk@' . \config('app.domain'))->first();
- $this->assertSame(null, $user->getSetting('external_email'));
+ $this->assertNull($user->getSetting('external_email'));
// Test the group plan
$plan = Plan::withEnvTenantContext()->where('title', 'group')->first();
@@ -812,12 +806,12 @@
// Register a valid token
$plan->signupTokens()->create(['id' => 'abcdefghijk']);
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Signup())
->waitFor('@step0 .plan-group button')
->click('@step0 .plan-group button')
// Step 1
- ->whenAvailable('@step1', function ($browser) {
+ ->whenAvailable('@step1', static function ($browser) {
$browser->assertSeeIn('.card-title', 'Sign Up - Step 1/2')
->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
@@ -834,7 +828,7 @@
->click('[type=submit]');
})
// Step 2
- ->whenAvailable('@step3', function ($browser) {
+ ->whenAvailable('@step3', static function ($browser) {
$browser->assertSeeIn('.card-title', 'Sign Up - Step 2/2')
->click('#custom_domain')
->type('input#signup_domain', 'user-domain-signup.com')
@@ -845,13 +839,13 @@
})
->waitUntilMissing('@step3')
->on(new Dashboard())
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
$user = User::where('email', 'admin@user-domain-signup.com')->first();
- $this->assertSame(null, $user->getSetting('external_email'));
+ $this->assertNull($user->getSetting('external_email'));
}
/**
@@ -865,7 +859,7 @@
->waitUntilMissing('.app-loader')
->waitFor('@step0')
->click('.plan-individual button')
- ->whenAvailable('@step1', function (Browser $browser) {
+ ->whenAvailable('@step1', static function (Browser $browser) {
$browser->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
@@ -883,7 +877,7 @@
$browser->type('#signup_short_code', $code->short_code)
->click('[type=submit]');
})
- ->whenAvailable('@step3', function (Browser $browser) {
+ ->whenAvailable('@step3', static function (Browser $browser) {
// Assert that the code is filled in the input
// Change it and test error handling
$browser->assertValue('#signup_voucher', 'TEST')
@@ -905,7 +899,7 @@
->on(new Dashboard())
->assertUser('signuptestdusk@' . \config('app.domain'))
// Logout the user
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -928,24 +922,24 @@
]);
$referral_code = $program->codes()->create(['user_id' => $referrer->id]);
- $this->browse(function (Browser $browser) use ($referral_code) {
+ $this->browse(static function (Browser $browser) use ($referral_code) {
$browser->visit('/signup/referral/' . $referral_code->code)
->onWithoutAssert(new Signup())
->waitUntilMissing('.app-loader')
->waitFor('@step0')
->click('.plan-individual button')
- ->whenAvailable('@step1', function (Browser $browser) {
+ ->whenAvailable('@step1', static function (Browser $browser) {
$browser->type('#signup_first_name', 'Test')
->type('#signup_last_name', 'User')
->type('#signup_email', 'BrowserSignupTestUser1@kolab.org')
->click('[type=submit]');
})
- ->whenAvailable('@step2', function (Browser $browser) {
+ ->whenAvailable('@step2', static function (Browser $browser) {
$code = SignupCode::orderBy('created_at', 'desc')->first();
$browser->type('#signup_short_code', $code->short_code)
->click('[type=submit]');
})
- ->whenAvailable('@step3', function (Browser $browser) {
+ ->whenAvailable('@step3', static function (Browser $browser) {
$browser->type('#signup_login', 'signuptestdusk')
->type('#signup_password', '123456789')
->type('#signup_password_confirmation', '123456789')
@@ -956,7 +950,7 @@
->on(new Dashboard())
->assertUser('signuptestdusk@' . \config('app.domain'))
// Logout the user
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
@@ -971,7 +965,7 @@
public function testSignupInvitation(): void
{
// Test non-existing invitation
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/signup/invite/TEST')
->onWithoutAssert(new Signup())
->waitFor('#app > #error-page')
@@ -980,13 +974,13 @@
$invitation = SignupInvitation::create(['email' => 'test@domain.org']);
- $this->browse(function (Browser $browser) use ($invitation) {
+ $this->browse(static function (Browser $browser) use ($invitation) {
$browser->visit('/signup/invite/' . $invitation->id)
->onWithoutAssert(new Signup())
->waitUntilMissing('.app-loader')
->waitFor('@step0')
->click('.plan-individual button')
- ->with('@step3', function ($step) {
+ ->with('@step3', static function ($step) {
$domains_count = count(Domain::getPublicDomains());
$step->assertMissing('.card-title')
@@ -1033,7 +1027,7 @@
->on(new Dashboard())
->assertUser('signuptestdusk@' . \config('app.domain'))
// Logout the user
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('logout');
});
});
diff --git a/src/tests/Browser/StatusTest.php b/src/tests/Browser/StatusTest.php
--- a/src/tests/Browser/StatusTest.php
+++ b/src/tests/Browser/StatusTest.php
@@ -5,6 +5,7 @@
use App\Domain;
use App\User;
use Carbon\Carbon;
+use Illuminate\Support\Facades\DB;
use Tests\Browser;
use Tests\Browser\Components\Status;
use Tests\Browser\Components\Toast;
@@ -15,14 +16,10 @@
use Tests\Browser\Pages\UserInfo;
use Tests\Browser\Pages\UserList;
use Tests\TestCaseDusk;
-use Illuminate\Support\Facades\DB;
class StatusTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -33,10 +30,7 @@
. " WHERE email = 'john@kolab.org'");
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$domain_status = Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED;
DB::statement("UPDATE domains SET status = (status | {$domain_status})"
@@ -70,11 +64,11 @@
$john->save();
- $this->browse(function ($browser) use ($john, $domain) {
+ $this->browse(static function ($browser) use ($john, $domain) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
- ->with(new Status(), function ($browser) use ($john) {
+ ->with(new Status(), static function ($browser) use ($john) {
$browser->assertSeeIn('@body', 'We are preparing your account')
->assertProgress(\config('app.with_ldap') ? 71 : 60, 'Creating a mailbox...', 'pending')
->assertMissing('#status-confirm')
@@ -103,7 +97,7 @@
->on(new DomainInfo())
->back()
->on(new Dashboard())
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertMissing('@refresh-button')
->assertProgress(
\config('app.with_ldap') ? 85 : 80,
@@ -134,9 +128,9 @@
$john->save();
- $this->browse(function ($browser) use ($john, $domain) {
+ $this->browse(static function ($browser) use ($john, $domain) {
$browser->visit(new Dashboard())
- ->with(new Status(), function ($browser) use ($john, $domain) {
+ ->with(new Status(), static function ($browser) use ($john, $domain) {
$browser->assertSeeIn('@body', 'We are preparing your account')
->assertProgress(\config('app.with_ldap') ? 71 : 60, 'Creating a mailbox...', 'failed')
->assertVisible('@refresh-button')
@@ -178,7 +172,7 @@
$this->assertFalse($domain->isSuspended());
$this->assertFalse($domain->isDeleted());
- $this->browse(function ($browser) use ($domain) {
+ $this->browse(static function ($browser) use ($domain) {
// Test auto-refresh
$browser->on(new Dashboard())
->click('@links a.link-domains')
@@ -189,7 +183,7 @@
->assertText('@table tbody tr:first-child td:first-child svg title', 'Not Ready')
->click('@table tbody tr:first-child td:first-child a')
->on(new DomainInfo())
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertSeeIn('@body', 'We are preparing the domain')
->assertProgress(\config('app.with_ldap') ? 50 : 33, 'Verifying a custom domain...', 'pending')
->assertMissing('@refresh-button')
@@ -203,7 +197,7 @@
// This should take less than 10 seconds
$browser->waitFor('@status.process-failed')
- ->with(new Status(), function ($browser) {
+ ->with(new Status(), static function ($browser) {
$browser->assertSeeIn('@body', 'The domain is almost ready')
->assertProgress(
\config('app.with_ldap') ? 75 : 66,
@@ -248,7 +242,7 @@
$domain->save();
}
- $this->browse(function ($browser) use ($john, $domain) {
+ $this->browse(static function ($browser) use ($john, $domain) {
$browser->visit(new Dashboard())
->click('@links a.link-users')
->on(new UserList())
@@ -260,12 +254,12 @@
->assertText('@table tbody tr:nth-child(3) td:first-child svg title', 'Not Ready')
->click('@table tbody tr:nth-child(3) td:first-child a')
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert state in the user edit form
$browser->assertSeeIn('div.row:nth-child(1) label', 'Status')
->assertSeeIn('div.row:nth-child(1) #status', 'Not Ready');
})
- ->with(new Status(), function ($browser) use ($john) {
+ ->with(new Status(), static function ($browser) use ($john) {
$browser->assertSeeIn('@body', 'We are preparing the user account')
->assertProgress(\config('app.with_ldap') ? 71 : 60, 'Creating a mailbox...', 'pending')
->assertMissing('#status-confirm')
@@ -273,7 +267,6 @@
->assertMissing('@refresh-button')
->assertMissing('@refresh-text');
-
$john->status |= User::STATUS_IMAP_READY;
$john->save();
diff --git a/src/tests/Browser/SupportTest.php b/src/tests/Browser/SupportTest.php
--- a/src/tests/Browser/SupportTest.php
+++ b/src/tests/Browser/SupportTest.php
@@ -15,20 +15,20 @@
*/
public function testSupportForm(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->withConfig(['app.support_email' => ""])
->visit('/')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('support');
})
->waitFor('#support')
->assertElementsCount('.card-title', 2)
- ->with('.row .col:last-child', function ($card) {
+ ->with('.row .col:last-child', static function ($card) {
$card->assertSeeIn('.card-title', 'Contact Support')
- ->assertSeeIn('.btn-primary', 'Contact Support')
- ->click('.btn-primary');
+ ->assertSeeIn('.btn-primary', 'Contact Support')
+ ->click('.btn-primary');
})
- ->with(new Dialog('#support-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#support-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Contact Support')
->assertFocused('#support-user')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -43,10 +43,10 @@
->click('@button-cancel');
})
->assertMissing('#support-dialog')
- ->with('.row .col:last-child', function ($card) {
+ ->with('.row .col:last-child', static function ($card) {
$card->click('.btn-primary');
})
- ->with(new Dialog('#support-dialog'), function (Browser $browser) {
+ ->with(new Dialog('#support-dialog'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Contact Support')
->assertFocused('#support-user')
->assertValue('#support-email', 'email@address.com')
@@ -64,10 +64,10 @@
*/
public function testNoSupportForm(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->withConfig(['app.support_email' => null])
->visit('/')
- ->within(new Menu(), function ($browser) {
+ ->within(new Menu(), static function ($browser) {
$browser->clickMenuItem('support');
})
->waitFor('#support')
diff --git a/src/tests/Browser/UserListTest.php b/src/tests/Browser/UserListTest.php
--- a/src/tests/Browser/UserListTest.php
+++ b/src/tests/Browser/UserListTest.php
@@ -2,9 +2,7 @@
namespace Tests\Browser;
-use App\User;
use Tests\Browser;
-use Tests\Browser\Components\Toast;
use Tests\Browser\Pages\Dashboard;
use Tests\Browser\Pages\Home;
use Tests\Browser\Pages\UserInfo;
@@ -13,18 +11,12 @@
class UserListTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -35,7 +27,7 @@
public function testListUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/users')->on(new Home());
});
}
@@ -45,7 +37,7 @@
*/
public function testList(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
// Test that the page requires authentication
// Test the list
$browser->visit(new Home())
@@ -54,7 +46,7 @@
->assertSeeIn('@links .link-users', 'User accounts')
->click('@links .link-users')
->on(new UserList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertElementsCount('tbody tr', 4)
->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org')
@@ -71,7 +63,7 @@
->type('@search input', 'jo')
->click('@search button')
->waitUntilMissing('@app .app-loader')
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')
->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1) a', 'joe@kolab.org')
@@ -82,7 +74,7 @@
->type('@search input', 'jojo')
->click('@search button')
->waitUntilMissing('@app .app-loader')
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tfoot tr')
->assertSeeIn('tfoot tr', "There are no users in this account.");
})
@@ -90,7 +82,7 @@
->vueClear('@search input')
->keys('@search input', '{enter}')
->waitUntilMissing('@app .app-loader')
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->waitFor('tbody tr')->assertElementsCount('tbody tr', 4);
});
@@ -99,7 +91,7 @@
$browser->click('@table tr:nth-child(3)')
->on(new UserInfo())
->assertSeeIn('#user-info .card-title', 'User account')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
$browser->assertValue('#email', 'john@kolab.org');
});
});
diff --git a/src/tests/Browser/UsersTest.php b/src/tests/Browser/UsersTest.php
--- a/src/tests/Browser/UsersTest.php
+++ b/src/tests/Browser/UsersTest.php
@@ -5,9 +5,11 @@
use App\Delegation;
use App\Discount;
use App\Entitlement;
+use App\Package;
use App\Sku;
use App\User;
use App\UserAlias;
+use App\VerificationCode;
use Tests\Browser;
use Tests\Browser\Components\CountrySelect;
use Tests\Browser\Components\Dialog;
@@ -35,10 +37,7 @@
'phone' => '+1 509-248-1111',
];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -64,17 +63,14 @@
$this->clearBetaEntitlements();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('julia.roberts@kolab.org');
$john = User::where('email', 'john@kolab.org')->first();
$john->setSettings($this->profile);
$john->aliases()->where('alias', 'john.test@kolab.org')->delete();
- $john->delegators()->each(function ($user) {
+ $john->delegators()->each(static function ($user) {
$user->delegation->delete();
});
@@ -114,7 +110,7 @@
->on(new UserInfo())
->assertSeeIn('#user-info .card-title', 'User account')
->assertSeeIn('@nav #tab-general', 'General')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert the General tab content
$browser->assertSeeIn('div.row:nth-child(1) label', 'Status')
->assertSeeIn('div.row:nth-child(1) #status', 'Active')
@@ -123,7 +119,7 @@
->assertDisabled('div.row:nth-child(2) input[type=text]')
->assertSeeIn('div.row:nth-child(3) label', 'Email Aliases')
->assertVisible('div.row:nth-child(3) .list-input')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue(['john.doe@kolab.org'])
->assertValue('@input', '');
})
@@ -138,7 +134,7 @@
// Test error handling (password)
$browser->type('#password', 'aaaaaA')
->vueClear('#password_confirmation')
- ->whenAvailable('#password_policy', function (Browser $browser) {
+ ->whenAvailable('#password_policy', static function (Browser $browser) {
$browser->assertElementsCount('li', 3)
->assertMissing('li:nth-child(1) svg.text-success')
->assertSeeIn('li:nth-child(1) small', "Minimum password length: 10 characters")
@@ -161,13 +157,13 @@
// Test form error handling (aliases)
$browser->vueClear('#password')
->vueClear('#password_confirmation')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->addListEntry('invalid address');
})
->scrollTo('button[type=submit]')->pause(500)
->click('button[type=submit]')
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertFormError(2, 'The specified alias is invalid.', false)
// Test adding aliases
->removeListEntry(2)
@@ -184,10 +180,10 @@
$this->assertTrue(!empty($alias));
// Test subscriptions
- $browser->with('@general', function (Browser $browser) {
+ $browser->with('@general', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(5) label', 'Subscriptions')
->assertVisible('@skus.row:nth-child(5)')
- ->with('@skus', function ($browser) {
+ ->with('@skus', static function ($browser) {
$browser->assertElementsCount('tbody tr', 5)
// Mailbox SKU
->assertSeeIn('tbody tr:nth-child(1) td.name', 'User Mailbox')
@@ -207,7 +203,7 @@
'tbody tr:nth-child(2) td.buttons button',
'Some wiggle room'
)
- ->with(new QuotaInput('tbody tr:nth-child(2) .range-input'), function ($browser) {
+ ->with(new QuotaInput('tbody tr:nth-child(2) .range-input'), static function ($browser) {
$browser->assertQuotaValue(5)->setQuotaValue(6);
})
->assertSeeIn('tr:nth-child(2) td.price', '0,25 CHF/month')
@@ -253,8 +249,8 @@
$this->assertEntitlements($john->fresh(), $expected);
// Test subscriptions interaction
- $browser->with('@general', function (Browser $browser) {
- $browser->with('@skus', function ($browser) {
+ $browser->with('@general', static function (Browser $browser) {
+ $browser->with('@skus', static function ($browser) {
// Uncheck 'groupware', expect activesync unchecked
$browser->click('#sku-input-groupware')
->assertNotChecked('#sku-input-groupware')
@@ -279,7 +275,7 @@
});
// Test password reset link delete and create
- $code = new \App\VerificationCode(['mode' => 'password-reset']);
+ $code = new VerificationCode(['mode' => 'password-reset']);
$jack->verificationcodes()->save($code);
$browser->visit('/user/' . $jack->id)
@@ -383,13 +379,13 @@
->on(new UserList());
$this->assertSame('Arnie', $john->getSetting('first_name'));
- $this->assertSame(null, $john->getSetting('last_name'));
+ $this->assertNull($john->getSetting('last_name'));
// Test the non-controller user
$browser->visit('/user/' . $jack->id)
->on(new UserInfo())
->click('#tab-personal')
- ->with('@personal', function (Browser $browser) {
+ ->with('@personal', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'First Name')
->assertValue('div.row:nth-child(1) input[type=text]', 'Jack')
->assertSeeIn('div.row:nth-child(2) label', 'Last Name')
@@ -419,13 +415,13 @@
$john->setSetting('guam_enabled', null);
$john->setSetting('limit_geo', null);
- $this->browse(function (Browser $browser) use ($john) {
+ $this->browse(static function (Browser $browser) use ($john) {
$browser->visit('/user/' . $john->id)
->on(new UserInfo())
->assertSeeIn('@nav #tab-settings', 'Settings')
->click('@nav #tab-settings')
->assertSeeIn('@setting-options-head', 'Main Options')
- ->with('@setting-options', function (Browser $browser) {
+ ->with('@setting-options', static function (Browser $browser) {
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting')
->assertMissing('div.row:nth-child(2)') // guam and geo-lockin settings are hidden
->click('div.row:nth-child(1) input[type=checkbox]:checked')
@@ -447,7 +443,7 @@
->assertSeeIn('div.row:nth-child(2) label', 'IMAP proxy')
->assertNotChecked('div.row:nth-child(2) input')
->assertSeeIn('div.row:nth-child(3) label', 'Geo-lockin')
- ->with(new CountrySelect('#limit_geo'), function ($browser) {
+ ->with(new CountrySelect('#limit_geo'), static function ($browser) {
$browser->assertCountries([])
->setCountries(['CH', 'PL'])
->assertCountries(['CH', 'PL']);
@@ -460,7 +456,7 @@
$this->assertSame('true', $john->getSetting('guam_enabled'));
$browser
- ->with(new CountrySelect('#limit_geo'), function ($browser) {
+ ->with(new CountrySelect('#limit_geo'), static function ($browser) {
$browser->setCountries([])
->assertCountries([]);
})
@@ -468,8 +464,8 @@
->click('button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.');
- $this->assertSame(null, $john->getSetting('limit_geo'));
- $this->assertSame(null, $john->getSetting('guam_enabled'));
+ $this->assertNull($john->getSetting('limit_geo'));
+ $this->assertNull($john->getSetting('guam_enabled'));
});
});
}
@@ -490,7 +486,7 @@
->assertSeeIn('#user-info .card-title', 'New user account')
->assertMissing('@nav #tab-settings')
->assertMissing('@nav #tab-personal')
- ->with('@general', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
// Assert form content
$browser->assertFocused('div.row:nth-child(1) input')
->assertSeeIn('div.row:nth-child(1) label', 'First Name')
@@ -504,7 +500,7 @@
->assertEnabled('div.row:nth-child(4) input[type=text]')
->assertSeeIn('div.row:nth-child(5) label', 'Email Aliases')
->assertVisible('div.row:nth-child(5) .list-input')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue([])
->assertValue('@input', '');
})
@@ -519,7 +515,7 @@
->assertMissing('div.row:nth-child(6) #password-link')
->assertSeeIn('div.row:nth-child(7) label', 'Package')
// assert packages list widget, select "Lite Account"
- ->with('@packages', function ($browser) {
+ ->with('@packages', static function ($browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1)', 'Groupware Account')
->assertSeeIn('tbody tr:nth-child(2)', 'Lite Account')
@@ -534,7 +530,8 @@
->assertSeeIn('button[type=submit]', 'Submit');
// Test browser-side required fields and error handling
- $browser->click('button[type=submit]')
+ $browser->scrollTo('button[type=submit]')->pause(500)
+ ->click('button[type=submit]')
->assertFocused('#email')
->type('#email', 'invalid email')
->type('#password', 'simple123')
@@ -549,34 +546,34 @@
});
// Test form error handling (aliases)
- $browser->with('@general', function (Browser $browser) {
+ $browser->with('@general', static function (Browser $browser) {
$browser->type('#email', 'julia.roberts@kolab.org')
->type('#password_confirmation', 'simple123')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->addListEntry('invalid address');
})
->click('button[type=submit]')
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertFormError(1, 'The specified alias is invalid.', false);
});
});
// Successful account creation
- $browser->with('@general', function (Browser $browser) {
+ $browser->with('@general', static function (Browser $browser) {
$browser->type('#first_name', 'Julia')
->type('#last_name', 'Roberts')
->type('#organization', 'Test Org')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->removeListEntry(1)
->addListEntry('julia.roberts2@kolab.org');
})
->click('button[type=submit]');
})
- ->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.')
+ ->assertToast(Toast::TYPE_SUCCESS, 'User created successfully.')
// check redirection to users list
- ->on(new UserList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->on(new UserList())
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 5)
->assertSeeIn('tbody tr:nth-child(4) a', 'julia.roberts@kolab.org');
});
@@ -593,7 +590,7 @@
// Some additional tests for the list input widget
$browser->click('@table tbody tr:nth-child(4) a')
->on(new UserInfo())
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertListInputValue(['julia.roberts2@kolab.org'])
->addListEntry('invalid address')
->type('.input-group:nth-child(2) input', '@kolab.org')
@@ -601,9 +598,9 @@
})
// TODO: Investigate why this click does not work, for now we
// submit the form with Enter key above
- //->click('@general button[type=submit]')
+ // ->click('@general button[type=submit]')
->assertToast(Toast::TYPE_ERROR, 'Form validation error')
- ->with(new ListInput('#aliases'), function (Browser $browser) {
+ ->with(new ListInput('#aliases'), static function (Browser $browser) {
$browser->assertVisible('.input-group:nth-child(2) input.is-invalid')
->assertVisible('.input-group:nth-child(3) input.is-invalid')
->type('.input-group:nth-child(2) input', 'julia.roberts3@kolab.org')
@@ -612,7 +609,7 @@
})
// TODO: Investigate why this click does not work, for now we
// submit the form with Enter key above
- //->click('@general button[type=submit]')
+ // ->click('@general button[type=submit]')
->assertToast(Toast::TYPE_SUCCESS, 'User data updated successfully.');
$julia = User::where('email', 'julia.roberts@kolab.org')->first();
@@ -632,7 +629,7 @@
// First create a new user
$john = $this->getTestUser('john@kolab.org');
$julia = $this->getTestUser('julia.roberts@kolab.org');
- $package_kolab = \App\Package::where('title', 'kolab')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
$john->assignPackage($package_kolab, $julia);
// Test deleting non-controller user
@@ -641,7 +638,7 @@
->on(new UserInfo())
->assertSeeIn('button.button-delete', 'Delete user')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function (Browser $browser) {
+ ->with(new Dialog('#delete-warning'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Delete julia.roberts@kolab.org')
->assertFocused('@button-cancel')
->assertSeeIn('@button-cancel', 'Cancel')
@@ -650,13 +647,13 @@
})
->waitUntilMissing('#delete-warning')
->click('button.button-delete')
- ->with(new Dialog('#delete-warning'), function (Browser $browser) {
+ ->with(new Dialog('#delete-warning'), static function (Browser $browser) {
$browser->click('@button-action');
})
->waitUntilMissing('#delete-warning')
->assertToast(Toast::TYPE_SUCCESS, 'User deleted successfully.')
->on(new UserList())
- ->with('@table', function (Browser $browser) {
+ ->with('@table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 4)
->assertSeeIn('tbody tr:nth-child(1) a', 'jack@kolab.org')
->assertSeeIn('tbody tr:nth-child(2) a', 'joe@kolab.org')
@@ -669,7 +666,7 @@
});
// Test that non-controller user cannot see/delete himself on the users list
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
@@ -678,16 +675,16 @@
});
// Test that controller user (Ned) can see all the users
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('ned@kolab.org', 'simple123', true)
->visit(new UserList())
- ->whenAvailable('@table', function (Browser $browser) {
+ ->whenAvailable('@table', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 4);
});
- // TODO: Test the delete action in details
+ // TODO: Test the delete action in details
});
// TODO: Test what happens with the logged in user session after he's been deleted by another user
@@ -706,7 +703,7 @@
$wallet->save();
// SKUs on user edit page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
@@ -714,8 +711,8 @@
->waitFor('@table tr:nth-child(2)')
->click('@table tr:nth-child(2) a') // joe@kolab.org
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
- $browser->whenAvailable('@skus', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
+ $browser->whenAvailable('@skus', static function (Browser $browser) {
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input');
$browser->waitFor('tbody tr')
->assertElementsCount('tbody tr', 5)
@@ -723,7 +720,7 @@
->assertSeeIn('tbody tr:nth-child(1) td.price', '4,50 CHF/month¹')
// Storage SKU
->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹')
- ->with($quota_input, function (Browser $browser) {
+ ->with($quota_input, static function (Browser $browser) {
$browser->setQuotaValue(100);
})
->assertSeeIn('tr:nth-child(2) td.price', '21,37 CHF/month¹')
@@ -734,67 +731,67 @@
// 2FA SKU
->assertSeeIn('tbody tr:nth-child(5) td.price', '0,00 CHF/month¹');
})
- ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher');
+ ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher');
});
});
// Packages on new user page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new UserList())
->click('button.user-new')
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
- $browser->whenAvailable('@packages', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
+ $browser->whenAvailable('@packages', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1) .price', '8,91 CHF/month¹') // Groupware
->assertSeeIn('tbody tr:nth-child(2) .price', '4,50 CHF/month¹'); // Lite
})
- ->assertSeeIn('@packages table + .hint', '¹ applied discount: 10% - Test voucher');
+ ->assertSeeIn('@packages table + .hint', '¹ applied discount: 10% - Test voucher');
});
});
// Test using entitlement cost instead of the SKU cost
- $this->browse(function (Browser $browser) use ($wallet) {
+ $this->browse(static function (Browser $browser) use ($wallet) {
$joe = User::where('email', 'joe@kolab.org')->first();
$beta_sku = Sku::withEnvTenantContext()->where('title', 'beta')->first();
$storage_sku = Sku::withEnvTenantContext()->where('title', 'storage')->first();
// Add an extra storage and beta entitlement with different prices
Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $beta_sku->id,
- 'cost' => 5010,
- 'entitleable_id' => $joe->id,
- 'entitleable_type' => User::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $beta_sku->id,
+ 'cost' => 5010,
+ 'entitleable_id' => $joe->id,
+ 'entitleable_type' => User::class,
]);
Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $storage_sku->id,
- 'cost' => 5000,
- 'entitleable_id' => $joe->id,
- 'entitleable_type' => User::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $storage_sku->id,
+ 'cost' => 5000,
+ 'entitleable_id' => $joe->id,
+ 'entitleable_type' => User::class,
]);
$browser->visit('/user/' . $joe->id)
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
- $browser->whenAvailable('@skus', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
+ $browser->whenAvailable('@skus', static function (Browser $browser) {
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input');
$browser->waitFor('tbody tr')
// Beta SKU
->assertSeeIn('tbody tr:nth-child(6) td.price', '45,09 CHF/month¹')
// Storage SKU
->assertSeeIn('tr:nth-child(2) td.price', '45,00 CHF/month¹')
- ->with($quota_input, function (Browser $browser) {
+ ->with($quota_input, static function (Browser $browser) {
$browser->setQuotaValue(7);
})
->assertSeeIn('tr:nth-child(2) td.price', '45,22 CHF/month¹')
- ->with($quota_input, function (Browser $browser) {
+ ->with($quota_input, static function (Browser $browser) {
$browser->setQuotaValue(5);
})
->assertSeeIn('tr:nth-child(2) td.price', '0,00 CHF/month¹');
})
- ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher');
+ ->assertSeeIn('@skus table + .hint', '¹ applied discount: 10% - Test voucher');
});
});
}
@@ -812,7 +809,7 @@
$wallet->save();
// On Dashboard and the wallet page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
@@ -824,13 +821,13 @@
});
// SKUs on user edit page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new UserList())
->waitFor('@table tr:nth-child(2)')
->click('@table tr:nth-child(2) a') // joe@kolab.org
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
- $browser->whenAvailable('@skus', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
+ $browser->whenAvailable('@skus', static function (Browser $browser) {
$quota_input = new QuotaInput('tbody tr:nth-child(2) .range-input');
$browser->waitFor('tbody tr')
->assertElementsCount('tbody tr', 5)
@@ -838,7 +835,7 @@
->assertSeeIn('tbody tr:nth-child(1) td.price', '5,00 €/month')
// Storage SKU
->assertSeeIn('tr:nth-child(2) td.price', '0,00 €/month')
- ->with($quota_input, function (Browser $browser) {
+ ->with($quota_input, static function (Browser $browser) {
$browser->setQuotaValue(100);
})
->assertSeeIn('tr:nth-child(2) td.price', '23,75 €/month');
@@ -847,12 +844,12 @@
});
// Packages on new user page
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new UserList())
->click('button.user-new')
->on(new UserInfo())
- ->with('@general', function (Browser $browser) {
- $browser->whenAvailable('@packages', function (Browser $browser) {
+ ->with('@general', static function (Browser $browser) {
+ $browser->whenAvailable('@packages', static function (Browser $browser) {
$browser->assertElementsCount('tbody tr', 2)
->assertSeeIn('tbody tr:nth-child(1) .price', '9,90 €/month') // Groupware
->assertSeeIn('tbody tr:nth-child(2) .price', '5,00 €/month'); // Lite
@@ -867,7 +864,7 @@
public function testUserDelegation(): void
{
$jack = $this->getTestUser('jack@kolab.org');
- $jack->delegatees()->each(function ($user) {
+ $jack->delegatees()->each(static function ($user) {
$user->delegation->delete();
});
@@ -884,13 +881,13 @@
->assertMissing('@setting-options-head')
->assertSeeIn('@setting-delegation-head', 'Delegation')
// ->click('@settings .accordion-item:nth-child(2) .accordion-button')
- ->whenAvailable('@setting-delegation', function (Browser $browser) {
+ ->whenAvailable('@setting-delegation', static function (Browser $browser) {
$browser->assertSeeIn('table tfoot td', 'There are no delegates.')
->assertMissing('table tbody tr');
})
->assertSeeIn('@setting-delegation-head .buttons button', 'Add delegate')
->click('@setting-delegation-head .buttons button')
- ->with(new Dialog('#delegation-create'), function (Browser $browser) {
+ ->with(new Dialog('#delegation-create'), static function (Browser $browser) {
$browser->assertSeeIn('@title', 'Add delegate')
->assertFocused('#delegation-email')
->assertValue('#delegation-email', '')
@@ -922,7 +919,7 @@
// Remove delegation
$browser->waitFor('@setting-delegation table tbody tr')
- ->whenAvailable('@setting-delegation', function (Browser $browser) {
+ ->whenAvailable('@setting-delegation', static function (Browser $browser) {
$browser->assertMissing('table tfoot td')
->assertSeeIn('table tbody tr td:first-child', 'john@kolab.org')
->click('table button.text-danger');
diff --git a/src/tests/Browser/WalletTest.php b/src/tests/Browser/WalletTest.php
--- a/src/tests/Browser/WalletTest.php
+++ b/src/tests/Browser/WalletTest.php
@@ -2,7 +2,9 @@
namespace Tests\Browser;
+use App\Package;
use App\Payment;
+use App\Plan;
use App\ReferralProgram;
use App\Transaction;
use App\Wallet;
@@ -15,10 +17,7 @@
class WalletTest extends TestCaseDusk
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -29,10 +28,7 @@
ReferralProgram::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -49,7 +45,7 @@
public function testWalletUnauth(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/wallet')->on(new Home());
});
}
@@ -60,7 +56,7 @@
public function testDashboard(): void
{
// Test that the page requires authentication
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit(new Home())
->submitLogon('john@kolab.org', 'simple123', true)
->on(new Dashboard())
@@ -76,7 +72,7 @@
*/
public function testWallet(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->click('@links .link-wallet')
->on(new WalletPage())
->assertSeeIn('#wallet .card-title', 'Account balance -12,34 CHF')
@@ -91,13 +87,13 @@
public function testReceipts(): void
{
$user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => 'simple123']);
- $plan = \App\Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
+ $plan = Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
$user->assignPlan($plan);
$wallet = $user->wallets()->first();
$wallet->payments()->delete();
// Log out John and log in the test user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->waitForLocation('/login')
->on(new Home())
@@ -105,7 +101,7 @@
});
// Assert Receipts tab content when there's no receipts available
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new Dashboard())
->click('@links .link-wallet')
->on(new WalletPage())
@@ -113,7 +109,7 @@
->assertSeeIn('#wallet .card-title .text-success', '0,00 CHF')
->assertSeeIn('#wallet .card-text', 'You are in your free trial period.')
->assertSeeIn('@nav #tab-receipts', 'Receipts')
- ->with('@receipts-tab', function (Browser $browser) {
+ ->with('@receipts-tab', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('td', 'There are no receipts for payments')
->assertMissing('button');
@@ -122,35 +118,35 @@
// Create some sample payments
$receipts = [];
- $date = Carbon::create(intval(date('Y')) - 1, 3, 30);
+ $date = Carbon::create((int) date('Y') - 1, 3, 30);
$payment = Payment::create([
- 'id' => 'AAA1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in March',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'currency_amount' => 1111,
- 'currency' => 'CHF',
+ 'id' => 'AAA1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in March',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'currency_amount' => 1111,
+ 'currency' => 'CHF',
]);
$payment->updated_at = $date;
$payment->save();
$receipts[] = $date->format('Y-m');
- $date = Carbon::create(intval(date('Y')) - 1, 4, 30);
+ $date = Carbon::create((int) date('Y') - 1, 4, 30);
$payment = Payment::create([
- 'id' => 'AAA2',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in April',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'currency_amount' => 1111,
- 'currency' => 'CHF',
+ 'id' => 'AAA2',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in April',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'currency_amount' => 1111,
+ 'currency' => 'CHF',
]);
$payment->updated_at = $date;
$payment->save();
@@ -189,7 +185,7 @@
$wallet = $user->wallets()->first();
// Log out and log-in the test user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->waitForLocation('/login')
->on(new Home())
@@ -197,13 +193,13 @@
});
// Assert Referral Programs tab content when there's no programs available
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->on(new Dashboard())
->click('@links .link-wallet')
->on(new WalletPage())
->assertSeeIn('@nav #tab-refprograms', 'Referral Programs')
->click('@nav #tab-refprograms')
- ->whenAvailable('@refprograms-tab', function (Browser $browser) {
+ ->whenAvailable('@refprograms-tab', static function (Browser $browser) {
$browser->waitUntilMissing('.app-loader')
->assertSeeIn('div', 'There are no active referral programs at this moment.')
->assertMissing('ul');
@@ -218,11 +214,11 @@
]);
// Assert Referral Programs tab with programs available
- $this->browse(function (Browser $browser) use ($program, $user) {
+ $this->browse(static function (Browser $browser) use ($program, $user) {
$browser->refresh()
->on(new WalletPage())
->click('@nav #tab-refprograms')
- ->whenAvailable('@refprograms-tab', function (Browser $browser) use ($program, $user) {
+ ->whenAvailable('@refprograms-tab', static function (Browser $browser) use ($program, $user) {
$code = $program->codes()->where('user_id', $user->id)->first();
$browser->waitFor('ul')
@@ -244,29 +240,29 @@
$user = $this->getTestUser('wallets-controller@kolabnow.com', ['password' => 'simple123']);
// Log out John and log in the test user
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->waitForLocation('/login')
->on(new Home())
->submitLogon('wallets-controller@kolabnow.com', 'simple123', true);
});
- $package_kolab = \App\Package::where('title', 'kolab')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
$user->assignPackage($package_kolab);
$wallet = $user->wallets()->first();
// Create some sample transactions
$transactions = $this->createTestTransactions($wallet);
$transactions = array_reverse($transactions);
- $pages = array_chunk($transactions, 10 /* page size*/);
+ $pages = array_chunk($transactions, 10 /* page size */);
- $this->browse(function (Browser $browser) use ($pages) {
+ $this->browse(static function (Browser $browser) use ($pages) {
$browser->on(new Dashboard())
->click('@links .link-wallet')
->on(new WalletPage())
->assertSeeIn('@nav #tab-history', 'History')
->click('@nav #tab-history')
- ->with('@history-tab', function (Browser $browser) use ($pages) {
+ ->with('@history-tab', static function (Browser $browser) use ($pages) {
$browser->waitUntilMissing('.app-loader')
->assertElementsCount('table tbody tr', 10)
->assertMissing('table td.email')
@@ -275,9 +271,9 @@
foreach ($pages[0] as $idx => $transaction) {
$selector = 'table tbody tr:nth-child(' . ($idx + 1) . ')';
$priceStyle = $transaction->type == Transaction::WALLET_AWARD ? 'text-success' : 'text-danger';
- $browser->assertSeeIn("$selector td.description", $transaction->shortDescription())
- ->assertMissing("$selector td.selection button")
- ->assertVisible("$selector td.price.{$priceStyle}");
+ $browser->assertSeeIn("{$selector} td.description", $transaction->shortDescription())
+ ->assertMissing("{$selector} td.selection button")
+ ->assertVisible("{$selector} td.price.{$priceStyle}");
// TODO: Test more transaction details
}
@@ -291,21 +287,21 @@
foreach ($pages[1] as $idx => $transaction) {
$selector = 'table tbody tr:nth-child(' . ($idx + 1 + 10) . ')';
$priceStyle = $transaction->type == Transaction::WALLET_CREDIT ? 'text-success' : 'text-danger';
- $browser->assertSeeIn("$selector td.description", $transaction->shortDescription());
+ $browser->assertSeeIn("{$selector} td.description", $transaction->shortDescription());
if ($transaction->type == Transaction::WALLET_DEBIT) {
$debitEntry = $selector;
} else {
- $browser->assertMissing("$selector td.selection button");
+ $browser->assertMissing("{$selector} td.selection button");
}
}
// Load sub-transactions
- $browser->scrollTo("$debitEntry td.selection button")->pause(500)
- ->click("$debitEntry td.selection button")
+ $browser->scrollTo("{$debitEntry} td.selection button")->pause(500)
+ ->click("{$debitEntry} td.selection button")
->waitUntilMissing('.app-loader')
- ->assertElementsCount("$debitEntry td.description ul li", 2)
- ->assertMissing("$debitEntry td.selection button");
+ ->assertElementsCount("{$debitEntry} td.description ul li", 2)
+ ->assertMissing("{$debitEntry} td.selection button");
});
});
}
@@ -315,7 +311,7 @@
*/
public function testAccessDenied(): void
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/logout')
->on(new Home())
->submitLogon('jack@kolab.org', 'simple123', true)
diff --git a/src/tests/BrowserAddonTrait.php b/src/tests/BrowserAddonTrait.php
--- a/src/tests/BrowserAddonTrait.php
+++ b/src/tests/BrowserAddonTrait.php
@@ -2,39 +2,40 @@
namespace Tests;
+use App\Wallet;
use Facebook\WebDriver\Chrome\ChromeOptions;
-use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
+use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\Chrome\SupportsChrome;
use Mollie\Laravel\Facades\Mollie;
+use Tests\Browser\Pages\PaymentMollie;
trait BrowserAddonTrait
{
use SupportsChrome;
- protected $browser;
-
+ protected static $browser;
/**
* Initialize and start Chrome driver and browser
*
* @returns Browser The browser
*/
- protected function startBrowser(): Browser
+ public static function startBrowser(): Browser
{
$driver = retry(5, function () {
- return $this->driver();
+ return self::driver();
}, 50);
- $this->browser = new Browser($driver);
+ self::$browser = new Browser($driver);
$screenshots_dir = __DIR__ . '/Browser/screenshots/';
Browser::$storeScreenshotsAt = $screenshots_dir;
if (!file_exists($screenshots_dir)) {
- mkdir($screenshots_dir, 0777, true);
+ mkdir($screenshots_dir, 0o777, true);
}
- return $this->browser;
+ return self::$browser;
}
/**
@@ -42,19 +43,19 @@
*
* @afterClass
*/
- protected function stopBrowser(): void
+ public static function stopBrowser(): void
{
- if ($this->browser) {
- $this->browser->quit();
+ if (self::$browser) {
+ self::$browser->quit();
static::stopChromeDriver();
- $this->browser = null;
+ self::$browser = null;
}
}
/**
* Initialize and start Chrome driver
*/
- protected function driver()
+ protected static function driver()
{
static::startChromeDriver(['--port=9515']);
@@ -76,8 +77,6 @@
/**
* Register an "after class" tear down callback.
- *
- * @param \Closure $callback
*/
public static function afterClass(\Closure $callback): void
{
@@ -87,7 +86,7 @@
/**
* Create Mollie's auto-payment mandate using our API and Chrome browser
*/
- public function createMollieMandate(\App\Wallet $wallet, array $params)
+ public function createMollieMandate(Wallet $wallet, array $params)
{
$wallet->setSetting('mollie_mandate_id', null);
@@ -102,12 +101,11 @@
// There's no easy way to confirm a created mandate.
// The only way seems to be to fire up Chrome on checkout page
// and do actions with use of Dusk browser.
- $this->startBrowser()->visit($json['redirectUrl']);
-
- $molliePage = new \Tests\Browser\Pages\PaymentMollie();
- $this->browser->on($molliePage);
- $molliePage->assert($this->browser);
- $molliePage->submitPayment($this->browser, 'paid');
+ $this->startBrowser()
+ ->visit($json['redirectUrl'])
+ ->on(new PaymentMollie())
+ ->submitPayment('paid');
+ $this->stopBrowser();
// Because of https://github.com/mollie/mollie-api-php/issues/649 mandate does not
// exist until payment is paid. As we do not expect a webhook to be handled, we
@@ -120,8 +118,6 @@
$json['mandateId'] = $mollie_payment->mandateId;
}
- $this->stopBrowser();
-
return $json;
}
}
diff --git a/src/tests/CoinbaseMocksTrait.php b/src/tests/CoinbaseMocksTrait.php
--- a/src/tests/CoinbaseMocksTrait.php
+++ b/src/tests/CoinbaseMocksTrait.php
@@ -2,6 +2,7 @@
namespace Tests;
+use App\Providers\Payment\Coinbase;
use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
@@ -16,7 +17,7 @@
*
* @see http://docs.guzzlephp.org/en/stable/testing.html
*
- * @return \GuzzleHttp\Handler\MockHandler
+ * @return MockHandler
*/
public function mockCoinbase()
{
@@ -28,13 +29,13 @@
Middleware::history($this->coinbaseRequestHistory)
);
- \App\Providers\Payment\Coinbase::$testClient = new Client(['handler' => $handler]);
+ Coinbase::$testClient = new Client(['handler' => $handler]);
return $mockHandler;
}
public function unmockCoinbase()
{
- \App\Providers\Payment\Coinbase::$testClient = null;
+ Coinbase::$testClient = null;
}
}
diff --git a/src/tests/Feature/Auth/SecondFactorTest.php b/src/tests/Feature/Auth/SecondFactorTest.php
--- a/src/tests/Feature/Auth/SecondFactorTest.php
+++ b/src/tests/Feature/Auth/SecondFactorTest.php
@@ -10,20 +10,14 @@
class SecondFactorTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('entitlement-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('entitlement-test@kolabnow.com');
diff --git a/src/tests/Feature/AuthAttemptTest.php b/src/tests/Feature/AuthAttemptTest.php
--- a/src/tests/Feature/AuthAttemptTest.php
+++ b/src/tests/Feature/AuthAttemptTest.php
@@ -7,20 +7,14 @@
class AuthAttemptTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('jane@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('jane@kolabnow.com');
@@ -30,16 +24,16 @@
public function testRecord(): void
{
$user = $this->getTestUser('jane@kolabnow.com');
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
- $this->assertEquals($authAttempt->user_id, $user->id);
- $this->assertEquals($authAttempt->ip, "10.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $this->assertSame($authAttempt->user_id, $user->id);
+ $this->assertSame($authAttempt->ip, "10.0.0.1");
$authAttempt->refresh();
- $this->assertEquals($authAttempt->status, "NEW");
+ $this->assertSame($authAttempt->status, "NEW");
- $authAttempt2 = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
- $this->assertEquals($authAttempt->id, $authAttempt2->id);
+ $authAttempt2 = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $this->assertSame($authAttempt->id, $authAttempt2->id);
- $authAttempt3 = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.2");
- $this->assertNotEquals($authAttempt->id, $authAttempt3->id);
+ $authAttempt3 = AuthAttempt::recordAuthAttempt($user, "10.0.0.2");
+ $this->assertNotSame($authAttempt->id, $authAttempt3->id);
}
}
diff --git a/src/tests/Feature/Backends/DAVTest.php b/src/tests/Feature/Backends/DAVTest.php
--- a/src/tests/Feature/Backends/DAVTest.php
+++ b/src/tests/Feature/Backends/DAVTest.php
@@ -12,10 +12,7 @@
private $user;
private $user2;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -24,10 +21,7 @@
}
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if ($this->user) {
$this->deleteTestUser($this->user->email, true);
@@ -38,6 +32,7 @@
parent::tearDown();
}
+
/**
* Test initializing default folders for a user.
*
@@ -87,7 +82,7 @@
$this->assertSame('Contacts-Test', $folders[0]->name);
$folders = $dav->listFolders(DAV::TYPE_VEVENT);
- $folders = array_filter($folders, function ($f) {
+ $folders = array_filter($folders, static function ($f) {
return $f->name != 'Inbox' && $f->name != 'Outbox';
});
$folders = array_values($folders);
@@ -97,7 +92,7 @@
$this->assertSame('Calendar-Test', $folders[0]->name);
$folders = $dav->listFolders(DAV::TYPE_VTODO);
- $folders = array_filter($folders, function ($f) {
+ $folders = array_filter($folders, static function ($f) {
return $f->name != 'Inbox' && $f->name != 'Outbox';
});
$folders = array_values($folders);
@@ -113,6 +108,7 @@
* Test sharing/unsharing folders for a user (delegation).
*
* @depends testInitDefaultFolders
+ *
* @group imap
* @group dav
*/
@@ -141,21 +137,21 @@
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VCARD),
- fn ($folder) => $folder->owner === $user->email
+ static fn ($folder) => $folder->owner === $user->email
));
$this->assertCount(1, $folders);
$this->assertSame('read-write', $folders[0]->shareAccess);
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VEVENT),
- fn ($folder) => $folder->owner === $user->email
+ static fn ($folder) => $folder->owner === $user->email
));
$this->assertCount(1, $folders);
$this->assertSame('read', $folders[0]->shareAccess);
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VTODO),
- fn ($folder) => $folder->owner === $user->email
+ static fn ($folder) => $folder->owner === $user->email
));
$this->assertCount(0, $folders);
@@ -166,13 +162,13 @@
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VCARD),
- fn ($folder) => $folder->owner === $user->email
+ static fn ($folder) => $folder->owner === $user->email
));
$this->assertCount(0, $folders);
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VEVENT),
- fn ($folder) => $folder->owner === $user->email
+ static fn ($folder) => $folder->owner === $user->email
));
$this->assertCount(0, $folders);
@@ -183,7 +179,7 @@
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VCARD),
- fn ($folder) => $folder->owner != $user->email
+ static fn ($folder) => $folder->owner != $user->email
|| $folder->shareAccess != DAV\Folder::SHARE_ACCESS_NONE
|| !empty($folder->invites)
));
@@ -191,7 +187,7 @@
$folders = array_values(array_filter(
$dav->listFolders(DAV::TYPE_VEVENT),
- fn ($folder) => $folder->owner != $user->email
+ static fn ($folder) => $folder->owner != $user->email
|| $folder->shareAccess != DAV\Folder::SHARE_ACCESS_NONE
|| !empty($folder->invites)
));
diff --git a/src/tests/Feature/Backends/IMAPTest.php b/src/tests/Feature/Backends/IMAPTest.php
--- a/src/tests/Feature/Backends/IMAPTest.php
+++ b/src/tests/Feature/Backends/IMAPTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Backends;
use App\Backends\IMAP;
+use App\Sku;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@@ -15,10 +16,7 @@
private $resource;
private $folder;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -27,10 +25,7 @@
}
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if ($this->imap) {
$this->imap->closeConnection();
@@ -74,10 +69,10 @@
$this->assertTrue($imap->setACL('user/john@kolab.org', $user->email, 'lrs'));
$this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $user->email, 'lrs'));
-/*
- $this->assertTrue($imap->setACL('user/john@kolab.org', $group->name, 'lrs'));
- $this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $group->name, 'lrs'));
-*/
+ /*
+ $this->assertTrue($imap->setACL('user/john@kolab.org', $group->name, 'lrs'));
+ $this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $group->name, 'lrs'));
+ */
// Cleanup ACL of a user
IMAP::aclCleanup($user->email);
@@ -86,15 +81,15 @@
$acl = $imap->getACL('shared/Resources/Conference Room #1@kolab.org');
$this->assertTrue(is_array($acl) && !isset($acl[$user->email]));
-/*
- // Cleanup ACL of a group
- IMAP::aclCleanup($group->name, 'kolab.org');
+ /*
+ // Cleanup ACL of a group
+ IMAP::aclCleanup($group->name, 'kolab.org');
- $acl = $imap->getACL('user/john@kolab.org');
- $this->assertTrue(is_array($acl) && !isset($acl[$user->email]));
- $acl = $imap->getACL('shared/Resources/Conference Room #1@kolab.org');
- $this->assertTrue(is_array($acl) && !isset($acl[$user->email]));
-*/
+ $acl = $imap->getACL('user/john@kolab.org');
+ $this->assertTrue(is_array($acl) && !isset($acl[$user->email]));
+ $acl = $imap->getACL('shared/Resources/Conference Room #1@kolab.org');
+ $this->assertTrue(is_array($acl) && !isset($acl[$user->email]));
+ */
}
/**
@@ -119,12 +114,12 @@
$this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', 'anyone', 'lrs'));
$this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', 'jack@kolab.org', 'lrs'));
$this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $user->email, 'lrs'));
-/*
- $this->assertTrue($imap->setACL('user/john@kolab.org', $group->name, 'lrs'));
- $this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $group->name, 'lrs'));
+ /*
+ $this->assertTrue($imap->setACL('user/john@kolab.org', $group->name, 'lrs'));
+ $this->assertTrue($imap->setACL('shared/Resources/Conference Room #1@kolab.org', $group->name, 'lrs'));
- $group->delete();
-*/
+ $group->delete();
+ */
$user->delete();
// Cleanup ACL for the domain
@@ -157,16 +152,16 @@
$ts = str_replace('.', '', (string) microtime(true));
$this->user = $user = $this->getTestUser("test-{$ts}@" . \config('app.domain'), []);
- $storage = \App\Sku::withObjectTenantContext($user)->where('title', 'storage')->first();
+ $storage = Sku::withObjectTenantContext($user)->where('title', 'storage')->first();
$user->assignSku($storage, 1, $user->wallets->first());
$expectedQuota = [
'user/' . $user->email => [
'storage' => [
'used' => 0,
- 'total' => 1048576
- ]
- ]
+ 'total' => 1048576,
+ ],
+ ],
];
// Create the mailbox
diff --git a/src/tests/Feature/Backends/LDAPTest.php b/src/tests/Feature/Backends/LDAPTest.php
--- a/src/tests/Feature/Backends/LDAPTest.php
+++ b/src/tests/Feature/Backends/LDAPTest.php
@@ -4,10 +4,13 @@
use App\Backends\LDAP;
use App\Domain;
-use App\Group;
use App\Entitlement;
+use App\Group;
+use App\Jobs\Group\UpdateJob;
+use App\Package;
use App\Resource;
use App\SharedFolder;
+use App\Sku;
use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@@ -16,10 +19,7 @@
{
private $ldap_config = [];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -39,10 +39,7 @@
// TODO: Remove group members
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
\config($this->ldap_config);
@@ -80,8 +77,8 @@
Queue::fake();
$domain = $this->getTestDomain('testldap.com', [
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
]);
// Create the domain
@@ -95,12 +92,12 @@
'objectclass' => [
'top',
'domainrelatedobject',
- 'inetdomain'
+ 'inetdomain',
],
];
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_domain[$attr]) ? $ldap_domain[$attr] : null);
+ $this->assertSame($value, $ldap_domain[$attr] ?? null);
}
// TODO: Test other attributes, aci, roles/ous
@@ -115,13 +112,13 @@
$ldap_domain = LDAP::getDomain($domain->namespace);
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_domain[$attr]) ? $ldap_domain[$attr] : null);
+ $this->assertSame($value, $ldap_domain[$attr] ?? null);
}
// Delete the domain
LDAP::deleteDomain($domain);
- $this->assertSame(null, LDAP::getDomain($domain->namespace));
+ $this->assertNull(LDAP::getDomain($domain->namespace));
}
/**
@@ -135,7 +132,7 @@
$root_dn = \config('services.ldap.hosted.root_dn');
$group = $this->getTestGroup('group@kolab.org', [
- 'members' => ['member1@testldap.com', 'member2@testldap.com']
+ 'members' => ['member1@testldap.com', 'member2@testldap.com'],
]);
$group->setSetting('sender_policy', '["test.com"]');
@@ -151,7 +148,7 @@
'objectclass' => [
'top',
'groupofuniquenames',
- 'kolabgroupofuniquenames'
+ 'kolabgroupofuniquenames',
],
'kolaballowsmtpsender' => 'test.com',
'uniquemember' => [
@@ -161,7 +158,7 @@
];
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute");
+ $this->assertSame($value, $ldap_group[$attr] ?? null, "Group {$attr} attribute");
}
// Update members
@@ -178,7 +175,7 @@
$ldap_group = LDAP::getGroup($group->email);
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute");
+ $this->assertSame($value, $ldap_group[$attr] ?? null, "Group {$attr} attribute");
}
$this->assertSame(['member3@testldap.com'], $group->fresh()->members);
@@ -195,25 +192,25 @@
// TODO: Should we force this to be always an array?
$expected['uniquemember'] = 'uid=member3@testldap.com,ou=People,ou=kolab.org,' . $root_dn;
$expected['kolaballowsmtpsender'] = null;
- $expected['dn'] = 'cn=Te(\\3dść)1,ou=Groups,ou=kolab.org,' . $root_dn;
+ $expected['dn'] = 'cn=Te(\3dść)1,ou=Groups,ou=kolab.org,' . $root_dn;
$expected['cn'] = 'Te(=ść)1';
$ldap_group = LDAP::getGroup($group->email);
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_group[$attr]) ? $ldap_group[$attr] : null, "Group $attr attribute");
+ $this->assertSame($value, $ldap_group[$attr] ?? null, "Group {$attr} attribute");
}
$this->assertSame(['member3@testldap.com'], $group->fresh()->members);
// We called save() twice, and setSettings() three times,
// this is making sure that there's no job executed by the LDAP backend
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 5);
+ Queue::assertPushed(UpdateJob::class, 5);
// Delete the group
LDAP::deleteGroup($group);
- $this->assertSame(null, LDAP::getGroup($group->email));
+ $this->assertNull(LDAP::getGroup($group->email));
}
/**
@@ -255,8 +252,8 @@
];
foreach ($expected as $attr => $value) {
- $ldap_value = isset($ldap_resource[$attr]) ? $ldap_resource[$attr] : null;
- $this->assertEquals($value, $ldap_value, "Resource $attr attribute");
+ $ldap_value = $ldap_resource[$attr] ?? null;
+ $this->assertSame($value, $ldap_value, "Resource {$attr} attribute");
}
// Update resource name and invitation_policy
@@ -269,15 +266,15 @@
$expected['kolabtargetfolder'] = 'shared/Resources/Te(=ść)1@kolab.org';
$expected['kolabinvitationpolicy'] = 'ACT_MANUAL';
$expected['owner'] = 'uid=john@kolab.org,ou=People,ou=kolab.org,' . $root_dn;
- $expected['dn'] = 'cn=Te(\\3dść)1,ou=Resources,ou=kolab.org,' . $root_dn;
+ $expected['dn'] = 'cn=Te(\3dść)1,ou=Resources,ou=kolab.org,' . $root_dn;
$expected['cn'] = 'Te(=ść)1';
$expected['acl'] = ['john@kolab.org, full', 'anyone, p'];
$ldap_resource = LDAP::getResource($resource->email);
foreach ($expected as $attr => $value) {
- $ldap_value = isset($ldap_resource[$attr]) ? $ldap_resource[$attr] : null;
- $this->assertEquals($value, $ldap_value, "Resource $attr attribute");
+ $ldap_value = $ldap_resource[$attr] ?? null;
+ $this->assertSame($value, $ldap_value, "Resource {$attr} attribute");
}
// Remove the invitation policy
@@ -292,14 +289,14 @@
$ldap_resource = LDAP::getResource($resource->email);
foreach ($expected as $attr => $value) {
- $ldap_value = isset($ldap_resource[$attr]) ? $ldap_resource[$attr] : null;
- $this->assertEquals($value, $ldap_value, "Resource $attr attribute");
+ $ldap_value = $ldap_resource[$attr] ?? null;
+ $this->assertSame($value, $ldap_value, "Resource {$attr} attribute");
}
// Delete the resource
LDAP::deleteResource($resource);
- $this->assertSame(null, LDAP::getResource($resource->email));
+ $this->assertNull(LDAP::getResource($resource->email));
}
/**
@@ -339,8 +336,8 @@
];
foreach ($expected as $attr => $value) {
- $ldap_value = isset($ldap_folder[$attr]) ? $ldap_folder[$attr] : null;
- $this->assertEquals($value, $ldap_value, "Shared folder $attr attribute");
+ $ldap_value = $ldap_folder[$attr] ?? null;
+ $this->assertSame($value, $ldap_value, "Shared folder {$attr} attribute");
}
// Update folder name and acl
@@ -354,21 +351,21 @@
$expected['kolabtargetfolder'] = 'shared/Te(=ść)1@kolab.org';
$expected['acl'] = ['john@kolab.org, read-write', 'anyone, lrsp'];
- $expected['dn'] = 'cn=Te(\\3dść)1,ou=Shared Folders,ou=kolab.org,' . $root_dn;
+ $expected['dn'] = 'cn=Te(\3dść)1,ou=Shared Folders,ou=kolab.org,' . $root_dn;
$expected['cn'] = 'Te(=ść)1';
$expected['alias'] = $aliases;
$ldap_folder = LDAP::getSharedFolder($folder->email);
foreach ($expected as $attr => $value) {
- $ldap_value = isset($ldap_folder[$attr]) ? $ldap_folder[$attr] : null;
- $this->assertEquals($value, $ldap_value, "Shared folder $attr attribute");
+ $ldap_value = $ldap_folder[$attr] ?? null;
+ $this->assertSame($value, $ldap_value, "Shared folder {$attr} attribute");
}
// Delete the resource
LDAP::deleteSharedFolder($folder);
- $this->assertSame(null, LDAP::getSharedFolder($folder->email));
+ $this->assertNull(LDAP::getSharedFolder($folder->email));
}
/**
@@ -399,7 +396,7 @@
'mail' => $user->email,
'uid' => $user->email,
'nsroledn' => [
- 'cn=imap-user,' . \config('services.ldap.hosted.root_dn')
+ 'cn=imap-user,' . \config('services.ldap.hosted.root_dn'),
],
'cn' => 'unknown',
'displayname' => '',
@@ -412,7 +409,7 @@
];
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_user[$attr]) ? $ldap_user[$attr] : null);
+ $this->assertSame($value, $ldap_user[$attr] ?? null);
}
// Add aliases, and change some user settings, and entitlements
@@ -426,7 +423,7 @@
$user->save();
$aliases = ['t1-' . $user->email, 't2-' . $user->email];
$user->setAliases($aliases);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
$user->assignPackage($package_kolab);
LDAP::updateUser($user->fresh());
@@ -444,12 +441,12 @@
$ldap_user = LDAP::getUser($user->email);
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_user[$attr]) ? $ldap_user[$attr] : null);
+ $this->assertSame($value, $ldap_user[$attr] ?? null);
}
// Update entitlements
- $sku_activesync = \App\Sku::withEnvTenantContext()->where('title', 'activesync')->first();
- $sku_groupware = \App\Sku::withEnvTenantContext()->where('title', 'groupware')->first();
+ $sku_activesync = Sku::withEnvTenantContext()->where('title', 'activesync')->first();
+ $sku_groupware = Sku::withEnvTenantContext()->where('title', 'groupware')->first();
$user->assignSku($sku_activesync, 1);
Entitlement::where(['sku_id' => $sku_groupware->id, 'entitleable_id' => $user->id])->delete();
@@ -457,7 +454,7 @@
$expected_roles = [
'activesync-user',
- 'imap-user'
+ 'imap-user',
];
$ldap_user = LDAP::getUser($user->email);
@@ -465,12 +462,11 @@
$this->assertCount(2, $ldap_user['nsroledn']);
$ldap_roles = array_map(
- function ($role) {
+ static function ($role) {
if (preg_match('/^cn=([a-z0-9-]+)/', $role, $m)) {
return $m[1];
- } else {
- return $role;
}
+ return $role;
},
$ldap_user['nsroledn']
);
@@ -479,8 +475,8 @@
// Test degraded user
- $sku_storage = \App\Sku::withEnvTenantContext()->where('title', 'storage')->first();
- $sku_2fa = \App\Sku::withEnvTenantContext()->where('title', '2fa')->first();
+ $sku_storage = Sku::withEnvTenantContext()->where('title', 'storage')->first();
+ $sku_2fa = Sku::withEnvTenantContext()->where('title', '2fa')->first();
$user->status |= User::STATUS_DEGRADED;
$user->update(['status' => $user->status]);
$user->assignSku($sku_storage, 2);
@@ -492,13 +488,13 @@
$expected['mailquota'] = \config('app.storage.min_qty') * 1048576;
$expected['nsroledn'] = [
'cn=2fa-user,' . \config('services.ldap.hosted.root_dn'),
- 'cn=degraded-user,' . \config('services.ldap.hosted.root_dn')
+ 'cn=degraded-user,' . \config('services.ldap.hosted.root_dn'),
];
$ldap_user = LDAP::getUser($user->email);
foreach ($expected as $attr => $value) {
- $this->assertEquals($value, isset($ldap_user[$attr]) ? $ldap_user[$attr] : null);
+ $this->assertSame($value, $ldap_user[$attr] ?? null);
}
// TODO: Test user who's owner is degraded
@@ -506,7 +502,7 @@
// Delete the user
LDAP::deleteUser($user);
- $this->assertSame(null, LDAP::getUser($user->email));
+ $this->assertNull(LDAP::getUser($user->email));
}
/**
@@ -520,9 +516,9 @@
$this->expectExceptionMessageMatches('/Failed to create resource/');
$resource = new Resource([
- 'email' => 'test-non-existing-ldap@non-existing.org',
- 'name' => 'Test',
- 'status' => Resource::STATUS_ACTIVE,
+ 'email' => 'test-non-existing-ldap@non-existing.org',
+ 'name' => 'Test',
+ 'status' => Resource::STATUS_ACTIVE,
]);
LDAP::createResource($resource);
@@ -539,9 +535,9 @@
$this->expectExceptionMessageMatches('/Failed to create group/');
$group = new Group([
- 'name' => 'test',
- 'email' => 'test@testldap.com',
- 'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE,
+ 'name' => 'test',
+ 'email' => 'test@testldap.com',
+ 'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE,
]);
LDAP::createGroup($group);
@@ -558,9 +554,9 @@
$this->expectExceptionMessageMatches('/Failed to create shared folder/');
$folder = new SharedFolder([
- 'email' => 'test-non-existing-ldap@non-existing.org',
- 'name' => 'Test',
- 'status' => SharedFolder::STATUS_ACTIVE,
+ 'email' => 'test-non-existing-ldap@non-existing.org',
+ 'name' => 'Test',
+ 'status' => SharedFolder::STATUS_ACTIVE,
]);
LDAP::createSharedFolder($folder);
@@ -577,8 +573,8 @@
$this->expectExceptionMessageMatches('/Failed to create user/');
$user = new User([
- 'email' => 'test-non-existing-ldap@non-existing.org',
- 'status' => User::STATUS_ACTIVE,
+ 'email' => 'test-non-existing-ldap@non-existing.org',
+ 'status' => User::STATUS_ACTIVE,
]);
LDAP::createUser($user);
@@ -595,9 +591,9 @@
$this->expectExceptionMessageMatches('/domain not found/');
$domain = new Domain([
- 'namespace' => 'testldap.com',
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
+ 'namespace' => 'testldap.com',
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
]);
LDAP::updateDomain($domain);
@@ -614,9 +610,9 @@
$this->expectExceptionMessageMatches('/group not found/');
$group = new Group([
- 'name' => 'test',
- 'email' => 'test@testldap.com',
- 'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE,
+ 'name' => 'test',
+ 'email' => 'test@testldap.com',
+ 'status' => Group::STATUS_NEW | Group::STATUS_ACTIVE,
]);
LDAP::updateGroup($group);
@@ -633,7 +629,7 @@
$this->expectExceptionMessageMatches('/resource not found/');
$resource = new Resource([
- 'email' => 'test-resource@kolab.org',
+ 'email' => 'test-resource@kolab.org',
]);
LDAP::updateResource($resource);
@@ -650,7 +646,7 @@
$this->expectExceptionMessageMatches('/folder not found/');
$folder = new SharedFolder([
- 'email' => 'test-folder-unknown@kolab.org',
+ 'email' => 'test-folder-unknown@kolab.org',
]);
LDAP::updateSharedFolder($folder);
@@ -667,8 +663,8 @@
$this->expectExceptionMessageMatches('/user not found/');
$user = new User([
- 'email' => 'test-non-existing-ldap@kolab.org',
- 'status' => User::STATUS_ACTIVE,
+ 'email' => 'test-non-existing-ldap@kolab.org',
+ 'status' => User::STATUS_ACTIVE,
]);
LDAP::updateUser($user);
diff --git a/src/tests/Feature/Backends/PGPTest.php b/src/tests/Feature/Backends/PGPTest.php
--- a/src/tests/Feature/Backends/PGPTest.php
+++ b/src/tests/Feature/Backends/PGPTest.php
@@ -4,34 +4,28 @@
use App\Backends\PGP;
use App\Backends\Roundcube;
-use App\UserAlias;
+use App\PowerDNS\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class PGPTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$user = $this->getTestUser('john@kolab.org');
$user->aliases()->where('alias', 'test-alias@kolab.org')->delete();
PGP::homedirCleanup($user);
- \App\PowerDNS\Domain::where('name', '_woat.kolab.org')->delete();
+ Domain::where('name', '_woat.kolab.org')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$user = $this->getTestUser('john@kolab.org');
$user->aliases()->where('alias', 'test-alias@kolab.org')->delete();
PGP::homedirCleanup($user);
- \App\PowerDNS\Domain::where('name', '_woat.kolab.org')->delete();
+ Domain::where('name', '_woat.kolab.org')->delete();
parent::tearDown();
}
@@ -67,28 +61,28 @@
$this->assertSame($user->email, $userIds[0]->getEmail());
$this->assertSame('', $userIds[0]->getName());
$this->assertSame('', $userIds[0]->getComment());
- $this->assertSame(true, $userIds[0]->isValid());
- $this->assertSame(false, $userIds[0]->isRevoked());
+ $this->assertTrue($userIds[0]->isValid());
+ $this->assertFalse($userIds[0]->isRevoked());
$key = $keys[0]->getPrimaryKey();
$this->assertSame(\Crypt_GPG_SubKey::ALGORITHM_RSA, $key->getAlgorithm());
$this->assertSame(0, $key->getExpirationDate());
$this->assertSame((int) \config('pgp.length'), $key->getLength());
- $this->assertSame(true, $key->hasPrivate());
- $this->assertSame(true, $key->canSign());
- $this->assertSame(false, $key->canEncrypt());
- $this->assertSame(false, $key->isRevoked());
+ $this->assertTrue($key->hasPrivate());
+ $this->assertTrue($key->canSign());
+ $this->assertFalse($key->canEncrypt());
+ $this->assertFalse($key->isRevoked());
$key = $keys[0]->getSubKeys()[1];
$this->assertSame(\Crypt_GPG_SubKey::ALGORITHM_RSA, $key->getAlgorithm());
$this->assertSame(0, $key->getExpirationDate());
$this->assertSame((int) \config('pgp.length'), $key->getLength());
- $this->assertSame(false, $key->canSign());
- $this->assertSame(true, $key->canEncrypt());
- $this->assertSame(false, $key->isRevoked());
+ $this->assertFalse($key->canSign());
+ $this->assertTrue($key->canEncrypt());
+ $this->assertFalse($key->isRevoked());
// Assert the public key in DNS
- $dns_domain = \App\PowerDNS\Domain::where('name', '_woat.kolab.org')->first();
+ $dns_domain = Domain::where('name', '_woat.kolab.org')->first();
$this->assertNotNull($dns_domain);
$dns_record = $dns_domain->records()->where('type', 'TXT')->first();
$this->assertNotNull($dns_record);
@@ -116,25 +110,25 @@
$this->assertSame('test-alias@kolab.org', $userIds[0]->getEmail());
$this->assertSame('', $userIds[0]->getName());
$this->assertSame('', $userIds[0]->getComment());
- $this->assertSame(true, $userIds[0]->isValid());
- $this->assertSame(false, $userIds[0]->isRevoked());
+ $this->assertTrue($userIds[0]->isValid());
+ $this->assertFalse($userIds[0]->isRevoked());
$key = $keys[1]->getPrimaryKey();
$this->assertSame(\Crypt_GPG_SubKey::ALGORITHM_RSA, $key->getAlgorithm());
$this->assertSame(0, $key->getExpirationDate());
$this->assertSame((int) \config('pgp.length'), $key->getLength());
- $this->assertSame(true, $key->hasPrivate());
- $this->assertSame(true, $key->canSign());
- $this->assertSame(false, $key->canEncrypt());
- $this->assertSame(false, $key->isRevoked());
+ $this->assertTrue($key->hasPrivate());
+ $this->assertTrue($key->canSign());
+ $this->assertFalse($key->canEncrypt());
+ $this->assertFalse($key->isRevoked());
$key = $keys[1]->getSubKeys()[1];
$this->assertSame(\Crypt_GPG_SubKey::ALGORITHM_RSA, $key->getAlgorithm());
$this->assertSame(0, $key->getExpirationDate());
$this->assertSame((int) \config('pgp.length'), $key->getLength());
- $this->assertSame(false, $key->canSign());
- $this->assertSame(true, $key->canEncrypt());
- $this->assertSame(false, $key->isRevoked());
+ $this->assertFalse($key->canSign());
+ $this->assertTrue($key->canEncrypt());
+ $this->assertFalse($key->isRevoked());
$this->assertSame(2, $dns_domain->records()->where('type', 'TXT')->count());
diff --git a/src/tests/Feature/Backends/RoundcubeTest.php b/src/tests/Feature/Backends/RoundcubeTest.php
--- a/src/tests/Feature/Backends/RoundcubeTest.php
+++ b/src/tests/Feature/Backends/RoundcubeTest.php
@@ -9,10 +9,7 @@
class RoundcubeTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +17,7 @@
$this->deleteTestUser('roundcube-delegatee@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('roundcube@' . \config('app.domain'));
$this->deleteTestUser('roundcube-delegatee@' . \config('app.domain'));
@@ -94,7 +88,7 @@
$this->assertSame($user->email, $idents[0]->email);
$this->assertSame('First Last', $idents[0]->name);
$this->assertSame(0, $idents[0]->standard);
- $this->assertSame(null, $idents[0]->signature);
+ $this->assertNull($idents[0]->signature);
// Test with no delegator user record (yet)
$db->table('identities')->where('user_id', $delegatee_id)->where('email', $user->email)->delete();
@@ -106,7 +100,7 @@
$this->assertSame($user->email, $idents[0]->email);
$this->assertSame('First Last', $idents[0]->name);
$this->assertSame(0, $idents[0]->standard);
- $this->assertSame(null, $idents[0]->signature);
+ $this->assertNull($idents[0]->signature);
// Test with delegator user record existing and his identity too
$db->table('identities')->where('user_id', $delegatee_id)->where('email', $user->email)->delete();
@@ -120,7 +114,7 @@
$this->assertCount(1, $idents);
$this->assertSame($user->email, $idents[0]->email);
$this->assertSame('Test', $idents[0]->name);
- $this->assertSame(null, $idents[0]->signature);
+ $this->assertNull($idents[0]->signature);
// TODO: signatures copying?
}
diff --git a/src/tests/Feature/Console/AuthAttempt/DeleteTest.php b/src/tests/Feature/Console/AuthAttempt/DeleteTest.php
--- a/src/tests/Feature/Console/AuthAttempt/DeleteTest.php
+++ b/src/tests/Feature/Console/AuthAttempt/DeleteTest.php
@@ -7,18 +7,12 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
diff --git a/src/tests/Feature/Console/AuthAttempt/ListTest.php b/src/tests/Feature/Console/AuthAttempt/ListTest.php
--- a/src/tests/Feature/Console/AuthAttempt/ListTest.php
+++ b/src/tests/Feature/Console/AuthAttempt/ListTest.php
@@ -7,19 +7,13 @@
class ListTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
AuthAttempt::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
AuthAttempt::truncate();
parent::tearDown();
@@ -39,13 +33,13 @@
$user = $this->getTestUser('john@kolab.org');
$authAttempt = AuthAttempt::recordAuthAttempt($user, '10.0.0.1');
- //For up-to date timestamps and whatnot
+ // For up-to date timestamps and whatnot
$authAttempt->refresh();
$code = \Artisan::call('authattempts');
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertSame($authAttempt->toJson(JSON_PRETTY_PRINT), $output);
+ $this->assertSame($authAttempt->toJson(\JSON_PRETTY_PRINT), $output);
}
}
diff --git a/src/tests/Feature/Console/AuthAttempt/PurgeTest.php b/src/tests/Feature/Console/AuthAttempt/PurgeTest.php
--- a/src/tests/Feature/Console/AuthAttempt/PurgeTest.php
+++ b/src/tests/Feature/Console/AuthAttempt/PurgeTest.php
@@ -2,25 +2,19 @@
namespace Tests\Feature\Console\AuthAttempt;
-use Carbon\Carbon;
use App\AuthAttempt;
+use Carbon\Carbon;
use Tests\TestCase;
class PurgeTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
AuthAttempt::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
AuthAttempt::truncate();
parent::tearDown();
diff --git a/src/tests/Feature/Console/Contact/ImportTest.php b/src/tests/Feature/Console/Contact/ImportTest.php
--- a/src/tests/Feature/Console/Contact/ImportTest.php
+++ b/src/tests/Feature/Console/Contact/ImportTest.php
@@ -7,20 +7,14 @@
class ImportTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Contact::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Contact::truncate();
diff --git a/src/tests/Feature/Console/Data/Import/LdifTest.php b/src/tests/Feature/Console/Data/Import/LdifTest.php
--- a/src/tests/Feature/Console/Data/Import/LdifTest.php
+++ b/src/tests/Feature/Console/Data/Import/LdifTest.php
@@ -2,24 +2,25 @@
namespace Tests\Feature\Console\Data\Import;
+use App\Console\Commands\Data\Import\LdifCommand;
+use App\Domain;
+use App\Group;
+use App\Resource;
+use App\SharedFolder;
+use App\User;
+use Symfony\Component\Console\Input\ArrayInput;
use Tests\TestCase;
class LdifTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('owner@kolab3.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('owner@kolab3.com');
@@ -62,7 +63,7 @@
$output
);
- $owner = \App\User::where('email', 'owner@kolab3.com')->first();
+ $owner = User::where('email', 'owner@kolab3.com')->first();
$this->assertNull($owner->password);
$this->assertSame(
@@ -92,7 +93,7 @@
// Users
$this->assertSame(2, $owner->users(false)->count());
- /** @var \App\User $user */
+ /** @var User $user */
$user = $owner->users(false)->where('email', 'user@kolab3.com')->first();
// User settings
@@ -113,20 +114,20 @@
]);
// Domains
- /** @var \App\Domain[] $domains */
+ /** @var Domain[] $domains */
$domains = $owner->domains(false, false)->orderBy('namespace')->get();
$this->assertCount(2, $domains);
$this->assertSame('kolab3-alias.com', $domains[0]->namespace);
$this->assertSame('kolab3.com', $domains[1]->namespace);
- $this->assertSame(\App\Domain::TYPE_EXTERNAL, $domains[0]->type);
- $this->assertSame(\App\Domain::TYPE_EXTERNAL, $domains[1]->type);
+ $this->assertSame(Domain::TYPE_EXTERNAL, $domains[0]->type);
+ $this->assertSame(Domain::TYPE_EXTERNAL, $domains[1]->type);
$this->assertEntitlements($domains[0], ['domain-hosting']);
$this->assertEntitlements($domains[1], ['domain-hosting']);
// Shared folders
- /** @var \App\SharedFolder[] $folders */
+ /** @var SharedFolder[] $folders */
$folders = $owner->sharedFolders(false)->orderBy('email')->get();
$this->assertCount(2, $folders);
@@ -147,7 +148,7 @@
);
// Groups
- /** @var \App\Group[] $groups */
+ /** @var Group[] $groups */
$groups = $owner->groups(false)->orderBy('email')->get();
$this->assertCount(1, $groups);
@@ -157,7 +158,7 @@
$this->assertSame('["sender@gmail.com","-"]', $groups[0]->getSetting('sender_policy'));
// Resources
- /** @var \App\Resource[] $resources */
+ /** @var Resource[] $resources */
$resources = $owner->resources(false)->orderBy('email')->get();
$this->assertCount(1, $resources);
@@ -172,7 +173,7 @@
*/
public function testParseACL(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$result = $this->invokeMethod($command, 'parseACL', [[]]);
$this->assertSame([], $result);
@@ -210,16 +211,16 @@
*/
public function testParseInvitationPolicy(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$result = $this->invokeMethod($command, 'parseInvitationPolicy', [[]]);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
$result = $this->invokeMethod($command, 'parseInvitationPolicy', [['UNKNOWN']]);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
$result = $this->invokeMethod($command, 'parseInvitationPolicy', [['ACT_ACCEPT']]);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
$result = $this->invokeMethod($command, 'parseInvitationPolicy', [['ACT_MANUAL']]);
$this->assertSame('manual', $result);
@@ -228,7 +229,7 @@
$this->assertSame('reject', $result);
$result = $this->invokeMethod($command, 'parseInvitationPolicy', [['ACT_ACCEPT_AND_NOTIFY', 'ACT_REJECT']]);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
}
/**
@@ -236,7 +237,7 @@
*/
public function testParseSenderPolicy(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$result = $this->invokeMethod($command, 'parseSenderPolicy', [[]]);
$this->assertSame([], $result);
@@ -253,7 +254,7 @@
*/
public function testParseLDAPDomain(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$entry = [];
$result = $this->invokeMethod($command, 'parseLDAPDomain', [$entry]);
@@ -263,7 +264,7 @@
$entry = ['associateddomain' => 'test.com'];
$result = $this->invokeMethod($command, 'parseLDAPDomain', [$entry]);
$this->assertSame(['namespace' => 'test.com'], $result[0]);
- $this->assertSame(null, $result[1]);
+ $this->assertNull($result[1]);
$entry = ['associateddomain' => 'test.com', 'inetdomainstatus' => 'deleted'];
$result = $this->invokeMethod($command, 'parseLDAPDomain', [$entry]);
@@ -276,7 +277,7 @@
*/
public function testParseLDAPGroup(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$entry = [];
$result = $this->invokeMethod($command, 'parseLDAPGroup', [$entry]);
@@ -309,7 +310,7 @@
$result = $this->invokeMethod($command, 'parseLDAPGroup', [$entry]);
$this->assertSame($expected, $result[0]);
- $this->assertSame(null, $result[1]);
+ $this->assertNull($result[1]);
}
/**
@@ -317,7 +318,7 @@
*/
public function testParseLDAPResource(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$entry = [];
$result = $this->invokeMethod($command, 'parseLDAPResource', [$entry]);
@@ -334,7 +335,7 @@
'mail' => 'Test@domain.tld',
'owner' => 'uid=user@kolab3.com,ou=People,ou=kolab3.com,dc=hosted,dc=com',
'kolabtargetfolder' => 'Folder',
- 'kolabinvitationpolicy' => 'ACT_REJECT'
+ 'kolabinvitationpolicy' => 'ACT_REJECT',
];
$expected = [
@@ -347,7 +348,7 @@
$result = $this->invokeMethod($command, 'parseLDAPResource', [$entry]);
$this->assertSame($expected, $result[0]);
- $this->assertSame(null, $result[1]);
+ $this->assertNull($result[1]);
}
/**
@@ -355,7 +356,7 @@
*/
public function testParseLDAPSharedFolder(): void
{
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
+ $command = new LdifCommand();
$entry = [];
$result = $this->invokeMethod($command, 'parseLDAPSharedFolder', [$entry]);
@@ -387,7 +388,7 @@
$result = $this->invokeMethod($command, 'parseLDAPSharedFolder', [$entry]);
$this->assertSame($expected, $result[0]);
- $this->assertSame(null, $result[1]);
+ $this->assertNull($result[1]);
}
/**
@@ -401,8 +402,8 @@
'owner' => 'test@domain.tld',
];
- $command = new \App\Console\Commands\Data\Import\LdifCommand();
- $command->setInput(new \Symfony\Component\Console\Input\ArrayInput($args, $command->getDefinition()));
+ $command = new LdifCommand();
+ $command->setInput(new ArrayInput($args, $command->getDefinition()));
$entry = ['cn' => 'Test'];
$result = $this->invokeMethod($command, 'parseLDAPUser', [$entry]);
@@ -438,7 +439,7 @@
$result = $this->invokeMethod($command, 'parseLDAPUser', [$entry]);
$this->assertSame($expected, $result[0]);
- $this->assertSame(null, $result[1]);
+ $this->assertNull($result[1]);
$this->assertSame($entry['dn'], $this->getObjectProperty($command, 'ownerDN'));
}
}
diff --git a/src/tests/Feature/Console/Data/Import/SignupTokensTest.php b/src/tests/Feature/Console/Data/Import/SignupTokensTest.php
--- a/src/tests/Feature/Console/Data/Import/SignupTokensTest.php
+++ b/src/tests/Feature/Console/Data/Import/SignupTokensTest.php
@@ -8,10 +8,7 @@
class SignupTokensTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
SignupToken::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Plan::where('title', 'test')->delete();
SignupToken::truncate();
@@ -55,10 +49,10 @@
$this->assertSame("The plan is not for tokens", $output);
$plan = Plan::create([
- 'title' => 'test',
- 'name' => 'Test Account',
- 'description' => 'Test',
- 'mode' => Plan::MODE_TOKEN,
+ 'title' => 'test',
+ 'name' => 'Test Account',
+ 'description' => 'Test',
+ 'mode' => Plan::MODE_TOKEN,
]);
// Non-existent input file
diff --git a/src/tests/Feature/Console/Data/InitTest.php b/src/tests/Feature/Console/Data/InitTest.php
--- a/src/tests/Feature/Console/Data/InitTest.php
+++ b/src/tests/Feature/Console/Data/InitTest.php
@@ -6,20 +6,12 @@
class InitTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
- {
- }
+ protected function tearDown(): void {}
/**
* Test the command
diff --git a/src/tests/Feature/Console/Data/Stats/CollectorTest.php b/src/tests/Feature/Console/Data/Stats/CollectorTest.php
--- a/src/tests/Feature/Console/Data/Stats/CollectorTest.php
+++ b/src/tests/Feature/Console/Data/Stats/CollectorTest.php
@@ -8,10 +8,7 @@
class CollectorTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
DB::table('transactions')->truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
DB::table('stats')->truncate();
DB::table('transactions')->truncate();
@@ -57,8 +51,8 @@
$this->assertSame(1, $stats->count());
$this->assertSame(StatsController::TYPE_PAYERS, $stats[0]->type);
- $this->assertEquals(\config('app.tenant_id'), $stats[0]->tenant_id);
- $this->assertEquals(4, $stats[0]->value); // there's 4 users in john's wallet
+ $this->assertSame((int) \config('app.tenant_id'), (int) $stats[0]->tenant_id);
+ $this->assertSame(4, $stats[0]->value); // there's 4 users in john's wallet
// TODO: More precise tests (degraded users)
}
diff --git a/src/tests/Feature/Console/Discount/ListTest.php b/src/tests/Feature/Console/Discount/ListTest.php
--- a/src/tests/Feature/Console/Discount/ListTest.php
+++ b/src/tests/Feature/Console/Discount/ListTest.php
@@ -9,7 +9,7 @@
public function testHandle(): void
{
$this->artisan('discounts')
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->markTestIncomplete();
}
diff --git a/src/tests/Feature/Console/Domain/CreateTest.php b/src/tests/Feature/Console/Domain/CreateTest.php
--- a/src/tests/Feature/Console/Domain/CreateTest.php
+++ b/src/tests/Feature/Console/Domain/CreateTest.php
@@ -2,25 +2,21 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
+use App\Tenant;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -36,23 +32,23 @@
// Existing domain
$ns = \config('app.domain');
- $code = \Artisan::call("domain:create $ns");
+ $code = \Artisan::call("domain:create {$ns}");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
- $this->assertSame("Domain $ns already exists.", $output);
+ $this->assertSame("Domain {$ns} already exists.", $output);
// Existing domain (with --force param)
- $code = \Artisan::call("domain:create $ns --force");
+ $code = \Artisan::call("domain:create {$ns} --force");
$output = trim(\Artisan::output());
$this->assertSame(1, $code);
- $this->assertSame("Domain $ns not marked as deleted... examine more closely", $output);
+ $this->assertSame("Domain {$ns} not marked as deleted... examine more closely", $output);
// A new domain
$code = \Artisan::call("domain:create domain-delete.com");
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $domain = \App\Domain::where('namespace', 'domain-delete.com')->first();
+ $domain = Domain::where('namespace', 'domain-delete.com')->first();
$this->assertSame("Domain domain-delete.com created with ID {$domain->id}. "
. "Remember to assign it to a wallet with 'domain:set-wallet'", $output);
@@ -61,7 +57,7 @@
$this->assertNull($domain->wallet());
$this->assertSame('domain-delete.com', $domain->namespace);
- $domain->status |= \App\Domain::STATUS_ACTIVE;
+ $domain->status |= Domain::STATUS_ACTIVE;
$domain->save();
$domain->delete();
@@ -86,12 +82,12 @@
$this->deleteTestDomain('domain-delete.com');
// Test --tenant option
- $tenant = \App\Tenant::orderBy('id', 'desc')->first();
+ $tenant = Tenant::orderBy('id', 'desc')->first();
$code = \Artisan::call("domain:create domain-delete.com --tenant={$tenant->id}");
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $domain = \App\Domain::where('namespace', 'domain-delete.com')->first();
+ $domain = Domain::where('namespace', 'domain-delete.com')->first();
$this->assertTrue($domain->isNew());
$this->assertSame($tenant->id, $domain->tenant_id);
diff --git a/src/tests/Feature/Console/Domain/DeleteTest.php b/src/tests/Feature/Console/Domain/DeleteTest.php
--- a/src/tests/Feature/Console/Domain/DeleteTest.php
+++ b/src/tests/Feature/Console/Domain/DeleteTest.php
@@ -2,15 +2,14 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
+use App\Package;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +17,7 @@
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@domain-delete.com');
$this->deleteTestDomain('domain-delete.com');
@@ -51,11 +47,11 @@
// Create a user account for delete
$user = $this->getTestUser('user@domain-delete.com');
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::where('title', 'kolab')->first();
- $package_domain = \App\Package::where('title', 'domain-hosting')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
+ $package_domain = Package::where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
diff --git a/src/tests/Feature/Console/Domain/ListTest.php b/src/tests/Feature/Console/Domain/ListTest.php
--- a/src/tests/Feature/Console/Domain/ListTest.php
+++ b/src/tests/Feature/Console/Domain/ListTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
use Tests\TestCase;
class ListTest extends TestCase
@@ -11,8 +12,8 @@
*/
public function testHandle(): void
{
- $domain1 = \App\Domain::where('namespace', 'kolab.org')->first();
- $domain2 = \App\Domain::whereNot('tenant_id', $domain1->tenant_id)->first();
+ $domain1 = Domain::where('namespace', 'kolab.org')->first();
+ $domain2 = Domain::whereNot('tenant_id', $domain1->tenant_id)->first();
// List domains for a specified tenant
$code = \Artisan::call("domains --tenant={$domain1->tenant_id}");
diff --git a/src/tests/Feature/Console/Domain/RestoreTest.php b/src/tests/Feature/Console/Domain/RestoreTest.php
--- a/src/tests/Feature/Console/Domain/RestoreTest.php
+++ b/src/tests/Feature/Console/Domain/RestoreTest.php
@@ -2,15 +2,14 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
+use App\Package;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class RestoreTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +17,7 @@
$this->deleteTestDomain('force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
$this->deleteTestDomain('force-delete.com');
@@ -45,11 +41,11 @@
// Create a user account for delete
$user = $this->getTestUser('user@force-delete.com');
$domain = $this->getTestDomain('force-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::where('title', 'kolab')->first();
- $package_domain = \App\Package::where('title', 'domain-hosting')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
+ $package_domain = Package::where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
$wallet = $user->wallets()->first();
diff --git a/src/tests/Feature/Console/Domain/SetStatusTest.php b/src/tests/Feature/Console/Domain/SetStatusTest.php
--- a/src/tests/Feature/Console/Domain/SetStatusTest.php
+++ b/src/tests/Feature/Console/Domain/SetStatusTest.php
@@ -2,25 +2,21 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
+use App\Jobs\Domain\UpdateJob;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SetStatusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -39,20 +35,20 @@
$this->assertSame("Domain not found.", $output);
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
Queue::fake();
- $code = \Artisan::call("domain:set-status domain-delete.com " . \App\Domain::STATUS_LDAP_READY);
+ $code = \Artisan::call("domain:set-status domain-delete.com " . Domain::STATUS_LDAP_READY);
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
$this->assertSame('Status (64): ldapReady (64)', $output);
- Queue::assertPushed(\App\Jobs\Domain\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
$domain->refresh();
- $this->assertSame(\App\Domain::STATUS_LDAP_READY, $domain->status);
+ $this->assertSame(Domain::STATUS_LDAP_READY, $domain->status);
}
}
diff --git a/src/tests/Feature/Console/Domain/SetWalletTest.php b/src/tests/Feature/Console/Domain/SetWalletTest.php
--- a/src/tests/Feature/Console/Domain/SetWalletTest.php
+++ b/src/tests/Feature/Console/Domain/SetWalletTest.php
@@ -2,25 +2,21 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
+use App\Sku;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SetWalletTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -41,8 +37,8 @@
$this->assertSame("Domain not found.", $output);
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
// Non-existing wallet
@@ -67,7 +63,7 @@
$this->assertSame('', $output);
$domain->refresh();
- $sku = \App\Sku::withObjectTenantContext($domain)->where('title', 'domain-hosting')->first();
+ $sku = Sku::withObjectTenantContext($domain)->where('title', 'domain-hosting')->first();
$entitlement = $domain->entitlements()->first();
$this->assertSame($sku->id, $entitlement->sku_id);
diff --git a/src/tests/Feature/Console/Domain/StatusTest.php b/src/tests/Feature/Console/Domain/StatusTest.php
--- a/src/tests/Feature/Console/Domain/StatusTest.php
+++ b/src/tests/Feature/Console/Domain/StatusTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class StatusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -52,8 +47,8 @@
// Test deleted domain
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$domain->delete();
diff --git a/src/tests/Feature/Console/Domain/SuspendTest.php b/src/tests/Feature/Console/Domain/SuspendTest.php
--- a/src/tests/Feature/Console/Domain/SuspendTest.php
+++ b/src/tests/Feature/Console/Domain/SuspendTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -41,8 +36,8 @@
$this->assertSame("Domain not found.", $output);
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$code = \Artisan::call("domain:suspend {$domain->namespace}");
diff --git a/src/tests/Feature/Console/Domain/UnsuspendTest.php b/src/tests/Feature/Console/Domain/UnsuspendTest.php
--- a/src/tests/Feature/Console/Domain/UnsuspendTest.php
+++ b/src/tests/Feature/Console/Domain/UnsuspendTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\Domain;
+use App\Domain;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UnsuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -41,8 +36,8 @@
$this->assertSame("Domain not found.", $output);
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => \App\Domain::STATUS_NEW | \App\Domain::STATUS_SUSPENDED,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED,
+ 'type' => Domain::TYPE_HOSTED,
]);
$this->assertTrue($domain->isSuspended());
diff --git a/src/tests/Feature/Console/Domain/UsersTest.php b/src/tests/Feature/Console/Domain/UsersTest.php
--- a/src/tests/Feature/Console/Domain/UsersTest.php
+++ b/src/tests/Feature/Console/Domain/UsersTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Console\Domain;
+use App\User;
use Tests\TestCase;
class UsersTest extends TestCase
@@ -16,9 +17,9 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $john = \App\User::where('email', 'john@kolab.org')->first();
+ $john = User::where('email', 'john@kolab.org')->first();
- $this->assertTrue(strpos($output, (string) $john->id) !== false);
+ $this->assertTrue(str_contains($output, (string) $john->id));
// TODO: Test output format and additional attributes
}
diff --git a/src/tests/Feature/Console/Group/AddMemberTest.php b/src/tests/Feature/Console/Group/AddMemberTest.php
--- a/src/tests/Feature/Console/Group/AddMemberTest.php
+++ b/src/tests/Feature/Console/Group/AddMemberTest.php
@@ -8,10 +8,7 @@
class AddMemberTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
$this->deleteTestGroup('group-test@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
$this->deleteTestGroup('group-test@kolab.org');
diff --git a/src/tests/Feature/Console/Group/CreateTest.php b/src/tests/Feature/Console/Group/CreateTest.php
--- a/src/tests/Feature/Console/Group/CreateTest.php
+++ b/src/tests/Feature/Console/Group/CreateTest.php
@@ -8,10 +8,7 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
$this->deleteTestGroup('group-testm@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
$this->deleteTestGroup('group-testm@kolab.org');
@@ -72,7 +66,7 @@
$group = Group::where('email', 'group-test@kolab.org')->first();
$this->assertSame(0, $code);
- $this->assertEquals($group->id, $output);
+ $this->assertSame((string) $group->id, $output);
$this->assertSame([], $group->members);
$this->assertSame($user->wallets->first()->id, $group->wallet()->id);
@@ -95,7 +89,7 @@
$output = trim(\Artisan::output());
$group = Group::where('email', 'group-testm@kolab.org')->first();
$this->assertSame(0, $code);
- $this->assertEquals($group->id, $output);
+ $this->assertSame((string) $group->id, $output);
$this->assertSame(['member1@kolabnow.com', 'member2@gmail.com'], $group->members);
$this->assertSame($user->wallets->first()->id, $group->wallet()->id);
}
diff --git a/src/tests/Feature/Console/Group/DeleteTest.php b/src/tests/Feature/Console/Group/DeleteTest.php
--- a/src/tests/Feature/Console/Group/DeleteTest.php
+++ b/src/tests/Feature/Console/Group/DeleteTest.php
@@ -8,10 +8,7 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
$this->deleteTestUser('group-owner@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
$this->deleteTestUser('group-owner@kolabnow.com');
diff --git a/src/tests/Feature/Console/Group/ForceDeleteTest.php b/src/tests/Feature/Console/Group/ForceDeleteTest.php
--- a/src/tests/Feature/Console/Group/ForceDeleteTest.php
+++ b/src/tests/Feature/Console/Group/ForceDeleteTest.php
@@ -8,20 +8,14 @@
class ForceDeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/Group/InfoTest.php b/src/tests/Feature/Console/Group/InfoTest.php
--- a/src/tests/Feature/Console/Group/InfoTest.php
+++ b/src/tests/Feature/Console/Group/InfoTest.php
@@ -8,20 +8,14 @@
class InfoTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/Group/RemoveMemberTest.php b/src/tests/Feature/Console/Group/RemoveMemberTest.php
--- a/src/tests/Feature/Console/Group/RemoveMemberTest.php
+++ b/src/tests/Feature/Console/Group/RemoveMemberTest.php
@@ -8,20 +8,14 @@
class RemoveMemberTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
@@ -46,8 +40,8 @@
$this->assertSame("Group test@group.com does not exist.", $output);
$group = Group::create([
- 'email' => 'group-test@kolabnow.com',
- 'members' => ['member1@gmail.com', 'member2@gmail.com'],
+ 'email' => 'group-test@kolabnow.com',
+ 'members' => ['member1@gmail.com', 'member2@gmail.com'],
]);
// Existing group, non-existing member
diff --git a/src/tests/Feature/Console/Group/RestoreTest.php b/src/tests/Feature/Console/Group/RestoreTest.php
--- a/src/tests/Feature/Console/Group/RestoreTest.php
+++ b/src/tests/Feature/Console/Group/RestoreTest.php
@@ -8,20 +8,14 @@
class RestoreTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/Group/SuspendTest.php b/src/tests/Feature/Console/Group/SuspendTest.php
--- a/src/tests/Feature/Console/Group/SuspendTest.php
+++ b/src/tests/Feature/Console/Group/SuspendTest.php
@@ -9,10 +9,7 @@
class SuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +17,7 @@
EventLog::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
EventLog::truncate();
@@ -55,7 +49,7 @@
$this->assertSame("", $output);
$this->assertTrue($group->fresh()->isSuspended());
$event = EventLog::where('object_id', $group->id)->where('object_type', Group::class)->first();
- $this->assertSame(null, $event->comment);
+ $this->assertNull($event->comment);
$this->assertSame(EventLog::TYPE_SUSPENDED, $event->type);
$group->unsuspend();
diff --git a/src/tests/Feature/Console/Group/UnsuspendTest.php b/src/tests/Feature/Console/Group/UnsuspendTest.php
--- a/src/tests/Feature/Console/Group/UnsuspendTest.php
+++ b/src/tests/Feature/Console/Group/UnsuspendTest.php
@@ -9,10 +9,7 @@
class UnsuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +17,7 @@
EventLog::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolabnow.com');
EventLog::truncate();
@@ -56,7 +50,7 @@
$this->assertSame("", $output);
$this->assertFalse($group->fresh()->isSuspended());
$event = EventLog::where('object_id', $group->id)->where('object_type', Group::class)->first();
- $this->assertSame(null, $event->comment);
+ $this->assertNull($event->comment);
$this->assertSame(EventLog::TYPE_UNSUSPENDED, $event->type);
$group->suspend();
diff --git a/src/tests/Feature/Console/OwnerSwapTest.php b/src/tests/Feature/Console/OwnerSwapTest.php
--- a/src/tests/Feature/Console/OwnerSwapTest.php
+++ b/src/tests/Feature/Console/OwnerSwapTest.php
@@ -2,16 +2,15 @@
namespace Tests\Feature\Console;
+use App\Domain;
+use App\Package;
use Illuminate\Support\Facades\Queue;
use Mollie\Laravel\Facades\Mollie;
use Tests\TestCase;
class OwnerSwapTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +19,7 @@
$this->deleteTestDomain('owner-swap.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user1@owner-swap.com');
$this->deleteTestUser('user2@owner-swap.com');
@@ -45,11 +41,11 @@
$owner = $this->getTestUser('user1@owner-swap.com');
$user = $this->getTestUser('user2@owner-swap.com');
$domain = $this->getTestDomain('owner-swap.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$owner->assignPackage($package_kolab);
$owner->assignPackage($package_kolab, $user);
$domain->assignPackage($package_domain, $owner);
@@ -100,7 +96,7 @@
$this->assertSame('test', $user->getSetting('plan_id'));
$wallet->refresh();
- $this->assertSame(null, $wallet->getSetting('test'));
+ $this->assertNull($wallet->getSetting('test'));
$this->assertSame(0, $wallet->balance);
$target_customer = $this->getMollieCustomer($target_wallet->getSetting('mollie_id'));
@@ -124,8 +120,8 @@
private function createMollieCustomer($wallet)
{
$customer = Mollie::api()->customers->create([
- 'name' => $wallet->owner->name(),
- 'email' => $wallet->id . '@private.' . \config('app.domain'),
+ 'name' => $wallet->owner->name(),
+ 'email' => $wallet->id . '@private.' . \config('app.domain'),
]);
$customer_id = $customer->id;
diff --git a/src/tests/Feature/Console/Package/SkusTest.php b/src/tests/Feature/Console/Package/SkusTest.php
--- a/src/tests/Feature/Console/Package/SkusTest.php
+++ b/src/tests/Feature/Console/Package/SkusTest.php
@@ -9,7 +9,7 @@
public function testHandle(): void
{
$this->artisan('package:skus')
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->markTestIncomplete();
}
diff --git a/src/tests/Feature/Console/PasswordRetentionTest.php b/src/tests/Feature/Console/PasswordRetentionTest.php
--- a/src/tests/Feature/Console/PasswordRetentionTest.php
+++ b/src/tests/Feature/Console/PasswordRetentionTest.php
@@ -2,36 +2,31 @@
namespace Tests\Feature\Console;
-use App\Jobs\MailJob;
use App\Jobs\Mail\PasswordRetentionJob;
+use App\Package;
use App\User;
+use App\UserSetting;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class PasswordRetentionTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user1@retention.com');
$this->deleteTestUser('user2@retention.com');
$keys = ['password_update', 'max_password_age', 'password_expiration_warning'];
- \App\UserSetting::whereIn('key', $keys)->delete();
+ UserSetting::whereIn('key', $keys)->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user1@retention.com');
$this->deleteTestUser('user2@retention.com');
$keys = ['password_update', 'max_password_age', 'password_expiration_warning'];
- \App\UserSetting::whereIn('key', $keys)->delete();
+ UserSetting::whereIn('key', $keys)->delete();
parent::tearDown();
}
@@ -49,7 +44,7 @@
$status = User::STATUS_IMAP_READY | User::STATUS_LDAP_READY;
$owner = $this->getTestUser('user1@retention.com', ['status' => $status]);
$user = $this->getTestUser('user2@retention.com', ['status' => $status]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
$owner->assignPackage($package_kolab);
$owner->assignPackage($package_kolab, $user);
@@ -91,11 +86,11 @@
$this->assertSame("", $output);
Queue::assertPushed(PasswordRetentionJob::class, 2);
- Queue::assertPushed(PasswordRetentionJob::class, function ($job) use ($user) {
+ Queue::assertPushed(PasswordRetentionJob::class, static function ($job) use ($user) {
$job_user = TestCase::getObjectProperty($job, 'user');
return $job_user->id === $user->id;
});
- Queue::assertPushed(PasswordRetentionJob::class, function ($job) use ($owner) {
+ Queue::assertPushed(PasswordRetentionJob::class, static function ($job) use ($owner) {
$job_user = TestCase::getObjectProperty($job, 'user');
return $job_user->id === $owner->id;
});
@@ -110,7 +105,7 @@
$this->assertSame(0, $code);
Queue::assertPushed(PasswordRetentionJob::class, 1);
- Queue::assertPushed(PasswordRetentionJob::class, function ($job) use ($user) {
+ Queue::assertPushed(PasswordRetentionJob::class, static function ($job) use ($user) {
$job_user = TestCase::getObjectProperty($job, 'user');
return $job_user->id === $user->id;
});
diff --git a/src/tests/Feature/Console/Plan/PackagesTest.php b/src/tests/Feature/Console/Plan/PackagesTest.php
--- a/src/tests/Feature/Console/Plan/PackagesTest.php
+++ b/src/tests/Feature/Console/Plan/PackagesTest.php
@@ -9,7 +9,7 @@
public function testHandle(): void
{
$this->artisan('plan:packages')
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->markTestIncomplete();
}
diff --git a/src/tests/Feature/Console/Scalpel/Domain/CreateCommandTest.php b/src/tests/Feature/Console/Scalpel/Domain/CreateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/Domain/CreateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/Domain/CreateCommandTest.php
@@ -3,24 +3,19 @@
namespace Tests\Feature\Console\Scalpel\Domain;
use App\Domain;
+use App\Tenant;
use Tests\TestCase;
class CreateCommandTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
@@ -42,7 +37,7 @@
$this->assertStringContainsString('--status[=STATUS]', $output);
$this->assertStringContainsString('--tenant_id[=TENANT_ID]', $output);
- $tenant = \App\Tenant::orderBy('id', 'desc')->first();
+ $tenant = Tenant::orderBy('id', 'desc')->first();
// Test successful domain creation
$code = \Artisan::call(
diff --git a/src/tests/Feature/Console/Scalpel/Domain/UpdateCommandTest.php b/src/tests/Feature/Console/Scalpel/Domain/UpdateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/Domain/UpdateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/Domain/UpdateCommandTest.php
@@ -7,10 +7,7 @@
class UpdateCommandTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +15,7 @@
$this->deleteTestDomain('domain-delete-mod.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-delete.com');
$this->deleteTestDomain('domain-delete-mod.com');
@@ -36,18 +30,18 @@
{
// Test unknown domain
$this->artisan("scalpel:domain:update unknown")
- ->assertExitCode(1)
- ->expectsOutput("No such domain unknown");
+ ->assertExitCode(1)
+ ->expectsOutput("No such domain unknown");
$domain = $this->getTestDomain('domain-delete.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
// Test successful update
$this->artisan("scalpel:domain:update {$domain->id}"
. " --namespace=domain-delete-mod.com --type=" . Domain::TYPE_PUBLIC)
- ->assertExitCode(0);
+ ->assertExitCode(0);
$domain->refresh();
diff --git a/src/tests/Feature/Console/Scalpel/TenantSetting/CreateCommandTest.php b/src/tests/Feature/Console/Scalpel/TenantSetting/CreateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/TenantSetting/CreateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/TenantSetting/CreateCommandTest.php
@@ -2,26 +2,22 @@
namespace Tests\Feature\Console\Scalpel\TenantSetting;
+use App\Tenant;
+use App\TenantSetting;
use Tests\TestCase;
class CreateCommandTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
parent::tearDown();
}
@@ -31,10 +27,10 @@
*/
public function testHandle(): void
{
- $tenant = \App\Tenant::whereNotIn('id', [1])->first();
+ $tenant = Tenant::whereNotIn('id', [1])->first();
$this->artisan("scalpel:tenant-setting:create --key=test --value=init --tenant_id={$tenant->id}")
- ->assertExitCode(0);
+ ->assertExitCode(0);
$setting = $tenant->settings()->where('key', 'test')->first();
diff --git a/src/tests/Feature/Console/Scalpel/TenantSetting/UpdateCommandTest.php b/src/tests/Feature/Console/Scalpel/TenantSetting/UpdateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/TenantSetting/UpdateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/TenantSetting/UpdateCommandTest.php
@@ -2,26 +2,22 @@
namespace Tests\Feature\Console\Scalpel\TenantSetting;
+use App\Tenant;
+use App\TenantSetting;
use Tests\TestCase;
class UpdateCommandTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
parent::tearDown();
}
@@ -29,17 +25,17 @@
public function testHandle(): void
{
$this->artisan("scalpel:tenant-setting:update unknown --value=test")
- ->assertExitCode(1)
- ->expectsOutput("No such tenant-setting unknown");
+ ->assertExitCode(1)
+ ->expectsOutput("No such tenant-setting unknown");
- $tenant = \App\Tenant::whereNotIn('id', [1])->first();
+ $tenant = Tenant::whereNotIn('id', [1])->first();
$tenant->setSetting('test', 'test-old');
$setting = $tenant->settings()->where('key', 'test')->first();
$this->assertSame('test-old', $setting->value);
$this->artisan("scalpel:tenant-setting:update {$setting->id} --value=test")
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertSame('test', $setting->fresh()->value);
$this->assertSame('test', $tenant->fresh()->getSetting('test'));
diff --git a/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php b/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/WalletSetting/CreateCommandTest.php
@@ -13,7 +13,7 @@
$wallet->setSetting('test', null);
$this->artisan("scalpel:wallet-setting:create --key=test --value=init --wallet_id={$wallet->id}")
- ->assertExitCode(0);
+ ->assertExitCode(0);
$setting = $wallet->settings()->where('key', 'test')->first();
diff --git a/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php b/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php
--- a/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php
+++ b/src/tests/Feature/Console/Scalpel/WalletSetting/UpdateCommandTest.php
@@ -13,13 +13,13 @@
$wallet->setSetting('test', 'init');
$this->artisan("scalpel:wallet-setting:update unknown --value=test")
- ->assertExitCode(1)
- ->expectsOutput("No such wallet-setting unknown");
+ ->assertExitCode(1)
+ ->expectsOutput("No such wallet-setting unknown");
$setting = $wallet->settings()->where('key', 'test')->first();
$this->artisan("scalpel:wallet-setting:update {$setting->id} --value=test")
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertSame('test', $setting->fresh()->value);
$this->assertSame('test', $wallet->fresh()->getSetting('test'));
diff --git a/src/tests/Feature/Console/SharedFolder/AddAliasTest.php b/src/tests/Feature/Console/SharedFolder/AddAliasTest.php
--- a/src/tests/Feature/Console/SharedFolder/AddAliasTest.php
+++ b/src/tests/Feature/Console/SharedFolder/AddAliasTest.php
@@ -2,14 +2,13 @@
namespace Tests\Feature\Console\SharedFolder;
+use App\Domain;
+use App\Package;
use Tests\TestCase;
class AddAliasTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +17,7 @@
$this->deleteTestDomain('force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@force-delete.com');
$this->deleteTestUser('user@force-delete.com');
@@ -44,11 +40,11 @@
$user = $this->getTestUser('user@force-delete.com');
$domain = $this->getTestDomain('force-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
$folder = $this->getTestSharedFolder('folder-test@force-delete.com');
diff --git a/src/tests/Feature/Console/SharedFolder/CreateTest.php b/src/tests/Feature/Console/SharedFolder/CreateTest.php
--- a/src/tests/Feature/Console/SharedFolder/CreateTest.php
+++ b/src/tests/Feature/Console/SharedFolder/CreateTest.php
@@ -8,10 +8,7 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +17,7 @@
}
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if ($folder = SharedFolder::withTrashed()->where('name', 'Tasks')->first()) {
$folder->forceDelete();
@@ -78,7 +72,7 @@
// Create a folder
$acl = '--acl="anyone, read-only" --acl="jack@kolab.org, full"';
- $code = \Artisan::call("sharedfolder:create kolab.org Tasks --type=task $acl");
+ $code = \Artisan::call("sharedfolder:create kolab.org Tasks --type=task {$acl}");
$output = trim(\Artisan::output());
$folder = SharedFolder::find($output);
diff --git a/src/tests/Feature/Console/SharedFolder/DeleteTest.php b/src/tests/Feature/Console/SharedFolder/DeleteTest.php
--- a/src/tests/Feature/Console/SharedFolder/DeleteTest.php
+++ b/src/tests/Feature/Console/SharedFolder/DeleteTest.php
@@ -2,16 +2,12 @@
namespace Tests\Feature\Console\SharedFolder;
-use App\SharedFolder;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +15,7 @@
$this->deleteTestUser('folder-owner@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@kolabnow.com');
$this->deleteTestUser('folder-owner@kolabnow.com');
diff --git a/src/tests/Feature/Console/SharedFolder/ForceDeleteTest.php b/src/tests/Feature/Console/SharedFolder/ForceDeleteTest.php
--- a/src/tests/Feature/Console/SharedFolder/ForceDeleteTest.php
+++ b/src/tests/Feature/Console/SharedFolder/ForceDeleteTest.php
@@ -8,20 +8,14 @@
class ForceDeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestSharedFolder('folder-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/Sku/ListUsersTest.php b/src/tests/Feature/Console/Sku/ListUsersTest.php
--- a/src/tests/Feature/Console/Sku/ListUsersTest.php
+++ b/src/tests/Feature/Console/Sku/ListUsersTest.php
@@ -3,7 +3,6 @@
namespace Tests\Feature\Console\Sku;
use App\Tenant;
-use Illuminate\Contracts\Console\Kernel;
use Tests\TestCase;
class ListUsersTest extends TestCase
diff --git a/src/tests/Feature/Console/Status/HealthTest.php b/src/tests/Feature/Console/Status/HealthTest.php
--- a/src/tests/Feature/Console/Status/HealthTest.php
+++ b/src/tests/Feature/Console/Status/HealthTest.php
@@ -2,12 +2,12 @@
namespace Tests\Feature\Console\Status;
-use Tests\TestCase;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
use App\Support\Facades\Roundcube;
use App\Support\Facades\Storage;
+use Tests\TestCase;
class HealthTest extends TestCase
{
diff --git a/src/tests/Feature/Console/Tenant/CreateTest.php b/src/tests/Feature/Console/Tenant/CreateTest.php
--- a/src/tests/Feature/Console/Tenant/CreateTest.php
+++ b/src/tests/Feature/Console/Tenant/CreateTest.php
@@ -2,6 +2,12 @@
namespace Tests\Feature\Console\Tenant;
+use App\Domain;
+use App\Package;
+use App\Plan;
+use App\Sku;
+use App\Tenant;
+use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@@ -9,33 +15,27 @@
{
private $tenantId;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('unknown@user.com');
$this->deleteTestDomain('tenant.com');
$this->deleteTestDomain('user.com');
- \App\Tenant::where('title', 'Test Tenant')->delete();
+ Tenant::where('title', 'Test Tenant')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if ($this->tenantId) {
Queue::fake();
- \App\User::where('tenant_id', $this->tenantId)->forceDelete();
- \App\Plan::where('tenant_id', $this->tenantId)->delete();
- \App\Package::where('tenant_id', $this->tenantId)->delete();
- \App\Sku::where('tenant_id', $this->tenantId)->delete();
- \App\Domain::where('tenant_id', $this->tenantId)->delete();
- \App\Tenant::find($this->tenantId)->delete();
+ User::where('tenant_id', $this->tenantId)->forceDelete();
+ Plan::where('tenant_id', $this->tenantId)->delete();
+ Package::where('tenant_id', $this->tenantId)->delete();
+ Sku::where('tenant_id', $this->tenantId)->delete();
+ Domain::where('tenant_id', $this->tenantId)->delete();
+ Tenant::find($this->tenantId)->delete();
}
$this->deleteTestUser('unknown@user.com');
@@ -66,22 +66,22 @@
preg_match("/Created tenant ([0-9]+)./", $output, $matches);
$this->tenantId = $matches[1];
- $tenant = \App\Tenant::find($this->tenantId);
+ $tenant = Tenant::find($this->tenantId);
$this->assertNotEmpty($tenant);
$this->assertSame('Test Tenant', $tenant->title);
preg_match("/Created user ([0-9]+)./", $output, $matches);
$userId = $matches[1];
- $user = \App\User::find($userId);
+ $user = User::find($userId);
$this->assertNotEmpty($user);
$this->assertSame('reseller', $user->role);
$this->assertSame($tenant->id, $user->tenant_id);
// Assert cloned SKUs
- $skus = \App\Sku::where('tenant_id', \config('app.tenant_id'))->where('active', true);
+ $skus = Sku::where('tenant_id', \config('app.tenant_id'))->where('active', true);
$skus->each(function ($sku) use ($tenant) {
- $sku_new = \App\Sku::where('tenant_id', $tenant->id)
+ $sku_new = Sku::where('tenant_id', $tenant->id)
->where('title', $sku->title)->get();
$this->assertSame(1, $sku_new->count());
diff --git a/src/tests/Feature/Console/Tenant/ListSettingsTest.php b/src/tests/Feature/Console/Tenant/ListSettingsTest.php
--- a/src/tests/Feature/Console/Tenant/ListSettingsTest.php
+++ b/src/tests/Feature/Console/Tenant/ListSettingsTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\Tenant;
+use App\Tenant;
use App\TenantSetting;
use Tests\TestCase;
class ListSettingsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
TenantSetting::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
TenantSetting::truncate();
@@ -37,7 +32,7 @@
$this->assertSame(1, $code);
$this->assertSame("Unable to find the tenant.", $output);
- $tenant = \App\Tenant::whereNotIn('id', [1])->first();
+ $tenant = Tenant::whereNotIn('id', [1])->first();
// A tenant without settings
$code = \Artisan::call("tenant:list-settings {$tenant->id}");
diff --git a/src/tests/Feature/Console/User/AddAliasTest.php b/src/tests/Feature/Console/User/AddAliasTest.php
--- a/src/tests/Feature/Console/User/AddAliasTest.php
+++ b/src/tests/Feature/Console/User/AddAliasTest.php
@@ -2,14 +2,13 @@
namespace Tests\Feature\Console\User;
+use App\Domain;
+use App\Package;
use Tests\TestCase;
class AddAliasTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -17,10 +16,7 @@
$this->deleteTestDomain('force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
$this->deleteTestDomain('force-delete.com');
@@ -42,11 +38,11 @@
$user = $this->getTestUser('user@force-delete.com');
$domain = $this->getTestDomain('force-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
diff --git a/src/tests/Feature/Console/User/AssignSkuTest.php b/src/tests/Feature/Console/User/AssignSkuTest.php
--- a/src/tests/Feature/Console/User/AssignSkuTest.php
+++ b/src/tests/Feature/Console/User/AssignSkuTest.php
@@ -2,24 +2,19 @@
namespace Tests\Feature\Console\User;
+use App\Sku;
use Tests\TestCase;
class AssignSkuTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('add-entitlement@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('add-entitlement@kolabnow.com');
@@ -31,32 +26,32 @@
*/
public function testHandle(): void
{
- $sku = \App\Sku::withEnvTenantContext()->where('title', 'groupware')->first();
+ $sku = Sku::withEnvTenantContext()->where('title', 'groupware')->first();
$user = $this->getTestUser('add-entitlement@kolabnow.com');
$this->artisan('user:assign-sku unknown@unknown.org ' . $sku->id)
- ->assertExitCode(1)
- ->expectsOutput("User not found.");
+ ->assertExitCode(1)
+ ->expectsOutput("User not found.");
$this->artisan('user:assign-sku ' . $user->email . ' unknownsku')
- ->assertExitCode(1)
- ->expectsOutput("Unable to find the SKU unknownsku.");
+ ->assertExitCode(1)
+ ->expectsOutput("Unable to find the SKU unknownsku.");
$this->artisan('user:assign-sku ' . $user->email . ' ' . $sku->id)
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertCount(1, $user->entitlements()->where('sku_id', $sku->id)->get());
// Try again (also test sku by title)
$this->artisan('user:assign-sku ' . $user->email . ' ' . $sku->title)
- ->assertExitCode(1)
- ->expectsOutput("The entitlement already exists. Maybe try with --qty=X?");
+ ->assertExitCode(1)
+ ->expectsOutput("The entitlement already exists. Maybe try with --qty=X?");
$this->assertCount(1, $user->entitlements()->where('sku_id', $sku->id)->get());
// Try again with --qty option, to force the assignment
$this->artisan('user:assign-sku ' . $user->email . ' ' . $sku->title . ' --qty=1')
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertCount(2, $user->entitlements()->where('sku_id', $sku->id)->get());
}
diff --git a/src/tests/Feature/Console/User/CreateTest.php b/src/tests/Feature/Console/User/CreateTest.php
--- a/src/tests/Feature/Console/User/CreateTest.php
+++ b/src/tests/Feature/Console/User/CreateTest.php
@@ -8,10 +8,7 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +18,7 @@
$this->deleteTestUser('reseller@unknown.domain.tld');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@kolab.org');
$this->deleteTestUser('user@kolabnow.com');
@@ -73,7 +67,7 @@
$output = trim(\Artisan::output());
$user = User::where('email', 'user@kolab.org')->first();
$this->assertSame(0, $code);
- $this->assertEquals($user->id, $output);
+ $this->assertSame((string) $user->id, $output);
$this->assertSame(1, $user->countEntitlementsBySku('mailbox'));
$this->assertSame(1, $user->countEntitlementsBySku('groupware'));
$this->assertSame(5, $user->countEntitlementsBySku('storage'));
@@ -83,23 +77,23 @@
$output = trim(\Artisan::output());
$user = User::where('email', 'admin@kolab.org')->first();
$this->assertSame(0, $code);
- $this->assertEquals($user->id, $output);
- $this->assertEquals($user->role, User::ROLE_ADMIN);
+ $this->assertSame((string) $user->id, $output);
+ $this->assertSame($user->role, User::ROLE_ADMIN);
// Valid (reseller)
$code = \Artisan::call("user:create reseller@unknown.domain.tld --role=reseller --password=simple123");
$output = trim(\Artisan::output());
$user = User::where('email', 'reseller@unknown.domain.tld')->first();
$this->assertSame(0, $code);
- $this->assertEquals($user->id, $output);
- $this->assertEquals($user->role, User::ROLE_RESELLER);
+ $this->assertSame((string) $user->id, $output);
+ $this->assertSame($user->role, User::ROLE_RESELLER);
// Valid (public domain)
$code = \Artisan::call("user:create user@kolabnow.com");
$output = trim(\Artisan::output());
$user = User::where('email', 'user@kolabnow.com')->first();
$this->assertSame(0, $code);
- $this->assertEquals($user->id, $output);
+ $this->assertSame((string) $user->id, $output);
// Invalid role
$code = \Artisan::call("user:create unknwon@kolab.org --role=unknown");
@@ -112,7 +106,7 @@
$output = trim(\Artisan::output());
$user = User::where('email', 'reseller@unknown.domain.tld')->first();
$this->assertSame(1, $code);
- $this->assertEquals("Email address is already in use", $output);
+ $this->assertSame("Email address is already in use", $output);
// TODO: Test a case where deleted user exists
}
diff --git a/src/tests/Feature/Console/User/DegradeTest.php b/src/tests/Feature/Console/User/DegradeTest.php
--- a/src/tests/Feature/Console/User/DegradeTest.php
+++ b/src/tests/Feature/Console/User/DegradeTest.php
@@ -7,20 +7,14 @@
class DegradeTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user-degrade-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-degrade-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/User/DeleteTest.php b/src/tests/Feature/Console/User/DeleteTest.php
--- a/src/tests/Feature/Console/User/DeleteTest.php
+++ b/src/tests/Feature/Console/User/DeleteTest.php
@@ -6,20 +6,14 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
diff --git a/src/tests/Feature/Console/User/EntitlementsTest.php b/src/tests/Feature/Console/User/EntitlementsTest.php
--- a/src/tests/Feature/Console/User/EntitlementsTest.php
+++ b/src/tests/Feature/Console/User/EntitlementsTest.php
@@ -21,8 +21,8 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertTrue(strpos($output, "storage: 5") !== false);
- $this->assertTrue(strpos($output, "mailbox: 1") !== false);
- $this->assertTrue(strpos($output, "groupware: 1") !== false);
+ $this->assertTrue(str_contains($output, "storage: 5"));
+ $this->assertTrue(str_contains($output, "mailbox: 1"));
+ $this->assertTrue(str_contains($output, "groupware: 1"));
}
}
diff --git a/src/tests/Feature/Console/User/ForceDeleteTest.php b/src/tests/Feature/Console/User/ForceDeleteTest.php
--- a/src/tests/Feature/Console/User/ForceDeleteTest.php
+++ b/src/tests/Feature/Console/User/ForceDeleteTest.php
@@ -2,15 +2,18 @@
namespace Tests\Feature\Console\User;
+use App\Domain;
+use App\Entitlement;
+use App\Package;
+use App\Transaction;
+use App\User;
+use App\Wallet;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class ForceDeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +21,7 @@
$this->deleteTestDomain('force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
$this->deleteTestDomain('force-delete.com');
@@ -36,16 +36,16 @@
{
// Non-existing user
$this->artisan('user:force-delete unknown@unknown.org')
- ->assertExitCode(1);
+ ->assertExitCode(1);
Queue::fake();
$user = $this->getTestUser('user@force-delete.com');
$domain = $this->getTestDomain('force-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
$wallet = $user->wallets()->first();
@@ -55,7 +55,7 @@
// Non-deleted user
$this->artisan('user:force-delete user@force-delete.com')
- ->assertExitCode(1);
+ ->assertExitCode(1);
$user->delete();
@@ -64,33 +64,33 @@
// Deleted user
$this->artisan('user:force-delete user@force-delete.com')
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertCount(
0,
- \App\User::withTrashed()->where('email', 'user@force-delete.com')->get()
+ User::withTrashed()->where('email', 'user@force-delete.com')->get()
);
$this->assertCount(
0,
- \App\Domain::withTrashed()->where('namespace', 'force-delete.com')->get()
+ Domain::withTrashed()->where('namespace', 'force-delete.com')->get()
);
$this->assertCount(
0,
- \App\Wallet::where('id', $wallet->id)->get()
+ Wallet::where('id', $wallet->id)->get()
);
$this->assertCount(
0,
- \App\Entitlement::withTrashed()->where('wallet_id', $wallet->id)->get()
+ Entitlement::withTrashed()->where('wallet_id', $wallet->id)->get()
);
$this->assertCount(
0,
- \App\Entitlement::withTrashed()->where('entitleable_id', $user->id)->get()
+ Entitlement::withTrashed()->where('entitleable_id', $user->id)->get()
);
$this->assertCount(
0,
- \App\Transaction::whereIn('object_id', $entitlements)
- ->where('object_type', \App\Entitlement::class)
+ Transaction::whereIn('object_id', $entitlements)
+ ->where('object_type', Entitlement::class)
->get()
);
diff --git a/src/tests/Feature/Console/User/GroupsTest.php b/src/tests/Feature/Console/User/GroupsTest.php
--- a/src/tests/Feature/Console/User/GroupsTest.php
+++ b/src/tests/Feature/Console/User/GroupsTest.php
@@ -6,20 +6,14 @@
class GroupsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group-test@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
diff --git a/src/tests/Feature/Console/User/InfoTest.php b/src/tests/Feature/Console/User/InfoTest.php
--- a/src/tests/Feature/Console/User/InfoTest.php
+++ b/src/tests/Feature/Console/User/InfoTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\User;
+use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class InfoTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
@@ -42,7 +37,7 @@
$this->assertSame("User not found.", $output);
// Test existing but soft-deleted user
- $user = $this->getTestUser('user@force-delete.com', ['status' => \App\User::STATUS_NEW]);
+ $user = $this->getTestUser('user@force-delete.com', ['status' => User::STATUS_NEW]);
$user->delete();
$code = \Artisan::call("user:info {$user->email}");
diff --git a/src/tests/Feature/Console/User/ListTest.php b/src/tests/Feature/Console/User/ListTest.php
--- a/src/tests/Feature/Console/User/ListTest.php
+++ b/src/tests/Feature/Console/User/ListTest.php
@@ -18,7 +18,7 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertTrue(strpos($output, (string) $john->id) !== false);
+ $this->assertTrue(str_contains($output, (string) $john->id));
// TODO: Test --deleted argument
// TODO: Test output format and other attributes
diff --git a/src/tests/Feature/Console/User/RemoveSkuTest.php b/src/tests/Feature/Console/User/RemoveSkuTest.php
--- a/src/tests/Feature/Console/User/RemoveSkuTest.php
+++ b/src/tests/Feature/Console/User/RemoveSkuTest.php
@@ -2,24 +2,19 @@
namespace Tests\Feature\Console\User;
+use App\Sku;
use Tests\TestCase;
class RemoveSkuTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('remove-entitlement@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('remove-entitlement@kolabnow.com');
@@ -31,23 +26,23 @@
*/
public function testHandle(): void
{
- $storage = \App\Sku::withEnvTenantContext()->where('title', 'storage')->first();
+ $storage = Sku::withEnvTenantContext()->where('title', 'storage')->first();
$user = $this->getTestUser('remove-entitlement@kolabnow.com');
// Unknown user
$this->artisan("user:remove-sku unknown@unknown.org {$storage->id}")
- ->assertExitCode(1)
- ->expectsOutput("User not found.");
+ ->assertExitCode(1)
+ ->expectsOutput("User not found.");
// Unknown SKU
$this->artisan("user:remove-sku {$user->email} unknownsku")
- ->assertExitCode(1)
- ->expectsOutput("Unable to find the SKU unknownsku.");
+ ->assertExitCode(1)
+ ->expectsOutput("Unable to find the SKU unknownsku.");
// Invalid quantity
$this->artisan("user:remove-sku {$user->email} {$storage->id} --qty=5")
- ->assertExitCode(1)
- ->expectsOutput("There aren't that many entitlements.");
+ ->assertExitCode(1)
+ ->expectsOutput("There aren't that many entitlements.");
$user->assignSku($storage, 80);
$entitlements = $user->entitlements()->where('sku_id', $storage->id);
@@ -55,14 +50,14 @@
// Remove single entitlement
$this->artisan("user:remove-sku {$user->email} {$storage->title}")
- ->assertExitCode(0);
+ ->assertExitCode(0);
$this->assertSame(79, $entitlements->count());
// Mass removal
$start = microtime(true);
$this->artisan("user:remove-sku {$user->email} {$storage->id} --qty=78")
- ->assertExitCode(0);
+ ->assertExitCode(0);
// 5GB is free, so it should stay at 5
$this->assertSame(5, $entitlements->count());
diff --git a/src/tests/Feature/Console/User/RestoreTest.php b/src/tests/Feature/Console/User/RestoreTest.php
--- a/src/tests/Feature/Console/User/RestoreTest.php
+++ b/src/tests/Feature/Console/User/RestoreTest.php
@@ -2,15 +2,14 @@
namespace Tests\Feature\Console\User;
+use App\Domain;
+use App\Package;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class RestoreTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +17,7 @@
$this->deleteTestDomain('force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
$this->deleteTestDomain('force-delete.com');
@@ -45,11 +41,11 @@
// Create a user account for delete
$user = $this->getTestUser('user@force-delete.com');
$domain = $this->getTestDomain('force-delete.com', [
- 'status' => \App\Domain::STATUS_NEW,
- 'type' => \App\Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
$wallet = $user->wallets()->first();
diff --git a/src/tests/Feature/Console/User/RestrictTest.php b/src/tests/Feature/Console/User/RestrictTest.php
--- a/src/tests/Feature/Console/User/RestrictTest.php
+++ b/src/tests/Feature/Console/User/RestrictTest.php
@@ -7,20 +7,14 @@
class RestrictTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user-restrict-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-restrict-test@kolabnow.com');
diff --git a/src/tests/Feature/Console/User/ResyncTest.php b/src/tests/Feature/Console/User/ResyncTest.php
--- a/src/tests/Feature/Console/User/ResyncTest.php
+++ b/src/tests/Feature/Console/User/ResyncTest.php
@@ -2,16 +2,15 @@
namespace Tests\Feature\Console\User;
+use App\Jobs\User\DeleteJob;
+use App\Jobs\User\ResyncJob;
use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class ResyncTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +18,7 @@
$this->deleteTestUser('user@incomplete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
$this->deleteTestUser('user@incomplete.com');
@@ -44,8 +40,8 @@
$user = $this->getTestUser('user@force-delete.com');
User::where('id', $user->id)->update([
- 'deleted_at' => now(),
- 'status' => User::STATUS_DELETED | User::STATUS_IMAP_READY,
+ 'deleted_at' => now(),
+ 'status' => User::STATUS_DELETED | User::STATUS_IMAP_READY,
]);
Queue::fake();
@@ -70,8 +66,8 @@
$this->assertFalse($user->isDeleted());
$this->assertTrue($user->isImapReady());
- Queue::assertPushed(\App\Jobs\User\DeleteJob::class, 1);
- Queue::assertPushed(\App\Jobs\User\DeleteJob::class, function ($job) use ($user) {
+ Queue::assertPushed(DeleteJob::class, 1);
+ Queue::assertPushed(DeleteJob::class, static function ($job) use ($user) {
$job_user_id = TestCase::getObjectProperty($job, 'userId');
return $job_user_id === $user->id;
});
@@ -90,7 +86,7 @@
Queue::fake();
User::withTrashed()->where('id', $user->id)->update([
- 'status' => User::STATUS_DELETED | User::STATUS_IMAP_READY
+ 'status' => User::STATUS_DELETED | User::STATUS_IMAP_READY,
]);
// Remove all deleted users except one, to not interfere
@@ -122,8 +118,8 @@
$this->assertSame(0, $code);
$this->assertSame("{$user->email}: pushed (resync)", $output);
- Queue::assertPushed(\App\Jobs\User\ResyncJob::class, 1);
- Queue::assertPushed(\App\Jobs\User\ResyncJob::class, function ($job) use ($user) {
+ Queue::assertPushed(ResyncJob::class, 1);
+ Queue::assertPushed(ResyncJob::class, static function ($job) use ($user) {
$job_user_id = TestCase::getObjectProperty($job, 'userId');
return $job_user_id === $user->id;
});
diff --git a/src/tests/Feature/Console/User/SetDiscountTest.php b/src/tests/Feature/Console/User/SetDiscountTest.php
--- a/src/tests/Feature/Console/User/SetDiscountTest.php
+++ b/src/tests/Feature/Console/User/SetDiscountTest.php
@@ -2,24 +2,19 @@
namespace Tests\Feature\Console\User;
+use App\Discount;
use Tests\TestCase;
class SetDiscountTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -33,7 +28,7 @@
{
$user = $this->getTestUser('wallets-controller@kolabnow.com');
$wallet = $user->wallets()->first();
- $discount = \App\Discount::withObjectTenantContext($user)->where('discount', 100)->first();
+ $discount = Discount::withObjectTenantContext($user)->where('discount', 100)->first();
// Invalid user id
$code = \Artisan::call("user:set-discount 123 123");
diff --git a/src/tests/Feature/Console/User/StatusTest.php b/src/tests/Feature/Console/User/StatusTest.php
--- a/src/tests/Feature/Console/User/StatusTest.php
+++ b/src/tests/Feature/Console/User/StatusTest.php
@@ -8,20 +8,14 @@
class StatusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
diff --git a/src/tests/Feature/Console/User/SuspendTest.php b/src/tests/Feature/Console/User/SuspendTest.php
--- a/src/tests/Feature/Console/User/SuspendTest.php
+++ b/src/tests/Feature/Console/User/SuspendTest.php
@@ -7,20 +7,14 @@
class SuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
diff --git a/src/tests/Feature/Console/User/UndegradeTest.php b/src/tests/Feature/Console/User/UndegradeTest.php
--- a/src/tests/Feature/Console/User/UndegradeTest.php
+++ b/src/tests/Feature/Console/User/UndegradeTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\User;
+use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UndegradeTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user-degrade-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-degrade-test@kolabnow.com');
@@ -42,7 +37,7 @@
$this->assertSame("User not found.", $output);
// Create a user account for degrade/undegrade
- $user = $this->getTestUser('user-degrade-test@kolabnow.com', ['status' => \App\User::STATUS_DEGRADED]);
+ $user = $this->getTestUser('user-degrade-test@kolabnow.com', ['status' => User::STATUS_DEGRADED]);
$this->assertTrue($user->isDegraded());
diff --git a/src/tests/Feature/Console/User/UnrestrictTest.php b/src/tests/Feature/Console/User/UnrestrictTest.php
--- a/src/tests/Feature/Console/User/UnrestrictTest.php
+++ b/src/tests/Feature/Console/User/UnrestrictTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\User;
+use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UnrestrictTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user-restrict-test@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-restrict-test@kolabnow.com');
@@ -41,7 +36,7 @@
$this->assertSame(1, $code);
$this->assertSame("User not found.", $output);
- $user = $this->getTestUser('user-restrict-test@kolabnow.com', ['status' => \App\User::STATUS_RESTRICTED]);
+ $user = $this->getTestUser('user-restrict-test@kolabnow.com', ['status' => User::STATUS_RESTRICTED]);
$this->assertTrue($user->isRestricted());
diff --git a/src/tests/Feature/Console/User/UnsuspendTest.php b/src/tests/Feature/Console/User/UnsuspendTest.php
--- a/src/tests/Feature/Console/User/UnsuspendTest.php
+++ b/src/tests/Feature/Console/User/UnsuspendTest.php
@@ -7,20 +7,14 @@
class UnsuspendTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
diff --git a/src/tests/Feature/Console/User/UsersTest.php b/src/tests/Feature/Console/User/UsersTest.php
--- a/src/tests/Feature/Console/User/UsersTest.php
+++ b/src/tests/Feature/Console/User/UsersTest.php
@@ -2,30 +2,26 @@
namespace Tests\Feature\Console\User;
+use App\Sku;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UsersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
parent::tearDown();
}
+
/**
* Test command runs
*/
@@ -53,7 +49,7 @@
// Note: User:users() uses entitlements to get the owned users,
// so we add a single entitlement, then we can soft-delete the user
$user = $this->getTestUser('user@force-delete.com');
- $storage = \App\Sku::withEnvTenantContext()->where('title', 'storage')->first();
+ $storage = Sku::withEnvTenantContext()->where('title', 'storage')->first();
$user->assignSku($storage, 1);
$user->delete();
diff --git a/src/tests/Feature/Console/User/VerifyTest.php b/src/tests/Feature/Console/User/VerifyTest.php
--- a/src/tests/Feature/Console/User/VerifyTest.php
+++ b/src/tests/Feature/Console/User/VerifyTest.php
@@ -7,20 +7,14 @@
class VerifyTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('user@force-delete.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@force-delete.com');
diff --git a/src/tests/Feature/Console/Wallet/AddTransactionTest.php b/src/tests/Feature/Console/Wallet/AddTransactionTest.php
--- a/src/tests/Feature/Console/Wallet/AddTransactionTest.php
+++ b/src/tests/Feature/Console/Wallet/AddTransactionTest.php
@@ -6,20 +6,14 @@
class AddTransactionTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
diff --git a/src/tests/Feature/Console/Wallet/BalancesTest.php b/src/tests/Feature/Console/Wallet/BalancesTest.php
--- a/src/tests/Feature/Console/Wallet/BalancesTest.php
+++ b/src/tests/Feature/Console/Wallet/BalancesTest.php
@@ -2,28 +2,24 @@
namespace Tests\Feature\Console\Wallet;
+use App\Transaction;
+use App\Wallet;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class BalancesTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
- \App\Wallet::query()->update(['balance' => 0]);
- \App\Transaction::truncate();
+ Wallet::query()->update(['balance' => 0]);
+ Transaction::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -78,6 +74,6 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertTrue(strpos($output, $wallet->id) === false);
+ $this->assertTrue(!str_contains($output, $wallet->id));
}
}
diff --git a/src/tests/Feature/Console/Wallet/ChargeTest.php b/src/tests/Feature/Console/Wallet/ChargeTest.php
--- a/src/tests/Feature/Console/Wallet/ChargeTest.php
+++ b/src/tests/Feature/Console/Wallet/ChargeTest.php
@@ -2,25 +2,21 @@
namespace Tests\Feature\Console\Wallet;
+use App\Jobs\Wallet\CheckJob;
+use App\Wallet;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class ChargeTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallet-charge@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallet-charge@kolabnow.com');
@@ -50,8 +46,8 @@
$this->artisan('wallet:charge ' . $wallet->id)
->assertExitCode(0);
- Queue::assertPushed(\App\Jobs\Wallet\CheckJob::class, 1);
- Queue::assertPushed(\App\Jobs\Wallet\CheckJob::class, function ($job) use ($wallet) {
+ Queue::assertPushed(CheckJob::class, 1);
+ Queue::assertPushed(CheckJob::class, static function ($job) use ($wallet) {
$job_wallet_id = TestCase::getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet->id;
});
@@ -68,7 +64,7 @@
$user2 = $this->getTestUser('wallet-charge@kolabnow.com');
$wallet2 = $user2->wallets()->first();
- $count = \App\Wallet::join('users', 'users.id', '=', 'wallets.user_id')
+ $count = Wallet::join('users', 'users.id', '=', 'wallets.user_id')
->whereNull('users.deleted_at')
->count();
@@ -76,12 +72,12 @@
$this->artisan('wallet:charge')->assertExitCode(0);
- Queue::assertPushed(\App\Jobs\Wallet\CheckJob::class, $count);
- Queue::assertPushed(\App\Jobs\Wallet\CheckJob::class, function ($job) use ($wallet1) {
+ Queue::assertPushed(CheckJob::class, $count);
+ Queue::assertPushed(CheckJob::class, static function ($job) use ($wallet1) {
$job_wallet_id = TestCase::getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet1->id;
});
- Queue::assertPushed(\App\Jobs\Wallet\CheckJob::class, function ($job) use ($wallet2) {
+ Queue::assertPushed(CheckJob::class, static function ($job) use ($wallet2) {
$job_wallet_id = TestCase::getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet2->id;
});
diff --git a/src/tests/Feature/Console/Wallet/EntitlementsTest.php b/src/tests/Feature/Console/Wallet/EntitlementsTest.php
--- a/src/tests/Feature/Console/Wallet/EntitlementsTest.php
+++ b/src/tests/Feature/Console/Wallet/EntitlementsTest.php
@@ -24,7 +24,7 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertTrue(strpos($output, "john@kolab.org (mailbox) 5,00 CHF") !== false);
- $this->assertTrue(strpos($output, "john@kolab.org (groupware) 4,90 CHF") !== false);
+ $this->assertTrue(str_contains($output, "john@kolab.org (mailbox) 5,00 CHF"));
+ $this->assertTrue(str_contains($output, "john@kolab.org (groupware) 4,90 CHF"));
}
}
diff --git a/src/tests/Feature/Console/Wallet/ExpectedTest.php b/src/tests/Feature/Console/Wallet/ExpectedTest.php
--- a/src/tests/Feature/Console/Wallet/ExpectedTest.php
+++ b/src/tests/Feature/Console/Wallet/ExpectedTest.php
@@ -7,20 +7,14 @@
class ExpectedTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -59,7 +53,7 @@
$output = trim(\Artisan::output());
$this->assertSame(0, $code);
- $this->assertTrue(strpos($output, $wallet->id) === false);
+ $this->assertTrue(!str_contains($output, $wallet->id));
// Expected charges for all wallets
$code = \Artisan::call("wallet:expected");
diff --git a/src/tests/Feature/Console/Wallet/GetBalanceTest.php b/src/tests/Feature/Console/Wallet/GetBalanceTest.php
--- a/src/tests/Feature/Console/Wallet/GetBalanceTest.php
+++ b/src/tests/Feature/Console/Wallet/GetBalanceTest.php
@@ -7,20 +7,14 @@
class GetBalanceTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
diff --git a/src/tests/Feature/Console/Wallet/GetDiscountTest.php b/src/tests/Feature/Console/Wallet/GetDiscountTest.php
--- a/src/tests/Feature/Console/Wallet/GetDiscountTest.php
+++ b/src/tests/Feature/Console/Wallet/GetDiscountTest.php
@@ -2,25 +2,20 @@
namespace Tests\Feature\Console\Wallet;
+use App\Discount;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class GetDiscountTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -57,7 +52,7 @@
$this->assertSame(0, $code);
$this->assertSame("0", $output);
- $discount = \App\Discount::withObjectTenantContext($user)->where('discount', 10)->first();
+ $discount = Discount::withObjectTenantContext($user)->where('discount', 10)->first();
$wallet->discount()->associate($discount);
$wallet->save();
diff --git a/src/tests/Feature/Console/Wallet/MandateTest.php b/src/tests/Feature/Console/Wallet/MandateTest.php
--- a/src/tests/Feature/Console/Wallet/MandateTest.php
+++ b/src/tests/Feature/Console/Wallet/MandateTest.php
@@ -7,20 +7,14 @@
class MandateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
diff --git a/src/tests/Feature/Console/Wallet/SetBalanceTest.php b/src/tests/Feature/Console/Wallet/SetBalanceTest.php
--- a/src/tests/Feature/Console/Wallet/SetBalanceTest.php
+++ b/src/tests/Feature/Console/Wallet/SetBalanceTest.php
@@ -7,20 +7,14 @@
class SetBalanceTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
diff --git a/src/tests/Feature/Console/Wallet/SetDiscountTest.php b/src/tests/Feature/Console/Wallet/SetDiscountTest.php
--- a/src/tests/Feature/Console/Wallet/SetDiscountTest.php
+++ b/src/tests/Feature/Console/Wallet/SetDiscountTest.php
@@ -2,24 +2,20 @@
namespace Tests\Feature\Console\Wallet;
+use App\Discount;
+use App\Package;
use Tests\TestCase;
class SetDiscountTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -32,10 +28,10 @@
public function testHandle(): void
{
$user = $this->getTestUser('wallets-controller@kolabnow.com');
- $package = \App\Package::where('title', 'kolab')->first();
+ $package = Package::where('title', 'kolab')->first();
$user->assignPackage($package);
$wallet = $user->wallets()->first();
- $discount = \App\Discount::withObjectTenantContext($user)->where('discount', 100)->first();
+ $discount = Discount::withObjectTenantContext($user)->where('discount', 100)->first();
// Invalid wallet id
$code = \Artisan::call("wallet:set-discount 123 123");
diff --git a/src/tests/Feature/Console/Wallet/TransactionsTest.php b/src/tests/Feature/Console/Wallet/TransactionsTest.php
--- a/src/tests/Feature/Console/Wallet/TransactionsTest.php
+++ b/src/tests/Feature/Console/Wallet/TransactionsTest.php
@@ -6,20 +6,14 @@
class TransactionsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('test-user1@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test-user1@kolabnow.com');
diff --git a/src/tests/Feature/Console/Wallet/TrialEndTest.php b/src/tests/Feature/Console/Wallet/TrialEndTest.php
--- a/src/tests/Feature/Console/Wallet/TrialEndTest.php
+++ b/src/tests/Feature/Console/Wallet/TrialEndTest.php
@@ -2,6 +2,9 @@
namespace Tests\Feature\Console\Wallet;
+use App\Jobs\Mail\TrialEndJob;
+use App\Package;
+use App\Plan;
use App\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Queue;
@@ -9,10 +12,7 @@
class TrialEndTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +20,7 @@
$this->deleteTestUser('test-user2@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test-user1@kolabnow.com');
$this->deleteTestUser('test-user2@kolabnow.com');
@@ -38,9 +35,9 @@
{
Queue::fake();
- $plan = \App\Plan::withEnvTenantContext()->where('title', 'individual')->first();
+ $plan = Plan::withEnvTenantContext()->where('title', 'individual')->first();
$user = $this->getTestUser('test-user1@kolabnow.com', [
- 'status' => User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE,
+ 'status' => User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE,
]);
$wallet = $user->wallets()->first();
$user->assignPlan($plan);
@@ -66,8 +63,8 @@
Queue::fake();
$code = \Artisan::call("wallet:trial-end");
- Queue::assertPushed(\App\Jobs\Mail\TrialEndJob::class, 1);
- Queue::assertPushed(\App\Jobs\Mail\TrialEndJob::class, function ($job) use ($user) {
+ Queue::assertPushed(TrialEndJob::class, 1);
+ Queue::assertPushed(TrialEndJob::class, static function ($job) use ($user) {
$job_user = TestCase::getObjectProperty($job, 'account');
return $job_user->id === $user->id;
});
@@ -102,9 +99,9 @@
// Make sure the non-controller users are omitted
$user2 = $this->getTestUser('test-user2@kolabnow.com', [
- 'status' => User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE,
+ 'status' => User::STATUS_IMAP_READY | User::STATUS_LDAP_READY | User::STATUS_ACTIVE,
]);
- $package = \App\Package::withEnvTenantContext()->where('title', 'lite')->first();
+ $package = Package::withEnvTenantContext()->where('title', 'lite')->first();
$user->assignPackage($package, $user2);
$user2->created_at = \now()->clone()->subMonthsNoOverflow(1);
$user2->save();
diff --git a/src/tests/Feature/Console/Wallet/UntilTest.php b/src/tests/Feature/Console/Wallet/UntilTest.php
--- a/src/tests/Feature/Console/Wallet/UntilTest.php
+++ b/src/tests/Feature/Console/Wallet/UntilTest.php
@@ -2,27 +2,22 @@
namespace Tests\Feature\Console\Wallet;
+use App\Package;
+use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
-use Carbon\Carbon;
class UntilTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
$this->deleteTestUser('wallets-controller@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
@@ -53,7 +48,7 @@
$this->assertSame(0, $code);
$this->assertSame("Lasts until: unknown", $output);
- $package = \App\Package::withObjectTenantContext($user)->where('title', 'kolab')->first();
+ $package = Package::withObjectTenantContext($user)->where('title', 'kolab')->first();
$user->assignPackage($package);
$wallet->balance = 1000;
$wallet->save();
diff --git a/src/tests/Feature/Controller/Admin/DiscountsTest.php b/src/tests/Feature/Controller/Admin/DiscountsTest.php
--- a/src/tests/Feature/Controller/Admin/DiscountsTest.php
+++ b/src/tests/Feature/Controller/Admin/DiscountsTest.php
@@ -7,19 +7,13 @@
class DiscountsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
diff --git a/src/tests/Feature/Controller/Admin/DomainsTest.php b/src/tests/Feature/Controller/Admin/DomainsTest.php
--- a/src/tests/Feature/Controller/Admin/DomainsTest.php
+++ b/src/tests/Feature/Controller/Admin/DomainsTest.php
@@ -11,10 +11,7 @@
class DomainsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -22,10 +19,7 @@
$this->deleteTestDomain('domainscontroller.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
@@ -130,15 +124,15 @@
$admin = $this->getTestUser('jeroen@jeroen.jeroen');
$user = $this->getTestUser('test1@domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
Entitlement::create([
- 'wallet_id' => $user->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
// Only admins can access it
@@ -150,10 +144,10 @@
$json = $response->json();
- $this->assertEquals($domain->id, $json['id']);
- $this->assertEquals($domain->namespace, $json['namespace']);
- $this->assertEquals($domain->status, $json['status']);
- $this->assertEquals($domain->type, $json['type']);
+ $this->assertSame($domain->id, $json['id']);
+ $this->assertSame($domain->namespace, $json['namespace']);
+ $this->assertSame($domain->status, $json['status']);
+ $this->assertSame($domain->type, $json['type']);
// Note: Other properties are being tested in the user controller tests
}
@@ -224,7 +218,7 @@
'object_id' => $domain->id,
'object_type' => Domain::class,
'type' => EventLog::TYPE_SUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
@@ -273,7 +267,7 @@
'object_id' => $domain->id,
'object_type' => Domain::class,
'type' => EventLog::TYPE_UNSUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
diff --git a/src/tests/Feature/Controller/Admin/EventLogTest.php b/src/tests/Feature/Controller/Admin/EventLogTest.php
--- a/src/tests/Feature/Controller/Admin/EventLogTest.php
+++ b/src/tests/Feature/Controller/Admin/EventLogTest.php
@@ -7,10 +7,7 @@
class EventLogTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -18,10 +15,7 @@
EventLog::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
EventLog::query()->delete();
diff --git a/src/tests/Feature/Controller/Admin/GroupsTest.php b/src/tests/Feature/Controller/Admin/GroupsTest.php
--- a/src/tests/Feature/Controller/Admin/GroupsTest.php
+++ b/src/tests/Feature/Controller/Admin/GroupsTest.php
@@ -9,10 +9,7 @@
class GroupsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -20,10 +17,7 @@
$this->deleteTestGroup('group-test@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
@@ -114,10 +108,10 @@
$json = $response->json();
- $this->assertEquals($group->id, $json['id']);
- $this->assertEquals($group->email, $json['email']);
- $this->assertEquals($group->name, $json['name']);
- $this->assertEquals($group->status, $json['status']);
+ $this->assertSame($group->id, $json['id']);
+ $this->assertSame($group->email, $json['email']);
+ $this->assertSame($group->name, $json['name']);
+ $this->assertSame($group->status, $json['status']);
}
/**
@@ -198,7 +192,7 @@
'object_id' => $group->id,
'object_type' => Group::class,
'type' => EventLog::TYPE_SUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
@@ -251,7 +245,7 @@
'object_id' => $group->id,
'object_type' => Group::class,
'type' => EventLog::TYPE_UNSUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
diff --git a/src/tests/Feature/Controller/Admin/ResourcesTest.php b/src/tests/Feature/Controller/Admin/ResourcesTest.php
--- a/src/tests/Feature/Controller/Admin/ResourcesTest.php
+++ b/src/tests/Feature/Controller/Admin/ResourcesTest.php
@@ -8,19 +8,13 @@
class ResourcesTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -109,9 +103,9 @@
$json = $response->json();
- $this->assertEquals($resource->id, $json['id']);
- $this->assertEquals($resource->email, $json['email']);
- $this->assertEquals($resource->name, $json['name']);
+ $this->assertSame($resource->id, $json['id']);
+ $this->assertSame($resource->email, $json['email']);
+ $this->assertSame($resource->name, $json['name']);
}
/**
diff --git a/src/tests/Feature/Controller/Admin/SharedFoldersTest.php b/src/tests/Feature/Controller/Admin/SharedFoldersTest.php
--- a/src/tests/Feature/Controller/Admin/SharedFoldersTest.php
+++ b/src/tests/Feature/Controller/Admin/SharedFoldersTest.php
@@ -2,25 +2,18 @@
namespace Tests\Feature\Controller\Admin;
-use App\SharedFolder;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SharedFoldersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -109,10 +102,10 @@
$json = $response->json();
- $this->assertEquals($folder->id, $json['id']);
- $this->assertEquals($folder->email, $json['email']);
- $this->assertEquals($folder->name, $json['name']);
- $this->assertEquals($folder->type, $json['type']);
+ $this->assertSame($folder->id, $json['id']);
+ $this->assertSame($folder->email, $json['email']);
+ $this->assertSame($folder->name, $json['name']);
+ $this->assertSame($folder->type, $json['type']);
}
/**
diff --git a/src/tests/Feature/Controller/Admin/SkusTest.php b/src/tests/Feature/Controller/Admin/SkusTest.php
--- a/src/tests/Feature/Controller/Admin/SkusTest.php
+++ b/src/tests/Feature/Controller/Admin/SkusTest.php
@@ -7,10 +7,7 @@
class SkusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -20,10 +17,7 @@
$this->clearBetaEntitlements();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Sku::where('title', 'test')->delete();
diff --git a/src/tests/Feature/Controller/Admin/StatsTest.php b/src/tests/Feature/Controller/Admin/StatsTest.php
--- a/src/tests/Feature/Controller/Admin/StatsTest.php
+++ b/src/tests/Feature/Controller/Admin/StatsTest.php
@@ -2,17 +2,16 @@
namespace Tests\Feature\Controller\Admin;
+use App\Discount;
use App\Http\Controllers\API\V4\Admin\StatsController;
use App\Payment;
+use App\Utils;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class StatsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -23,10 +22,7 @@
$this->deleteTestUser('test-stats@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Payment::query()->delete();
DB::table('wallets')->update(['discount_id' => null]);
@@ -73,7 +69,7 @@
$this->assertSame('bar', $json['type']);
$this->assertCount(8, $json['data']['labels']);
$this->assertSame(date('Y-W'), $json['data']['labels'][7]);
- $this->assertSame([['values' => [0,0,0,0,0,0,0,0]]], $json['data']['datasets']);
+ $this->assertSame([['values' => [0, 0, 0, 0, 0, 0, 0, 0]]], $json['data']['datasets']);
// 'users' chart
$response = $this->actingAs($admin)->get("api/v4/stats/chart/users");
@@ -99,7 +95,7 @@
$this->assertCount(1, $json['data']['datasets']);
// 'vouchers' chart
- $discount = \App\Discount::withObjectTenantContext($user)->where('code', 'TEST')->first();
+ $discount = Discount::withObjectTenantContext($user)->where('code', 'TEST')->first();
$wallet = $user->wallets->first();
$wallet->discount()->associate($discount);
$wallet->save();
@@ -129,76 +125,76 @@
// Create some test payments
Payment::create([
- 'id' => 'test1',
- 'description' => '',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 1000,
- 'credit_amount' => 1000,
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'EUR',
- 'currency_amount' => 1000,
+ 'id' => 'test1',
+ 'description' => '',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 1000,
+ 'credit_amount' => 1000,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'EUR',
+ 'currency_amount' => 1000,
]);
Payment::create([
- 'id' => 'test2',
- 'description' => '',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 2000,
- 'credit_amount' => 2000,
- 'type' => Payment::TYPE_RECURRING,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'EUR',
- 'currency_amount' => 2000,
+ 'id' => 'test2',
+ 'description' => '',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 2000,
+ 'credit_amount' => 2000,
+ 'type' => Payment::TYPE_RECURRING,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'EUR',
+ 'currency_amount' => 2000,
]);
Payment::create([
- 'id' => 'test3',
- 'description' => '',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 3000,
- 'credit_amount' => 3000,
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $johns_wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'EUR',
- 'currency_amount' => 2800,
+ 'id' => 'test3',
+ 'description' => '',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 3000,
+ 'credit_amount' => 3000,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $johns_wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'EUR',
+ 'currency_amount' => 2800,
]);
Payment::create([
- 'id' => 'test4',
- 'description' => '',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 4000,
- 'credit_amount' => 4000,
- 'type' => Payment::TYPE_RECURRING,
- 'wallet_id' => $johns_wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'CHF',
- 'currency_amount' => 4000,
+ 'id' => 'test4',
+ 'description' => '',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 4000,
+ 'credit_amount' => 4000,
+ 'type' => Payment::TYPE_RECURRING,
+ 'wallet_id' => $johns_wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'CHF',
+ 'currency_amount' => 4000,
]);
Payment::create([
- 'id' => 'test5',
- 'description' => '',
- 'status' => Payment::STATUS_OPEN,
- 'amount' => 5000,
- 'credit_amount' => 5000,
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $johns_wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'CHF',
- 'currency_amount' => 5000,
+ 'id' => 'test5',
+ 'description' => '',
+ 'status' => Payment::STATUS_OPEN,
+ 'amount' => 5000,
+ 'credit_amount' => 5000,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $johns_wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'CHF',
+ 'currency_amount' => 5000,
]);
Payment::create([
- 'id' => 'test6',
- 'description' => '',
- 'status' => Payment::STATUS_FAILED,
- 'amount' => 6000,
- 'credit_amount' => 6000,
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $johns_wallet->id,
- 'provider' => 'mollie',
- 'currency' => 'CHF',
- 'currency_amount' => 6000,
+ 'id' => 'test6',
+ 'description' => '',
+ 'status' => Payment::STATUS_FAILED,
+ 'amount' => 6000,
+ 'credit_amount' => 6000,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $johns_wallet->id,
+ 'provider' => 'mollie',
+ 'currency' => 'CHF',
+ 'currency_amount' => 6000,
]);
// 'income' chart
@@ -213,7 +209,7 @@
$this->assertSame(date('Y-W'), $json['data']['labels'][7]);
// 7000 CHF + 3000 EUR =
- $expected = 7000 + intval(round(3000 * \App\Utils::exchangeRate('EUR', 'CHF')));
+ $expected = 7000 + (int) round(3000 * Utils::exchangeRate('EUR', 'CHF'));
$this->assertCount(1, $json['data']['datasets']);
$this->assertSame($expected / 100, $json['data']['datasets'][0]['values'][7]);
@@ -241,14 +237,14 @@
$this->assertCount(54, $json['data']['datasets'][0]['values']);
DB::table('stats')->insert([
- 'type' => StatsController::TYPE_PAYERS,
- 'value' => 5,
- 'created_at' => \now(),
+ 'type' => StatsController::TYPE_PAYERS,
+ 'value' => 5,
+ 'created_at' => \now(),
]);
DB::table('stats')->insert([
- 'type' => StatsController::TYPE_PAYERS,
- 'value' => 7,
- 'created_at' => \now(),
+ 'type' => StatsController::TYPE_PAYERS,
+ 'value' => 7,
+ 'created_at' => \now(),
]);
$response = $this->actingAs($admin)->get("api/v4/stats/chart/payers");
diff --git a/src/tests/Feature/Controller/Admin/UsersTest.php b/src/tests/Feature/Controller/Admin/UsersTest.php
--- a/src/tests/Feature/Controller/Admin/UsersTest.php
+++ b/src/tests/Feature/Controller/Admin/UsersTest.php
@@ -3,7 +3,11 @@
namespace Tests\Feature\Controller\Admin;
use App\Auth\SecondFactor;
+use App\Domain;
use App\EventLog;
+use App\Payment;
+use App\Plan;
+use App\SharedFolderAlias;
use App\Sku;
use App\User;
use Illuminate\Support\Facades\Queue;
@@ -11,10 +15,7 @@
class UsersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
@@ -27,14 +28,11 @@
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSetting('external_email', null);
- \App\SharedFolderAlias::truncate();
- \App\Payment::query()->delete();
+ SharedFolderAlias::truncate();
+ Payment::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UsersControllerTest1@userscontroller.com');
$this->deleteTestUser('test@testsearch.com');
@@ -43,8 +41,8 @@
$jack = $this->getTestUser('jack@kolab.org');
$jack->setSetting('external_email', null);
- \App\SharedFolderAlias::truncate();
- \App\Payment::query()->delete();
+ SharedFolderAlias::truncate();
+ Payment::query()->delete();
parent::tearDown();
}
@@ -227,16 +225,16 @@
$this->assertSame($user->email, $json['list'][0]['email']);
// Deleted users/domains
- $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]);
+ $domain = $this->getTestDomain('testsearch.com', ['type' => Domain::TYPE_EXTERNAL]);
$user = $this->getTestUser('test@testsearch.com');
- $plan = \App\Plan::where('title', 'group')->first();
+ $plan = Plan::where('title', 'group')->first();
$user->assignPlan($plan, $domain);
$user->setAliases(['alias@testsearch.com']);
$wallet = $user->wallets()->first();
$wallet->setSetting('mollie_id', 'cst_nonsense');
- \App\Payment::create(
+ Payment::create(
[
'id' => 'tr_nonsense',
'wallet_id' => $wallet->id,
@@ -247,7 +245,7 @@
'provider' => 'self',
'type' => 'oneoff',
'currency' => 'CHF',
- 'currency_amount' => 1337
+ 'currency_amount' => 1337,
]
);
@@ -518,7 +516,7 @@
'object_id' => $user->id,
'object_type' => User::class,
'type' => EventLog::TYPE_SUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
@@ -565,7 +563,7 @@
'object_id' => $user->id,
'object_type' => User::class,
'type' => EventLog::TYPE_UNSUSPENDED,
- 'comment' => 'Test'
+ 'comment' => 'Test',
];
$this->assertSame(1, EventLog::where($where)->count());
diff --git a/src/tests/Feature/Controller/Admin/WalletsTest.php b/src/tests/Feature/Controller/Admin/WalletsTest.php
--- a/src/tests/Feature/Controller/Admin/WalletsTest.php
+++ b/src/tests/Feature/Controller/Admin/WalletsTest.php
@@ -8,19 +8,13 @@
class WalletsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useAdminUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -163,7 +157,7 @@
// Create some sample transactions
$transactions = $this->createTestTransactions($wallet);
$transactions = array_reverse($transactions);
- $pages = array_chunk($transactions, 10 /* page size*/);
+ $pages = array_chunk($transactions, 10 /* page size */);
// Get the 2nd page
$response = $this->actingAs($admin)->get("api/v4/wallets/{$wallet->id}/transactions?page=2");
@@ -175,7 +169,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(2, $json['page']);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(2, $json['list']);
foreach ($pages[1] as $idx => $transaction) {
$this->assertSame($transaction->id, $json['list'][$idx]['id']);
@@ -227,8 +221,8 @@
$this->assertSame('success', $json['status']);
$this->assertSame('User wallet updated successfully.', $json['message']);
$this->assertSame($wallet->id, $json['id']);
- $this->assertSame(null, $json['discount_id']);
+ $this->assertNull($json['discount_id']);
$this->assertTrue(empty($json['discount_description']));
- $this->assertSame(null, $wallet->fresh()->discount);
+ $this->assertNull($wallet->fresh()->discount);
}
}
diff --git a/src/tests/Feature/Controller/AuthAttemptsTest.php b/src/tests/Feature/Controller/AuthAttemptsTest.php
--- a/src/tests/Feature/Controller/AuthAttemptsTest.php
+++ b/src/tests/Feature/Controller/AuthAttemptsTest.php
@@ -2,16 +2,13 @@
namespace Tests\Feature\Controller;
-use App\User;
use App\AuthAttempt;
+use App\User;
use Tests\TestCase;
class AuthAttemptsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
$this->deleteTestDomain('userscontroller.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UsersControllerTest1@userscontroller.com');
$this->deleteTestDomain('userscontroller.com');
@@ -36,7 +30,7 @@
public function testAccept(): void
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
$response = $this->actingAs($user)->post("api/v4/auth-attempts/{$authAttempt->id}/confirm");
$response->assertStatus(200);
@@ -53,14 +47,13 @@
$response->assertStatus(404);
}
-
/**
* Test deny (POST /api/v4/auth-attempts/<authAttempt>/deny)
*/
public function testDeny(): void
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
$response = $this->actingAs($user)->post("api/v4/auth-attempts/{$authAttempt->id}/deny");
$response->assertStatus(200);
@@ -77,14 +70,13 @@
$response->assertStatus(404);
}
-
/**
* Test details (GET /api/v4/auth-attempts/<authAttempt>/details)
*/
public function testDetails(): void
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
$response = $this->actingAs($user)->get("api/v4/auth-attempts/{$authAttempt->id}/details");
$response->assertStatus(200);
@@ -93,10 +85,10 @@
$authAttempt->refresh();
- $this->assertEquals($user->email, $json['username']);
- $this->assertEquals($authAttempt->ip, $json['entry']['ip']);
- $this->assertEquals(json_encode($authAttempt->updated_at), "\"" . $json['entry']['updated_at'] . "\"");
- $this->assertEquals("CH", $json['country']);
+ $this->assertSame($user->email, $json['username']);
+ $this->assertSame($authAttempt->ip, $json['entry']['ip']);
+ $this->assertSame(json_encode($authAttempt->updated_at), "\"" . $json['entry']['updated_at'] . "\"");
+ $this->assertSame("CH", $json['country']);
// wrong user
$user2 = $this->getTestUser('UsersControllerTest2@userscontroller.com');
@@ -108,15 +100,14 @@
$response->assertStatus(404);
}
-
/**
* Test list (GET /api/v4/auth-attempts)
*/
public function testList(): void
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
- $authAttempt2 = \App\AuthAttempt::recordAuthAttempt($user, "10.0.0.2");
+ $authAttempt = AuthAttempt::recordAuthAttempt($user, "10.0.0.1");
+ $authAttempt2 = AuthAttempt::recordAuthAttempt($user, "10.0.0.2");
$response = $this->actingAs($user)->get("api/v4/auth-attempts");
$response->assertStatus(200);
diff --git a/src/tests/Feature/Controller/AuthTest.php b/src/tests/Feature/Controller/AuthTest.php
--- a/src/tests/Feature/Controller/AuthTest.php
+++ b/src/tests/Feature/Controller/AuthTest.php
@@ -2,8 +2,11 @@
namespace Tests\Feature\Controller;
+use App\Auth\PassportClient;
use App\Domain;
+use App\IP4Net;
use App\User;
+use App\Utils;
use Tests\TestCase;
class AuthTest extends TestCase
@@ -18,10 +21,7 @@
$this->app['auth']->forgetGuards();
}
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -30,21 +30,18 @@
$this->expectedExpiry = \config('auth.token_expiry_minutes') * 60;
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
$user = $this->getTestUser('john@kolab.org');
$user->setSetting('limit_geo', null);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UsersControllerTest1@userscontroller.com');
$this->deleteTestDomain('userscontroller.com');
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
$user = $this->getTestUser('john@kolab.org');
$user->setSetting('limit_geo', null);
@@ -59,8 +56,8 @@
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com', ['status' => User::STATUS_NEW]);
$domain = $this->getTestDomain('userscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$response = $this->get("api/auth/info");
@@ -71,9 +68,9 @@
$json = $response->json();
- $this->assertEquals($user->id, $json['id']);
- $this->assertEquals($user->email, $json['email']);
- $this->assertEquals(User::STATUS_NEW, $json['status']);
+ $this->assertSame($user->id, $json['id']);
+ $this->assertSame($user->email, $json['email']);
+ $this->assertSame(User::STATUS_NEW, $json['status']);
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
$this->assertTrue(!isset($json['access_token']));
@@ -92,7 +89,7 @@
$json = $response->json();
- $this->assertEquals('john@kolab.org', $json['email']);
+ $this->assertSame('john@kolab.org', $json['email']);
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
$this->assertTrue(!empty($json['access_token']));
@@ -120,13 +117,13 @@
$this->assertSame('127.0.0.2', $json['ipAddress']);
$this->assertSame('', $json['countryCode']);
- \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$response = $this->actingAs($user)->withHeaders($headers)->get("api/auth/location");
@@ -173,12 +170,12 @@
$response->assertStatus(200);
$this->assertTrue(!empty($json['access_token']));
$this->assertTrue(
- ($this->expectedExpiry - 5) < $json['expires_in'] &&
- $json['expires_in'] < ($this->expectedExpiry + 5)
+ ($this->expectedExpiry - 5) < $json['expires_in']
+ && $json['expires_in'] < ($this->expectedExpiry + 5)
);
- $this->assertEquals('bearer', $json['token_type']);
- $this->assertEquals($user->id, $json['id']);
- $this->assertEquals($user->email, $json['email']);
+ $this->assertSame('bearer', $json['token_type']);
+ $this->assertSame($user->id, $json['id']);
+ $this->assertSame($user->email, $json['email']);
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
@@ -197,10 +194,10 @@
$response->assertStatus(200);
$this->assertTrue(!empty($json['access_token']));
$this->assertTrue(
- ($this->expectedExpiry - 5) < $json['expires_in'] &&
- $json['expires_in'] < ($this->expectedExpiry + 5)
+ ($this->expectedExpiry - 5) < $json['expires_in']
+ && $json['expires_in'] < ($this->expectedExpiry + 5)
);
- $this->assertEquals('bearer', $json['token_type']);
+ $this->assertSame('bearer', $json['token_type']);
// TODO: We have browser tests for 2FA but we should probably also test it here
@@ -213,7 +210,7 @@
public function testLoginServiceAccount(): void
{
$user = $this->getTestUser('cyrus-admin');
- $user->role = \App\User::ROLE_SERVICE;
+ $user->role = User::ROLE_SERVICE;
$user->password = 'simple123';
$user->save();
@@ -247,13 +244,13 @@
$this->assertSame("Invalid username or password.", $json['message']);
$this->assertSame('error', $json['status']);
- \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$response = $this->withHeaders($headers)->post("api/auth/login", $post);
@@ -262,7 +259,7 @@
$json = $response->json();
$this->assertTrue(!empty($json['access_token']));
- $this->assertEquals($user->id, $json['id']);
+ $this->assertSame($user->id, $json['id']);
}
/**
@@ -290,8 +287,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('Successfully logged out.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('Successfully logged out.', $json['message']);
$this->resetAuth();
// Check if it really destroyed the token?
@@ -330,10 +327,10 @@
$this->assertTrue(!empty($json['access_token']));
$this->assertTrue($json['access_token'] != $token);
$this->assertTrue(
- ($this->expectedExpiry - 5) < $json['expires_in'] &&
- $json['expires_in'] < ($this->expectedExpiry + 5)
+ ($this->expectedExpiry - 5) < $json['expires_in']
+ && $json['expires_in'] < ($this->expectedExpiry + 5)
);
- $this->assertEquals('bearer', $json['token_type']);
+ $this->assertSame('bearer', $json['token_type']);
$new_token = $json['access_token'];
// TODO: Shall we invalidate the old token?
@@ -382,7 +379,7 @@
$this->assertSame('invalid_client', $json['error']);
$this->assertSame('Client authentication failed', $json['message']);
- $client = \App\Auth\PassportClient::find(\config('auth.synapse.client_id'));
+ $client = PassportClient::find(\config('auth.synapse.client_id'));
$post['client_id'] = $client->id;
@@ -474,8 +471,8 @@
$this->assertTrue(!empty($json['refresh_token']));
$this->assertTrue(!empty($json['expires_in']));
$this->assertTrue(empty($json['id_token']));
- $this->assertNotEquals($json['access_token'], $params['access_token']);
- $this->assertNotEquals($json['refresh_token'], $params['refresh_token']);
+ $this->assertNotSame($json['access_token'], $params['access_token']);
+ $this->assertNotSame($json['refresh_token'], $params['refresh_token']);
$token = $json['access_token'];
@@ -487,8 +484,8 @@
$json = $response->json();
- $this->assertEquals($user->id, $json['sub']);
- $this->assertEquals($user->email, $json['email']);
+ $this->assertSame($user->id, $json['sub']);
+ $this->assertSame($user->email, $json['email']);
// Validate that the access token does not give access to API other than /oauth/userinfo
$this->resetAuth(); // reset guards
@@ -502,11 +499,11 @@
public function testOAuthApprovePrompt(): void
{
// HTTP_HOST is not set in tests for some reason, but it's required down the line
- $host = parse_url(\App\Utils::serviceUrl('/'), \PHP_URL_HOST);
+ $host = parse_url(Utils::serviceUrl('/'), \PHP_URL_HOST);
$_SERVER['HTTP_HOST'] = $host;
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
- $client = \App\Auth\PassportClient::find(\config('auth.sso.client_id'));
+ $client = PassportClient::find(\config('auth.sso.client_id'));
$post = [
'client_id' => $client->id,
@@ -559,11 +556,11 @@
public function testOIDCAuthorizationCodeFlow(): void
{
// HTTP_HOST is not set in tests for some reason, but it's required down the line
- $host = parse_url(\App\Utils::serviceUrl('/'), \PHP_URL_HOST);
+ $host = parse_url(Utils::serviceUrl('/'), \PHP_URL_HOST);
$_SERVER['HTTP_HOST'] = $host;
$user = $this->getTestUser('john@kolab.org');
- $client = \App\Auth\PassportClient::find(\config('auth.sso.client_id'));
+ $client = PassportClient::find(\config('auth.sso.client_id'));
// Note: Invalid input cases were tested above, we omit them here
@@ -645,8 +642,8 @@
$json = $response->json();
- $this->assertEquals($user->id, $json['sub']);
- $this->assertEquals($user->email, $json['email']);
+ $this->assertSame($user->id, $json['sub']);
+ $this->assertSame($user->email, $json['email']);
// Validate that the access token does not give access to API other than /oauth/userinfo
$this->resetAuth(); // reset guards state
diff --git a/src/tests/Feature/Controller/CompanionAppsTest.php b/src/tests/Feature/Controller/CompanionAppsTest.php
--- a/src/tests/Feature/Controller/CompanionAppsTest.php
+++ b/src/tests/Feature/Controller/CompanionAppsTest.php
@@ -2,19 +2,16 @@
namespace Tests\Feature\Controller;
-use App\User;
use App\CompanionApp;
-use Laravel\Passport\Token;
+use App\Utils;
use Laravel\Passport\Passport;
+use Laravel\Passport\Token;
use Laravel\Passport\TokenRepository;
use Tests\TestCase;
class CompanionAppsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -23,10 +20,7 @@
$this->deleteTestCompanionApp('testdevice');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('CompanionAppsTest1@userscontroller.com');
$this->deleteTestUser('CompanionAppsTest2@userscontroller.com');
@@ -54,10 +48,10 @@
$this->assertSame('success', $json['status']);
$this->assertSame("Companion app has been created.", $json['message']);
- $companionApp = \App\CompanionApp::where('name', $name)->first();
+ $companionApp = CompanionApp::where('name', $name)->first();
$this->assertTrue($companionApp != null);
- $this->assertEquals($name, $companionApp->name);
- $this->assertFalse((bool)$companionApp->mfa_enabled);
+ $this->assertSame($name, $companionApp->name);
+ $this->assertFalse((bool) $companionApp->mfa_enabled);
}
/**
@@ -90,7 +84,7 @@
'personal_access_client' => 0,
'password_client' => 1,
'revoked' => false,
- 'allowed_scopes' => ["mfa"]
+ 'allowed_scopes' => ["mfa"],
]);
$client->save();
$companionApp->oauth_client_id = $client->id;
@@ -101,14 +95,13 @@
'id' => 'testtoken',
'revoked' => false,
'user_id' => $user->id,
- 'client_id' => $client->id
+ 'client_id' => $client->id,
]);
- //Make sure we have a token to revoke
+ // Make sure we have a token to revoke
$tokenCount = Token::where('user_id', $user->id)->where('client_id', $client->id)->count();
$this->assertTrue($tokenCount > 0);
-
$response = $this->actingAs($user2)->delete("api/v4/companions/{$companionApp->id}");
$response->assertStatus(403);
@@ -122,9 +115,9 @@
$this->assertSame("Companion app has been removed.", $json['message']);
$client->refresh();
- $this->assertSame((bool)$client->revoked, true);
+ $this->assertSame((bool) $client->revoked, true);
- $companionApp = \App\CompanionApp::where('device_id', 'testdevice')->first();
+ $companionApp = CompanionApp::where('device_id', 'testdevice')->first();
$this->assertTrue($companionApp == null);
$tokenCount = Token::where('user_id', $user->id)
@@ -228,7 +221,7 @@
'notificationToken' => $notificationToken,
'deviceId' => $deviceId,
'name' => $name,
- 'companionId' => $companionApp->id
+ 'companionId' => $companionApp->id,
]
);
@@ -236,10 +229,10 @@
$companionApp->refresh();
$this->assertTrue($companionApp != null);
- $this->assertEquals($deviceId, $companionApp->device_id);
- $this->assertEquals($name, $companionApp->name);
- $this->assertEquals($notificationToken, $companionApp->notification_token);
- $this->assertTrue((bool)$companionApp->mfa_enabled);
+ $this->assertSame($deviceId, $companionApp->device_id);
+ $this->assertSame($name, $companionApp->name);
+ $this->assertSame($notificationToken, $companionApp->notification_token);
+ $this->assertTrue((bool) $companionApp->mfa_enabled);
// Companion id required
$response = $this->actingAs($user)->post(
@@ -256,14 +249,14 @@
'notificationToken' => $notificationToken,
'deviceId' => $deviceId,
'name' => $name,
- 'companionId' => $companionApp->id
+ 'companionId' => $companionApp->id,
]
);
$response->assertStatus(200);
$companionApp->refresh();
- $this->assertEquals($notificationToken, $companionApp->notification_token);
+ $this->assertSame($notificationToken, $companionApp->notification_token);
// Failing input valdiation
$response = $this->actingAs($user)->post(
@@ -280,7 +273,7 @@
'notificationToken' => $notificationToken,
'deviceId' => $deviceId,
'name' => $name,
- 'companionId' => $companionApp->id
+ 'companionId' => $companionApp->id,
]
);
$response->assertStatus(403);
@@ -317,7 +310,7 @@
$this->assertSame($companionApp->id, $json['companionId']);
$this->assertSame($client->id, $json['clientIdentifier']); // TODO: This should be clientId
$this->assertSame($client->secret, $json['clientSecret']);
- $this->assertSame(\App\Utils::serviceUrl('', $user->tenant_id), $json['serverUrl']);
+ $this->assertSame(Utils::serviceUrl('', $user->tenant_id), $json['serverUrl']);
$this->assertArrayHasKey('qrcode', $json);
$this->assertSame('data:image/svg+xml;base64,', substr($json['qrcode'], 0, 26));
}
diff --git a/src/tests/Feature/Controller/ConfigTest.php b/src/tests/Feature/Controller/ConfigTest.php
--- a/src/tests/Feature/Controller/ConfigTest.php
+++ b/src/tests/Feature/Controller/ConfigTest.php
@@ -46,9 +46,9 @@
$json = $response->json();
$this->assertSame([], $json['plugins']);
- $this->assertSame(true, $json['calendar_disabled']);
- $this->assertSame(true, $json['kolab_files_disabled']);
- $this->assertSame(true, $json['kolab_tags_disabled']);
- $this->assertSame(true, $json['tasklist_disabled']);
+ $this->assertTrue($json['calendar_disabled']);
+ $this->assertTrue($json['kolab_files_disabled']);
+ $this->assertTrue($json['kolab_tags_disabled']);
+ $this->assertTrue($json['tasklist_disabled']);
}
}
diff --git a/src/tests/Feature/Controller/DomainsTest.php b/src/tests/Feature/Controller/DomainsTest.php
--- a/src/tests/Feature/Controller/DomainsTest.php
+++ b/src/tests/Feature/Controller/DomainsTest.php
@@ -2,22 +2,20 @@
namespace Tests\Feature\Controller;
+use App\Discount;
use App\Domain;
use App\Entitlement;
+use App\Package;
use App\Sku;
use App\Tenant;
use App\User;
use App\Wallet;
use Illuminate\Support\Facades\Queue;
-use Illuminate\Support\Str;
use Tests\TestCase;
class DomainsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -28,7 +26,7 @@
Sku::where('title', 'test')->delete();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test1@' . \config('app.domain'));
$this->deleteTestUser('test2@' . \config('app.domain'));
@@ -44,6 +42,7 @@
/**
* Test domain confirm request
+ *
* @group skipci
*/
public function testConfirm(): void
@@ -55,15 +54,15 @@
$ned = $this->getTestUser('ned@kolab.org');
$user = $this->getTestUser('test1@domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
Entitlement::create([
- 'wallet_id' => $user->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
$response = $this->actingAs($user)->get("api/v4/domains/{$domain->id}/confirm");
@@ -72,8 +71,8 @@
$json = $response->json();
$this->assertCount(2, $json);
- $this->assertEquals('error', $json['status']);
- $this->assertEquals('Domain ownership confirmation failed.', $json['message']);
+ $this->assertSame('error', $json['status']);
+ $this->assertSame('Domain ownership confirmation failed.', $json['message']);
$domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
@@ -83,8 +82,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('Domain ownership confirmed successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('Domain ownership confirmed successfully.', $json['message']);
$this->assertTrue(is_array($json['statusInfo']));
// Not authorized access
@@ -110,15 +109,15 @@
$user1 = $this->getTestUser('test1@' . \config('app.domain'));
$user2 = $this->getTestUser('test2@' . \config('app.domain'));
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
Entitlement::create([
- 'wallet_id' => $user1->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user1->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
// Not authorized access
@@ -132,8 +131,8 @@
$json = $response->json();
$this->assertCount(2, $json);
- $this->assertEquals('error', $json['status']);
- $this->assertEquals('Unable to delete a domain with assigned users or other objects.', $json['message']);
+ $this->assertSame('error', $json['status']);
+ $this->assertSame('Unable to delete a domain with assigned users or other objects.', $json['message']);
// Successful deletion
$response = $this->actingAs($user1)->delete("api/v4/domains/{$domain->id}");
@@ -142,22 +141,22 @@
$json = $response->json();
$this->assertCount(2, $json);
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('Domain deleted successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('Domain deleted successfully.', $json['message']);
$this->assertTrue($domain->fresh()->trashed());
// Authorized access by additional account controller
$this->deleteTestDomain('domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
Entitlement::create([
- 'wallet_id' => $user1->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user1->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
$user1->wallets()->first()->addController($user2);
@@ -167,8 +166,8 @@
$json = $response->json();
$this->assertCount(2, $json);
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('Domain deleted successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('Domain deleted successfully.', $json['message']);
$this->assertTrue($domain->fresh()->trashed());
}
@@ -186,7 +185,7 @@
$this->assertCount(4, $json);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("0 domains have been found.", $json['message']);
$this->assertSame([], $json['list']);
@@ -200,7 +199,7 @@
$json = $response->json();
$this->assertCount(4, $json);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("1 domains have been found.", $json['message']);
$this->assertCount(1, $json['list']);
$this->assertSame('kolab.org', $json['list'][0]['namespace']);
@@ -310,20 +309,20 @@
$sku_domain = Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$user = $this->getTestUser('test1@domainscontroller.com');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- $discount = \App\Discount::withEnvTenantContext()->where('code', 'TEST')->first();
+ $discount = Discount::withEnvTenantContext()->where('code', 'TEST')->first();
$wallet = $user->wallet();
$wallet->discount()->associate($discount);
$wallet->save();
Entitlement::create([
- 'wallet_id' => $user->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
$response = $this->actingAs($user)->get("api/v4/domains/{$domain->id}");
@@ -331,19 +330,19 @@
$json = $response->json();
- $this->assertEquals($domain->id, $json['id']);
- $this->assertEquals($domain->namespace, $json['namespace']);
- $this->assertEquals($domain->status, $json['status']);
- $this->assertEquals($domain->type, $json['type']);
+ $this->assertSame($domain->id, $json['id']);
+ $this->assertSame($domain->namespace, $json['namespace']);
+ $this->assertSame($domain->status, $json['status']);
+ $this->assertSame($domain->type, $json['type']);
$this->assertSame($domain->hash(Domain::HASH_TEXT), $json['hash_text']);
$this->assertSame($domain->hash(Domain::HASH_CNAME), $json['hash_cname']);
$this->assertSame($domain->hash(Domain::HASH_CODE), $json['hash_code']);
$this->assertSame([], $json['config']['spf_whitelist']);
$this->assertCount(4, $json['mx']);
- $this->assertTrue(strpos(implode("\n", $json['mx']), $domain->namespace) !== false);
+ $this->assertTrue(str_contains(implode("\n", $json['mx']), $domain->namespace));
$this->assertCount(8, $json['dns']);
- $this->assertTrue(strpos(implode("\n", $json['dns']), $domain->namespace) !== false);
- $this->assertTrue(strpos(implode("\n", $json['dns']), $domain->hash()) !== false);
+ $this->assertTrue(str_contains(implode("\n", $json['dns']), $domain->namespace));
+ $this->assertTrue(str_contains(implode("\n", $json['dns']), $domain->hash()));
$this->assertTrue(is_array($json['statusInfo']));
// Values below are tested by Unit tests
$this->assertArrayHasKey('isConfirmed', $json);
@@ -399,12 +398,12 @@
// Create an sku for another tenant, to make sure it is not included in the result
$nsku = Sku::create([
- 'title' => 'test',
- 'name' => 'Test',
- 'description' => '',
- 'active' => true,
- 'cost' => 100,
- 'handler_class' => 'App\Handlers\Domain',
+ 'title' => 'test',
+ 'name' => 'Test',
+ 'description' => '',
+ 'active' => true,
+ 'cost' => 100,
+ 'handler_class' => 'App\Handlers\Domain',
]);
$tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first();
$nsku->tenant_id = $tenant->id;
@@ -417,11 +416,11 @@
$this->assertCount(1, $json);
$this->assertSkuElement('domain-hosting', $json[0], [
- 'prio' => 0,
- 'type' => 'domain',
- 'handler' => 'DomainHosting',
- 'enabled' => true,
- 'readonly' => true,
+ 'prio' => 0,
+ 'type' => 'domain',
+ 'handler' => 'DomainHosting',
+ 'enabled' => true,
+ 'readonly' => true,
]);
}
@@ -460,7 +459,7 @@
$this->assertFalse($json['isDone']);
$this->assertCount($withLdap ? 4 : 3, $json['process']);
$this->assertSame('domain-verified', $json['process'][$withLdap ? 2 : 1]['label']);
- $this->assertSame(false, $json['process'][$withLdap ? 2 : 1]['state']);
+ $this->assertFalse($json['process'][$withLdap ? 2 : 1]['state']);
$this->assertTrue(empty($json['status']));
$this->assertTrue(empty($json['message']));
@@ -475,9 +474,9 @@
$this->assertTrue($json['isDone']);
$this->assertCount($withLdap ? 4 : 3, $json['process']);
$this->assertSame('domain-verified', $json['process'][$withLdap ? 2 : 1]['label']);
- $this->assertSame(true, $json['process'][$withLdap ? 2 : 1]['state']);
+ $this->assertTrue($json['process'][$withLdap ? 2 : 1]['state']);
$this->assertSame('domain-confirmed', $json['process'][$withLdap ? 3 : 2]['label']);
- $this->assertSame(true, $json['process'][$withLdap ? 3 : 2]['state']);
+ $this->assertTrue($json['process'][$withLdap ? 3 : 2]['state']);
$this->assertSame('success', $json['status']);
$this->assertSame('Setup process finished successfully.', $json['message']);
@@ -541,8 +540,8 @@
$this->assertCount(2, $json);
$this->assertSame('The specified domain is not available.', $json['errors']['namespace']);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
// Missing package
$post = ['namespace' => 'domainscontroller.com'];
diff --git a/src/tests/Feature/Controller/FsTest.php b/src/tests/Feature/Controller/FsTest.php
--- a/src/tests/Feature/Controller/FsTest.php
+++ b/src/tests/Feature/Controller/FsTest.php
@@ -6,8 +6,10 @@
use App\Fs\Property;
use App\Support\Facades\Storage;
use App\User;
+use App\Utils;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage as LaravelStorage;
+use Illuminate\Testing\TestResponse;
use Tests\TestCase;
/**
@@ -15,20 +17,14 @@
*/
class FsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Item::query()->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Item::query()->forceDelete();
@@ -69,7 +65,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame("File deleted successfully.", $json['message']);
- $this->assertSame(null, Item::find($file->id));
+ $this->assertNull(Item::find($file->id));
// Note: The file is expected to stay still in the filesystem, we're not testing this here.
@@ -92,7 +88,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame("Collection deleted successfully.", $json['message']);
- $this->assertSame(null, Item::find($collection->id));
+ $this->assertNull(Item::find($collection->id));
}
/**
@@ -245,7 +241,7 @@
$this->assertSame($permission->key, $json['id']);
$this->assertSame($jack->email, $json['user']);
$this->assertSame('read-only', $json['permissions']);
- $this->assertSame(\App\Utils::serviceUrl('file/' . $permission->key), $json['link']);
+ $this->assertSame(Utils::serviceUrl('file/' . $permission->key), $json['link']);
// Error handling on use of the same user
$post = ['user' => 'jack@kolab.org', 'permissions' => 'read-only'];
@@ -276,7 +272,7 @@
$this->assertSame($permission->key, $json['id']);
$this->assertSame($jack->email, $json['user']);
$this->assertSame('read-write', $json['permissions']);
- $this->assertSame(\App\Utils::serviceUrl('file/' . $permission->key), $json['link']);
+ $this->assertSame(Utils::serviceUrl('file/' . $permission->key), $json['link']);
// Input validation on update
$post = ['user' => 'jack@kolab.org', 'permissions' => 'read'];
@@ -301,7 +297,7 @@
$this->assertSame($permission->key, $json['list'][0]['id']);
$this->assertSame($jack->email, $json['list'][0]['user']);
$this->assertSame('read-write', $json['list'][0]['permissions']);
- $this->assertSame(\App\Utils::serviceUrl('file/' . $permission->key), $json['list'][0]['link']);
+ $this->assertSame(Utils::serviceUrl('file/' . $permission->key), $json['list'][0]['link']);
// Delete permission
$response = $this->actingAs($john)->delete("api/v4/fs/{$file->id}/permissions/1234");
@@ -338,7 +334,7 @@
$this->assertCount(3, $json);
$this->assertSame([], $json['list']);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
// Create some files and test again
$file1 = $this->getTestFile($user, 'test1.txt', [], ['mimetype' => 'text/plain', 'size' => 12345]);
@@ -351,7 +347,7 @@
$this->assertCount(3, $json);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(2, $json['list']);
$this->assertSame('test1.txt', $json['list'][0]['name']);
$this->assertSame($file1->id, $json['list'][0]['id']);
@@ -366,7 +362,7 @@
$this->assertCount(3, $json);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame('test2.gif', $json['list'][0]['name']);
$this->assertSame($file2->id, $json['list'][0]['id']);
@@ -457,9 +453,9 @@
$this->assertSame($file->getProperty('mimetype'), $json['mimetype']);
$this->assertSame((int) $file->getProperty('size'), $json['size']);
$this->assertSame($file->getProperty('name'), $json['name']);
- $this->assertSame(true, $json['isOwner']);
- $this->assertSame(true, $json['canUpdate']);
- $this->assertSame(true, $json['canDelete']);
+ $this->assertTrue($json['isOwner']);
+ $this->assertTrue($json['canUpdate']);
+ $this->assertTrue($json['canDelete']);
// Get file content
$response = $this->actingAs($john)->get("api/v4/fs/{$file->id}?download=1");
@@ -477,9 +473,9 @@
$json = $response->json();
$this->assertSame($file->id, $json['id']);
- $this->assertSame(false, $json['isOwner']);
- $this->assertSame(false, $json['canUpdate']);
- $this->assertSame(false, $json['canDelete']);
+ $this->assertFalse($json['isOwner']);
+ $this->assertFalse($json['canUpdate']);
+ $this->assertFalse($json['canDelete']);
}
/**
@@ -635,7 +631,6 @@
$this->assertSame($collection->id, $json['id']);
$this->assertSame($params['name'], $collection->getProperty('name'));
-
// Deduplicate again, but without changes
$parent = $this->getTestCollection($john, 'Parent');
$response = $this->actingAs($john)->post("api/v4/fs?type=collection", $params);
@@ -665,7 +660,6 @@
$this->assertSame(1, $newItem->parents()->count());
$this->assertSame($collection->id, $newItem->parents()->first()->id);
-
$collection2 = $this->getTestCollection($john, 'My Test Collection2');
$headers = ["X-Kolab-Parents" => implode(',', [$collection->id, $collection2->id])];
$response = $this->sendRawBody($john, 'POST', "api/v4/fs?name=test2.txt", $headers, $body);
@@ -723,7 +717,7 @@
$fileContent = '';
for ($x = 0; $x <= 2; $x++) {
- $body = str_repeat("$x", 100);
+ $body = str_repeat("{$x}", 100);
$response = $this->sendRawBody(null, 'POST', "api/v4/fs/uploads/{$uploadId}?from={$size}", [], $body);
$response->assertStatus(200);
@@ -735,7 +729,7 @@
$this->assertSame($uploadId, $json['uploadId']);
}
- $body = str_repeat("$x", 100);
+ $body = str_repeat("{$x}", 100);
$response = $this->sendRawBody(null, 'POST', "api/v4/fs/uploads/{$uploadId}?from={$size}", [], $body);
$response->assertStatus(200);
@@ -876,12 +870,10 @@
/**
* Create a test file.
*
- * @param \App\User $user File owner
+ * @param User $user File owner
* @param string $name File name
* @param string|array $content File content
* @param array $props Extra file properties
- *
- * @return \App\Fs\Item
*/
protected function getTestFile(User $user, string $name, $content = [], $props = []): Item
{
@@ -894,7 +886,7 @@
// do nothing, we don't need the body here
} else {
foreach ((array) $content as $idx => $chunk) {
- $chunkId = \App\Utils::uuidStr();
+ $chunkId = Utils::uuidStr();
$path = Storage::chunkLocation($chunkId, $file);
$disk->write($path, $chunk);
@@ -902,9 +894,9 @@
$size += strlen($chunk);
$file->chunks()->create([
- 'chunk_id' => $chunkId,
- 'sequence' => $idx,
- 'size' => strlen($chunk),
+ 'chunk_id' => $chunkId,
+ 'sequence' => $idx,
+ 'size' => strlen($chunk),
]);
}
}
@@ -923,11 +915,9 @@
/**
* Create a test collection.
*
- * @param \App\User $user File owner
- * @param string $name File name
- * @param array $props Extra collection properties
- *
- * @return \App\Fs\Item
+ * @param User $user File owner
+ * @param string $name File name
+ * @param array $props Extra collection properties
*/
protected function getTestCollection(User $user, string $name, $props = []): Item
{
@@ -945,15 +935,13 @@
/**
* Get contents of a test file.
*
- * @param \App\Fs\Item $file File record
- *
- * @return string
+ * @param Item $file File record
*/
protected function getTestFileContent(Item $file): string
{
$content = '';
- $file->chunks()->orderBy('sequence')->get()->each(function ($chunk) use ($file, &$content) {
+ $file->chunks()->orderBy('sequence')->get()->each(static function ($chunk) use ($file, &$content) {
$disk = LaravelStorage::disk(\config('filesystems.default'));
$path = Storage::chunkLocation($chunk->chunk_id, $file);
@@ -966,32 +954,32 @@
/**
* Create a test file permission.
*
- * @param \App\Fs\Item $file The file
- * @param \App\User $user File owner
- * @param string $permission File permission
+ * @param Item $file The file
+ * @param User $user File owner
+ * @param string $permission File permission
*
- * @return \App\Fs\Property File permission property
+ * @return Property File permission property
*/
protected function getTestFilePermission(Item $file, User $user, string $permission): Property
{
- $shareId = 'share-' . \App\Utils::uuidStr();
+ $shareId = 'share-' . Utils::uuidStr();
return $file->properties()->create([
- 'key' => $shareId,
- 'value' => "{$user->email}:{$permission}",
+ 'key' => $shareId,
+ 'value' => "{$user->email}:{$permission}",
]);
}
/**
* Invoke a HTTP request with a custom raw body
*
- * @param ?\App\User $user Authenticated user
- * @param string $method Request method (POST, PUT)
- * @param string $uri Request URL
- * @param array $headers Request headers
- * @param string $content Raw body content
+ * @param ?User $user Authenticated user
+ * @param string $method Request method (POST, PUT)
+ * @param string $uri Request URL
+ * @param array $headers Request headers
+ * @param string $content Raw body content
*
- * @return \Illuminate\Testing\TestResponse HTTP Response object
+ * @return TestResponse HTTP Response object
*/
protected function sendRawBody(?User $user, string $method, string $uri, array $headers, string $content)
{
@@ -1002,9 +990,8 @@
if ($user) {
return $this->actingAs($user)->call($method, $uri, [], $cookies, [], $server, $content);
- } else {
- // TODO: Make sure this does not use "acting user" set earlier
- return $this->call($method, $uri, [], $cookies, [], $server, $content);
}
+ // TODO: Make sure this does not use "acting user" set earlier
+ return $this->call($method, $uri, [], $cookies, [], $server, $content);
}
}
diff --git a/src/tests/Feature/Controller/GroupsTest.php b/src/tests/Feature/Controller/GroupsTest.php
--- a/src/tests/Feature/Controller/GroupsTest.php
+++ b/src/tests/Feature/Controller/GroupsTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Controller;
+use App\Domain;
use App\Group;
use App\Http\Controllers\API\V4\GroupsController;
use Carbon\Carbon;
@@ -10,10 +11,7 @@
class GroupsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +19,7 @@
$this->deleteTestGroup('group-test2@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
$this->deleteTestGroup('group-test2@kolab.org');
@@ -67,8 +62,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals("Distribution list deleted successfully.", $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame("Distribution list deleted successfully.", $json['message']);
}
/**
@@ -95,7 +90,7 @@
$this->assertCount(4, $json);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("0 distribution lists have been found.", $json['message']);
$this->assertSame([], $json['list']);
@@ -107,7 +102,7 @@
$this->assertCount(4, $json);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("1 distribution lists have been found.", $json['message']);
$this->assertCount(1, $json['list']);
$this->assertSame($group->id, $json['list'][0]['id']);
@@ -128,7 +123,7 @@
$this->assertCount(4, $json);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("1 distribution lists have been found.", $json['message']);
$this->assertCount(1, $json['list']);
$this->assertSame($group->email, $json['list'][0]['email']);
@@ -285,11 +280,11 @@
$this->assertCount(1, $json);
$this->assertSkuElement('group', $json[0], [
- 'prio' => 0,
- 'type' => 'group',
- 'handler' => 'Group',
- 'enabled' => true,
- 'readonly' => true,
+ 'prio' => 0,
+ 'type' => 'group',
+ 'handler' => 'Group',
+ 'enabled' => true,
+ 'readonly' => true,
]);
}
@@ -329,7 +324,7 @@
$this->assertFalse($json['isReady']);
$this->assertCount(6, $json['process']);
$this->assertSame('distlist-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
} else {
$this->assertCount(4, $json['process']);
$this->assertTrue($json['isReady']);
@@ -338,13 +333,13 @@
$this->assertTrue($json['isActive']);
$this->assertFalse($json['isDeleted']);
$this->assertSame('distlist-new', $json['process'][0]['label']);
- $this->assertSame(true, $json['process'][0]['state']);
+ $this->assertTrue($json['process'][0]['state']);
$this->assertTrue(empty($json['status']));
$this->assertTrue(empty($json['message']));
// Make sure the domain is confirmed (other test might unset that status)
$domain = $this->getTestDomain('kolab.org');
- $domain->status |= \App\Domain::STATUS_CONFIRMED;
+ $domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
// Now "reboot" the process and the group
@@ -357,14 +352,14 @@
$this->assertTrue($json['isLdapReady']);
$this->assertCount(6, $json['process']);
$this->assertSame('distlist-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(true, $json['process'][1]['state']);
+ $this->assertTrue($json['process'][1]['state']);
}
$this->assertTrue($json['isReady']);
$this->assertSame('success', $json['status']);
$this->assertSame('Setup process finished successfully.', $json['message']);
// Test a case when a domain is not ready
- $domain->status ^= \App\Domain::STATUS_CONFIRMED;
+ $domain->status ^= Domain::STATUS_CONFIRMED;
$domain->save();
$response = $this->actingAs($john)->get("/api/v4/groups/{$group->id}/status?refresh=1");
@@ -376,7 +371,7 @@
$this->assertTrue($json['isLdapReady']);
$this->assertCount(6, $json['process']);
$this->assertSame('distlist-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(true, $json['process'][1]['state']);
+ $this->assertTrue($json['process'][1]['state']);
}
$this->assertTrue($json['isReady']);
$this->assertSame('success', $json['status']);
@@ -400,9 +395,9 @@
$this->assertFalse($result['isDone']);
$this->assertCount(6, $result['process']);
$this->assertSame('distlist-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
$this->assertSame('distlist-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
$this->assertSame('running', $result['processState']);
} else {
$this->assertTrue($result['isDone']);
@@ -425,9 +420,9 @@
$this->assertTrue($result['isDone']);
$this->assertCount(6, $result['process']);
$this->assertSame('distlist-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
$this->assertSame('distlist-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
$this->assertSame('done', $result['processState']);
}
@@ -492,7 +487,7 @@
$post = [
'name' => 'Test Group',
'email' => 'group-test@kolab.org',
- 'members' => ['test1@domain.tld', 'test2@domain.tld']
+ 'members' => ['test1@domain.tld', 'test2@domain.tld'],
];
$response = $this->actingAs($john)->post("/api/v4/groups", $post);
@@ -570,7 +565,7 @@
// Valid data - members and name changed
$post = [
'name' => 'Test Gr',
- 'members' => ['member1@test.domain', 'member2@test.domain']
+ 'members' => ['member1@test.domain', 'member2@test.domain'],
];
$response = $this->actingAs($john)->put("/api/v4/groups/{$group->id}", $post);
@@ -630,7 +625,7 @@
// valid
$result = GroupsController::validateGroupEmail('admin@kolab.org', $john);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
}
/**
@@ -656,14 +651,14 @@
// Test local existing user
$result = GroupsController::validateMemberEmail('ned@kolab.org', $john);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
// Test existing user, but not in the same account
$result = GroupsController::validateMemberEmail('jeroen@jeroen.jeroen', $john);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
// Valid address
$result = GroupsController::validateMemberEmail('test@google.com', $john);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
}
}
diff --git a/src/tests/Feature/Controller/HealthTest.php b/src/tests/Feature/Controller/HealthTest.php
--- a/src/tests/Feature/Controller/HealthTest.php
+++ b/src/tests/Feature/Controller/HealthTest.php
@@ -6,18 +6,12 @@
class HealthTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
diff --git a/src/tests/Feature/Controller/LicenseTest.php b/src/tests/Feature/Controller/LicenseTest.php
--- a/src/tests/Feature/Controller/LicenseTest.php
+++ b/src/tests/Feature/Controller/LicenseTest.php
@@ -7,10 +7,7 @@
class LicenseTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +15,7 @@
$user->licenses()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$user = $this->getTestUser('john@kolab.org');
$user->licenses()->delete();
@@ -42,9 +36,9 @@
$response->assertStatus(401);
$license = License::create([
- 'key' => (string) microtime(true),
- 'type' => 'test',
- 'tenant_id' => $user->tenant_id,
+ 'key' => (string) microtime(true),
+ 'type' => 'test',
+ 'tenant_id' => $user->tenant_id,
]);
// Unknow type
@@ -70,7 +64,7 @@
$this->assertSame($license->type, $json['list'][0]['type']);
$license->refresh();
- $this->assertEquals($user->id, $license->user_id);
+ $this->assertSame($user->id, $license->user_id);
// Try again with assigned license
$response = $this->actingAs($user)->get("api/v4/license/test");
@@ -83,6 +77,6 @@
$this->assertFalse($json['hasMore']);
$this->assertSame($license->key, $json['list'][0]['key']);
$this->assertSame($license->type, $json['list'][0]['type']);
- $this->assertEquals($user->id, $license->user_id);
+ $this->assertSame($user->id, $license->user_id);
}
}
diff --git a/src/tests/Feature/Controller/MeetTest.php b/src/tests/Feature/Controller/MeetTest.php
--- a/src/tests/Feature/Controller/MeetTest.php
+++ b/src/tests/Feature/Controller/MeetTest.php
@@ -2,16 +2,12 @@
namespace Tests\Feature\Controller;
-use App\Http\Controllers\API\V4\MeetController;
use App\Meet\Room;
use Tests\TestCase;
class MeetTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +15,7 @@
$room->setSettings(['password' => null, 'locked' => null, 'nomedia' => null]);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$room = Room::where('name', 'john')->first();
$room->setSettings(['password' => null, 'locked' => null, 'nomedia' => null]);
@@ -267,6 +260,7 @@
* Test joining the room
*
* @group meet
+ *
* @depends testJoinRoom
*/
public function testJoinRoomGuest(): void
diff --git a/src/tests/Feature/Controller/MetricsTest.php b/src/tests/Feature/Controller/MetricsTest.php
--- a/src/tests/Feature/Controller/MetricsTest.php
+++ b/src/tests/Feature/Controller/MetricsTest.php
@@ -6,19 +6,13 @@
class MetricsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->useServicesUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
diff --git a/src/tests/Feature/Controller/NGINXTest.php b/src/tests/Feature/Controller/NGINXTest.php
--- a/src/tests/Feature/Controller/NGINXTest.php
+++ b/src/tests/Feature/Controller/NGINXTest.php
@@ -3,42 +3,40 @@
namespace Tests\Feature\Controller;
use App\Auth\Utils as AuthUtils;
+use App\AuthAttempt;
+use App\CompanionApp;
+use App\IP4Net;
+use App\Utils;
use Tests\TestCase;
class NGINXTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$john = $this->getTestUser('john@kolab.org');
- \App\CompanionApp::where('user_id', $john->id)->delete();
- \App\AuthAttempt::where('user_id', $john->id)->delete();
+ CompanionApp::where('user_id', $john->id)->delete();
+ AuthAttempt::where('user_id', $john->id)->delete();
$john->setSettings([
- 'limit_geo' => null,
- 'guam_enabled' => null,
+ 'limit_geo' => null,
+ 'guam_enabled' => null,
]);
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
$this->useServicesUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$john = $this->getTestUser('john@kolab.org');
- \App\CompanionApp::where('user_id', $john->id)->delete();
- \App\AuthAttempt::where('user_id', $john->id)->delete();
+ CompanionApp::where('user_id', $john->id)->delete();
+ AuthAttempt::where('user_id', $john->id)->delete();
$john->setSettings([
- 'limit_geo' => null,
- 'guam_enabled' => null,
+ 'limit_geo' => null,
+ 'guam_enabled' => null,
]);
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
parent::tearDown();
}
@@ -54,7 +52,7 @@
$response->assertStatus(200);
$response->assertHeader('auth-status', 'authentication failure');
- $pass = \App\Utils::generatePassphrase();
+ $pass = Utils::generatePassphrase();
$headers = [
'Auth-Login-Attempt' => '1',
'Auth-Method' => 'plain',
@@ -69,7 +67,7 @@
'Auth-SSL-Subject' => '/CN=example.com',
'Auth-SSL-Issuer' => '/CN=example.com',
'Auth-SSL-Serial' => 'C07AD56B846B5BFF',
- 'Auth-SSL-Fingerprint' => '29d6a80a123d13355ed16b4b04605e29cb55a5ad'
+ 'Auth-SSL-Fingerprint' => '29d6a80a123d13355ed16b4b04605e29cb55a5ad',
];
// Pass
@@ -150,7 +148,7 @@
);
// 2-FA with accepted auth attempt
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($john, "127.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($john, "127.0.0.1");
$authAttempt->accept();
$response = $this->withHeaders($headers)->get("api/webhooks/nginx");
@@ -179,25 +177,25 @@
$response->assertStatus(200);
$response->assertHeader('auth-status', 'authentication failure');
- $authAttempt = \App\AuthAttempt::where('ip', $headers['Client-Ip'])->where('user_id', $john->id)->first();
+ $authAttempt = AuthAttempt::where('ip', $headers['Client-Ip'])->where('user_id', $john->id)->first();
$this->assertSame('geolocation', $authAttempt->reason);
- \App\AuthAttempt::where('user_id', $john->id)->delete();
+ AuthAttempt::where('user_id', $john->id)->delete();
// Geo-lockin (success)
- \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$response = $this->withHeaders($headers)->get("api/webhooks/nginx");
$response->assertStatus(200);
$response->assertHeader('auth-status', 'OK');
- $this->assertCount(0, \App\AuthAttempt::where('user_id', $john->id)->get());
+ $this->assertCount(0, AuthAttempt::where('user_id', $john->id)->get());
// Token auth (valid)
$modifiedHeaders['Auth-Pass'] = AuthUtils::tokenCreate($john->id);
@@ -223,7 +221,7 @@
$response = $this->get("api/webhooks/nginx-httpauth");
$response->assertStatus(200);
- $pass = \App\Utils::generatePassphrase();
+ $pass = Utils::generatePassphrase();
$headers = [
'Php-Auth-Pw' => $pass,
'Php-Auth-User' => 'john@kolab.org',
@@ -284,7 +282,7 @@
);
// 2-FA with accepted auth attempt
- $authAttempt = \App\AuthAttempt::recordAuthAttempt($john, "127.0.0.1");
+ $authAttempt = AuthAttempt::recordAuthAttempt($john, "127.0.0.1");
$authAttempt->accept();
$response = $this->withHeaders($headers)->get("api/webhooks/nginx-httpauth");
@@ -314,14 +312,14 @@
*/
public function testCyrusSaslHook(): void
{
- $pass = \App\Utils::generatePassphrase();
+ $pass = Utils::generatePassphrase();
// Pass
- $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john kolab.org $pass");
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john kolab.org {$pass}");
$response->assertStatus(200);
// Pass without realm
- $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john@kolab.org $pass");
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "john@kolab.org {$pass}");
$response->assertStatus(200);
// Invalid password
@@ -332,15 +330,15 @@
$pass = \config('services.imap.admin_password');
// cyrus-admin Pass
- $response = $this->postWithBody("api/webhooks/cyrus-sasl", "$cyrusAdmin $pass");
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "{$cyrusAdmin} {$pass}");
$response->assertStatus(200);
// cyrus-admin fail
- $response = $this->postWithBody("api/webhooks/cyrus-sasl", "$cyrusAdmin fail");
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "{$cyrusAdmin} fail");
$response->assertStatus(403);
// unknown user fail
- $response = $this->postWithBody("api/webhooks/cyrus-sasl", "missing@kolab.org $pass");
+ $response = $this->postWithBody("api/webhooks/cyrus-sasl", "missing@kolab.org {$pass}");
$response->assertStatus(403);
}
}
diff --git a/src/tests/Feature/Controller/PasswordPolicyTest.php b/src/tests/Feature/Controller/PasswordPolicyTest.php
--- a/src/tests/Feature/Controller/PasswordPolicyTest.php
+++ b/src/tests/Feature/Controller/PasswordPolicyTest.php
@@ -92,21 +92,21 @@
$this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']);
$this->assertSame('min', $json['list'][0]['label']);
$this->assertSame('8', $json['list'][0]['param']);
- $this->assertSame(true, $json['list'][0]['enabled']);
+ $this->assertTrue($json['list'][0]['enabled']);
$this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']);
$this->assertSame('max', $json['list'][1]['label']);
$this->assertSame('255', $json['list'][1]['param']);
- $this->assertSame(true, $json['list'][1]['enabled']);
+ $this->assertTrue($json['list'][1]['enabled']);
$this->assertSame('lower', $json['list'][2]['label']);
- $this->assertSame(false, $json['list'][2]['enabled']);
+ $this->assertFalse($json['list'][2]['enabled']);
$this->assertSame('upper', $json['list'][3]['label']);
- $this->assertSame(false, $json['list'][3]['enabled']);
+ $this->assertFalse($json['list'][3]['enabled']);
$this->assertSame('digit', $json['list'][4]['label']);
- $this->assertSame(false, $json['list'][4]['enabled']);
+ $this->assertFalse($json['list'][4]['enabled']);
$this->assertSame('special', $json['list'][5]['label']);
- $this->assertSame(true, $json['list'][5]['enabled']);
+ $this->assertTrue($json['list'][5]['enabled']);
$this->assertSame('last', $json['list'][6]['label']);
- $this->assertSame(false, $json['list'][6]['enabled']);
+ $this->assertFalse($json['list'][6]['enabled']);
// Test acting as Jack
$response = $this->actingAs($jack)->get('/api/v4/password-policy');
@@ -121,20 +121,20 @@
$this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']);
$this->assertSame('min', $json['list'][0]['label']);
$this->assertSame('8', $json['list'][0]['param']);
- $this->assertSame(true, $json['list'][0]['enabled']);
+ $this->assertTrue($json['list'][0]['enabled']);
$this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']);
$this->assertSame('max', $json['list'][1]['label']);
$this->assertSame('255', $json['list'][1]['param']);
- $this->assertSame(true, $json['list'][1]['enabled']);
+ $this->assertTrue($json['list'][1]['enabled']);
$this->assertSame('lower', $json['list'][2]['label']);
- $this->assertSame(false, $json['list'][2]['enabled']);
+ $this->assertFalse($json['list'][2]['enabled']);
$this->assertSame('upper', $json['list'][3]['label']);
- $this->assertSame(false, $json['list'][3]['enabled']);
+ $this->assertFalse($json['list'][3]['enabled']);
$this->assertSame('digit', $json['list'][4]['label']);
- $this->assertSame(false, $json['list'][4]['enabled']);
+ $this->assertFalse($json['list'][4]['enabled']);
$this->assertSame('special', $json['list'][5]['label']);
- $this->assertSame(true, $json['list'][5]['enabled']);
+ $this->assertTrue($json['list'][5]['enabled']);
$this->assertSame('last', $json['list'][6]['label']);
- $this->assertSame(false, $json['list'][6]['enabled']);
+ $this->assertFalse($json['list'][6]['enabled']);
}
}
diff --git a/src/tests/Feature/Controller/PasswordResetTest.php b/src/tests/Feature/Controller/PasswordResetTest.php
--- a/src/tests/Feature/Controller/PasswordResetTest.php
+++ b/src/tests/Feature/Controller/PasswordResetTest.php
@@ -2,33 +2,30 @@
namespace Tests\Feature\Controller;
-use App\VerificationCode;
+use App\IP4Net;
+use App\Jobs\Mail\PasswordResetJob;
+use App\Jobs\User\UpdateJob;
use App\User;
+use App\VerificationCode;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class PasswordResetTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('passwordresettest@' . \config('app.domain'));
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('passwordresettest@' . \config('app.domain'));
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
parent::tearDown();
}
@@ -120,17 +117,17 @@
$this->assertNotEmpty($json['code']);
// Assert the email sending job was pushed once
- Queue::assertPushed(\App\Jobs\Mail\PasswordResetJob::class, 1);
+ Queue::assertPushed(PasswordResetJob::class, 1);
// Assert the job has proper data assigned
- Queue::assertPushed(\App\Jobs\Mail\PasswordResetJob::class, function ($job) use ($user, &$code, $json) {
+ Queue::assertPushed(PasswordResetJob::class, static function ($job) use ($user, &$code, $json) {
$code = TestCase::getObjectProperty($job, 'code');
return $code->user->id == $user->id && $code->code == $json['code'];
});
return [
- 'code' => $code
+ 'code' => $code,
];
}
@@ -157,13 +154,13 @@
$this->assertSame('error', $json['status']);
$this->assertSame("The request location is not allowed.", $json['errors']['email']);
- \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$response = $this->withHeaders($headers)->post('/api/auth/password-reset/init', $post);
@@ -177,8 +174,6 @@
/**
* Test password-reset/verify with invalid input
- *
- * @return void
*/
public function testPasswordResetVerifyInvalidInput()
{
@@ -230,8 +225,6 @@
/**
* Test password-reset/verify with valid input
- *
- * @return void
*/
public function testPasswordResetVerifyValidInput()
{
@@ -257,8 +250,6 @@
/**
* Test password-reset with invalid input
- *
- * @return void
*/
public function testPasswordResetInvalidInput()
{
@@ -345,8 +336,6 @@
/**
* Test password reset with valid input
- *
- * @return void
*/
public function testPasswordResetValidInput()
{
@@ -375,11 +364,11 @@
$this->assertSame($user->email, $json['email']);
$this->assertSame($user->id, $json['id']);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($user) {
+ UpdateJob::class,
+ static function ($job) use ($user) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
$userId = TestCase::getObjectProperty($job, 'userId');
@@ -397,8 +386,6 @@
/**
* Test creating a password verification code
- *
- * @return void
*/
public function testCodeCreate()
{
@@ -420,8 +407,6 @@
/**
* Test deleting a password verification code
- *
- * @return void
*/
public function testCodeDelete()
{
diff --git a/src/tests/Feature/Controller/PaymentsCoinbaseTest.php b/src/tests/Feature/Controller/PaymentsCoinbaseTest.php
--- a/src/tests/Feature/Controller/PaymentsCoinbaseTest.php
+++ b/src/tests/Feature/Controller/PaymentsCoinbaseTest.php
@@ -2,24 +2,22 @@
namespace Tests\Feature\Controller;
+use App\Jobs\Mail\PaymentJob;
use App\Payment;
use App\Transaction;
+use App\Utils;
use App\Wallet;
use App\WalletSetting;
-use App\Utils;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
-use Tests\TestCase;
use Tests\CoinbaseMocksTrait;
+use Tests\TestCase;
class PaymentsCoinbaseTest extends TestCase
{
use CoinbaseMocksTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -43,10 +41,7 @@
Transaction::where('object_id', $wallet->id)->whereIn('type', $types)->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.coinbase.key')) {
$john = $this->getTestUser('john@kolab.org');
@@ -164,12 +159,11 @@
$this->assertSame('BTC', $payment->currency);
$this->assertSame($user->tenant->title . ' Payment', $payment->description);
$this->assertSame('open', $payment->status);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
// Test the webhook
$post = [
- 'event' =>
- [
+ 'event' => [
'api_version' => '2018-03-22',
'data' => [
'code' => $payment->id,
@@ -181,7 +175,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -194,12 +188,11 @@
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
// Verify "paid -> open -> paid" scenario, assert that balance didn't change
$post = [
- 'event' =>
- [
+ 'event' => [
'api_version' => '2018-03-22',
'data' => [
'code' => $payment->id,
@@ -211,11 +204,10 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$post = [
- 'event' =>
- [
+ 'event' => [
'api_version' => '2018-03-22',
'data' => [
'code' => $payment->id,
@@ -228,7 +220,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Test for payment failure
Bus::fake();
@@ -238,8 +230,7 @@
$payment->save();
$post = [
- 'event' =>
- [
+ 'event' => [
'api_version' => '2018-03-22',
'data' => [
'code' => $payment->id,
@@ -253,11 +244,11 @@
$response->assertStatus(200);
$this->assertSame('failed', $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
}
/**
@@ -298,11 +289,10 @@
$this->assertSame(1234, $payment->amount);
$this->assertSame(5, $payment->currency_amount);
$this->assertSame('BTC', $payment->currency);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
$post = [
- 'event' =>
- [
+ 'event' => [
'api_version' => '2018-03-22',
'data' => [
'code' => $payment->id,
@@ -315,7 +305,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
}
/**
@@ -343,19 +333,19 @@
$user = $this->getTestUser('john@kolab.org');
- //Empty response
+ // Empty response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(0, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(0, $json['list']);
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
$wallet = $user->wallets()->first();
@@ -379,14 +369,14 @@
$response = $this->actingAs($user)->post("api/v4/payments", $post);
$response->assertStatus(200);
- //A response
+ // A response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame(Payment::STATUS_OPEN, $json['list'][0]['status']);
$this->assertSame('CHF', $json['list'][0]['currency']);
@@ -395,7 +385,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(true, $json['hasPending']);
+ $this->assertTrue($json['hasPending']);
// Set the payment to paid
$payments = Payment::where('wallet_id', $wallet->id)->get();
@@ -415,7 +405,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
}
/**
diff --git a/src/tests/Feature/Controller/PaymentsMollieEuroTest.php b/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
--- a/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
+++ b/src/tests/Feature/Controller/PaymentsMollieEuroTest.php
@@ -2,16 +2,19 @@
namespace Tests\Feature\Controller;
+use App\Jobs\Mail\PaymentJob;
+use App\Jobs\Mail\PaymentMandateDisabledJob;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
use App\Providers\PaymentProvider;
use App\Transaction;
use App\Wallet;
-use App\WalletSetting;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Http;
-use Tests\TestCase;
+use Mollie\Api\Types\RefundStatus;
use Tests\BrowserAddonTrait;
+use Tests\TestCase;
class PaymentsMollieEuroTest extends TestCase
{
@@ -19,10 +22,7 @@
protected const API_URL = 'https://api.mollie.com/v2';
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -34,10 +34,7 @@
\config(['services.payment_provider' => 'mollie']);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.mollie.key')) {
$this->deleteTestUser('euro@' . \config('app.domain'));
@@ -103,7 +100,7 @@
$this->assertCount(1, $json['errors']);
$min = $wallet->money(Payment::MIN_AMOUNT);
$this->assertSame("Minimum amount for a single payment is {$min}.", $json['errors']['amount']);
- $this->assertMatchesRegularExpression("/[0-9.,]+ €\.$/", $json['errors']['amount']);
+ $this->assertMatchesRegularExpression("/[0-9.,]+ €\\.$/", $json['errors']['amount']);
// Test creating a mandate (negative balance, amount too small)
Wallet::where('id', $wallet->id)->update(['balance' => -2000]);
@@ -138,12 +135,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(false, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertFalse($json['isDisabled']);
$wallet = $user->wallets()->first();
$wallet->setSetting('mandate_disabled', 1);
@@ -153,12 +150,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(true, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertTrue($json['isDisabled']);
Bus::fake();
$wallet->setSetting('mandate_disabled', null);
@@ -186,7 +183,7 @@
$this->assertSame('error', $json['status']);
$this->assertCount(1, $json['errors']);
$this->assertSame("Minimum amount for a single payment is {$min}.", $json['errors']['amount']);
- $this->assertMatchesRegularExpression("/[0-9.,]+ €\.$/", $json['errors']['amount']);
+ $this->assertMatchesRegularExpression("/[0-9.,]+ €\\.$/", $json['errors']['amount']);
// Test updating a mandate (valid input)
$post = ['amount' => 30.10, 'balance' => 10];
@@ -202,10 +199,10 @@
$wallet->refresh();
- $this->assertEquals(30.10, $wallet->getSetting('mandate_amount'));
- $this->assertEquals(10, $wallet->getSetting('mandate_balance'));
+ $this->assertSame(30.10, $wallet->getSetting('mandate_amount'));
+ $this->assertSame(10, $wallet->getSetting('mandate_balance'));
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 0);
+ Bus::assertDispatchedTimes(ChargeJob::class, 0);
// Test updating a disabled mandate (invalid input)
$wallet->setSetting('mandate_disabled', 1);
@@ -235,8 +232,8 @@
$this->assertSame($mandate_id, $json['id']);
$this->assertFalse($json['isDisabled']);
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Wallet\ChargeJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(ChargeJob::class, 1);
+ Bus::assertDispatched(ChargeJob::class, function ($job) use ($wallet) {
$job_wallet_id = $this->getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet->id;
});
@@ -268,9 +265,9 @@
'_links' => [
'documentation' => [
'href' => "https://docs.mollie.com/errors",
- 'type' => "text/html"
- ]
- ]
+ 'type' => "text/html",
+ ],
+ ],
];
$mollieId = $wallet->getSetting('mollie_id');
@@ -319,7 +316,7 @@
$this->assertCount(1, $json['errors']);
$min = $wallet->money(Payment::MIN_AMOUNT);
$this->assertSame("Minimum amount for a single payment is {$min}.", $json['errors']['amount']);
- $this->assertMatchesRegularExpression("/[0-9.,]+ €\.$/", $json['errors']['amount']);
+ $this->assertMatchesRegularExpression("/[0-9.,]+ €\\.$/", $json['errors']['amount']);
// Invalid currency
$post = ['amount' => '12.34', 'currency' => 'FOO', 'methodId' => 'creditcard'];
@@ -345,7 +342,7 @@
$this->assertSame('EUR', $payment->currency);
$this->assertSame($user->tenant->title . ' Payment', $payment->description);
$this->assertSame('open', $payment->status);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
// Test the webhook
// Note: Webhook end-point does not require authentication
@@ -371,7 +368,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -384,7 +381,7 @@
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
// Verify "paid -> open -> paid" scenario, assert that balance didn't change
$mollie_response['status'] = 'open';
@@ -398,7 +395,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$mollie_response['status'] = 'paid';
$mollie_response['paidAt'] = date('c');
@@ -411,7 +408,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Test for payment failure
Bus::fake();
@@ -438,11 +435,11 @@
$response->assertStatus(200);
$this->assertSame('failed', $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
}
/**
@@ -486,7 +483,7 @@
// immediately the balance update
// Assert that email notification job has been dispatched
$this->assertSame(Payment::STATUS_PAID, $payment->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -496,8 +493,8 @@
$transaction->description
);
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -524,8 +521,8 @@
$this->assertFalse($result);
$this->assertCount(2, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatched(PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
$job_wallet = $this->getObjectProperty($job, 'wallet');
return $job_wallet->id === $wallet->id;
});
@@ -538,7 +535,7 @@
$this->assertFalse($result);
$this->assertCount(2, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
// Test webhook for recurring payments
@@ -571,7 +568,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -583,8 +580,8 @@
);
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -616,12 +613,12 @@
$wallet->refresh();
$this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->balance);
+ $this->assertSame(2010, $wallet->balance);
$this->assertTrue(!empty($wallet->getSetting('mandate_disabled')));
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -644,16 +641,16 @@
// Create a paid payment
$payment = Payment::create([
- 'id' => 'tr_123456',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 123,
- 'credit_amount' => 123,
- 'currency_amount' => 123,
- 'currency' => 'EUR',
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'description' => 'test',
+ 'id' => 'tr_123456',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 123,
+ 'credit_amount' => 123,
+ 'currency_amount' => 123,
+ 'currency' => 'EUR',
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'description' => 'test',
]);
// Test handling a refund by the webhook
@@ -667,10 +664,10 @@
"mode" => "test",
"_links" => [
"refunds" => [
- "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
- "type" => "application/hal+json"
- ]
- ]
+ "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
+ "type" => "application/hal+json",
+ ],
+ ],
];
$mollie_response2 = [
@@ -681,16 +678,16 @@
[
"resource" => "refund",
"id" => "re_123456",
- "status" => \Mollie\Api\Types\RefundStatus::STATUS_REFUNDED,
+ "status" => RefundStatus::STATUS_REFUNDED,
"paymentId" => $payment->id,
"description" => "refund desc",
"amount" => [
"currency" => "EUR",
"value" => "1.01",
],
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
// We'll trigger the webhook with payment id and use mocking for
@@ -706,7 +703,7 @@
$wallet->refresh();
- $this->assertEquals(-101, $wallet->balance);
+ $this->assertSame(-101, $wallet->balance);
$transactions = $wallet->transactions()->where('type', Transaction::WALLET_REFUND)->get();
@@ -729,9 +726,9 @@
$mollie_response1["_links"] = [
"chargebacks" => [
- "href" => "https://api.mollie.com/v2/payments/{$payment->id}/chargebacks",
- "type" => "application/hal+json"
- ]
+ "href" => "https://api.mollie.com/v2/payments/{$payment->id}/chargebacks",
+ "type" => "application/hal+json",
+ ],
];
$mollie_response2 = [
@@ -747,9 +744,9 @@
"currency" => "EUR",
"value" => "0.15",
],
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
// We'll trigger the webhook with payment id and use mocking for
@@ -765,7 +762,7 @@
$wallet->refresh();
- $this->assertEquals(-116, $wallet->balance);
+ $this->assertSame(-116, $wallet->balance);
$transactions = $wallet->transactions()->where('type', Transaction::WALLET_CHARGEBACK)->get();
@@ -783,7 +780,7 @@
$this->assertSame("mollie", $payments[0]->provider);
$this->assertSame('', $payments[0]->description);
- Bus::assertNotDispatched(\App\Jobs\Mail\PaymentJob::class);
+ Bus::assertNotDispatched(PaymentJob::class);
}
/**
@@ -800,33 +797,33 @@
$wallet->currency = 'EUR';
$wallet->save();
- //Empty response
+ // Empty response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(0, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(0, $json['list']);
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
// Successful payment
$post = ['amount' => '12.34', 'currency' => 'EUR', 'methodId' => 'creditcard'];
$response = $this->actingAs($user)->post("api/v4/payments", $post);
$response->assertStatus(200);
- //A response
+ // A response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame(Payment::STATUS_OPEN, $json['list'][0]['status']);
$this->assertSame('EUR', $json['list'][0]['currency']);
@@ -835,7 +832,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(true, $json['hasPending']);
+ $this->assertTrue($json['hasPending']);
// Set the payment to paid
$payments = Payment::where('wallet_id', $wallet->id)->get();
@@ -855,7 +852,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
}
/**
@@ -878,7 +875,7 @@
$hasCoinbase = !empty(\config('services.coinbase.key'));
- $this->assertCount(3 + intval($hasCoinbase), $json);
+ $this->assertCount(3 + (int) $hasCoinbase, $json);
$this->assertSame('creditcard', $json[0]['id']);
$this->assertSame('paypal', $json[1]['id']);
$this->assertSame('banktransfer', $json[2]['id']);
diff --git a/src/tests/Feature/Controller/PaymentsMollieTest.php b/src/tests/Feature/Controller/PaymentsMollieTest.php
--- a/src/tests/Feature/Controller/PaymentsMollieTest.php
+++ b/src/tests/Feature/Controller/PaymentsMollieTest.php
@@ -2,19 +2,23 @@
namespace Tests\Feature\Controller;
+use App\Jobs\Mail\PaymentJob;
+use App\Jobs\Mail\PaymentMandateDisabledJob;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
use App\Plan;
use App\Providers\PaymentProvider;
use App\Transaction;
+use App\Utils;
+use App\VatRate;
use App\Wallet;
use App\WalletSetting;
-use App\VatRate;
-use App\Utils;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Http;
-use Tests\TestCase;
+use Mollie\Api\Types\RefundStatus;
use Tests\BrowserAddonTrait;
+use Tests\TestCase;
class PaymentsMollieTest extends TestCase
{
@@ -22,10 +26,7 @@
protected const API_URL = 'https://api.mollie.com/v2';
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -55,10 +56,7 @@
Plan::withEnvTenantContext()->where('title', 'individual')->update(['mode' => 'email', 'months' => 1]);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.mollie.key')) {
$this->deleteTestUser('payment-test@' . \config('app.domain'));
@@ -173,12 +171,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(false, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertFalse($json['isDisabled']);
$wallet = $user->wallets()->first();
$wallet->setSetting('mandate_disabled', 1);
@@ -188,12 +186,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(true, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertTrue($json['isDisabled']);
Bus::fake();
$wallet->setSetting('mandate_disabled', null);
@@ -236,10 +234,10 @@
$wallet->refresh();
- $this->assertEquals(30.10, $wallet->getSetting('mandate_amount'));
- $this->assertEquals(10, $wallet->getSetting('mandate_balance'));
+ $this->assertSame(30.10, $wallet->getSetting('mandate_amount'));
+ $this->assertSame(10, $wallet->getSetting('mandate_balance'));
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 0);
+ Bus::assertDispatchedTimes(ChargeJob::class, 0);
// Test updating a disabled mandate (invalid input)
$wallet->setSetting('mandate_disabled', 1);
@@ -269,8 +267,8 @@
$this->assertSame($mandate_id, $json['id']);
$this->assertFalse($json['isDisabled']);
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Wallet\ChargeJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(ChargeJob::class, 1);
+ Bus::assertDispatched(ChargeJob::class, function ($job) use ($wallet) {
$job_wallet_id = $this->getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet->id;
});
@@ -312,9 +310,9 @@
'_links' => [
'documentation' => [
'href' => "https://docs.mollie.com/errors",
- 'type' => "text/html"
- ]
- ]
+ 'type' => "text/html",
+ ],
+ ],
];
$mollieId = $wallet->getSetting('mollie_id');
@@ -365,8 +363,8 @@
$json = $response->json();
- $this->assertEquals(round($plan->cost() / 100, 2), $json['minAmount']);
- $this->assertEquals($json['minAmount'], $json['amount']);
+ $this->assertSame(round($plan->cost() / 100, 2), $json['minAmount']);
+ $this->assertSame($json['minAmount'], $json['amount']);
// TODO: Test more cases
// TODO: Test user unrestricting if mandate is valid
@@ -424,7 +422,7 @@
$this->assertSame('CHF', $payment->currency);
$this->assertSame($user->tenant->title . ' Payment', $payment->description);
$this->assertSame('open', $payment->status);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
// Test the webhook
// Note: Webhook end-point does not require authentication
@@ -450,7 +448,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -463,7 +461,7 @@
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
// Verify "paid -> open -> paid" scenario, assert that balance didn't change
$mollie_response['status'] = 'open';
@@ -476,7 +474,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$mollie_response['status'] = 'paid';
$mollie_response['paidAt'] = date('c');
@@ -488,7 +486,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Test for payment failure
Bus::fake();
@@ -512,11 +510,11 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
}
/**
@@ -542,7 +540,7 @@
$this->assertSame(1234, $payment->amount);
$this->assertSame(1117, $payment->currency_amount);
$this->assertSame('EUR', $payment->currency);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
$mollie_response = [
"resource" => "payment",
@@ -562,7 +560,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
}
/**
@@ -603,7 +601,7 @@
// immediately the balance update
// Assert that email notification job has been dispatched
$this->assertSame(Payment::STATUS_PAID, $payment->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -613,8 +611,8 @@
$transaction->description
);
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -641,8 +639,8 @@
$this->assertFalse($result);
$this->assertCount(2, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatched(PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
$job_wallet = $this->getObjectProperty($job, 'wallet');
return $job_wallet->id === $wallet->id;
});
@@ -655,7 +653,7 @@
$this->assertFalse($result);
$this->assertCount(2, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
// Test webhook for recurring payments
@@ -688,7 +686,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -700,8 +698,8 @@
);
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -733,12 +731,12 @@
$wallet->refresh();
$this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->balance);
+ $this->assertSame(2010, $wallet->balance);
$this->assertTrue(!empty($wallet->getSetting('mandate_disabled')));
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -758,9 +756,9 @@
$user->setSetting('country', 'US');
$wallet = $user->wallets()->first();
$vatRate = VatRate::create([
- 'country' => 'US',
- 'rate' => 5.0,
- 'start' => now()->subDay(),
+ 'country' => 'US',
+ 'rate' => 5.0,
+ 'start' => now()->subDay(),
]);
// Payment
@@ -770,7 +768,7 @@
// Check that the payments table contains a new record with proper amount(s)
$payment = $wallet->payments()->first();
- $this->assertSame(1000 + intval(round(1000 * $vatRate->rate / 100)), $payment->amount);
+ $this->assertSame(1000 + (int) round(1000 * $vatRate->rate / 100), $payment->amount);
$this->assertSame(1000, $payment->credit_amount);
$this->assertSame($payment->amount, $payment->currency_amount);
$this->assertSame('CHF', $payment->currency);
@@ -787,7 +785,7 @@
// Check that the payments table contains a new record with proper amount(s)
$payment = $wallet->payments()->first();
- $this->assertSame(2010 + intval(round(2010 * $vatRate->rate / 100)), $payment->amount);
+ $this->assertSame(2010 + (int) round(2010 * $vatRate->rate / 100), $payment->amount);
$this->assertSame(2010, $payment->credit_amount);
$this->assertSame($payment->amount, $payment->currency_amount);
$this->assertSame($vatRate->id, $payment->vat_rate_id);
@@ -803,7 +801,7 @@
// Check that the payments table contains a new record with proper amount(s)
$payment = $wallet->payments()->first();
- $this->assertSame(2010 + intval(round(2010 * $vatRate->rate / 100)), $payment->amount);
+ $this->assertSame(2010 + (int) round(2010 * $vatRate->rate / 100), $payment->amount);
$this->assertSame(2010, $payment->credit_amount);
$this->assertSame($payment->amount, $payment->currency_amount);
$this->assertSame($vatRate->id, $payment->vat_rate_id);
@@ -824,16 +822,16 @@
// Create a paid payment
$payment = Payment::create([
- 'id' => 'tr_123456',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 123,
- 'credit_amount' => 123,
- 'currency_amount' => 123,
- 'currency' => 'CHF',
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'description' => 'test',
+ 'id' => 'tr_123456',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 123,
+ 'credit_amount' => 123,
+ 'currency_amount' => 123,
+ 'currency' => 'CHF',
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'description' => 'test',
]);
// Test handling a refund by the webhook
@@ -847,10 +845,10 @@
"mode" => "test",
"_links" => [
"refunds" => [
- "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
- "type" => "application/hal+json"
- ]
- ]
+ "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
+ "type" => "application/hal+json",
+ ],
+ ],
];
$mollie_response2 = [
@@ -861,16 +859,16 @@
[
"resource" => "refund",
"id" => "re_123456",
- "status" => \Mollie\Api\Types\RefundStatus::STATUS_REFUNDED,
+ "status" => RefundStatus::STATUS_REFUNDED,
"paymentId" => $payment->id,
"description" => "refund desc",
"amount" => [
"currency" => "CHF",
"value" => "1.01",
],
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
// We'll trigger the webhook with payment id and use mocking for requests to the Mollie payments API.
@@ -885,7 +883,7 @@
$wallet->refresh();
- $this->assertEquals(-101, $wallet->balance);
+ $this->assertSame(-101, $wallet->balance);
$transactions = $wallet->transactions()->where('type', Transaction::WALLET_REFUND)->get();
@@ -908,9 +906,9 @@
$mollie_response1["_links"] = [
"chargebacks" => [
- "href" => "https://api.mollie.com/v2/payments/{$payment->id}/chargebacks",
- "type" => "application/hal+json"
- ]
+ "href" => "https://api.mollie.com/v2/payments/{$payment->id}/chargebacks",
+ "type" => "application/hal+json",
+ ],
];
$mollie_response2 = [
@@ -926,9 +924,9 @@
"currency" => "CHF",
"value" => "0.15",
],
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
// We'll trigger the webhook with payment id and use mocking for
@@ -944,7 +942,7 @@
$wallet->refresh();
- $this->assertEquals(-116, $wallet->balance);
+ $this->assertSame(-116, $wallet->balance);
$transactions = $wallet->transactions()->where('type', Transaction::WALLET_CHARGEBACK)->get();
@@ -962,7 +960,7 @@
$this->assertSame("mollie", $payments[0]->provider);
$this->assertSame('', $payments[0]->description);
- Bus::assertNotDispatched(\App\Jobs\Mail\PaymentJob::class);
+ Bus::assertNotDispatched(PaymentJob::class);
}
/**
@@ -980,16 +978,16 @@
// Create a paid payment
$payment = Payment::create([
- 'id' => 'tr_123456',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 1234,
- 'credit_amount' => 1234,
- 'currency_amount' => 1117,
- 'currency' => 'EUR',
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'description' => 'test',
+ 'id' => 'tr_123456',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 1234,
+ 'credit_amount' => 1234,
+ 'currency_amount' => 1117,
+ 'currency' => 'EUR',
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'description' => 'test',
]);
// Test handling a refund by the webhook
@@ -1003,10 +1001,10 @@
"mode" => "test",
"_links" => [
"refunds" => [
- "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
- "type" => "application/hal+json"
- ]
- ]
+ "href" => "https://api.mollie.com/v2/payments/{$payment->id}/refunds",
+ "type" => "application/hal+json",
+ ],
+ ],
];
$mollie_response2 = [
@@ -1017,16 +1015,16 @@
[
"resource" => "refund",
"id" => "re_123456",
- "status" => \Mollie\Api\Types\RefundStatus::STATUS_REFUNDED,
+ "status" => RefundStatus::STATUS_REFUNDED,
"paymentId" => $payment->id,
"description" => "refund desc",
"amount" => [
"currency" => "EUR",
"value" => "1.01",
],
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
// We'll trigger the webhook with payment id and use mocking for
@@ -1065,19 +1063,19 @@
$user = $this->getTestUser('john@kolab.org');
- //Empty response
+ // Empty response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(0, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(0, $json['list']);
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
$wallet = $user->wallets()->first();
@@ -1086,14 +1084,14 @@
$response = $this->actingAs($user)->post("api/v4/payments", $post);
$response->assertStatus(200);
- //A response
+ // A response
$response = $this->actingAs($user)->get("api/v4/payments/pending");
$json = $response->json();
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame(Payment::STATUS_OPEN, $json['list'][0]['status']);
$this->assertSame('CHF', $json['list'][0]['currency']);
@@ -1102,7 +1100,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(true, $json['hasPending']);
+ $this->assertTrue($json['hasPending']);
// Set the payment to paid
$payments = Payment::where('wallet_id', $wallet->id)->get();
@@ -1122,7 +1120,7 @@
$response = $this->actingAs($user)->get("api/v4/payments/has-pending");
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
}
/**
@@ -1142,7 +1140,7 @@
$hasCoinbase = !empty(\config('services.coinbase.key'));
- $this->assertCount(3 + intval($hasCoinbase), $json);
+ $this->assertCount(3 + (int) $hasCoinbase, $json);
$this->assertSame('creditcard', $json[0]['id']);
$this->assertSame('paypal', $json[1]['id']);
$this->assertSame('banktransfer', $json[2]['id']);
diff --git a/src/tests/Feature/Controller/PaymentsStripeTest.php b/src/tests/Feature/Controller/PaymentsStripeTest.php
--- a/src/tests/Feature/Controller/PaymentsStripeTest.php
+++ b/src/tests/Feature/Controller/PaymentsStripeTest.php
@@ -2,25 +2,24 @@
namespace Tests\Feature\Controller;
+use App\Jobs\Mail\PaymentJob;
+use App\Jobs\Mail\PaymentMandateDisabledJob;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
use App\Providers\PaymentProvider;
use App\Transaction;
+use App\VatRate;
use App\Wallet;
use App\WalletSetting;
-use App\VatRate;
-use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
-use Tests\TestCase;
use Tests\StripeMocksTrait;
+use Tests\TestCase;
class PaymentsStripeTest extends TestCase
{
use StripeMocksTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -44,10 +43,7 @@
VatRate::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.stripe.key')) {
$this->deleteTestUser('payment-test@' . \config('app.domain'));
@@ -159,9 +155,9 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
- $this->assertSame(false, $json['isDisabled']);
+ $this->assertSame('20.1', $json['amount']);
+ $this->assertSame('0', $json['balance']);
+ $this->assertFalse($json['isDisabled']);
// We would have to invoke a browser to accept the "first payment" to make
// the mandate validated/completed. Instead, we'll mock the mandate object.
@@ -202,12 +198,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
- $this->assertEquals('Visa (**** **** **** 4242)', $json['method']);
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(true, $json['isDisabled']);
+ $this->assertSame('20.1', $json['amount']);
+ $this->assertSame('0', $json['balance']);
+ $this->assertSame('Visa (**** **** **** 4242)', $json['method']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertTrue($json['isDisabled']);
// Test updating mandate details (invalid input)
$wallet->setSetting('mandate_disabled', null);
@@ -247,8 +243,8 @@
$this->assertSame('success', $json['status']);
$this->assertSame('The auto-payment has been updated.', $json['message']);
- $this->assertEquals(30.10, $wallet->getSetting('mandate_amount'));
- $this->assertEquals(10, $wallet->getSetting('mandate_balance'));
+ $this->assertSame('30.1', $wallet->getSetting('mandate_amount'));
+ $this->assertSame('10', $wallet->getSetting('mandate_balance'));
$this->assertSame('AAA', $json['id']);
$this->assertFalse($json['isDisabled']);
@@ -283,8 +279,8 @@
$this->assertSame('AAA', $json['id']);
$this->assertFalse($json['isDisabled']);
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Wallet\ChargeJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(ChargeJob::class, 1);
+ Bus::assertDispatched(ChargeJob::class, function ($job) use ($wallet) {
$job_wallet_id = $this->getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet->id;
});
@@ -366,7 +362,7 @@
$this->assertSame(1234, $payment->amount);
$this->assertSame($user->tenant->title . ' Payment', $payment->description);
$this->assertSame('open', $payment->status);
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
// Test the webhook
@@ -392,10 +388,10 @@
'livemode' => false,
'metadata' => [],
'receipt_email' => "payment-test@kolabnow.com",
- 'status' => "succeeded"
- ]
+ 'status' => "succeeded",
+ ],
],
- 'type' => "payment_intent.succeeded"
+ 'type' => "payment_intent.succeeded",
];
// Test payment succeeded event
@@ -403,7 +399,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -416,14 +412,14 @@
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
// Test that balance didn't change if the same event is posted
$response = $this->webhookRequest($post);
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Test for payment failure ('failed' status)
$payment->refresh();
@@ -437,11 +433,11 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
// Test for payment failure ('canceled' status)
$payment->refresh();
@@ -455,11 +451,11 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_CANCELED, $payment->fresh()->status);
- $this->assertEquals(1234, $wallet->fresh()->balance);
+ $this->assertSame(1234, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
}
/**
@@ -498,10 +494,10 @@
'customer' => "cus_HKDZ53OsKdlM83",
'last_setup_error' => null,
'metadata' => [],
- 'status' => "succeeded"
- ]
+ 'status' => "succeeded",
+ ],
],
- 'type' => "setup_intent.succeeded"
+ 'type' => "setup_intent.succeeded",
];
Bus::fake();
@@ -516,8 +512,8 @@
$this->assertSame($payment->id, $wallet->fresh()->getSetting('stripe_mandate_id'));
// Expect a wallet charge job if the balance is negative
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Wallet\ChargeJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(ChargeJob::class, 1);
+ Bus::assertDispatched(ChargeJob::class, static function ($job) use ($wallet) {
$job_wallet_id = TestCase::getObjectProperty($job, 'walletId');
return $job_wallet_id === $wallet->id;
});
@@ -547,34 +543,34 @@
]);
$setupIntent = json_encode([
- "id" => "AAA",
- "object" => "setup_intent",
- "created" => 123456789,
- "payment_method" => "pm_YYY",
- "status" => "succeeded",
- "usage" => "off_session",
- "customer" => null
+ "id" => "AAA",
+ "object" => "setup_intent",
+ "created" => 123456789,
+ "payment_method" => "pm_YYY",
+ "status" => "succeeded",
+ "usage" => "off_session",
+ "customer" => null,
]);
$paymentMethod = json_encode([
- "id" => "pm_YYY",
- "object" => "payment_method",
- "card" => [
- "brand" => "visa",
- "country" => "US",
- "last4" => "4242"
- ],
- "created" => 123456789,
- "type" => "card"
+ "id" => "pm_YYY",
+ "object" => "payment_method",
+ "card" => [
+ "brand" => "visa",
+ "country" => "US",
+ "last4" => "4242",
+ ],
+ "created" => 123456789,
+ "type" => "card",
]);
$paymentIntent = json_encode([
- "id" => "pi_XX",
- "object" => "payment_intent",
- "created" => 123456789,
- "amount" => 2010,
- "currency" => "chf",
- "description" => $user->tenant->title . " Recurring Payment"
+ "id" => "pi_XX",
+ "object" => "payment_intent",
+ "created" => 123456789,
+ "amount" => 2010,
+ "currency" => "chf",
+ "description" => $user->tenant->title . " Recurring Payment",
]);
$client = $this->mockStripe();
@@ -621,8 +617,8 @@
$this->assertFalse($result);
$this->assertCount(1, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatched(PaymentMandateDisabledJob::class, function ($job) use ($wallet) {
$job_wallet = $this->getObjectProperty($job, 'wallet');
return $job_wallet->id === $wallet->id;
});
@@ -635,7 +631,7 @@
$this->assertFalse($result);
$this->assertCount(1, $wallet->payments()->get());
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentMandateDisabledJob::class, 1);
+ Bus::assertDispatchedTimes(PaymentMandateDisabledJob::class, 1);
$this->unmockStripe();
@@ -658,10 +654,10 @@
'last_payment_error' => null,
'metadata' => [],
'receipt_email' => "payment-test@kolabnow.com",
- 'status' => "succeeded"
- ]
+ 'status' => "succeeded",
+ ],
],
- 'type' => "payment_intent.succeeded"
+ 'type' => "payment_intent.succeeded",
];
// Test payment succeeded event
@@ -669,7 +665,7 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_PAID, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
$transaction = $wallet->transactions()
->where('type', Transaction::WALLET_CREDIT)->get()->last();
@@ -680,8 +676,8 @@
);
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -704,12 +700,12 @@
$wallet->refresh();
$this->assertSame(Payment::STATUS_FAILED, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->balance);
+ $this->assertSame(2010, $wallet->balance);
$this->assertTrue(!empty($wallet->getSetting('mandate_disabled')));
// Assert that email notification job has been dispatched
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 1);
- Bus::assertDispatched(\App\Jobs\Mail\PaymentJob::class, function ($job) use ($payment) {
+ Bus::assertDispatchedTimes(PaymentJob::class, 1);
+ Bus::assertDispatched(PaymentJob::class, function ($job) use ($payment) {
$job_payment = $this->getObjectProperty($job, 'payment');
return $job_payment->id === $payment->id;
});
@@ -728,11 +724,11 @@
$response->assertStatus(200);
$this->assertSame(Payment::STATUS_CANCELED, $payment->fresh()->status);
- $this->assertEquals(2010, $wallet->fresh()->balance);
+ $this->assertSame(2010, $wallet->fresh()->balance);
// Assert that email notification job wasn't dispatched,
// it is expected only for recurring payments
- Bus::assertDispatchedTimes(\App\Jobs\Mail\PaymentJob::class, 0);
+ Bus::assertDispatchedTimes(PaymentJob::class, 0);
}
/**
@@ -748,9 +744,9 @@
$user->setSetting('country', 'US');
$wallet = $user->wallets()->first();
$vatRate = VatRate::create([
- 'country' => 'US',
- 'rate' => 5.0,
- 'start' => now()->subDay(),
+ 'country' => 'US',
+ 'rate' => 5.0,
+ 'start' => now()->subDay(),
]);
// Payment
@@ -760,7 +756,7 @@
// Check that the payments table contains a new record with proper amount(s)
$payment = $wallet->payments()->first();
- $this->assertSame(1000 + intval(round(1000 * $vatRate->rate / 100)), $payment->amount);
+ $this->assertSame(1000 + (int) round(1000 * $vatRate->rate / 100), $payment->amount);
$this->assertSame(1000, $payment->credit_amount);
$this->assertSame($payment->amount, $payment->currency_amount);
$this->assertSame('CHF', $payment->currency);
@@ -783,7 +779,7 @@
$this->assertSame(0, $payment->amount);
$this->assertSame(0, $payment->credit_amount);
$this->assertSame(0, $payment->currency_amount);
- $this->assertSame(null, $payment->vat_rate_id);
+ $this->assertNull($payment->vat_rate_id);
$wallet->payments()->delete();
$wallet->balance = -1000;
@@ -794,34 +790,34 @@
// and the balance is below the threshold
$wallet->setSettings(['stripe_mandate_id' => 'AAA']);
$setupIntent = json_encode([
- "id" => "AAA",
- "object" => "setup_intent",
- "created" => 123456789,
- "payment_method" => "pm_YYY",
- "status" => "succeeded",
- "usage" => "off_session",
- "customer" => null
+ "id" => "AAA",
+ "object" => "setup_intent",
+ "created" => 123456789,
+ "payment_method" => "pm_YYY",
+ "status" => "succeeded",
+ "usage" => "off_session",
+ "customer" => null,
]);
$paymentMethod = json_encode([
- "id" => "pm_YYY",
- "object" => "payment_method",
- "card" => [
- "brand" => "visa",
- "country" => "US",
- "last4" => "4242"
- ],
- "created" => 123456789,
- "type" => "card"
+ "id" => "pm_YYY",
+ "object" => "payment_method",
+ "card" => [
+ "brand" => "visa",
+ "country" => "US",
+ "last4" => "4242",
+ ],
+ "created" => 123456789,
+ "type" => "card",
]);
$paymentIntent = json_encode([
- "id" => "pi_XX",
- "object" => "payment_intent",
- "created" => 123456789,
- "amount" => 2010 + intval(round(2010 * $vatRate->rate / 100)),
- "currency" => "chf",
- "description" => "Recurring Payment"
+ "id" => "pi_XX",
+ "object" => "payment_intent",
+ "created" => 123456789,
+ "amount" => 2010 + (int) round(2010 * $vatRate->rate / 100),
+ "currency" => "chf",
+ "description" => "Recurring Payment",
]);
$client = $this->mockStripe();
@@ -835,7 +831,7 @@
// Check that the payments table contains a new record with proper amount(s)
$payment = $wallet->payments()->first();
- $this->assertSame(2010 + intval(round(2010 * $vatRate->rate / 100)), $payment->amount);
+ $this->assertSame(2010 + (int) round(2010 * $vatRate->rate / 100), $payment->amount);
$this->assertSame(2010, $payment->credit_amount);
$this->assertSame($payment->amount, $payment->currency_amount);
$this->assertSame($vatRate->id, $payment->vat_rate_id);
@@ -858,7 +854,7 @@
$hasCoinbase = !empty(\config('services.coinbase.key'));
- $this->assertCount(2 + intval($hasCoinbase), $json);
+ $this->assertCount(2 + (int) $hasCoinbase, $json);
$this->assertSame('creditcard', $json[0]['id']);
$this->assertSame('paypal', $json[1]['id']);
if ($hasCoinbase) {
@@ -881,7 +877,7 @@
$secret = \config('services.stripe.webhook_secret');
$ts = time();
- $payload = "$ts." . json_encode($post);
+ $payload = "{$ts}." . json_encode($post);
$sig = sprintf('t=%d,v1=%s', $ts, \hash_hmac('sha256', $payload, $secret));
return $this->withHeaders(['Stripe-Signature' => $sig])
diff --git a/src/tests/Feature/Controller/PaymentsTest.php b/src/tests/Feature/Controller/PaymentsTest.php
--- a/src/tests/Feature/Controller/PaymentsTest.php
+++ b/src/tests/Feature/Controller/PaymentsTest.php
@@ -7,20 +7,14 @@
class PaymentsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Payment::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Payment::query()->delete();
@@ -44,16 +38,16 @@
$response->assertStatus(404);
$payment = Payment::create([
- 'id' => 'tr_123456',
- 'status' => Payment::STATUS_PAID,
- 'amount' => 123,
- 'credit_amount' => 123,
- 'currency_amount' => 123,
- 'currency' => 'CHF',
- 'type' => Payment::TYPE_ONEOFF,
- 'wallet_id' => $wallet->id,
- 'provider' => 'mollie',
- 'description' => 'test',
+ 'id' => 'tr_123456',
+ 'status' => Payment::STATUS_PAID,
+ 'amount' => 123,
+ 'credit_amount' => 123,
+ 'currency_amount' => 123,
+ 'currency' => 'CHF',
+ 'type' => Payment::TYPE_ONEOFF,
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'mollie',
+ 'description' => 'test',
]);
// Test a paid payment
diff --git a/src/tests/Feature/Controller/PolicyTest.php b/src/tests/Feature/Controller/PolicyTest.php
--- a/src/tests/Feature/Controller/PolicyTest.php
+++ b/src/tests/Feature/Controller/PolicyTest.php
@@ -3,8 +3,9 @@
namespace Tests\Feature\Controller;
use App\Domain;
+use App\IP4Net;
use App\Policy\Greylist;
-use Illuminate\Support\Facades\DB;
+use Carbon\Carbon;
use Tests\TestCase;
class PolicyTest extends TestCase
@@ -14,24 +15,24 @@
private $testUser;
private $testDomain;
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->clientAddress = '127.0.0.100';
- $this->net = \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ $this->net = IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$this->testDomain = $this->getTestDomain('test.domain', [
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]);
$this->testUser = $this->getTestUser('john@test.domain');
@@ -42,7 +43,7 @@
$this->useServicesUrl();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser($this->testUser->email);
$this->deleteTestDomain($this->testDomain->namespace);
@@ -66,7 +67,7 @@
'sender' => 'someone@sender.domain',
'recipient' => $this->testUser->email,
'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx'
+ 'client_name' => 'some.mx',
];
$response = $this->post('/api/webhooks/policy/greylist', $post);
@@ -75,12 +76,12 @@
$json = $response->json();
- $this->assertEquals('DEFER_IF_PERMIT', $json['response']);
- $this->assertEquals("Greylisted for 5 minutes. Try again later.", $json['reason']);
+ $this->assertSame('DEFER_IF_PERMIT', $json['response']);
+ $this->assertSame("Greylisted for 5 minutes. Try again later.", $json['reason']);
// Test 200 response
$connect = Greylist\Connect::where('sender_domain', 'sender.domain')->first();
- $connect->created_at = \Carbon\Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(6);
$connect->save();
$response = $this->post('/api/webhooks/policy/greylist', $post);
@@ -89,7 +90,7 @@
$json = $response->json();
- $this->assertEquals('DUNNO', $json['response']);
+ $this->assertSame('DUNNO', $json['response']);
$this->assertMatchesRegularExpression('/^Received-Greylist: greylisted from/', $json['prepend'][0]);
}
@@ -142,8 +143,8 @@
$json = $response->json();
- $this->assertEquals('REJECT', $json['response']);
- $this->assertEquals("Invalid sender", $json['reason']);
+ $this->assertSame('REJECT', $json['response']);
+ $this->assertSame("Invalid sender", $json['reason']);
// Test invalid user
$post = [
@@ -157,8 +158,8 @@
$json = $response->json();
- $this->assertEquals('REJECT', $json['response']);
- $this->assertEquals("Invalid user", $json['reason']);
+ $this->assertSame('REJECT', $json['response']);
+ $this->assertSame("Invalid user", $json['reason']);
// Test unknown user
$post = [
@@ -172,8 +173,8 @@
$json = $response->json();
- $this->assertEquals('REJECT', $json['response']);
- $this->assertEquals("Could not find user {$post['user']}", $json['reason']);
+ $this->assertSame('REJECT', $json['response']);
+ $this->assertSame("Could not find user {$post['user']}", $json['reason']);
// Test existing user and an invalid sender address
$post = [
@@ -187,8 +188,8 @@
$json = $response->json();
- $this->assertEquals('REJECT', $json['response']);
- $this->assertEquals("john@test.domain is unauthorized to send mail as john1@test.domain", $json['reason']);
+ $this->assertSame('REJECT', $json['response']);
+ $this->assertSame("john@test.domain is unauthorized to send mail as john1@test.domain", $json['reason']);
// Test existing user with a valid sender address
$post = [
@@ -202,7 +203,7 @@
$json = $response->json();
- $this->assertEquals('PERMIT', $json['response']);
+ $this->assertSame('PERMIT', $json['response']);
}
/**
@@ -285,7 +286,7 @@
'sender' => 'sender@spf-fail.kolab.org',
'client_name' => 'mx.kolabnow.com',
'client_address' => '212.103.80.148',
- 'recipient' => $this->testUser->email
+ 'recipient' => $this->testUser->email,
];
$response = $this->post('/api/webhooks/policy/spf', $post);
diff --git a/src/tests/Feature/Controller/Reseller/DiscountsTest.php b/src/tests/Feature/Controller/Reseller/DiscountsTest.php
--- a/src/tests/Feature/Controller/Reseller/DiscountsTest.php
+++ b/src/tests/Feature/Controller/Reseller/DiscountsTest.php
@@ -8,19 +8,13 @@
class DiscountsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
diff --git a/src/tests/Feature/Controller/Reseller/DomainsTest.php b/src/tests/Feature/Controller/Reseller/DomainsTest.php
--- a/src/tests/Feature/Controller/Reseller/DomainsTest.php
+++ b/src/tests/Feature/Controller/Reseller/DomainsTest.php
@@ -11,10 +11,7 @@
class DomainsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -22,10 +19,7 @@
$this->deleteTestDomain('domainscontroller.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('test1@domainscontroller.com');
$this->deleteTestDomain('domainscontroller.com');
@@ -40,8 +34,8 @@
{
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain'));
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
// THe end-point exists on the users controller, but not reseller's
@@ -150,15 +144,15 @@
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain'));
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local');
$domain = $this->getTestDomain('domainscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
Entitlement::create([
- 'wallet_id' => $user->wallets()->first()->id,
- 'sku_id' => $sku_domain->id,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class
+ 'wallet_id' => $user->wallets()->first()->id,
+ 'sku_id' => $sku_domain->id,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
// Unauthorized access (user)
@@ -178,10 +172,10 @@
$json = $response->json();
- $this->assertEquals($domain->id, $json['id']);
- $this->assertEquals($domain->namespace, $json['namespace']);
- $this->assertEquals($domain->status, $json['status']);
- $this->assertEquals($domain->type, $json['type']);
+ $this->assertSame($domain->id, $json['id']);
+ $this->assertSame($domain->namespace, $json['namespace']);
+ $this->assertSame($domain->status, $json['status']);
+ $this->assertSame($domain->type, $json['type']);
// Note: Other properties are being tested in the user controller tests
}
diff --git a/src/tests/Feature/Controller/Reseller/EventLogTest.php b/src/tests/Feature/Controller/Reseller/EventLogTest.php
--- a/src/tests/Feature/Controller/Reseller/EventLogTest.php
+++ b/src/tests/Feature/Controller/Reseller/EventLogTest.php
@@ -7,10 +7,7 @@
class EventLogTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -18,10 +15,7 @@
EventLog::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
EventLog::query()->delete();
diff --git a/src/tests/Feature/Controller/Reseller/GroupsTest.php b/src/tests/Feature/Controller/Reseller/GroupsTest.php
--- a/src/tests/Feature/Controller/Reseller/GroupsTest.php
+++ b/src/tests/Feature/Controller/Reseller/GroupsTest.php
@@ -8,10 +8,7 @@
class GroupsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -19,10 +16,7 @@
$this->deleteTestGroup('group-test@kolab.org');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group-test@kolab.org');
@@ -143,10 +137,10 @@
$json = $response->json();
- $this->assertEquals($group->id, $json['id']);
- $this->assertEquals($group->email, $json['email']);
- $this->assertEquals($group->name, $json['name']);
- $this->assertEquals($group->status, $json['status']);
+ $this->assertSame($group->id, $json['id']);
+ $this->assertSame($group->email, $json['email']);
+ $this->assertSame($group->name, $json['name']);
+ $this->assertSame($group->status, $json['status']);
}
/**
diff --git a/src/tests/Feature/Controller/Reseller/InvitationsTest.php b/src/tests/Feature/Controller/Reseller/InvitationsTest.php
--- a/src/tests/Feature/Controller/Reseller/InvitationsTest.php
+++ b/src/tests/Feature/Controller/Reseller/InvitationsTest.php
@@ -10,10 +10,7 @@
class InvitationsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -22,10 +19,7 @@
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
SignupInvitation::truncate();
@@ -72,7 +66,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame("Invitation deleted successfully.", $json['message']);
- $this->assertSame(null, SignupInvitation::find($inv->id));
+ $this->assertNull(SignupInvitation::find($inv->id));
}
/**
@@ -144,10 +138,10 @@
$this->assertTrue($json['hasMore']);
$this->assertSame($i1->id, $json['list'][0]['id']);
$this->assertSame($i1->email, $json['list'][0]['email']);
- $this->assertSame(true, $json['list'][0]['isFailed']);
- $this->assertSame(false, $json['list'][0]['isNew']);
- $this->assertSame(false, $json['list'][0]['isSent']);
- $this->assertSame(false, $json['list'][0]['isCompleted']);
+ $this->assertTrue($json['list'][0]['isFailed']);
+ $this->assertFalse($json['list'][0]['isNew']);
+ $this->assertFalse($json['list'][0]['isSent']);
+ $this->assertFalse($json['list'][0]['isCompleted']);
$this->assertSame($i2->id, $json['list'][1]['id']);
$this->assertSame($i2->email, $json['list'][1]['email']);
$this->assertFalse(in_array($i12->email, array_column($json['list'], 'email')));
diff --git a/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php b/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
--- a/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
+++ b/src/tests/Feature/Controller/Reseller/PaymentsMollieTest.php
@@ -2,24 +2,21 @@
namespace Tests\Feature\Controller\Reseller;
-use App\Http\Controllers\API\V4\Reseller\PaymentsController;
+use App\Jobs\Wallet\ChargeJob;
use App\Payment;
use App\Transaction;
use App\Wallet;
use App\WalletSetting;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Facades\Bus;
-use Tests\TestCase;
use Tests\BrowserAddonTrait;
+use Tests\TestCase;
class PaymentsMollieTest extends TestCase
{
use BrowserAddonTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -38,10 +35,7 @@
Transaction::where('object_id', $wallet->id)->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (\config('services.mollie.key')) {
$reseller = $this->getTestUser('reseller@' . \config('app.domain'));
@@ -97,12 +91,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(false, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertFalse($json['isDisabled']);
$wallet = $reseller->wallets()->first();
$wallet->setSetting('mandate_disabled', 1);
@@ -112,12 +106,12 @@
$json = $response->json();
- $this->assertEquals(20.10, $json['amount']);
- $this->assertEquals(0, $json['balance']);
+ $this->assertSame(20.10, $json['amount']);
+ $this->assertSame(0, $json['balance']);
$this->assertTrue(in_array($json['method'], ['Mastercard (**** **** **** 9399)', 'Credit Card']));
- $this->assertSame(false, $json['isPending']);
- $this->assertSame(true, $json['isValid']);
- $this->assertSame(true, $json['isDisabled']);
+ $this->assertFalse($json['isPending']);
+ $this->assertTrue($json['isValid']);
+ $this->assertTrue($json['isDisabled']);
Bus::fake();
$wallet->setSetting('mandate_disabled', null);
@@ -138,10 +132,10 @@
$wallet->refresh();
- $this->assertEquals(30.10, $wallet->getSetting('mandate_amount'));
- $this->assertEquals(10, $wallet->getSetting('mandate_balance'));
+ $this->assertSame(30.10, $wallet->getSetting('mandate_amount'));
+ $this->assertSame(10, $wallet->getSetting('mandate_balance'));
- Bus::assertDispatchedTimes(\App\Jobs\Wallet\ChargeJob::class, 0);
+ Bus::assertDispatchedTimes(ChargeJob::class, 0);
// Delete mandate
$response = $this->actingAs($reseller)->delete("api/v4/payments/mandate");
@@ -199,7 +193,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(0, $json['count']);
$this->assertSame(1, $json['page']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(0, $json['list']);
$response = $this->actingAs($reseller)->get("api/v4/payments/has-pending");
@@ -207,7 +201,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasPending']);
+ $this->assertFalse($json['hasPending']);
}
/**
@@ -227,7 +221,7 @@
$hasCoinbase = !empty(\config('services.coinbase.key'));
- $this->assertCount(3 + intval($hasCoinbase), $json);
+ $this->assertCount(3 + (int) $hasCoinbase, $json);
$this->assertSame('creditcard', $json[0]['id']);
$this->assertSame('paypal', $json[1]['id']);
$this->assertSame('banktransfer', $json[2]['id']);
diff --git a/src/tests/Feature/Controller/Reseller/ResourcesTest.php b/src/tests/Feature/Controller/Reseller/ResourcesTest.php
--- a/src/tests/Feature/Controller/Reseller/ResourcesTest.php
+++ b/src/tests/Feature/Controller/Reseller/ResourcesTest.php
@@ -8,19 +8,13 @@
class ResourcesTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -137,9 +131,9 @@
$json = $response->json();
- $this->assertEquals($resource->id, $json['id']);
- $this->assertEquals($resource->email, $json['email']);
- $this->assertEquals($resource->name, $json['name']);
+ $this->assertSame($resource->id, $json['id']);
+ $this->assertSame($resource->email, $json['email']);
+ $this->assertSame($resource->name, $json['name']);
}
/**
diff --git a/src/tests/Feature/Controller/Reseller/SharedFoldersTest.php b/src/tests/Feature/Controller/Reseller/SharedFoldersTest.php
--- a/src/tests/Feature/Controller/Reseller/SharedFoldersTest.php
+++ b/src/tests/Feature/Controller/Reseller/SharedFoldersTest.php
@@ -2,25 +2,18 @@
namespace Tests\Feature\Controller\Reseller;
-use App\SharedFolder;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SharedFoldersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -137,9 +130,9 @@
$json = $response->json();
- $this->assertEquals($folder->id, $json['id']);
- $this->assertEquals($folder->email, $json['email']);
- $this->assertEquals($folder->name, $json['name']);
+ $this->assertSame($folder->id, $json['id']);
+ $this->assertSame($folder->email, $json['email']);
+ $this->assertSame($folder->name, $json['name']);
}
/**
diff --git a/src/tests/Feature/Controller/Reseller/SkusTest.php b/src/tests/Feature/Controller/Reseller/SkusTest.php
--- a/src/tests/Feature/Controller/Reseller/SkusTest.php
+++ b/src/tests/Feature/Controller/Reseller/SkusTest.php
@@ -7,10 +7,7 @@
class SkusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -20,10 +17,7 @@
$this->clearBetaEntitlements();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Sku::where('title', 'test')->delete();
diff --git a/src/tests/Feature/Controller/Reseller/StatsTest.php b/src/tests/Feature/Controller/Reseller/StatsTest.php
--- a/src/tests/Feature/Controller/Reseller/StatsTest.php
+++ b/src/tests/Feature/Controller/Reseller/StatsTest.php
@@ -2,15 +2,13 @@
namespace Tests\Feature\Controller\Reseller;
+use App\Discount;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;
class StatsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -18,10 +16,7 @@
DB::table('wallets')->update(['discount_id' => null]);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
DB::table('wallets')->update(['discount_id' => null]);
@@ -92,7 +87,7 @@
$this->assertCount(1, $json['data']['datasets']);
// 'vouchers' chart
- $discount = \App\Discount::withObjectTenantContext($user)->where('code', 'TEST')->first();
+ $discount = Discount::withObjectTenantContext($user)->where('code', 'TEST')->first();
$wallet = $user->wallets->first();
$wallet->discount()->associate($discount);
$wallet->save();
diff --git a/src/tests/Feature/Controller/Reseller/UsersTest.php b/src/tests/Feature/Controller/Reseller/UsersTest.php
--- a/src/tests/Feature/Controller/Reseller/UsersTest.php
+++ b/src/tests/Feature/Controller/Reseller/UsersTest.php
@@ -2,18 +2,19 @@
namespace Tests\Feature\Controller\Reseller;
-use App\Tenant;
+use App\Auth\SecondFactor;
+use App\Domain;
+use App\Plan;
+use App\SharedFolderAlias;
use App\Sku;
+use App\Tenant;
use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UsersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
@@ -23,16 +24,13 @@
$this->deleteTestDomain('testsearch.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UsersControllerTest1@userscontroller.com');
$this->deleteTestUser('test@testsearch.com');
$this->deleteTestDomain('testsearch.com');
- \App\SharedFolderAlias::truncate();
+ SharedFolderAlias::truncate();
parent::tearDown();
}
@@ -157,13 +155,13 @@
$this->assertSame($user->email, $json['list'][0]['email']);
// Create a domain with some users in the Sample Tenant so we have anything to search for
- $domain = $this->getTestDomain('testsearch.com', ['type' => \App\Domain::TYPE_EXTERNAL]);
+ $domain = $this->getTestDomain('testsearch.com', ['type' => Domain::TYPE_EXTERNAL]);
$domain->tenant_id = $reseller2->tenant_id;
$domain->save();
$user = $this->getTestUser('test@testsearch.com');
$user->tenant_id = $reseller2->tenant_id;
$user->save();
- $plan = \App\Plan::where('title', 'group')->first();
+ $plan = Plan::where('title', 'group')->first();
$user->assignPlan($plan, $domain);
$user->setAliases(['alias@testsearch.com']);
$user->setSetting('external_email', 'john.doe.external@gmail.com');
@@ -284,9 +282,9 @@
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain'));
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local');
- $sku2fa = \App\Sku::withEnvTenantContext()->where('title', '2fa')->first();
+ $sku2fa = Sku::withEnvTenantContext()->where('title', '2fa')->first();
$user->assignSku($sku2fa);
- \App\Auth\SecondFactor::seed('userscontrollertest1@userscontroller.com');
+ SecondFactor::seed('userscontrollertest1@userscontroller.com');
// Test unauthorized access
$response = $this->actingAs($user)->post("/api/v4/users/{$user->id}/reset2FA", []);
@@ -305,7 +303,7 @@
$entitlements = $user->fresh()->entitlements()->where('sku_id', $sku2fa->id)->get();
$this->assertCount(1, $entitlements);
- $sf = new \App\Auth\SecondFactor($user);
+ $sf = new SecondFactor($user);
$this->assertCount(1, $sf->factors());
// Test reseting 2FA
@@ -321,7 +319,7 @@
$entitlements = $user->fresh()->entitlements()->where('sku_id', $sku2fa->id)->get();
$this->assertCount(0, $entitlements);
- $sf = new \App\Auth\SecondFactor($user);
+ $sf = new SecondFactor($user);
$this->assertCount(0, $sf->factors());
}
diff --git a/src/tests/Feature/Controller/Reseller/WalletsTest.php b/src/tests/Feature/Controller/Reseller/WalletsTest.php
--- a/src/tests/Feature/Controller/Reseller/WalletsTest.php
+++ b/src/tests/Feature/Controller/Reseller/WalletsTest.php
@@ -8,19 +8,13 @@
class WalletsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
self::useResellerUrl();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -217,7 +211,7 @@
// Create some sample transactions
$transactions = $this->createTestTransactions($wallet);
$transactions = array_reverse($transactions);
- $pages = array_chunk($transactions, 10 /* page size*/);
+ $pages = array_chunk($transactions, 10 /* page size */);
// Get the 2nd page
$response = $this->actingAs($reseller1)->get("api/v4/wallets/{$wallet->id}/transactions?page=2");
@@ -229,7 +223,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(2, $json['page']);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(2, $json['list']);
foreach ($pages[1] as $idx => $transaction) {
$this->assertSame($transaction->id, $json['list'][$idx]['id']);
@@ -299,8 +293,8 @@
$this->assertSame('success', $json['status']);
$this->assertSame('User wallet updated successfully.', $json['message']);
$this->assertSame($wallet->id, $json['id']);
- $this->assertSame(null, $json['discount_id']);
+ $this->assertNull($json['discount_id']);
$this->assertTrue(empty($json['discount_description']));
- $this->assertSame(null, $wallet->fresh()->discount);
+ $this->assertNull($wallet->fresh()->discount);
}
}
diff --git a/src/tests/Feature/Controller/ResourcesTest.php b/src/tests/Feature/Controller/ResourcesTest.php
--- a/src/tests/Feature/Controller/ResourcesTest.php
+++ b/src/tests/Feature/Controller/ResourcesTest.php
@@ -2,18 +2,17 @@
namespace Tests\Feature\Controller;
-use App\Resource;
+use App\Domain;
use App\Http\Controllers\API\V4\ResourcesController;
+use App\Jobs\Resource\CreateJob;
+use App\Resource;
use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class ResourcesTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +20,7 @@
Resource::where('name', 'Test Resource')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestResource('resource-test@kolab.org');
Resource::where('name', 'Test Resource')->delete();
@@ -67,8 +63,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals("Resource deleted successfully.", $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame("Resource deleted successfully.", $json['message']);
}
/**
@@ -92,7 +88,7 @@
$this->assertCount(4, $json);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("0 resources have been found.", $json['message']);
$this->assertSame([], $json['list']);
@@ -106,7 +102,7 @@
$this->assertCount(4, $json);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("2 resources have been found.", $json['message']);
$this->assertCount(2, $json['list']);
$this->assertSame($resource->id, $json['list'][0]['id']);
@@ -127,7 +123,7 @@
$this->assertCount(4, $json);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("2 resources have been found.", $json['message']);
$this->assertCount(2, $json['list']);
$this->assertSame($resource->email, $json['list'][0]['email']);
@@ -283,11 +279,11 @@
$this->assertCount(1, $json);
$this->assertSkuElement('resource', $json[0], [
- 'prio' => 0,
- 'type' => 'resource',
- 'handler' => 'Resource',
- 'enabled' => true,
- 'readonly' => true,
+ 'prio' => 0,
+ 'type' => 'resource',
+ 'handler' => 'Resource',
+ 'enabled' => true,
+ 'readonly' => true,
]);
}
@@ -327,16 +323,16 @@
$this->assertTrue($json['isActive']);
$this->assertFalse($json['isImapReady']);
$this->assertSame('resource-new', $json['process'][0]['label']);
- $this->assertSame(true, $json['process'][0]['state']);
+ $this->assertTrue($json['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertFalse($json['isLdapReady']);
$this->assertSame('resource-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('resource-imap-ready', $json['process'][2]['label']);
- $this->assertSame(false, $json['process'][2]['state']);
+ $this->assertFalse($json['process'][2]['state']);
} else {
$this->assertSame('resource-imap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
}
$this->assertTrue(empty($json['status']));
$this->assertTrue(empty($json['message']));
@@ -344,7 +340,7 @@
// Make sure the domain is confirmed (other test might unset that status)
$domain = $this->getTestDomain('kolab.org');
- $domain->status |= \App\Domain::STATUS_CONFIRMED;
+ $domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
$resource->status |= Resource::STATUS_IMAP_READY;
$resource->save();
@@ -362,24 +358,24 @@
$this->assertFalse($json['isReady']);
$this->assertFalse($json['isLdapReady']);
$this->assertSame('resource-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('resource-imap-ready', $json['process'][2]['label']);
- $this->assertSame(true, $json['process'][2]['state']);
+ $this->assertTrue($json['process'][2]['state']);
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']);
$this->assertSame('waiting', $json['processState']);
- Queue::assertPushed(\App\Jobs\Resource\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
} else {
$this->assertTrue($json['isReady']);
$this->assertSame('resource-imap-ready', $json['process'][1]['label']);
- $this->assertSame(true, $json['process'][1]['state']);
+ $this->assertTrue($json['process'][1]['state']);
$this->assertSame('Setup process finished successfully.', $json['message']);
$this->assertSame('done', $json['processState']);
}
// Test a case when a domain is not ready
Queue::fake();
- $domain->status ^= \App\Domain::STATUS_CONFIRMED;
+ $domain->status ^= Domain::STATUS_CONFIRMED;
$domain->save();
$response = $this->actingAs($john)->get("/api/v4/resources/{$resource->id}/status?refresh=1");
@@ -392,11 +388,11 @@
$this->assertFalse($json['isReady']);
$this->assertFalse($json['isLdapReady']);
$this->assertSame('resource-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']);
$this->assertSame('waiting', $json['processState']);
- Queue::assertPushed(\App\Jobs\Resource\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
} else {
$this->assertSame('Setup process finished successfully.', $json['message']);
$this->assertTrue($json['isReady']);
@@ -415,22 +411,22 @@
$resource->status = Resource::STATUS_NEW | Resource::STATUS_ACTIVE;
$resource->save();
$domain = $this->getTestDomain('kolab.org');
- $domain->status |= \App\Domain::STATUS_CONFIRMED;
+ $domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
$result = ResourcesController::statusInfo($resource);
$this->assertFalse($result['isDone']);
$this->assertSame('resource-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertSame('resource-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
$this->assertSame('resource-imap-ready', $result['process'][2]['label']);
- $this->assertSame(false, $result['process'][2]['state']);
+ $this->assertFalse($result['process'][2]['state']);
} else {
$this->assertSame('resource-imap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
}
$this->assertSame('running', $result['processState']);
@@ -448,15 +444,15 @@
$this->assertTrue($result['isDone']);
$this->assertSame('resource-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertSame('resource-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
$this->assertSame('resource-imap-ready', $result['process'][2]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
} else {
$this->assertSame('resource-imap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
}
$this->assertSame('done', $result['processState']);
}
diff --git a/src/tests/Feature/Controller/RoomsTest.php b/src/tests/Feature/Controller/RoomsTest.php
--- a/src/tests/Feature/Controller/RoomsTest.php
+++ b/src/tests/Feature/Controller/RoomsTest.php
@@ -3,24 +3,19 @@
namespace Tests\Feature\Controller;
use App\Meet\Room;
+use App\Sku;
use Tests\TestCase;
class RoomsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
@@ -166,8 +161,8 @@
$this->assertCount(2, $json);
$this->assertSame('success', $json['status']);
$this->assertSame("Room configuration updated successfully.", $json['message']);
- $this->assertSame(null, $room->getSetting('password'));
- $this->assertSame(null, $room->getSetting('locked'));
+ $this->assertNull($room->getSetting('password'));
+ $this->assertNull($room->getSetting('locked'));
// Test invalid option error
$post = ['password' => 'eee', 'unknown' => 0];
@@ -257,7 +252,7 @@
$this->assertSame($room->id, $json['id']);
$this->assertSame('test', $json['name']);
$this->assertSame('desc', $json['description']);
- $this->assertSame(false, $json['isDeleted']);
+ $this->assertFalse($json['isDeleted']);
$this->assertTrue($json['isOwner']);
$this->assertTrue($json['canUpdate']);
$this->assertTrue($json['canDelete']);
@@ -265,7 +260,7 @@
$this->assertCount(1, $json['skus']);
$this->assertSame([], $json['config']['acl']);
$this->assertSame('pass', $json['config']['password']);
- $this->assertSame(true, $json['config']['locked']);
+ $this->assertTrue($json['config']['locked']);
$this->assertSame($wallet->id, $json['wallet']['id']);
$this->assertSame($wallet->currency, $json['wallet']['currency']);
$this->assertSame($wallet->balance, $json['wallet']['balance']);
@@ -328,9 +323,9 @@
$this->assertCount(2, $json);
$this->assertSame('room', $json[0]['title']);
- $this->assertSame(true, $json[0]['enabled']);
+ $this->assertTrue($json[0]['enabled']);
$this->assertSame('group-room', $json[1]['title']);
- $this->assertSame(false, $json[1]['enabled']);
+ $this->assertFalse($json[1]['enabled']);
// Room's wallet controller, not owner
$response = $this->actingAs($ned)->get("api/v4/rooms/{$room->id}/skus");
@@ -340,9 +335,9 @@
$this->assertCount(2, $json);
$this->assertSame('room', $json[0]['title']);
- $this->assertSame(true, $json[0]['enabled']);
+ $this->assertTrue($json[0]['enabled']);
$this->assertSame('group-room', $json[1]['title']);
- $this->assertSame(false, $json[1]['enabled']);
+ $this->assertFalse($json[1]['enabled']);
// Test non-controller user, expect no group-room SKU on the list
$room = $this->getTestRoom('test', $jack->wallets()->first());
@@ -354,7 +349,7 @@
$this->assertCount(1, $json);
$this->assertSame('room', $json[0]['title']);
- $this->assertSame(true, $json[0]['enabled']);
+ $this->assertTrue($json[0]['enabled']);
}
/**
@@ -402,7 +397,7 @@
$this->assertSame('room', $room->entitlements()->first()->sku->title);
// Successful room creation (acting as a room controller), non-default SKU
- $sku = \App\Sku::withObjectTenantContext($ned)->where('title', 'group-room')->first();
+ $sku = Sku::withObjectTenantContext($ned)->where('title', 'group-room')->first();
$post = ['description' => 'test456', 'skus' => [$sku->id => 1]];
$response = $this->actingAs($ned)->post("api/v4/rooms", $post);
$response->assertStatus(200);
@@ -493,7 +488,7 @@
$this->assertSame($post['description'], $room->description);
// Test changing the room SKU (from 'group-room' to 'room')
- $sku = \App\Sku::withObjectTenantContext($ned)->where('title', 'room')->first();
+ $sku = Sku::withObjectTenantContext($ned)->where('title', 'room')->first();
$post = ['skus' => [$sku->id => 1]];
$response = $this->actingAs($ned)->put("api/v4/rooms/{$room->id}", $post);
$response->assertStatus(200);
diff --git a/src/tests/Feature/Controller/SearchTest.php b/src/tests/Feature/Controller/SearchTest.php
--- a/src/tests/Feature/Controller/SearchTest.php
+++ b/src/tests/Feature/Controller/SearchTest.php
@@ -7,10 +7,7 @@
class SearchTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,10 +15,7 @@
Contact::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('jane@kolabnow.com');
Contact::truncate();
@@ -210,7 +204,6 @@
],
];
-
$this->assertSame(count($users), $json['count']);
$this->assertSame($users, $json['list']);
diff --git a/src/tests/Feature/Controller/SharedFoldersTest.php b/src/tests/Feature/Controller/SharedFoldersTest.php
--- a/src/tests/Feature/Controller/SharedFoldersTest.php
+++ b/src/tests/Feature/Controller/SharedFoldersTest.php
@@ -2,18 +2,17 @@
namespace Tests\Feature\Controller;
-use App\SharedFolder;
+use App\Domain;
use App\Http\Controllers\API\V4\SharedFoldersController;
+use App\Jobs\SharedFolder\CreateJob;
+use App\SharedFolder;
use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SharedFoldersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +20,7 @@
SharedFolder::where('name', 'like', 'Test_Folder')->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@kolab.org');
SharedFolder::where('name', 'like', 'Test_Folder')->forceDelete();
@@ -66,8 +62,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals("Shared folder deleted successfully.", $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame("Shared folder deleted successfully.", $json['message']);
}
/**
@@ -91,7 +87,7 @@
$this->assertCount(4, $json);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("0 shared folders have been found.", $json['message']);
$this->assertSame([], $json['list']);
@@ -105,7 +101,7 @@
$this->assertCount(4, $json);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("2 shared folders have been found.", $json['message']);
$this->assertCount(2, $json['list']);
$this->assertSame($folder->id, $json['list'][0]['id']);
@@ -127,7 +123,7 @@
$this->assertCount(4, $json);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame("2 shared folders have been found.", $json['message']);
$this->assertCount(2, $json['list']);
$this->assertSame($folder->email, $json['list'][0]['email']);
@@ -290,11 +286,11 @@
$this->assertCount(1, $json);
$this->assertSkuElement('shared-folder', $json[0], [
- 'prio' => 0,
- 'type' => 'sharedFolder',
- 'handler' => 'SharedFolder',
- 'enabled' => true,
- 'readonly' => true,
+ 'prio' => 0,
+ 'type' => 'sharedFolder',
+ 'handler' => 'SharedFolder',
+ 'enabled' => true,
+ 'readonly' => true,
]);
}
@@ -337,16 +333,16 @@
$this->assertTrue(empty($json['status']));
$this->assertTrue(empty($json['message']));
$this->assertSame('shared-folder-new', $json['process'][0]['label']);
- $this->assertSame(true, $json['process'][0]['state']);
+ $this->assertTrue($json['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertFalse($json['isLdapReady']);
$this->assertSame('shared-folder-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
}
// Make sure the domain is confirmed (other test might unset that status)
$domain = $this->getTestDomain('kolab.org');
- $domain->status |= \App\Domain::STATUS_CONFIRMED;
+ $domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
$folder->status |= SharedFolder::STATUS_IMAP_READY;
$folder->save();
@@ -366,17 +362,17 @@
$this->assertFalse($json['isReady']);
$this->assertFalse($json['isLdapReady']);
$this->assertSame('shared-folder-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('shared-folder-imap-ready', $json['process'][2]['label']);
- $this->assertSame(true, $json['process'][2]['state']);
+ $this->assertTrue($json['process'][2]['state']);
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']);
$this->assertSame('waiting', $json['processState']);
- Queue::assertPushed(\App\Jobs\SharedFolder\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
} else {
$this->assertTrue($json['isReady']);
$this->assertSame('shared-folder-imap-ready', $json['process'][1]['label']);
- $this->assertSame(true, $json['process'][1]['state']);
+ $this->assertTrue($json['process'][1]['state']);
$this->assertSame('Setup process finished successfully.', $json['message']);
$this->assertSame('done', $json['processState']);
}
@@ -384,7 +380,7 @@
// Test a case when a domain is not ready
Queue::fake();
- $domain->status ^= \App\Domain::STATUS_CONFIRMED;
+ $domain->status ^= Domain::STATUS_CONFIRMED;
$domain->save();
$response = $this->actingAs($john)->get("/api/v4/shared-folders/{$folder->id}/status?refresh=1");
@@ -398,14 +394,14 @@
$this->assertFalse($json['isReady']);
$this->assertFalse($json['isLdapReady']);
$this->assertSame('shared-folder-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']);
- Queue::assertPushed(\App\Jobs\SharedFolder\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
} else {
$this->assertTrue($json['isReady']);
$this->assertSame('shared-folder-imap-ready', $json['process'][1]['label']);
- $this->assertSame(true, $json['process'][1]['state']);
+ $this->assertTrue($json['process'][1]['state']);
$this->assertSame('done', $json['processState']);
}
}
@@ -421,7 +417,7 @@
$folder->status = SharedFolder::STATUS_NEW | SharedFolder::STATUS_ACTIVE;
$folder->save();
$domain = $this->getTestDomain('kolab.org');
- $domain->status |= \App\Domain::STATUS_CONFIRMED;
+ $domain->status |= Domain::STATUS_CONFIRMED;
$domain->save();
$result = SharedFoldersController::statusInfo($folder);
@@ -429,10 +425,10 @@
$this->assertFalse($result['isDone']);
$this->assertSame('running', $result['processState']);
$this->assertSame('shared-folder-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertSame('shared-folder-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
}
$folder->created_at = Carbon::now()->subSeconds(181);
@@ -450,15 +446,15 @@
$this->assertTrue($result['isDone']);
$this->assertSame('done', $result['processState']);
$this->assertSame('shared-folder-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
if (\config('app.with_ldap')) {
$this->assertSame('shared-folder-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
$this->assertSame('shared-folder-imap-ready', $result['process'][2]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
} else {
$this->assertSame('shared-folder-imap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
}
}
diff --git a/src/tests/Feature/Controller/SignupTest.php b/src/tests/Feature/Controller/SignupTest.php
--- a/src/tests/Feature/Controller/SignupTest.php
+++ b/src/tests/Feature/Controller/SignupTest.php
@@ -2,12 +2,14 @@
namespace Tests\Feature\Controller;
-use App\Http\Controllers\API\SignupController;
use App\Discount;
use App\Domain;
+use App\Http\Controllers\API\SignupController;
use App\IP4Net;
-use App\Plan;
+use App\Jobs\Mail\SignupVerificationJob;
+use App\Jobs\User\CreateJob;
use App\Package;
+use App\Plan;
use App\ReferralProgram;
use App\SignupCode;
use App\SignupInvitation as SI;
@@ -21,10 +23,7 @@
{
private $domain;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -32,8 +31,8 @@
// we should probably create plans here to not depend on that
$this->domain = $this->getPublicDomain();
- $this->deleteTestUser("SignupControllerTest1@$this->domain");
- $this->deleteTestUser("signuplogin@$this->domain");
+ $this->deleteTestUser("SignupControllerTest1@{$this->domain}");
+ $this->deleteTestUser("signuplogin@{$this->domain}");
$this->deleteTestUser("admin@external.com");
$this->deleteTestUser("test-inv@kolabnow.com");
@@ -50,13 +49,10 @@
ReferralProgram::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
- $this->deleteTestUser("SignupControllerTest1@$this->domain");
- $this->deleteTestUser("signuplogin@$this->domain");
+ $this->deleteTestUser("SignupControllerTest1@{$this->domain}");
+ $this->deleteTestUser("signuplogin@{$this->domain}");
$this->deleteTestUser("admin@external.com");
$this->deleteTestUser("test-inv@kolabnow.com");
@@ -88,9 +84,9 @@
if (empty($this->domain)) {
$this->domain = 'signup-domain.com';
Domain::create([
- 'namespace' => $this->domain,
- 'status' => Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_PUBLIC,
+ 'namespace' => $this->domain,
+ 'status' => Domain::STATUS_ACTIVE,
+ 'type' => Domain::TYPE_PUBLIC,
]);
}
}
@@ -121,11 +117,11 @@
$individual = Plan::withEnvTenantContext()->where('title', 'individual')->first();
$group = Plan::withEnvTenantContext()->where('title', 'group')->first();
$hidden = Plan::create([
- 'title' => 'test',
- 'name' => 'Test Account',
- 'description' => 'Test',
- 'hidden' => true,
- 'mode' => Plan::MODE_MANDATE,
+ 'title' => 'test',
+ 'name' => 'Test Account',
+ 'description' => 'Test',
+ 'hidden' => true,
+ 'mode' => Plan::MODE_MANDATE,
]);
$response = $this->get('/api/auth/signup/plans');
@@ -345,21 +341,21 @@
$this->assertCount(5, $json);
$this->assertSame('success', $json['status']);
$this->assertSame('email', $json['mode']);
- $this->assertSame(true, $json['is_domain']);
+ $this->assertTrue($json['is_domain']);
$this->assertNotEmpty($json['code']);
$this->assertSame($all_domains = Domain::getPublicDomains(), $json['domains']);
$code = SignupCode::find($json['code']);
$this->assertSame('10.1.1.2', $code->ip_address);
- $this->assertSame(null, $code->verify_ip_address);
- $this->assertSame(null, $code->submit_ip_address);
+ $this->assertNull($code->verify_ip_address);
+ $this->assertNull($code->submit_ip_address);
// Assert the email sending job was pushed once
- Queue::assertPushed(\App\Jobs\Mail\SignupVerificationJob::class, 1);
+ Queue::assertPushed(SignupVerificationJob::class, 1);
// Assert the job has proper data assigned
- Queue::assertPushed(\App\Jobs\Mail\SignupVerificationJob::class, function ($job) use ($data, $json) {
+ Queue::assertPushed(SignupVerificationJob::class, static function ($job) use ($data, $json) {
$code = TestCase::getObjectProperty($job, 'code');
return $code->code === $json['code']
@@ -380,12 +376,12 @@
$this->assertCount(5, $json);
$this->assertSame('success', $json['status']);
$this->assertSame('email', $json['mode']);
- $this->assertSame(false, $json['is_domain']);
+ $this->assertFalse($json['is_domain']);
$this->assertNotEmpty($json['code']);
$this->assertSame($all_domains, $json['domains']);
// Assert the job has proper data assigned
- Queue::assertPushed(\App\Jobs\Mail\SignupVerificationJob::class, function ($job) use ($data, $json) {
+ Queue::assertPushed(SignupVerificationJob::class, static function ($job) use ($data, $json) {
$code = TestCase::getObjectProperty($job, 'code');
return $code->code === $json['code']
@@ -402,7 +398,7 @@
'first_name' => $data['first_name'],
'last_name' => $data['last_name'],
'plan' => $data['plan'],
- 'voucher' => $data['voucher']
+ 'voucher' => $data['voucher'],
];
}
@@ -480,14 +476,14 @@
$this->assertSame($result['first_name'], $json['first_name']);
$this->assertSame($result['last_name'], $json['last_name']);
$this->assertSame($result['voucher'], $json['voucher']);
- $this->assertSame(false, $json['is_domain']);
- //$this->assertTrue(is_array($json['domains']) && !empty($json['domains']));
+ $this->assertFalse($json['is_domain']);
+ // $this->assertTrue(is_array($json['domains']) && !empty($json['domains']));
$code->refresh();
$this->assertSame('10.1.1.2', $code->ip_address);
$this->assertSame('10.1.1.3', $code->verify_ip_address);
- $this->assertSame(null, $code->submit_ip_address);
+ $this->assertNull($code->submit_ip_address);
return $result;
}
@@ -664,11 +660,11 @@
$this->assertNotEmpty($json['access_token']);
$this->assertSame($identity, $json['email']);
- Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\CreateJob::class,
- function ($job) use ($data) {
+ CreateJob::class,
+ static function ($job) use ($data) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
return $userEmail === \strtolower($data['login'] . '@' . $data['domain']);
}
@@ -740,15 +736,15 @@
$this->assertCount(5, $json);
$this->assertSame('success', $json['status']);
$this->assertSame('email', $json['mode']);
- $this->assertSame(true, $json['is_domain']);
+ $this->assertTrue($json['is_domain']);
$this->assertNotEmpty($json['code']);
$this->assertSame(Domain::getPublicDomains(), $json['domains']);
// Assert the email sending job was pushed once
- Queue::assertPushed(\App\Jobs\Mail\SignupVerificationJob::class, 1);
+ Queue::assertPushed(SignupVerificationJob::class, 1);
// Assert the job has proper data assigned
- Queue::assertPushed(\App\Jobs\Mail\SignupVerificationJob::class, function ($job) use ($data, $json) {
+ Queue::assertPushed(SignupVerificationJob::class, static function ($job) use ($data, $json) {
$code = TestCase::getObjectProperty($job, 'code');
return $code->code === $json['code']
@@ -774,8 +770,8 @@
$this->assertSame($user_data['email'], $result['email']);
$this->assertSame($user_data['first_name'], $result['first_name']);
$this->assertSame($user_data['last_name'], $result['last_name']);
- $this->assertSame(null, $result['voucher']);
- $this->assertSame(true, $result['is_domain']);
+ $this->assertNull($result['voucher']);
+ $this->assertTrue($result['is_domain']);
// Final signup request
$login = 'admin';
@@ -797,24 +793,24 @@
$this->assertSame('bearer', $result['token_type']);
$this->assertTrue(!empty($result['expires_in']) && is_int($result['expires_in']) && $result['expires_in'] > 0);
$this->assertNotEmpty($result['access_token']);
- $this->assertSame("$login@$domain", $result['email']);
+ $this->assertSame("{$login}@{$domain}", $result['email']);
Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1);
Queue::assertPushed(
\App\Jobs\Domain\CreateJob::class,
- function ($job) use ($domain) {
+ static function ($job) use ($domain) {
$domainNamespace = TestCase::getObjectProperty($job, 'domainNamespace');
return $domainNamespace === $domain;
}
);
- Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\CreateJob::class,
- function ($job) use ($data) {
+ CreateJob::class,
+ static function ($job) use ($data) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
return $userEmail === $data['login'] . '@' . $data['domain'];
@@ -859,17 +855,17 @@
\config(['services.payment_provider' => 'mollie']);
$plan = Plan::create([
- 'title' => 'test',
- 'name' => 'Test Account',
- 'description' => 'Test',
- 'free_months' => 1,
- 'discount_qty' => 0,
- 'discount_rate' => 0,
- 'mode' => Plan::MODE_MANDATE,
+ 'title' => 'test',
+ 'name' => 'Test Account',
+ 'description' => 'Test',
+ 'free_months' => 1,
+ 'discount_qty' => 0,
+ 'discount_rate' => 0,
+ 'mode' => Plan::MODE_MANDATE,
]);
$packages = [
- Package::where(['title' => 'kolab', 'tenant_id' => \config('app.tenant_id')])->first()
+ Package::where(['title' => 'kolab', 'tenant_id' => \config('app.tenant_id')])->first(),
];
$plan->packages()->saveMany($packages);
@@ -977,13 +973,13 @@
Queue::fake();
$plan = Plan::create([
- 'title' => 'test',
- 'name' => 'Test Account',
- 'description' => 'Test',
- 'free_months' => 1,
- 'discount_qty' => 0,
- 'discount_rate' => 0,
- 'mode' => Plan::MODE_TOKEN,
+ 'title' => 'test',
+ 'name' => 'Test Account',
+ 'description' => 'Test',
+ 'free_months' => 1,
+ 'discount_qty' => 0,
+ 'discount_rate' => 0,
+ 'mode' => Plan::MODE_TOKEN,
]);
$post = [
@@ -1019,7 +1015,7 @@
$this->assertNotEmpty($user);
$this->assertSame($plan->id, $user->getSetting('plan_id'));
$this->assertSame($plan->signupTokens()->first()->id, $user->getSetting('signup_token'));
- $this->assertSame(null, $user->getSetting('external_email'));
+ $this->assertNull($user->getSetting('external_email'));
// Token's counter bumped up
$this->assertSame(1, $plan->signupTokens()->first()->counter);
@@ -1097,18 +1093,18 @@
Queue::fake();
$plan = Plan::create([
- 'title' => 'test',
- 'name' => 'Test Account',
- 'description' => 'Test',
- 'free_months' => 1,
- 'months' => 12,
- 'discount_qty' => 0,
- 'discount_rate' => 0,
- 'mode' => Plan::MODE_MANDATE,
+ 'title' => 'test',
+ 'name' => 'Test Account',
+ 'description' => 'Test',
+ 'free_months' => 1,
+ 'months' => 12,
+ 'discount_qty' => 0,
+ 'discount_rate' => 0,
+ 'mode' => Plan::MODE_MANDATE,
]);
$packages = [
- Package::where(['title' => 'kolab', 'tenant_id' => \config('app.tenant_id')])->first()
+ Package::where(['title' => 'kolab', 'tenant_id' => \config('app.tenant_id')])->first(),
];
$plan->packages()->saveMany($packages);
@@ -1155,18 +1151,18 @@
// Prepare VAT rate and network entries, so we can test the VAT related output
VatRate::create([
- 'country' => 'CH',
- 'rate' => 7.7,
- 'start' => now()->copy()->subDay(),
+ 'country' => 'CH',
+ 'rate' => 7.7,
+ 'start' => now()->copy()->subDay(),
]);
IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'CH',
- 'rir_name' => 'test',
- 'serial' => 1,
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'CH',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
// Test with mode=mandate plan, and valid voucher code
diff --git a/src/tests/Feature/Controller/SkusTest.php b/src/tests/Feature/Controller/SkusTest.php
--- a/src/tests/Feature/Controller/SkusTest.php
+++ b/src/tests/Feature/Controller/SkusTest.php
@@ -3,16 +3,14 @@
namespace Tests\Feature\Controller;
use App\Http\Controllers\API\V4\SkusController;
+use App\Package;
use App\Sku;
use App\Tenant;
use Tests\TestCase;
class SkusTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +19,7 @@
Sku::where('title', 'test')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('jane@kolabnow.com');
$this->clearBetaEntitlements();
@@ -48,12 +43,12 @@
// Create an sku for another tenant, to make sure it is not included in the result
$nsku = Sku::create([
- 'title' => 'test',
- 'name' => 'Test',
- 'description' => '',
- 'active' => true,
- 'cost' => 100,
- 'handler_class' => 'App\Handlers\Mailbox',
+ 'title' => 'test',
+ 'name' => 'Test',
+ 'description' => '',
+ 'active' => true,
+ 'cost' => 100,
+ 'handler_class' => 'App\Handlers\Mailbox',
]);
$tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first();
$nsku->tenant_id = $tenant->id;
@@ -90,7 +85,7 @@
// Test the type filter, and nextCost property (user with no domain)
$jane = $this->getTestUser('jane@kolabnow.com');
- $kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
$jane->assignPackage($kolab);
$response = $this->actingAs($jane)->get("api/v4/skus?type=domain");
diff --git a/src/tests/Feature/Controller/SupportTest.php b/src/tests/Feature/Controller/SupportTest.php
--- a/src/tests/Feature/Controller/SupportTest.php
+++ b/src/tests/Feature/Controller/SupportTest.php
@@ -2,7 +2,8 @@
namespace Tests\Feature\Controller;
-use App\Http\Controllers\API\SupportController;
+use Symfony\Component\Mailer\SentMessage;
+use Symfony\Component\Mime\Email;
use Tests\TestCase;
class SupportTest extends TestCase
@@ -94,14 +95,14 @@
/**
* Get all messages that have been sent
*
- * @return \Symfony\Component\Mime\Email[]
+ * @return Email[]
*/
protected function getSentMessages(): array
{
$transport = $this->app->make('mail.manager')->mailer()->getSymfonyTransport();
return $this->getObjectProperty($transport, 'messages')
- ->map(function (\Symfony\Component\Mailer\SentMessage $item) {
+ ->map(static function (SentMessage $item) {
return $item->getOriginalMessage();
})
->all();
diff --git a/src/tests/Feature/Controller/User/DelegationTest.php b/src/tests/Feature/Controller/User/DelegationTest.php
--- a/src/tests/Feature/Controller/User/DelegationTest.php
+++ b/src/tests/Feature/Controller/User/DelegationTest.php
@@ -9,10 +9,7 @@
class DelegationTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +17,7 @@
Delegation::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('deleted@kolabnow.com');
Delegation::query()->delete();
@@ -236,7 +230,7 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('Delegation deleted successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('Delegation deleted successfully.', $json['message']);
}
}
diff --git a/src/tests/Feature/Controller/UsersTest.php b/src/tests/Feature/Controller/UsersTest.php
--- a/src/tests/Feature/Controller/UsersTest.php
+++ b/src/tests/Feature/Controller/UsersTest.php
@@ -5,23 +5,22 @@
use App\Discount;
use App\Domain;
use App\Http\Controllers\API\V4\UsersController;
+use App\Jobs\User\CreateJob;
use App\Package;
use App\Plan;
use App\Sku;
use App\Tenant;
use App\User;
+use App\UserAlias;
+use App\VerificationCode;
use App\Wallet;
use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
-use Illuminate\Support\Str;
use Tests\TestCase;
class UsersTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -53,10 +52,7 @@
$user->setSettings(['plan_id' => null]);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->clearBetaEntitlements();
$this->deleteTestUser('jane@kolabnow.com');
@@ -94,16 +90,16 @@
public function testDestroy(): void
{
// First create some users/accounts to delete
- $package_kolab = \App\Package::where('title', 'kolab')->first();
- $package_domain = \App\Package::where('title', 'domain-hosting')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
+ $package_domain = Package::where('title', 'domain-hosting')->first();
$john = $this->getTestUser('john@kolab.org');
$user1 = $this->getTestUser('UsersControllerTest1@userscontroller.com');
$user2 = $this->getTestUser('UsersControllerTest2@userscontroller.com');
$user3 = $this->getTestUser('UsersControllerTest3@userscontroller.com');
$domain = $this->getTestDomain('userscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$user1->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user1);
@@ -135,8 +131,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('User deleted successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('User deleted successfully.', $json['message']);
// Test removing self (an account with users)
$response = $this->actingAs($user1)->delete("api/v4/users/{$user1->id}");
@@ -144,8 +140,8 @@
$json = $response->json();
- $this->assertEquals('success', $json['status']);
- $this->assertEquals('User deleted successfully.', $json['message']);
+ $this->assertSame('success', $json['status']);
+ $this->assertSame('User deleted successfully.', $json['message']);
}
/**
@@ -154,14 +150,14 @@
public function testDestroyByController(): void
{
// Create an account with additional controller - $user2
- $package_kolab = \App\Package::where('title', 'kolab')->first();
- $package_domain = \App\Package::where('title', 'domain-hosting')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
+ $package_domain = Package::where('title', 'domain-hosting')->first();
$user1 = $this->getTestUser('UsersControllerTest1@userscontroller.com');
$user2 = $this->getTestUser('UsersControllerTest2@userscontroller.com');
$user3 = $this->getTestUser('UsersControllerTest3@userscontroller.com');
$domain = $this->getTestDomain('userscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$user1->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user1);
@@ -176,8 +172,8 @@
// However, this is not 0-regression scenario as we
// do not fully support additional controllers.
- //$response = $this->actingAs($user2)->delete("api/v4/users/{$user2->id}");
- //$response->assertStatus(403);
+ // $response = $this->actingAs($user2)->delete("api/v4/users/{$user2->id}");
+ // $response->assertStatus(403);
$response = $this->actingAs($user2)->delete("api/v4/users/{$user3->id}");
$response->assertStatus(200);
@@ -211,7 +207,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(0, $json['count']);
$this->assertCount(0, $json['list']);
@@ -220,7 +216,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(4, $json['count']);
$this->assertCount(4, $json['list']);
$this->assertSame($jack->email, $json['list'][0]['email']);
@@ -246,7 +242,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(4, $json['count']);
$this->assertCount(4, $json['list']);
$this->assertSame($jack->email, $json['list'][0]['email']);
@@ -260,7 +256,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(1, $json['count']);
$this->assertCount(1, $json['list']);
$this->assertSame($jack->email, $json['list'][0]['email']);
@@ -271,7 +267,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(1, $json['count']);
$this->assertCount(1, $json['list']);
$this->assertSame($joe->email, $json['list'][0]['email']);
@@ -282,7 +278,7 @@
$json = $response->json();
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertSame(1, $json['count']);
$this->assertCount(1, $json['list']);
$this->assertSame($ned->email, $json['list'][0]['email']);
@@ -303,8 +299,8 @@
$json = $response->json();
$response->assertStatus(200);
- $this->assertEquals($userA->id, $json['id']);
- $this->assertEquals($userA->email, $json['email']);
+ $this->assertSame($userA->id, $json['id']);
+ $this->assertSame($userA->email, $json['email']);
$this->assertTrue(is_array($json['statusInfo']));
$this->assertTrue(is_array($json['settings']));
$this->assertTrue($json['config']['greylist_enabled']);
@@ -360,7 +356,7 @@
$this->assertCount(5, $json['skus']);
$this->assertSame(5, $json['skus'][$storage_sku->id]['count']);
- $this->assertSame([0,0,0,0,0], $json['skus'][$storage_sku->id]['costs']);
+ $this->assertSame([0, 0, 0, 0, 0], $json['skus'][$storage_sku->id]['costs']);
$this->assertSame(1, $json['skus'][$groupware_sku->id]['count']);
$this->assertSame([490], $json['skus'][$groupware_sku->id]['costs']);
$this->assertSame(1, $json['skus'][$mailbox_sku->id]['count']);
@@ -384,12 +380,12 @@
// Create an sku for another tenant, to make sure it is not included in the result
$nsku = Sku::create([
- 'title' => 'test',
- 'name' => 'Test',
- 'description' => '',
- 'active' => true,
- 'cost' => 100,
- 'handler_class' => 'Mailbox',
+ 'title' => 'test',
+ 'name' => 'Test',
+ 'description' => '',
+ 'active' => true,
+ 'cost' => 100,
+ 'handler_class' => 'Mailbox',
]);
$tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first();
$nsku->tenant_id = $tenant->id;
@@ -403,50 +399,50 @@
$this->assertCount(5, $json);
$this->assertSkuElement('mailbox', $json[0], [
- 'prio' => 100,
- 'type' => 'user',
- 'handler' => 'Mailbox',
- 'enabled' => true,
- 'readonly' => true,
+ 'prio' => 100,
+ 'type' => 'user',
+ 'handler' => 'Mailbox',
+ 'enabled' => true,
+ 'readonly' => true,
]);
$this->assertSkuElement('storage', $json[1], [
- 'prio' => 90,
- 'type' => 'user',
- 'handler' => 'Storage',
- 'enabled' => true,
- 'readonly' => true,
- 'range' => [
- 'min' => 5,
- 'max' => 100,
- 'unit' => 'GB',
- ]
+ 'prio' => 90,
+ 'type' => 'user',
+ 'handler' => 'Storage',
+ 'enabled' => true,
+ 'readonly' => true,
+ 'range' => [
+ 'min' => 5,
+ 'max' => 100,
+ 'unit' => 'GB',
+ ],
]);
$this->assertSkuElement('groupware', $json[2], [
- 'prio' => 80,
- 'type' => 'user',
- 'handler' => 'Groupware',
- 'enabled' => false,
- 'readonly' => false,
+ 'prio' => 80,
+ 'type' => 'user',
+ 'handler' => 'Groupware',
+ 'enabled' => false,
+ 'readonly' => false,
]);
$this->assertSkuElement('activesync', $json[3], [
- 'prio' => 70,
- 'type' => 'user',
- 'handler' => 'Activesync',
- 'enabled' => false,
- 'readonly' => false,
- 'required' => ['Groupware'],
+ 'prio' => 70,
+ 'type' => 'user',
+ 'handler' => 'Activesync',
+ 'enabled' => false,
+ 'readonly' => false,
+ 'required' => ['Groupware'],
]);
$this->assertSkuElement('2fa', $json[4], [
- 'prio' => 60,
- 'type' => 'user',
- 'handler' => 'Auth2F',
- 'enabled' => false,
- 'readonly' => false,
- 'forbidden' => ['Activesync'],
+ 'prio' => 60,
+ 'type' => 'user',
+ 'handler' => 'Auth2F',
+ 'enabled' => false,
+ 'readonly' => false,
+ 'forbidden' => ['Activesync'],
]);
// Test inclusion of beta SKUs
@@ -460,11 +456,11 @@
$this->assertCount(6, $json);
$this->assertSkuElement('beta', $json[5], [
- 'prio' => 10,
- 'type' => 'user',
- 'handler' => 'Beta',
- 'enabled' => false,
- 'readonly' => false,
+ 'prio' => 10,
+ 'type' => 'user',
+ 'handler' => 'Beta',
+ 'enabled' => false,
+ 'readonly' => false,
]);
}
@@ -530,15 +526,15 @@
if (\config('app.with_ldap')) {
$this->assertFalse($json['isLdapReady']);
$this->assertSame('user-ldap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
$this->assertSame('user-imap-ready', $json['process'][2]['label']);
- $this->assertSame(false, $json['process'][2]['state']);
+ $this->assertFalse($json['process'][2]['state']);
} else {
$this->assertSame('user-imap-ready', $json['process'][1]['label']);
- $this->assertSame(false, $json['process'][1]['state']);
+ $this->assertFalse($json['process'][1]['state']);
}
- Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
}
/**
@@ -548,8 +544,8 @@
{
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com');
$domain = $this->getTestDomain('userscontroller.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$user->created_at = Carbon::now();
@@ -563,16 +559,16 @@
if (\config('app.with_ldap')) {
$this->assertCount(3, $result['process']);
$this->assertSame('user-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
$this->assertSame('user-imap-ready', $result['process'][2]['label']);
- $this->assertSame(false, $result['process'][2]['state']);
+ $this->assertFalse($result['process'][2]['state']);
} else {
$this->assertCount(2, $result['process']);
$this->assertSame('user-imap-ready', $result['process'][1]['label']);
- $this->assertSame(false, $result['process'][1]['state']);
+ $this->assertFalse($result['process'][1]['state']);
}
$this->assertSame('user-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
$this->assertSame('running', $result['processState']);
$this->assertTrue($result['enableRooms']);
$this->assertFalse($result['enableBeta']);
@@ -594,16 +590,16 @@
if (\config('app.with_ldap')) {
$this->assertCount(3, $result['process']);
$this->assertSame('user-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
$this->assertSame('user-imap-ready', $result['process'][2]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
} else {
$this->assertCount(2, $result['process']);
$this->assertSame('user-imap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
}
$this->assertSame('user-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
$domain->status |= Domain::STATUS_VERIFIED;
$domain->type = Domain::TYPE_EXTERNAL;
@@ -616,30 +612,30 @@
if (\config('app.with_ldap')) {
$this->assertCount(7, $result['process']);
$this->assertSame('user-ldap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
$this->assertSame('user-imap-ready', $result['process'][2]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
$this->assertSame('domain-new', $result['process'][3]['label']);
- $this->assertSame(true, $result['process'][3]['state']);
+ $this->assertTrue($result['process'][3]['state']);
$this->assertSame('domain-ldap-ready', $result['process'][4]['label']);
- $this->assertSame(false, $result['process'][4]['state']);
+ $this->assertFalse($result['process'][4]['state']);
$this->assertSame('domain-verified', $result['process'][5]['label']);
- $this->assertSame(true, $result['process'][5]['state']);
+ $this->assertTrue($result['process'][5]['state']);
$this->assertSame('domain-confirmed', $result['process'][6]['label']);
- $this->assertSame(false, $result['process'][6]['state']);
+ $this->assertFalse($result['process'][6]['state']);
} else {
$this->assertCount(5, $result['process']);
$this->assertSame('user-imap-ready', $result['process'][1]['label']);
- $this->assertSame(true, $result['process'][1]['state']);
+ $this->assertTrue($result['process'][1]['state']);
$this->assertSame('domain-new', $result['process'][2]['label']);
- $this->assertSame(true, $result['process'][2]['state']);
+ $this->assertTrue($result['process'][2]['state']);
$this->assertSame('domain-verified', $result['process'][3]['label']);
- $this->assertSame(true, $result['process'][3]['state']);
+ $this->assertTrue($result['process'][3]['state']);
$this->assertSame('domain-confirmed', $result['process'][4]['label']);
- $this->assertSame(false, $result['process'][4]['state']);
+ $this->assertFalse($result['process'][4]['state']);
}
$this->assertSame('user-new', $result['process'][0]['label']);
- $this->assertSame(true, $result['process'][0]['state']);
+ $this->assertTrue($result['process'][0]['state']);
// Test 'skus' property
$user->assignSku(Sku::withEnvTenantContext()->where('title', 'beta')->first());
@@ -770,7 +766,7 @@
$this->assertSame('User settings updated successfully.', $json['message']);
$this->assertSame('false', $john->fresh()->getSetting('greylist_enabled'));
- $this->assertSame(null, $john->fresh()->getSetting('guam_enabled'));
+ $this->assertNull($john->fresh()->getSetting('guam_enabled'));
$this->assertSame('min:10,max:255,upper,last:1', $john->fresh()->getSetting('password_policy'));
}
@@ -839,8 +835,8 @@
$this->assertCount(2, $json);
$this->assertSame('The specified email is not available.', $json['errors']['email']);
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$post = [
'password' => 'simple123',
@@ -915,7 +911,7 @@
$this->assertSame('Doe2', $user->getSetting('last_name'));
$this->assertSame('TestOrg', $user->getSetting('organization'));
$this->assertFalse($user->isRestricted());
- /** @var \App\UserAlias[] $aliases */
+ /** @var UserAlias[] $aliases */
$aliases = $user->aliases()->orderBy('alias')->get();
$this->assertCount(2, $aliases);
$this->assertSame('deleted@kolab.org', $aliases[0]->alias);
@@ -951,7 +947,7 @@
'storage', 'storage', 'storage', 'storage', 'storage']);
// Test password reset link "mode"
- $code = new \App\VerificationCode(['mode' => 'password-reset', 'active' => false]);
+ $code = new VerificationCode(['mode' => 'password-reset', 'active' => false]);
$john->verificationcodes()->save($code);
$post = [
@@ -1069,7 +1065,7 @@
'billing_address' => 'billing',
'country' => 'CH',
'currency' => 'CHF',
- 'aliases' => ['useralias1@' . \config('app.domain'), 'useralias2@' . \config('app.domain')]
+ 'aliases' => ['useralias1@' . \config('app.domain'), 'useralias2@' . \config('app.domain')],
];
$response = $this->actingAs($userA)->put("/api/v4/users/{$userA->id}", $post);
@@ -1101,7 +1097,7 @@
'billing_address' => '',
'country' => '',
'currency' => '',
- 'aliases' => ['useralias2@' . \config('app.domain')]
+ 'aliases' => ['useralias2@' . \config('app.domain')],
];
$response = $this->actingAs($userA)->put("/api/v4/users/{$userA->id}", $post);
@@ -1128,7 +1124,7 @@
'useralias2@' . \config('app.domain'),
'useralias1@kolab.org',
'@kolab.org',
- ]
+ ],
];
$response = $this->actingAs($userA)->put("/api/v4/users/{$userA->id}", $post);
@@ -1212,7 +1208,7 @@
$this->assertTrue(empty($json['statusInfo']));
// Test password reset link "mode"
- $code = new \App\VerificationCode(['mode' => 'password-reset', 'active' => false]);
+ $code = new VerificationCode(['mode' => 'password-reset', 'active' => false]);
$owner->verificationcodes()->save($code);
$post = ['passwordLinkCode' => $code->short_code . '-' . $code->code];
@@ -1251,8 +1247,8 @@
$mailbox->id => 1,
$groupware->id => 1,
$storage->id => 7,
- $activesync->id => 1
- ]
+ $activesync->id => 1,
+ ],
];
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post);
@@ -1270,7 +1266,7 @@
'storage',
'storage',
'storage',
- 'storage'
+ 'storage',
]
);
@@ -1280,8 +1276,8 @@
$mailbox->id => 1,
$groupware->id => 1,
$storage->id => 9,
- $activesync->id => 0
- ]
+ $activesync->id => 0,
+ ],
];
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post);
@@ -1300,7 +1296,7 @@
'storage',
'storage',
'storage',
- 'storage'
+ 'storage',
]
);
@@ -1310,8 +1306,8 @@
$mailbox->id => 2,
$groupware->id => 1,
$storage->id => 9,
- $activesync->id => 0
- ]
+ $activesync->id => 0,
+ ],
];
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post);
@@ -1330,7 +1326,7 @@
'storage',
'storage',
'storage',
- 'storage'
+ 'storage',
]
);
@@ -1340,8 +1336,8 @@
$mailbox->id => 0,
$groupware->id => 1,
$storage->id => 9,
- $activesync->id => 0
- ]
+ $activesync->id => 0,
+ ],
];
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post);
@@ -1360,7 +1356,7 @@
'storage',
'storage',
'storage',
- 'storage'
+ 'storage',
]
);
@@ -1370,8 +1366,8 @@
$mailbox->id => 1,
$groupware->id => 1,
$storage->id => 1,
- $activesync->id => 0
- ]
+ $activesync->id => 0,
+ ],
];
$response = $this->actingAs($jane)->put("/api/v4/users/{$jane->id}", $post);
@@ -1386,7 +1382,7 @@
'storage',
'storage',
'storage',
- 'storage'
+ 'storage',
]
);
}
@@ -1403,9 +1399,9 @@
$wallet->owner->setSettings(['plan_id' => null]);
$result = $this->invokeMethod(new UsersController(), 'userResponse', [$john]);
- $this->assertEquals($john->id, $result['id']);
- $this->assertEquals($john->email, $result['email']);
- $this->assertEquals($john->status, $result['status']);
+ $this->assertSame($john->id, $result['id']);
+ $this->assertSame($john->email, $result['email']);
+ $this->assertSame($john->status, $result['status']);
$this->assertTrue(is_array($result['statusInfo']));
$this->assertTrue(is_array($result['settings']));
@@ -1439,8 +1435,8 @@
$ned_wallet = $ned->wallets()->first();
$result = $this->invokeMethod(new UsersController(), 'userResponse', [$ned]);
- $this->assertEquals($ned->id, $result['id']);
- $this->assertEquals($ned->email, $result['email']);
+ $this->assertSame($ned->id, $result['id']);
+ $this->assertSame($ned->email, $result['email']);
$this->assertTrue(is_array($result['accounts']));
$this->assertTrue(is_array($result['wallets']));
$this->assertCount(1, $result['accounts']);
@@ -1472,7 +1468,7 @@
$result = $this->invokeMethod(new UsersController(), 'userResponse', [$john]);
- $this->assertEquals($john->id, $result['id']);
+ $this->assertSame($john->id, $result['id']);
$this->assertSame($discount->id, $result['wallet']['discount_id']);
$this->assertSame($discount->discount, $result['wallet']['discount']);
$this->assertSame($discount->description, $result['wallet']['discount_description']);
@@ -1540,20 +1536,20 @@
["admin@kolab.org", $john, null],
// valid (public domain)
- ["test.test@$domain", $john, null],
+ ["test.test@{$domain}", $john, null],
// Invalid format
- ["$domain", $john, 'The specified email is invalid.'],
- [".@$domain", $john, 'The specified email is invalid.'],
+ ["{$domain}", $john, 'The specified email is invalid.'],
+ [".@{$domain}", $john, 'The specified email is invalid.'],
["test123456@localhost", $john, 'The specified domain is invalid.'],
["test123456@unknown-domain.org", $john, 'The specified domain is invalid.'],
- ["$domain", $john, 'The specified email is invalid.'],
- [".@$domain", $john, 'The specified email is invalid.'],
+ ["{$domain}", $john, 'The specified email is invalid.'],
+ [".@{$domain}", $john, 'The specified email is invalid.'],
// forbidden local part on public domains
- ["admin@$domain", $john, 'The specified email is not available.'],
- ["administrator@$domain", $john, 'The specified email is not available.'],
+ ["admin@{$domain}", $john, 'The specified email is not available.'],
+ ["administrator@{$domain}", $john, 'The specified email is not available.'],
// forbidden (other user's domain)
["testtest@kolab.org", $user, 'The specified domain is not available.'],
@@ -1583,7 +1579,7 @@
];
foreach ($cases as $idx => $case) {
- list($email, $user, $expected) = $case;
+ [$email, $user, $expected] = $case;
$deleted = null;
$result = UsersController::validateEmail($email, $user, $deleted);
@@ -1610,16 +1606,16 @@
$deleted_pub->delete();
$result = UsersController::validateEmail('deleted@kolab.org', $john, $deleted);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
$this->assertSame($deleted_priv->id, $deleted->id);
$result = UsersController::validateEmail('deleted@kolabnow.com', $john, $deleted);
$this->assertSame('The specified email is not available.', $result);
- $this->assertSame(null, $deleted);
+ $this->assertNull($deleted);
$result = UsersController::validateEmail('jack@kolab.org', $john, $deleted);
$this->assertSame('The specified email is not available.', $result);
- $this->assertSame(null, $deleted);
+ $this->assertNull($deleted);
$pub_group = $this->getTestGroup('group-test@kolabnow.com');
$priv_group = $this->getTestGroup('group-test@kolab.org');
@@ -1645,7 +1641,7 @@
// A group in a private domain, deleted
$result = UsersController::validateEmail($priv_group->email, $john, $deleted);
- $this->assertSame(null, $result);
+ $this->assertNull($result);
$this->assertSame($priv_group->id, $deleted->id);
// TODO: Test the same with a resource and shared folder
@@ -1685,17 +1681,17 @@
$cases = [
// Invalid format
- ["$domain", $john, 'The specified alias is invalid.'],
- [".@$domain", $john, 'The specified alias is invalid.'],
+ ["{$domain}", $john, 'The specified alias is invalid.'],
+ [".@{$domain}", $john, 'The specified alias is invalid.'],
["test123456@localhost", $john, 'The specified domain is invalid.'],
["test123456@unknown-domain.org", $john, 'The specified domain is invalid.'],
- ["$domain", $john, 'The specified alias is invalid.'],
- [".@$domain", $john, 'The specified alias is invalid.'],
+ ["{$domain}", $john, 'The specified alias is invalid.'],
+ [".@{$domain}", $john, 'The specified alias is invalid.'],
// forbidden local part on public domains
- ["admin@$domain", $john, 'The specified alias is not available.'],
- ["administrator@$domain", $john, 'The specified alias is not available.'],
+ ["admin@{$domain}", $john, 'The specified alias is not available.'],
+ ["administrator@{$domain}", $john, 'The specified alias is not available.'],
// forbidden (other user's domain)
["testtest@kolab.org", $user, 'The specified domain is not available.'],
@@ -1710,7 +1706,7 @@
["admin@kolab.org", $john, null],
// valid (public domain)
- ["test.test@$domain", $john, null],
+ ["test.test@{$domain}", $john, null],
// An alias that was a user email before is allowed, but only for custom domains
["deleted@kolab.org", $john, null],
@@ -1740,7 +1736,7 @@
];
foreach ($cases as $idx => $case) {
- list($alias, $user, $expected) = $case;
+ [$alias, $user, $expected] = $case;
$result = UsersController::validateAlias($alias, $user);
$this->assertSame($expected, $result, "Case {$alias}");
}
diff --git a/src/tests/Feature/Controller/VPNTest.php b/src/tests/Feature/Controller/VPNTest.php
--- a/src/tests/Feature/Controller/VPNTest.php
+++ b/src/tests/Feature/Controller/VPNTest.php
@@ -2,32 +2,27 @@
namespace Tests\Feature\Controller;
-use Tests\TestCase;
use Carbon\Carbon;
use Lcobucci\JWT\Encoding\JoseEncoder;
+use Lcobucci\JWT\Signer\Key\InMemory;
+use Lcobucci\JWT\Signer\Rsa\Sha256;
use Lcobucci\JWT\Token\Parser;
use Lcobucci\JWT\Token\RegisteredClaims;
-use Lcobucci\JWT\Signer\Rsa\Sha256;
-use Lcobucci\JWT\Signer\Key\InMemory;
+use Lcobucci\JWT\UnencryptedToken;
use Lcobucci\JWT\Validation\Constraint;
-use Lcobucci\JWT\Validation\Validator;
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
+use Lcobucci\JWT\Validation\Validator;
+use Tests\TestCase;
class VPNTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
- Carbon::setTestNow(Carbon::create(2022, 02, 02, 13, 0, 0));
+ Carbon::setTestNow(Carbon::create(2022, 2, 2, 13, 0, 0));
parent::setUp();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
@@ -38,49 +33,49 @@
public function testToken(): void
{
// openssl genpkey -algorithm RSA -out private.pem -pkeyopt rsa_keygen_bits:2048
- $privateKey = <<<EOF
------BEGIN PRIVATE KEY-----
-MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCmfUb5J+na6LV1
-6PTmOX6alvyEbWEUA1HykKFsKRq3q8nraZU4LlfhM1qoeA23re4WEmT2SoCXq8sd
-ewRXP+swYl6vAPZFtqCR52vApEXn+b221g3gEa5KnZeQ3APTej6wcs+3etMcDFAh
-Sabrjvl3eoHXmO2RQoeSjSfp6N4LPvbbOjkLR5EYdDNxVuwU7HRkwkXve1rWh94z
-RbSl7o4XkP/qzOGEDfrm7SivcSWqwFndHkxNeum1FnBfDZ9ChOwEunuIZiPX2TDb
-K3WZ+TJn29xNERAJJgFZLspB9RK+FT/lCX4IZgdl8ZyU8lC68QXaZuAcQhg7TU7l
-xBw7ZJXBAgMBAAECggEAAqEL/R9tJmISNYJgKv+MQ9mFCNFSXQwgCpN6nRg5aLOb
-h25o0b+M7zc4pAbrTokpBJZgm5wPE6C99HakGahJKOqGF2o4OV8aLNupnFvrvQSj
-reQLnuF17g3hiMMqA02qTkPYiwud6FLlyV9zSu58etoc0UsEBg0gfMcNCDj/bVAt
-b+JvZjfFXG9TQRNx7F3H/yRO5kHw+oqeDBAvHN+Mkq9KATLQ8GBZznwpN7fHL+Is
-PZCDvcAg/4OtN1cNgMOKkdBDSMzjtn7xHUX9jl03VUPvXfa9KDdFCMdVndtnACRK
-lFNMdD+ugQ7Ch1oHI16HUWo663fjF+9m3neYjoAiwQKBgQC+UykotVMHX65OsYx7
-tXankRmj9WnoiUFrfClrdVynbkcbZvCt9NdNluv0eNRbEaNXD07nOIppACSDaQ0i
-DdIALbFU6I3kzAF+z25Rh6SaIl5gaUGxSLSzmpswJsv0hiu/5Sb8t6fOX+VWBV7I
-Fw7MqASoggV5rEAvRVtwiw4TsQKBgQDf8IwZDwXlTFc7/VsAjLfb+edpVcavOB9d
-DAXAwUH+2FJb9AWPOLrTnKdsRV9yw9FueMciuROGi9btOYxEcLGvNcvsyaWy0eFQ
-vN2w0NsxpBodRylxMQLGDc5wO9lbrVuftzC0rDaQaD9gPQaKFoQI7ww81Jmx6u1Y
-OP/Nsq53EQKBgD8vIoHmOItBI3/yh53mL18P18BLz/4n2vURAjsvejQHc0nQkeRe
-XT/f87N0jaMyJtTXOy2d4q1bI8QQkxCUH/x5Lt7uWXT0mSZ9PLWKX4XgFQ7SwsFV
-TtA1aoHAz4L9K/cH3zqUyfvEcEFvhPjOVtZwjSNYDvNG0QQgdWvWbjTxAoGAE50R
-6C/0qDyjd1GdYtLwV4fvyL4GhNo5hQDEkDlc+mEf9YXN5tllI5uY3lbFIVwdP7u8
-VUI4f5RH4scjjesA5QOlNLwEk0DmpxejoxTn3dUtpFrTOmK8h3Q2HIZhZzIr0DVP
-QsPCk6tNwbQWmomWTuIBBGLqgza8SvnTDcUUmsECgYBXk4MAk1FennJuDvpiD1Gg
-HiIQykUOQeA5wk+R97X7D4kI8kj6XzCuRjG+nSJiYmpZBHRvA5XtRtMJWep11R6O
-8yu8ftj4xBQr6roUoHwJ/JBxe8JuKW3yh52CaZLP2KjizwzNI0hDMUzinZIReex+
-iFyt8WwtMwzW/520PlwUyQ==
------END PRIVATE KEY-----
-EOF;
+ $privateKey = <<<'EOF'
+ -----BEGIN PRIVATE KEY-----
+ MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCmfUb5J+na6LV1
+ 6PTmOX6alvyEbWEUA1HykKFsKRq3q8nraZU4LlfhM1qoeA23re4WEmT2SoCXq8sd
+ ewRXP+swYl6vAPZFtqCR52vApEXn+b221g3gEa5KnZeQ3APTej6wcs+3etMcDFAh
+ Sabrjvl3eoHXmO2RQoeSjSfp6N4LPvbbOjkLR5EYdDNxVuwU7HRkwkXve1rWh94z
+ RbSl7o4XkP/qzOGEDfrm7SivcSWqwFndHkxNeum1FnBfDZ9ChOwEunuIZiPX2TDb
+ K3WZ+TJn29xNERAJJgFZLspB9RK+FT/lCX4IZgdl8ZyU8lC68QXaZuAcQhg7TU7l
+ xBw7ZJXBAgMBAAECggEAAqEL/R9tJmISNYJgKv+MQ9mFCNFSXQwgCpN6nRg5aLOb
+ h25o0b+M7zc4pAbrTokpBJZgm5wPE6C99HakGahJKOqGF2o4OV8aLNupnFvrvQSj
+ reQLnuF17g3hiMMqA02qTkPYiwud6FLlyV9zSu58etoc0UsEBg0gfMcNCDj/bVAt
+ b+JvZjfFXG9TQRNx7F3H/yRO5kHw+oqeDBAvHN+Mkq9KATLQ8GBZznwpN7fHL+Is
+ PZCDvcAg/4OtN1cNgMOKkdBDSMzjtn7xHUX9jl03VUPvXfa9KDdFCMdVndtnACRK
+ lFNMdD+ugQ7Ch1oHI16HUWo663fjF+9m3neYjoAiwQKBgQC+UykotVMHX65OsYx7
+ tXankRmj9WnoiUFrfClrdVynbkcbZvCt9NdNluv0eNRbEaNXD07nOIppACSDaQ0i
+ DdIALbFU6I3kzAF+z25Rh6SaIl5gaUGxSLSzmpswJsv0hiu/5Sb8t6fOX+VWBV7I
+ Fw7MqASoggV5rEAvRVtwiw4TsQKBgQDf8IwZDwXlTFc7/VsAjLfb+edpVcavOB9d
+ DAXAwUH+2FJb9AWPOLrTnKdsRV9yw9FueMciuROGi9btOYxEcLGvNcvsyaWy0eFQ
+ vN2w0NsxpBodRylxMQLGDc5wO9lbrVuftzC0rDaQaD9gPQaKFoQI7ww81Jmx6u1Y
+ OP/Nsq53EQKBgD8vIoHmOItBI3/yh53mL18P18BLz/4n2vURAjsvejQHc0nQkeRe
+ XT/f87N0jaMyJtTXOy2d4q1bI8QQkxCUH/x5Lt7uWXT0mSZ9PLWKX4XgFQ7SwsFV
+ TtA1aoHAz4L9K/cH3zqUyfvEcEFvhPjOVtZwjSNYDvNG0QQgdWvWbjTxAoGAE50R
+ 6C/0qDyjd1GdYtLwV4fvyL4GhNo5hQDEkDlc+mEf9YXN5tllI5uY3lbFIVwdP7u8
+ VUI4f5RH4scjjesA5QOlNLwEk0DmpxejoxTn3dUtpFrTOmK8h3Q2HIZhZzIr0DVP
+ QsPCk6tNwbQWmomWTuIBBGLqgza8SvnTDcUUmsECgYBXk4MAk1FennJuDvpiD1Gg
+ HiIQykUOQeA5wk+R97X7D4kI8kj6XzCuRjG+nSJiYmpZBHRvA5XtRtMJWep11R6O
+ 8yu8ftj4xBQr6roUoHwJ/JBxe8JuKW3yh52CaZLP2KjizwzNI0hDMUzinZIReex+
+ iFyt8WwtMwzW/520PlwUyQ==
+ -----END PRIVATE KEY-----
+ EOF;
// openssl rsa -pubout -in private.pem -out public.pem
- $publicKey = <<<EOF
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApn1G+Sfp2ui1dej05jl+
-mpb8hG1hFANR8pChbCkat6vJ62mVOC5X4TNaqHgNt63uFhJk9kqAl6vLHXsEVz/r
-MGJerwD2RbagkedrwKRF5/m9ttYN4BGuSp2XkNwD03o+sHLPt3rTHAxQIUmm6475
-d3qB15jtkUKHko0n6ejeCz722zo5C0eRGHQzcVbsFOx0ZMJF73ta1ofeM0W0pe6O
-F5D/6szhhA365u0or3ElqsBZ3R5MTXrptRZwXw2fQoTsBLp7iGYj19kw2yt1mfky
-Z9vcTREQCSYBWS7KQfUSvhU/5Ql+CGYHZfGclPJQuvEF2mbgHEIYO01O5cQcO2SV
-wQIDAQAB
------END PUBLIC KEY-----
-EOF;
+ $publicKey = <<<'EOF'
+ -----BEGIN PUBLIC KEY-----
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApn1G+Sfp2ui1dej05jl+
+ mpb8hG1hFANR8pChbCkat6vJ62mVOC5X4TNaqHgNt63uFhJk9kqAl6vLHXsEVz/r
+ MGJerwD2RbagkedrwKRF5/m9ttYN4BGuSp2XkNwD03o+sHLPt3rTHAxQIUmm6475
+ d3qB15jtkUKHko0n6ejeCz722zo5C0eRGHQzcVbsFOx0ZMJF73ta1ofeM0W0pe6O
+ F5D/6szhhA365u0or3ElqsBZ3R5MTXrptRZwXw2fQoTsBLp7iGYj19kw2yt1mfky
+ Z9vcTREQCSYBWS7KQfUSvhU/5Ql+CGYHZfGclPJQuvEF2mbgHEIYO01O5cQcO2SV
+ wQIDAQAB
+ -----END PUBLIC KEY-----
+ EOF;
\config(['app.vpn.token_signing_key' => $privateKey]);
@@ -97,7 +92,7 @@
$parser = new Parser(new JoseEncoder());
- /** @var \Lcobucci\JWT\UnencryptedToken $token */
+ /** @var UnencryptedToken $token */
$token = $parser->parse($jwt);
$this->assertSame("default", $token->claims()->get('entitlement'));
@@ -109,17 +104,17 @@
$key = InMemory::plainText($publicKey);
$validator->assert($token, new Constraint\SignedWith(new Sha256(), $key));
- $invalidKey = <<<EOF
------BEGIN PUBLIC KEY-----
-MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApn1G+Sfp2ui1dej05jl+
-mpb8hG1hFANR8pChbCkat6vJ62mVOC5X4TNaqHgNt63uFhJk9kqAl6vLHXsEVz/r
-MGJerwD2RbagkedrwKRF5/m9ttYN4BGuSp2XkNwD03o+sHLPt3rTHAxQIUmm6475
-d3qB15jtkUKHko0n6ejeCz722zo5C0eRGHQzcVbsFOx0ZMJF73ta1ofeM0W0pe6O
-F5D/6szhhA365u0or3ElqsBZ3R5MTXrptRZwXw2fQoTsBLp7iGYj19kw2yt1mfky
-Z9vcTREQCSYBWS7KQfUSvhU/5Ql+CGYHZfGclPJQuvEF2mbgHEIYO01O5cQcO2SV
-wQIDAQAC
------END PUBLIC KEY-----
-EOF;
+ $invalidKey = <<<'EOF'
+ -----BEGIN PUBLIC KEY-----
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApn1G+Sfp2ui1dej05jl+
+ mpb8hG1hFANR8pChbCkat6vJ62mVOC5X4TNaqHgNt63uFhJk9kqAl6vLHXsEVz/r
+ MGJerwD2RbagkedrwKRF5/m9ttYN4BGuSp2XkNwD03o+sHLPt3rTHAxQIUmm6475
+ d3qB15jtkUKHko0n6ejeCz722zo5C0eRGHQzcVbsFOx0ZMJF73ta1ofeM0W0pe6O
+ F5D/6szhhA365u0or3ElqsBZ3R5MTXrptRZwXw2fQoTsBLp7iGYj19kw2yt1mfky
+ Z9vcTREQCSYBWS7KQfUSvhU/5Ql+CGYHZfGclPJQuvEF2mbgHEIYO01O5cQcO2SV
+ wQIDAQAC
+ -----END PUBLIC KEY-----
+ EOF;
$this->expectException(RequiredConstraintsViolated::class);
$key = InMemory::plainText($invalidKey);
$validator->assert($token, new Constraint\SignedWith(new Sha256(), $key));
diff --git a/src/tests/Feature/Controller/WalletsTest.php b/src/tests/Feature/Controller/WalletsTest.php
--- a/src/tests/Feature/Controller/WalletsTest.php
+++ b/src/tests/Feature/Controller/WalletsTest.php
@@ -2,8 +2,11 @@
namespace Tests\Feature\Controller;
+use App\Discount;
use App\Http\Controllers\API\V4\WalletsController;
+use App\Package;
use App\Payment;
+use App\Plan;
use App\ReferralProgram;
use App\Transaction;
use Carbon\Carbon;
@@ -11,10 +14,7 @@
class WalletsTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -22,10 +22,7 @@
ReferralProgram::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallets-controller@kolabnow.com');
ReferralProgram::query()->delete();
@@ -39,7 +36,7 @@
public function testGetWalletNotice(): void
{
$user = $this->getTestUser('wallets-controller@kolabnow.com');
- $plan = \App\Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
+ $plan = Plan::withObjectTenantContext($user)->where('title', 'individual')->first();
$user->assignPlan($plan);
$wallet = $user->wallets()->first();
@@ -92,12 +89,12 @@
// Old entitlements, 100% discount
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subDays(40));
- $discount = \App\Discount::withObjectTenantContext($user)->where('discount', 100)->first();
+ $discount = Discount::withObjectTenantContext($user)->where('discount', 100)->first();
$wallet->discount()->associate($discount);
$notice = $method->invoke($controller, $wallet->refresh());
- $this->assertSame(null, $notice);
+ $this->assertNull($notice);
}
/**
@@ -126,9 +123,9 @@
$response->assertStatus(404);
// Valid receipt id
- $year = intval(date('Y')) - 1;
- $receiptId = "$year-12";
- $filename = \config('app.name') . " Receipt for $year-12.pdf";
+ $year = (int) date('Y') - 1;
+ $receiptId = "{$year}-12";
+ $filename = \config('app.name') . " Receipt for {$year}-12.pdf";
$response = $this->actingAs($user)->get("api/v4/wallets/{$wallet->id}/receipts/{$receiptId}");
@@ -137,10 +134,10 @@
$response->assertHeader('content-disposition', 'attachment; filename="' . $filename . '"');
$response->assertHeader('content-length');
- $length = $response->headers->get('content-length');
+ $length = (int) $response->headers->get('content-length');
$content = $response->content();
$this->assertStringStartsWith("%PDF-1.", $content);
- $this->assertEquals(strlen($content), $length);
+ $this->assertSame(strlen($content), $length);
}
/**
@@ -170,21 +167,21 @@
$this->assertSame([], $json['list']);
$this->assertSame(1, $json['page']);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
// Insert a payment to the database
- $date = Carbon::create(intval(date('Y')) - 1, 4, 30);
+ $date = Carbon::create((int) date('Y') - 1, 4, 30);
$payment = Payment::create([
- 'id' => 'AAA1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in April',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'currency' => 'CHF',
- 'currency_amount' => 1111,
+ 'id' => 'AAA1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in April',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'currency' => 'CHF',
+ 'currency_amount' => 1111,
]);
$payment->updated_at = $date;
$payment->save();
@@ -200,7 +197,7 @@
$this->assertSame($expected, $json['list'][0]);
$this->assertSame(1, $json['page']);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
}
/**
@@ -227,7 +224,7 @@
$this->assertSame([], $json['list']);
$this->assertSame(1, $json['page']);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
// Insert a test program
$program = ReferralProgram::create([
@@ -254,7 +251,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['page']);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame($program->id, $json['list'][0]['id']);
$this->assertSame($program->name, $json['list'][0]['name']);
@@ -281,7 +278,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['page']);
$this->assertSame(1, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(1, $json['list']);
$this->assertSame($program->id, $json['list'][0]['id']);
$this->assertCount(1, $program->codes->fresh());
@@ -326,7 +323,7 @@
*/
public function testTransactions(): void
{
- $package_kolab = \App\Package::where('title', 'kolab')->first();
+ $package_kolab = Package::where('title', 'kolab')->first();
$user = $this->getTestUser('wallets-controller@kolabnow.com');
$user->assignPackage($package_kolab);
$john = $this->getTestUser('john@kolab.org');
@@ -349,12 +346,12 @@
$this->assertSame([], $json['list']);
$this->assertSame(1, $json['page']);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
// Create some sample transactions
$transactions = $this->createTestTransactions($wallet);
$transactions = array_reverse($transactions);
- $pages = array_chunk($transactions, 10 /* page size*/);
+ $pages = array_chunk($transactions, 10 /* page size */);
// Get the first page
$response = $this->actingAs($user)->get("api/v4/wallets/{$wallet->id}/transactions");
@@ -366,7 +363,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['page']);
$this->assertSame(10, $json['count']);
- $this->assertSame(true, $json['hasMore']);
+ $this->assertTrue($json['hasMore']);
$this->assertCount(10, $json['list']);
foreach ($pages[0] as $idx => $transaction) {
$this->assertSame($transaction->id, $json['list'][$idx]['id']);
@@ -389,7 +386,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(2, $json['page']);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(2, $json['list']);
foreach ($pages[1] as $idx => $transaction) {
$this->assertSame($transaction->id, $json['list'][$idx]['id']);
@@ -416,7 +413,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(3, $json['page']);
$this->assertSame(0, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(0, $json['list']);
// Sub-transaction searching
@@ -432,7 +429,7 @@
$this->assertSame('success', $json['status']);
$this->assertSame(1, $json['page']);
$this->assertSame(2, $json['count']);
- $this->assertSame(false, $json['hasMore']);
+ $this->assertFalse($json['hasMore']);
$this->assertCount(2, $json['list']);
$this->assertSame(Transaction::ENTITLEMENT_BILLED, $json['list'][0]['type']);
$this->assertSame(Transaction::ENTITLEMENT_BILLED, $json['list'][1]['type']);
diff --git a/src/tests/Feature/Controller/WellKnownTest.php b/src/tests/Feature/Controller/WellKnownTest.php
--- a/src/tests/Feature/Controller/WellKnownTest.php
+++ b/src/tests/Feature/Controller/WellKnownTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Controller;
+use App\Utils;
use Tests\TestCase;
class WellKnownTest extends TestCase
@@ -11,7 +12,7 @@
*/
public function testOpenidConfiguration(): void
{
- $href = \App\Utils::serviceUrl('/');
+ $href = Utils::serviceUrl('/');
// HTTP_HOST is not set in tests for some reason, but it's required down the line
$host = parse_url($href, \PHP_URL_HOST);
@@ -31,10 +32,10 @@
'password',
],
'response_types_supported' => [
- 'code'
+ 'code',
],
'id_token_signing_alg_values_supported' => [
- 'RS256'
+ 'RS256',
],
'scopes_supported' => [
'openid',
diff --git a/src/tests/Feature/DataMigrator/DAVTest.php b/src/tests/Feature/DataMigrator/DAVTest.php
--- a/src/tests/Feature/DataMigrator/DAVTest.php
+++ b/src/tests/Feature/DataMigrator/DAVTest.php
@@ -15,20 +15,14 @@
{
use BackendsTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
MigratorQueue::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
MigratorQueue::truncate();
@@ -90,6 +84,7 @@
* Test DAV to DAV incremental migration run
*
* @group dav
+ *
* @depends testInitialMigration
*/
public function testIncrementalMigration(): void
diff --git a/src/tests/Feature/DataMigrator/EWSTest.php b/src/tests/Feature/DataMigrator/EWSTest.php
--- a/src/tests/Feature/DataMigrator/EWSTest.php
+++ b/src/tests/Feature/DataMigrator/EWSTest.php
@@ -17,22 +17,16 @@
private const EVENT1 = '1F3C13D7E99642A75ABE23D50487B454-8FE68B2E68E1B348';
private const EVENT2 = '040000008200E00074C5B7101A82E00800000000B6140C77B81BDA01000000000000000'
- . '010000000FA0F989A1B3C20499E1DE5B68DB1E339';
+ . '010000000FA0F989A1B3C20499E1DE5B68DB1E339';
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
MigratorQueue::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
MigratorQueue::truncate();
@@ -97,8 +91,8 @@
$contacts = \collect($dstObjects)->keyBy('fn')->all();
$this->assertCount(3, $contacts);
- $this->assertSame(null, $contacts['Nowy Kontakt']->kind);
- $this->assertSame(null, $contacts['Test Surname']->kind);
+ $this->assertNull($contacts['Nowy Kontakt']->kind);
+ $this->assertNull($contacts['Test Surname']->kind);
$this->assertSame('group', $contacts['nowa lista']->kind);
}
@@ -107,6 +101,7 @@
*
* @group dav
* @group ews
+ *
* @depends testInitialMigration
*/
public function testIncrementalMigration(): void
@@ -147,9 +142,9 @@
$contacts = \collect($dstObjects)->keyBy('fn')->all();
$this->assertCount(4, $contacts);
- $this->assertSame(null, $contacts['Nowy Kontakt']->kind);
- $this->assertSame(null, $contacts['Test Surname 1']->kind);
- $this->assertSame(null, $contacts['Test New']->kind);
+ $this->assertNull($contacts['Nowy Kontakt']->kind);
+ $this->assertNull($contacts['Test Surname 1']->kind);
+ $this->assertNull($contacts['Test New']->kind);
$this->assertSame('group', $contacts['nowa lista']->kind);
// TODO: Assert that unmodified objects aren't migrated again,
@@ -162,6 +157,7 @@
* Test OAuth2 use
*
* @group ews dav
+ *
* @depends testIncrementalMigration
*/
public function testOAuth2(): void
@@ -207,7 +203,7 @@
ksort($playback);
- file_put_contents($dir . '/' . 'saveState.json', json_encode($playback));
+ file_put_contents($dir . '/saveState.json', json_encode($playback));
return $dir;
}
diff --git a/src/tests/Feature/DataMigrator/EngineTest.php b/src/tests/Feature/DataMigrator/EngineTest.php
--- a/src/tests/Feature/DataMigrator/EngineTest.php
+++ b/src/tests/Feature/DataMigrator/EngineTest.php
@@ -3,11 +3,10 @@
namespace Tests\Feature\DataMigrator;
use App\DataMigrator\Account;
+use App\DataMigrator\Driver\Test;
use App\DataMigrator\Engine;
use App\DataMigrator\Jobs\FolderJob;
-use App\DataMigrator\Jobs\ItemJob;
use App\DataMigrator\Queue as MigratorQueue;
-use App\DataMigrator\Driver\Test;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@@ -51,20 +50,14 @@
],
];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
MigratorQueue::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
MigratorQueue::truncate();
@@ -91,21 +84,21 @@
Queue::assertPushed(FolderJob::class, 3);
Queue::assertPushed(
FolderJob::class,
- function ($job) use ($queue) {
+ static function ($job) use ($queue) {
$folder = TestCase::getObjectProperty($job, 'folder');
return $folder->id === 'Inbox' && $folder->queueId = $queue->id;
}
);
Queue::assertPushed(
FolderJob::class,
- function ($job) use ($queue) {
+ static function ($job) use ($queue) {
$folder = TestCase::getObjectProperty($job, 'folder');
return $folder->id === 'Contacts' && $folder->queueId = $queue->id;
}
);
Queue::assertPushed(
FolderJob::class,
- function ($job) use ($queue) {
+ static function ($job) use ($queue) {
$folder = TestCase::getObjectProperty($job, 'folder');
return $folder->id === 'Calendar' && $folder->queueId = $queue->id;
}
diff --git a/src/tests/Feature/DataMigrator/IMAPTest.php b/src/tests/Feature/DataMigrator/IMAPTest.php
--- a/src/tests/Feature/DataMigrator/IMAPTest.php
+++ b/src/tests/Feature/DataMigrator/IMAPTest.php
@@ -12,20 +12,14 @@
{
use BackendsTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
MigratorQueue::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
MigratorQueue::truncate();
@@ -41,7 +35,7 @@
{
$uri = \config('services.imap.uri');
- if (strpos($uri, '://') === false) {
+ if (!str_contains($uri, '://')) {
$uri = 'imap://' . $uri;
}
@@ -106,21 +100,22 @@
* Test IMAP to IMAP incremental migration run
*
* @group imap
+ *
* @depends testInitialMigration
*/
public function testIncrementalMigration(): void
{
$uri = \config('services.imap.uri');
- if (strpos($uri, '://') === false) {
+ if (!str_contains($uri, '://')) {
$uri = 'imap://' . $uri;
}
// Let's test with impersonation now
$adminUser = \config('services.imap.admin_login');
$adminPass = \config('services.imap.admin_password');
- $src = new Account(str_replace('://', "://$adminUser:$adminPass@", $uri) . '?user=john%40kolab.org');
- $dst = new Account(str_replace('://', "://$adminUser:$adminPass@", $uri) . '?user=jack%40kolab.org');
+ $src = new Account(str_replace('://', "://{$adminUser}:{$adminPass}@", $uri) . '?user=john%40kolab.org');
+ $dst = new Account(str_replace('://', "://{$adminUser}:{$adminPass}@", $uri) . '?user=jack%40kolab.org');
// Add some mails to the source account
$srcMessages = $this->imapList($src, 'INBOX');
@@ -145,8 +140,8 @@
$msg = array_shift($dstMessages);
$this->assertSame('<sync2@kolab.org>', $msg->messageID);
$this->assertSame(['FLAGGED'], array_keys($msg->flags));
- $ids = array_map(fn ($msg) => $msg->messageID, $dstMessages);
- $this->assertSame(['<sync3@kolab.org>','<sync4@kolab.org>'], $ids);
+ $ids = array_map(static fn ($msg) => $msg->messageID, $dstMessages);
+ $this->assertSame(['<sync3@kolab.org>', '<sync4@kolab.org>'], $ids);
// Nothing changed in the other folder
$utf7_folder = \mb_convert_encoding('ImapDataMigrator/&kość', 'UTF7-IMAP', 'UTF8');
diff --git a/src/tests/Feature/DataMigrator/KolabTest.php b/src/tests/Feature/DataMigrator/KolabTest.php
--- a/src/tests/Feature/DataMigrator/KolabTest.php
+++ b/src/tests/Feature/DataMigrator/KolabTest.php
@@ -28,10 +28,7 @@
private static $skipTearDown = false;
private static $skipSetUp = false;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -43,10 +40,7 @@
self::$skipSetUp = false;
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
if (!self::$skipTearDown) {
MigratorQueue::truncate();
@@ -178,9 +172,9 @@
$this->assertTrue($folders['Files']->children->contains($files['empty.txt']));
$this->assertTrue($folders['Files']->children->contains($files['&kość.odt']));
$this->assertTrue($folders['A€B']->children->contains($files['test2.odt']));
- $this->assertEquals(10000, $files['&kość.odt']->getProperty('size'));
- $this->assertEquals(0, $files['empty.txt']->getProperty('size'));
- $this->assertEquals(10000, $files['test2.odt']->getProperty('size'));
+ $this->assertSame(10000, (int) $files['&kość.odt']->getProperty('size'));
+ $this->assertSame(0, (int) $files['empty.txt']->getProperty('size'));
+ $this->assertSame(10000, (int) $files['test2.odt']->getProperty('size'));
$this->assertSame('application/vnd.oasis.opendocument.odt', $files['&kość.odt']->getProperty('mimetype'));
$this->assertSame('text/plain', $files['empty.txt']->getProperty('mimetype'));
$this->assertSame('application/vnd.oasis.opendocument.odt', $files['test2.odt']->getProperty('mimetype'));
@@ -213,7 +207,7 @@
$replace = [
// '/john@kolab.org/' => 'ned@kolab.org',
'/DTSTAMP:19970714T170000Z/' => 'DTSTAMP:20240714T170000Z',
- '/SUMMARY:Party/' => 'SUMMARY:Test'
+ '/SUMMARY:Party/' => 'SUMMARY:Test',
];
$this->davAppend($src_dav, 'Calendar', ['event/1.ics'], Engine::TYPE_EVENT, $replace);
$this->imapEmptyFolder($src_imap, 'Files');
@@ -223,7 +217,7 @@
// Run the migration
$migrator = new Engine();
- $migrator->migrate($src, $dst, ['force' => true,'sync' => true]);
+ $migrator->migrate($src, $dst, ['force' => true, 'sync' => true]);
// Assert the migrated mail
$messages = $this->imapList($dst_imap, 'INBOX');
@@ -270,7 +264,7 @@
->keyBy('name')
->all();
$this->assertSame(3, count($files));
- $this->assertEquals(3, $files['&kość.odt']->getProperty('size'));
+ $this->assertSame(3, (int) $files['&kość.odt']->getProperty('size'));
$this->assertSame('application/vnd.oasis.opendocument.odt', $files['&kość.odt']->getProperty('mimetype'));
$this->assertSame('2024-01-12 09:09:09', $files['&kość.odt']->updated_at->toDateTimeString());
$this->assertSame('123', Storage::fileFetch($files['&kość.odt']));
@@ -319,7 +313,7 @@
$dav_uri = \config('services.dav.uri');
$dav_uri = preg_replace('|^http|', 'dav', $dav_uri);
$imap_uri = \config('services.imap.uri');
- if (strpos($imap_uri, '://') === false) {
+ if (!str_contains($imap_uri, '://')) {
$imap_uri = 'imap://' . $imap_uri;
}
diff --git a/src/tests/Feature/DataMigrator/TakeoutTest.php b/src/tests/Feature/DataMigrator/TakeoutTest.php
--- a/src/tests/Feature/DataMigrator/TakeoutTest.php
+++ b/src/tests/Feature/DataMigrator/TakeoutTest.php
@@ -17,20 +17,14 @@
{
use BackendsTrait;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
MigratorQueue::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
MigratorQueue::truncate();
@@ -139,13 +133,13 @@
$this->davEmptyFolder($dav, 'Custom Calendar', Engine::TYPE_EVENT);
$replace = [
'/UID:aaa-aaa/' => 'UID:44gvk1rth37n1qk8nsml26o7og@google.com',
- '/john@kolab.org/' => 'test@gmail.com'
+ '/john@kolab.org/' => 'test@gmail.com',
];
$this->davAppend($dav, 'Calendar', ['event/3.ics'], Engine::TYPE_EVENT, $replace);
// Run the migration
$migrator = new Engine();
- $migrator->migrate($src, $dst, ['force' => true,'sync' => true]);
+ $migrator->migrate($src, $dst, ['force' => true, 'sync' => true]);
// Assert the migrated mail
$messages = $this->imapList($imap, 'INBOX');
@@ -179,7 +173,7 @@
$dav_uri = \config('services.dav.uri');
$dav_uri = preg_replace('|^http|', 'dav', $dav_uri);
$imap_uri = \config('services.imap.uri');
- if (strpos($imap_uri, '://') === false) {
+ if (!str_contains($imap_uri, '://')) {
$imap_uri = 'imap://' . $imap_uri;
}
diff --git a/src/tests/Feature/DelegationTest.php b/src/tests/Feature/DelegationTest.php
--- a/src/tests/Feature/DelegationTest.php
+++ b/src/tests/Feature/DelegationTest.php
@@ -3,16 +3,14 @@
namespace Tests\Feature;
use App\Delegation;
+use App\Jobs\User\Delegation\DeleteJob;
use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class DelegationTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -20,10 +18,7 @@
$this->deleteTestUser('UserAccountB@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UserAccountA@UserAccount.com');
$this->deleteTestUser('UserAccountB@UserAccount.com');
@@ -51,10 +46,10 @@
$this->assertNull(Delegation::find($delegation->id));
- Queue::assertPushed(\App\Jobs\User\Delegation\DeleteJob::class, 1);
+ Queue::assertPushed(DeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\Delegation\DeleteJob::class,
- function ($job) use ($userA, $userB) {
+ DeleteJob::class,
+ static function ($job) use ($userA, $userB) {
$delegator = TestCase::getObjectProperty($job, 'delegatorEmail');
$delegatee = TestCase::getObjectProperty($job, 'delegateeEmail');
return $delegator === $userA->email && $delegatee === $userB->email;
diff --git a/src/tests/Feature/Documents/ReceiptTest.php b/src/tests/Feature/Documents/ReceiptTest.php
--- a/src/tests/Feature/Documents/ReceiptTest.php
+++ b/src/tests/Feature/Documents/ReceiptTest.php
@@ -5,15 +5,15 @@
use App\Documents\Receipt;
use App\Payment;
use App\User;
-use App\Wallet;
use App\VatRate;
+use App\Wallet;
use Carbon\Carbon;
use Illuminate\Support\Facades\Bus;
use Tests\TestCase;
class ReceiptTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +21,7 @@
VatRate::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('receipt-test@kolabnow.com');
@@ -72,17 +69,17 @@
$cells = $records[1]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-01', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('12,34 CHF', $this->getNodeContent($cells[2]));
$cells = $records[2]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-10', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('0,01 CHF', $this->getNodeContent($cells[2]));
$cells = $records[3]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-21', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('1,00 CHF', $this->getNodeContent($cells[2]));
$cells = $records[4]->getElementsByTagName('td');
$this->assertCount(3, $cells);
@@ -106,14 +103,14 @@
$customerExpected = "Firstname Lastname\nTest Unicode Straße 150\n10115 Berlin";
$this->assertSame($customerExpected, $this->getNodeContent($customerCells[0]));
$customerIdents = $this->getNodeContent($customerCells[1]);
- //$this->assertTrue(strpos($customerIdents, "Account ID {$wallet->id}") !== false);
- $this->assertTrue(strpos($customerIdents, "Customer No. {$wallet->owner->id}") !== false);
+ // $this->assertTrue(strpos($customerIdents, "Account ID {$wallet->id}") !== false);
+ $this->assertTrue(str_contains($customerIdents, "Customer No. {$wallet->owner->id}"));
// Company details in the footer
$footer = $dom->getElementById('footer');
$footerOutput = $footer->textContent;
$this->assertStringStartsWith(\config('app.company.details'), $footerOutput);
- $this->assertTrue(strpos($footerOutput, \config('app.company.email')) !== false);
+ $this->assertTrue(str_contains($footerOutput, \config('app.company.email')));
}
/**
@@ -139,17 +136,17 @@
$cells = $records[1]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-01', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('11,39 CHF', $this->getNodeContent($cells[2]));
$cells = $records[2]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-10', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('0,01 CHF', $this->getNodeContent($cells[2]));
$cells = $records[3]->getElementsByTagName('td');
$this->assertCount(3, $cells);
$this->assertSame('2020-05-21', $this->getNodeContent($cells[0]));
- $this->assertSame("$appName Services", $this->getNodeContent($cells[1]));
+ $this->assertSame("{$appName} Services", $this->getNodeContent($cells[1]));
$this->assertSame('0,92 CHF', $this->getNodeContent($cells[2]));
$cells = $records[4]->getElementsByTagName('td');
$this->assertCount(3, $cells);
@@ -194,19 +191,17 @@
* Prepare data for a test
*
* @param string $country User country code
- *
- * @return \App\Wallet
*/
- protected function getTestData(string $country = null): Wallet
+ protected function getTestData(?string $country = null): Wallet
{
Bus::fake();
$user = $this->getTestUser('receipt-test@kolabnow.com');
$user->setSettings([
- 'first_name' => 'Firstname',
- 'last_name' => 'Lastname',
- 'billing_address' => "Test Unicode Straße 150\n10115 Berlin",
- 'country' => $country
+ 'first_name' => 'Firstname',
+ 'last_name' => 'Lastname',
+ 'billing_address' => "Test Unicode Straße 150\n10115 Berlin",
+ 'country' => $country,
]);
$wallet = $user->wallets()->first();
@@ -214,9 +209,9 @@
$vat = null;
if ($country) {
$vat = VatRate::create([
- 'country' => $country,
- 'rate' => 7.7,
- 'start' => now(),
+ 'country' => $country,
+ 'rate' => 7.7,
+ 'start' => now(),
])->id;
}
@@ -225,146 +220,146 @@
// and one with amount 0, and an extra refund and chanrgeback
$payment = Payment::create([
- 'id' => 'AAA1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in April',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1111,
- 'credit_amount' => 1111,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 1111,
+ 'id' => 'AAA1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in April',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1111,
+ 'credit_amount' => 1111,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 1111,
]);
$payment->updated_at = Carbon::create(2020, 4, 30, 12, 0, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'AAA2',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Paid in June',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 2222,
- 'credit_amount' => 2222,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 2222,
+ 'id' => 'AAA2',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Paid in June',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 2222,
+ 'credit_amount' => 2222,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 2222,
]);
$payment->updated_at = Carbon::create(2020, 6, 1, 0, 0, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'AAA3',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Auto-Payment Setup',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 0,
- 'credit_amount' => 0,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 0,
+ 'id' => 'AAA3',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Auto-Payment Setup',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 0,
+ 'credit_amount' => 0,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 0,
]);
$payment->updated_at = Carbon::create(2020, 5, 1, 0, 0, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'AAA4',
- 'status' => Payment::STATUS_OPEN,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Payment not yet paid',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 990,
- 'credit_amount' => 990,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 990,
+ 'id' => 'AAA4',
+ 'status' => Payment::STATUS_OPEN,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Payment not yet paid',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 990,
+ 'credit_amount' => 990,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 990,
]);
$payment->updated_at = Carbon::create(2020, 5, 1, 0, 0, 0);
$payment->save();
// ... so we expect the five three on the receipt
$payment = Payment::create([
- 'id' => 'AAA5',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Payment OK',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1234,
- 'credit_amount' => 1234,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 1234,
+ 'id' => 'AAA5',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Payment OK',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1234,
+ 'credit_amount' => 1234,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 1234,
]);
$payment->updated_at = Carbon::create(2020, 5, 1, 0, 0, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'AAA6',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_ONEOFF,
- 'description' => 'Payment OK',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 1,
- 'credit_amount' => 1,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 1,
+ 'id' => 'AAA6',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_ONEOFF,
+ 'description' => 'Payment OK',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 1,
+ 'credit_amount' => 1,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 1,
]);
$payment->updated_at = Carbon::create(2020, 5, 10, 0, 0, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'AAA7',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_RECURRING,
- 'description' => 'Payment OK',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => 100,
- 'credit_amount' => 100,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => 100,
+ 'id' => 'AAA7',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_RECURRING,
+ 'description' => 'Payment OK',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => 100,
+ 'credit_amount' => 100,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => 100,
]);
$payment->updated_at = Carbon::create(2020, 5, 21, 23, 59, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'ref1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_REFUND,
- 'description' => 'refund desc',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => -100,
- 'credit_amount' => -100,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => -100,
+ 'id' => 'ref1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_REFUND,
+ 'description' => 'refund desc',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => -100,
+ 'credit_amount' => -100,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => -100,
]);
$payment->updated_at = Carbon::create(2020, 5, 30, 23, 59, 0);
$payment->save();
$payment = Payment::create([
- 'id' => 'chback1',
- 'status' => Payment::STATUS_PAID,
- 'type' => Payment::TYPE_CHARGEBACK,
- 'description' => '',
- 'wallet_id' => $wallet->id,
- 'provider' => 'stripe',
- 'amount' => -10,
- 'credit_amount' => -10,
- 'vat_rate_id' => $vat,
- 'currency' => 'CHF',
- 'currency_amount' => -10,
+ 'id' => 'chback1',
+ 'status' => Payment::STATUS_PAID,
+ 'type' => Payment::TYPE_CHARGEBACK,
+ 'description' => '',
+ 'wallet_id' => $wallet->id,
+ 'provider' => 'stripe',
+ 'amount' => -10,
+ 'credit_amount' => -10,
+ 'vat_rate_id' => $vat,
+ 'currency' => 'CHF',
+ 'currency_amount' => -10,
]);
$payment->updated_at = Carbon::create(2020, 5, 31, 23, 59, 0);
$payment->save();
@@ -404,6 +399,6 @@
}
}
- return trim(implode($content));
+ return trim(implode('', $content));
}
}
diff --git a/src/tests/Feature/DomainTest.php b/src/tests/Feature/DomainTest.php
--- a/src/tests/Feature/DomainTest.php
+++ b/src/tests/Feature/DomainTest.php
@@ -5,8 +5,11 @@
use App\Domain;
use App\Entitlement;
use App\EventLog;
+use App\Jobs\Domain\CreateJob;
+use App\Jobs\Domain\DeleteJob;
+use App\Jobs\Domain\UpdateJob;
+use App\Package;
use App\Sku;
-use App\User;
use App\Tenant;
use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
@@ -24,14 +27,11 @@
'ci-failure-none.kolab.org',
];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
foreach ($this->domains as $domain) {
$this->deleteTestDomain($domain);
}
@@ -39,10 +39,7 @@
$this->deleteTestUser('user@gmail.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
foreach ($this->domains as $domain) {
$this->deleteTestDomain($domain);
@@ -60,11 +57,11 @@
{
$user = $this->getTestUser('user@gmail.com');
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- $package = \App\Package::withObjectTenantContext($user)->where('title', 'domain-hosting')->first();
+ $package = Package::withObjectTenantContext($user)->where('title', 'domain-hosting')->first();
$wallet = $user->wallets()->first();
$domain->assignPackage($package, $user);
@@ -75,8 +72,8 @@
// Assert that units_free might not work as we intended to
// The second domain is still free, but it should cost 100.
$domain = $this->getTestDomain('public-active.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
$domain->assignPackage($package, $user);
@@ -98,9 +95,9 @@
Queue::fake();
$domain = Domain::create([
- 'namespace' => 'GMAIL.COM',
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'namespace' => 'GMAIL.COM',
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
$result = Domain::where('namespace', 'gmail.com')->first();
@@ -121,21 +118,21 @@
Queue::assertNothingPushed();
$domain = Domain::create([
- 'namespace' => 'gmail.com',
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'namespace' => 'gmail.com',
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
- Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Domain\CreateJob::class,
- function ($job) use ($domain) {
+ CreateJob::class,
+ static function ($job) use ($domain) {
$domainId = TestCase::getObjectProperty($job, 'domainId');
$domainNamespace = TestCase::getObjectProperty($job, 'domainNamespace');
- return $domainId === $domain->id &&
- $domainNamespace === $domain->namespace;
+ return $domainId === $domain->id
+ && $domainNamespace === $domain->namespace;
}
);
}
@@ -152,9 +149,9 @@
$queue = Queue::fake();
$domain = Domain::create([
- 'namespace' => 'public-active.com',
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'namespace' => 'public-active.com',
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
// External domains should not be returned
@@ -246,8 +243,8 @@
Queue::fake();
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$domain->delete();
@@ -255,8 +252,8 @@
$this->assertTrue($domain->fresh()->trashed());
$this->assertFalse($domain->fresh()->isDeleted());
- Queue::assertPushed(\App\Jobs\Domain\DeleteJob::class, 1);
- Queue::assertPushed(\App\Jobs\Domain\UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 0);
// Delete the domain for real
$domain->status |= Domain::STATUS_DELETED;
@@ -268,8 +265,8 @@
$this->assertCount(0, Domain::withTrashed()->where('id', $domain->id)->get());
- Queue::assertPushed(\App\Jobs\Domain\DeleteJob::class, 0);
- Queue::assertPushed(\App\Jobs\Domain\UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
}
/**
@@ -280,8 +277,8 @@
Queue::fake();
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
EventLog::createFor($domain, EventLog::TYPE_SUSPENDED, 'test');
@@ -309,8 +306,8 @@
// Empty domain
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
$this->assertTrue($domain->isEmpty());
@@ -346,30 +343,30 @@
Queue::fake();
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED
- | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED
+ | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$user = $this->getTestUser('user@gmail.com');
- $sku = \App\Sku::where('title', 'domain-hosting')->first();
- $now = \Carbon\Carbon::now();
+ $sku = Sku::where('title', 'domain-hosting')->first();
+ $now = Carbon::now();
// Assign two entitlements to the domain, so we can assert that only the
// ones deleted last will be restored
- $ent1 = \App\Entitlement::create([
- 'wallet_id' => $user->wallets->first()->id,
- 'sku_id' => $sku->id,
- 'cost' => 0,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class,
+ $ent1 = Entitlement::create([
+ 'wallet_id' => $user->wallets->first()->id,
+ 'sku_id' => $sku->id,
+ 'cost' => 0,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
- $ent2 = \App\Entitlement::create([
- 'wallet_id' => $user->wallets->first()->id,
- 'sku_id' => $sku->id,
- 'cost' => 0,
- 'entitleable_id' => $domain->id,
- 'entitleable_type' => Domain::class,
+ $ent2 = Entitlement::create([
+ 'wallet_id' => $user->wallets->first()->id,
+ 'sku_id' => $sku->id,
+ 'cost' => 0,
+ 'entitleable_id' => $domain->id,
+ 'entitleable_type' => Domain::class,
]);
$domain->delete();
@@ -380,8 +377,8 @@
$this->assertTrue($ent2->fresh()->trashed());
// Backdate some properties
- \App\Entitlement::withTrashed()->where('id', $ent2->id)->update(['deleted_at' => $now->subMinutes(2)]);
- \App\Entitlement::withTrashed()->where('id', $ent1->id)->update(['updated_at' => $now->subMinutes(10)]);
+ Entitlement::withTrashed()->where('id', $ent2->id)->update(['deleted_at' => $now->subMinutes(2)]);
+ Entitlement::withTrashed()->where('id', $ent1->id)->update(['updated_at' => $now->subMinutes(10)]);
Queue::fake();
@@ -399,18 +396,18 @@
// Assert entitlements
$this->assertTrue($ent2->fresh()->trashed());
$this->assertFalse($ent1->fresh()->trashed());
- $this->assertTrue($ent1->updated_at->greaterThan(\Carbon\Carbon::now()->subSeconds(5)));
+ $this->assertTrue($ent1->updated_at->greaterThan(Carbon::now()->subSeconds(5)));
// We expect only one CreateJob and one UpdateJob
// Because how Illuminate/Database/Eloquent/SoftDeletes::restore() method
// is implemented we cannot skip the UpdateJob in any way.
// I don't want to overwrite this method, the extra job shouldn't do any harm.
$this->assertCount(2, Queue::pushedJobs()); // @phpstan-ignore-line
- Queue::assertPushed(\App\Jobs\Domain\UpdateJob::class, 1);
- Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Domain\CreateJob::class,
- function ($job) use ($domain) {
+ CreateJob::class,
+ static function ($job) use ($domain) {
return $domain->id === TestCase::getObjectProperty($job, 'domainId');
}
);
@@ -494,12 +491,12 @@
// A domain without an owner
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED
- | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED
+ | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED,
+ 'type' => Domain::TYPE_PUBLIC,
]);
- $this->assertSame(null, $domain->walletOwner());
+ $this->assertNull($domain->walletOwner());
}
/**
@@ -511,8 +508,8 @@
// A domain with DNS records
$domain = $this->getTestDomain('gmail.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$this->assertTrue($domain->verify());
@@ -520,8 +517,8 @@
// A domain without DNS records
$domain = $this->getTestDomain('public-active.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$this->assertFalse($domain->verify());
diff --git a/src/tests/Feature/EntitlementTest.php b/src/tests/Feature/EntitlementTest.php
--- a/src/tests/Feature/EntitlementTest.php
+++ b/src/tests/Feature/EntitlementTest.php
@@ -4,6 +4,7 @@
use App\Domain;
use App\Entitlement;
+use App\Jobs\User\UpdateJob;
use App\Package;
use App\Sku;
use App\User;
@@ -13,10 +14,7 @@
class EntitlementTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -26,10 +24,7 @@
$this->deleteTestDomain('custom-domain.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('entitlement-test@kolabnow.com');
$this->deleteTestUser('entitled-user@custom-domain.com');
@@ -53,16 +48,16 @@
$user = $this->getTestUser('entitlement-test@kolabnow.com');
$wallet = $user->wallets->first();
- $assertPushedUserUpdateJob = function ($ifLdap = false) use ($user) {
+ $assertPushedUserUpdateJob = static function ($ifLdap = false) use ($user) {
if ($ifLdap && !\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
return;
}
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($user) {
+ UpdateJob::class,
+ static function ($job) use ($user) {
return $user->id === TestCase::getObjectProperty($job, 'userId');
}
);
@@ -73,10 +68,10 @@
// 'mailbox' SKU should not dispatch update jobs
$this->fakeQueueReset();
$user->assignSku($skuMailbox, 1, $wallet);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
$this->fakeQueueReset();
$user->entitlements()->where('sku_id', $skuMailbox->id)->first()->delete();
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Test dispatching update jobs for the user - 'storage' SKU
$this->fakeQueueReset();
@@ -113,10 +108,10 @@
// Beta SKU should not trigger a user update job
$this->fakeQueueReset();
$user->assignSku($skuBeta, 1, $wallet);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
$this->fakeQueueReset();
$user->entitlements()->where('sku_id', $skuBeta->id)->first()->delete();
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// TODO: Assert 'creating' checks
// TODO: Assert transaction records being created
@@ -126,6 +121,7 @@
/**
* Tests for entitlements
+ *
* @todo This really should be in User or Wallet tests file
*/
public function testEntitlements(): void
@@ -191,9 +187,9 @@
$user->assignPackage($packageKolab);
$group->assignToWallet($wallet);
- $sku_mailbox = \App\Sku::withEnvTenantContext()->where('title', 'mailbox')->first();
- $sku_group = \App\Sku::withEnvTenantContext()->where('title', 'group')->first();
- $sku_domain = \App\Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $sku_mailbox = Sku::withEnvTenantContext()->where('title', 'mailbox')->first();
+ $sku_group = Sku::withEnvTenantContext()->where('title', 'group')->first();
+ $sku_domain = Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$entitlement = Entitlement::where('wallet_id', $wallet->id)
->where('sku_id', $sku_mailbox->id)->first();
@@ -225,7 +221,7 @@
public function testEntitleableRemoveSku(): void
{
$user = $this->getTestUser('entitlement-test@kolabnow.com');
- $storage = \App\Sku::withEnvTenantContext()->where('title', 'storage')->first();
+ $storage = Sku::withEnvTenantContext()->where('title', 'storage')->first();
$user->assignSku($storage, 6);
diff --git a/src/tests/Feature/GroupTest.php b/src/tests/Feature/GroupTest.php
--- a/src/tests/Feature/GroupTest.php
+++ b/src/tests/Feature/GroupTest.php
@@ -2,14 +2,19 @@
namespace Tests\Feature;
-use App\Group;
+use App\Entitlement;
use App\EventLog;
+use App\Group;
+use App\Jobs\Group\CreateJob;
+use App\Jobs\Group\DeleteJob;
+use App\Jobs\Group\UpdateJob;
+use Carbon\Carbon;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class GroupTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -17,7 +22,7 @@
$this->deleteTestGroup('group-test@kolabnow.com');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-test@kolabnow.com');
$this->deleteTestGroup('group-test@kolabnow.com');
@@ -66,6 +71,7 @@
$this->assertSame('["test","-"]', $group->getSetting('sender_policy'));
$this->assertSame([], $result);
}
+
/**
* Test creating a group
*/
@@ -83,8 +89,8 @@
$this->assertFalse($group->isActive());
Queue::assertPushed(
- \App\Jobs\Group\CreateJob::class,
- function ($job) use ($group) {
+ CreateJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
@@ -105,7 +111,7 @@
$group = $this->getTestGroup('group-test@kolabnow.com');
$group->assignToWallet($user->wallets->first());
- $entitlements = \App\Entitlement::where('entitleable_id', $group->id);
+ $entitlements = Entitlement::where('entitleable_id', $group->id);
$this->assertSame(1, $entitlements->count());
@@ -115,11 +121,11 @@
$this->assertSame(0, $entitlements->count());
$this->assertSame(1, $entitlements->withTrashed()->count());
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\Group\DeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Group\DeleteJob::class,
- function ($job) use ($group) {
+ DeleteJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
@@ -135,8 +141,8 @@
$this->assertSame(0, $entitlements->withTrashed()->count());
$this->assertCount(0, Group::withTrashed()->where('id', $group->id)->get());
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\Group\DeleteJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 0);
}
/**
@@ -182,20 +188,18 @@
$this->assertSame($result->id, $group->id);
}
- /*
- * Test group restoring
- */
+ // Test group restoring
public function testRestore(): void
{
Queue::fake();
$user = $this->getTestUser('user-test@kolabnow.com');
$group = $this->getTestGroup('group-test@kolabnow.com', [
- 'status' => Group::STATUS_ACTIVE | Group::STATUS_LDAP_READY | Group::STATUS_SUSPENDED,
+ 'status' => Group::STATUS_ACTIVE | Group::STATUS_LDAP_READY | Group::STATUS_SUSPENDED,
]);
$group->assignToWallet($user->wallets->first());
- $entitlements = \App\Entitlement::where('entitleable_id', $group->id);
+ $entitlements = Entitlement::where('entitleable_id', $group->id);
$this->assertTrue($group->isSuspended());
if (\config('app.with_ldap')) {
@@ -226,13 +230,13 @@
$this->assertSame(1, $entitlements->count());
$entitlements->get()->each(function ($ent) {
- $this->assertTrue($ent->updated_at->greaterThan(\Carbon\Carbon::now()->subSeconds(5)));
+ $this->assertTrue($ent->updated_at->greaterThan(Carbon::now()->subSeconds(5)));
});
- Queue::assertPushed(\App\Jobs\Group\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Group\CreateJob::class,
- function ($job) use ($group) {
+ CreateJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
@@ -252,18 +256,18 @@
$group = $this->getTestGroup('group-test@kolabnow.com');
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting
$group->setSetting('unknown', 'test');
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting that is synced to LDAP
$group->setSetting('sender_policy', '[]');
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current group as well as fresh group object
@@ -276,13 +280,13 @@
// Update a setting
$group->setSetting('unknown', 'test1');
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Update a setting that is synced to LDAP
$group->setSetting('sender_policy', '["-"]');
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
$this->assertSame('test1', $group->getSetting('unknown'));
@@ -293,17 +297,17 @@
// Delete a setting (null)
$group->setSetting('unknown', null);
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Delete a setting that is synced to LDAP
$group->setSetting('sender_policy', null);
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
- $this->assertSame(null, $group->getSetting('unknown'));
- $this->assertSame(null, $group->fresh()->getSetting('sender_policy'));
+ $this->assertNull($group->getSetting('unknown'));
+ $this->assertNull($group->fresh()->getSetting('sender_policy'));
}
/**
@@ -313,66 +317,66 @@
{
$group = new Group();
- $this->assertSame(false, $group->isNew());
- $this->assertSame(false, $group->isActive());
- $this->assertSame(false, $group->isDeleted());
+ $this->assertFalse($group->isNew());
+ $this->assertFalse($group->isActive());
+ $this->assertFalse($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(false, $group->isLdapReady());
+ $this->assertFalse($group->isLdapReady());
}
- $this->assertSame(false, $group->isSuspended());
+ $this->assertFalse($group->isSuspended());
$group->status = Group::STATUS_NEW;
- $this->assertSame(true, $group->isNew());
- $this->assertSame(false, $group->isActive());
- $this->assertSame(false, $group->isDeleted());
+ $this->assertTrue($group->isNew());
+ $this->assertFalse($group->isActive());
+ $this->assertFalse($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(false, $group->isLdapReady());
+ $this->assertFalse($group->isLdapReady());
}
- $this->assertSame(false, $group->isSuspended());
+ $this->assertFalse($group->isSuspended());
$group->status |= Group::STATUS_ACTIVE;
- $this->assertSame(true, $group->isNew());
- $this->assertSame(true, $group->isActive());
- $this->assertSame(false, $group->isDeleted());
+ $this->assertTrue($group->isNew());
+ $this->assertTrue($group->isActive());
+ $this->assertFalse($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(false, $group->isLdapReady());
+ $this->assertFalse($group->isLdapReady());
}
- $this->assertSame(false, $group->isSuspended());
+ $this->assertFalse($group->isSuspended());
if (\config('app.with_ldap')) {
$group->status |= Group::STATUS_LDAP_READY;
}
- $this->assertSame(true, $group->isNew());
- $this->assertSame(true, $group->isActive());
- $this->assertSame(false, $group->isDeleted());
+ $this->assertTrue($group->isNew());
+ $this->assertTrue($group->isActive());
+ $this->assertFalse($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(true, $group->isLdapReady());
+ $this->assertTrue($group->isLdapReady());
}
- $this->assertSame(false, $group->isSuspended());
+ $this->assertFalse($group->isSuspended());
$group->status |= Group::STATUS_DELETED;
- $this->assertSame(true, $group->isNew());
- $this->assertSame(true, $group->isActive());
- $this->assertSame(true, $group->isDeleted());
+ $this->assertTrue($group->isNew());
+ $this->assertTrue($group->isActive());
+ $this->assertTrue($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(true, $group->isLdapReady());
+ $this->assertTrue($group->isLdapReady());
}
- $this->assertSame(false, $group->isSuspended());
+ $this->assertFalse($group->isSuspended());
$group->status |= Group::STATUS_SUSPENDED;
- $this->assertSame(true, $group->isNew());
- $this->assertSame(true, $group->isActive());
- $this->assertSame(true, $group->isDeleted());
+ $this->assertTrue($group->isNew());
+ $this->assertTrue($group->isActive());
+ $this->assertTrue($group->isDeleted());
if (\config('app.with_ldap')) {
- $this->assertSame(true, $group->isLdapReady());
+ $this->assertTrue($group->isLdapReady());
}
- $this->assertSame(true, $group->isSuspended());
+ $this->assertTrue($group->isSuspended());
// Unknown status value
$this->expectException(\Exception::class);
@@ -391,10 +395,10 @@
$this->assertTrue($group->isSuspended());
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Group\UpdateJob::class,
- function ($job) use ($group) {
+ UpdateJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
@@ -415,10 +419,10 @@
$group->status |= Group::STATUS_DELETED;
$group->save();
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Group\UpdateJob::class,
- function ($job) use ($group) {
+ UpdateJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
@@ -441,10 +445,10 @@
$this->assertFalse($group->isSuspended());
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Group\UpdateJob::class,
- function ($job) use ($group) {
+ UpdateJob::class,
+ static function ($job) use ($group) {
$groupEmail = TestCase::getObjectProperty($job, 'groupEmail');
$groupId = TestCase::getObjectProperty($job, 'groupId');
diff --git a/src/tests/Feature/Jobs/Domain/CreateTest.php b/src/tests/Feature/Jobs/Domain/CreateTest.php
--- a/src/tests/Feature/Jobs/Domain/CreateTest.php
+++ b/src/tests/Feature/Jobs/Domain/CreateTest.php
@@ -3,23 +3,22 @@
namespace Tests\Feature\Jobs\Domain;
use App\Domain;
+use App\Jobs\Domain\CreateJob;
+use App\Jobs\Domain\VerifyJob;
use App\Support\Facades\LDAP;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-create-test.com');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-create-test.com');
@@ -49,25 +48,25 @@
LDAP::shouldReceive('createDomain')->once()->with($domain)->andReturn(true);
- $job = new \App\Jobs\Domain\CreateJob($domain->id);
+ $job = new CreateJob($domain->id);
$job->handle();
$this->assertTrue($domain->fresh()->isLdapReady());
- Queue::assertPushed(\App\Jobs\Domain\VerifyJob::class, 1);
+ Queue::assertPushed(VerifyJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Domain\VerifyJob::class,
- function ($job) use ($domain) {
+ VerifyJob::class,
+ static function ($job) use ($domain) {
$domainId = TestCase::getObjectProperty($job, 'domainId');
$domainNamespace = TestCase::getObjectProperty($job, 'domainNamespace');
- return $domainId === $domain->id &&
- $domainNamespace === $domain->namespace;
+ return $domainId === $domain->id
+ && $domainNamespace === $domain->namespace;
}
);
// Test job releasing on unknown identifier
- $job = (new \App\Jobs\Domain\CreateJob(123))->withFakeQueueInteractions();
+ $job = (new CreateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertReleased(delay: 5);
diff --git a/src/tests/Feature/Jobs/Domain/DeleteTest.php b/src/tests/Feature/Jobs/Domain/DeleteTest.php
--- a/src/tests/Feature/Jobs/Domain/DeleteTest.php
+++ b/src/tests/Feature/Jobs/Domain/DeleteTest.php
@@ -3,22 +3,20 @@
namespace Tests\Feature\Jobs\Domain;
use App\Domain;
+use App\Jobs\Domain\DeleteJob;
use App\Support\Facades\LDAP;
use Tests\TestCase;
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-create-test.com');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-create-test.com');
@@ -45,7 +43,7 @@
LDAP::shouldReceive('deleteDomain')->once()->with($domain)->andReturn(true);
- $job = new \App\Jobs\Domain\DeleteJob($domain->id);
+ $job = new DeleteJob($domain->id);
$job->handle();
$domain->refresh();
diff --git a/src/tests/Feature/Jobs/Domain/UpdateTest.php b/src/tests/Feature/Jobs/Domain/UpdateTest.php
--- a/src/tests/Feature/Jobs/Domain/UpdateTest.php
+++ b/src/tests/Feature/Jobs/Domain/UpdateTest.php
@@ -3,22 +3,20 @@
namespace Tests\Feature\Jobs\Domain;
use App\Domain;
+use App\Jobs\Domain\UpdateJob;
use App\Support\Facades\LDAP;
use Tests\TestCase;
class UpdateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestDomain('domain-create-test.com');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('domain-create-test.com');
@@ -44,7 +42,7 @@
LDAP::shouldReceive('updateDomain')->once()->with($domain)->andReturn(true);
- $job = new \App\Jobs\Domain\UpdateJob($domain->id);
+ $job = new UpdateJob($domain->id);
$job->handle();
// TODO: More cases
diff --git a/src/tests/Feature/Jobs/Domain/VerifyTest.php b/src/tests/Feature/Jobs/Domain/VerifyTest.php
--- a/src/tests/Feature/Jobs/Domain/VerifyTest.php
+++ b/src/tests/Feature/Jobs/Domain/VerifyTest.php
@@ -3,14 +3,12 @@
namespace Tests\Feature\Jobs\Domain;
use App\Domain;
+use App\Jobs\Domain\VerifyJob;
use Tests\TestCase;
class VerifyTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,7 +16,7 @@
$this->deleteTestDomain('some-non-existing-domain.fff');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestDomain('gmail.com');
$this->deleteTestDomain('some-non-existing-domain.fff');
@@ -43,13 +41,13 @@
$this->assertFalse($domain->isVerified());
- $job = new \App\Jobs\Domain\VerifyJob($domain->id);
+ $job = new VerifyJob($domain->id);
$job->handle();
$this->assertTrue($domain->fresh()->isVerified());
// Test non-existing domain ID
- $job = (new \App\Jobs\Domain\VerifyJob(123))->withFakeQueueInteractions();
+ $job = (new VerifyJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Domain 123 could not be found in the database.");
}
@@ -71,7 +69,7 @@
$this->assertFalse($domain->isVerified());
- $job = new \App\Jobs\Domain\VerifyJob($domain->id);
+ $job = new VerifyJob($domain->id);
$job->handle();
$this->assertFalse($domain->fresh()->isVerified());
diff --git a/src/tests/Feature/Jobs/Group/CreateTest.php b/src/tests/Feature/Jobs/Group/CreateTest.php
--- a/src/tests/Feature/Jobs/Group/CreateTest.php
+++ b/src/tests/Feature/Jobs/Group/CreateTest.php
@@ -3,22 +3,20 @@
namespace Tests\Feature\Jobs\Group;
use App\Group;
+use App\Jobs\Group\CreateJob;
use App\Support\Facades\LDAP;
use Tests\TestCase;
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group@kolab.org');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group@kolab.org');
@@ -38,7 +36,7 @@
LDAP::shouldReceive('createGroup')->once()->with($group)->andReturn(true);
- $job = (new \App\Jobs\Group\CreateJob($group->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -48,7 +46,7 @@
$this->assertTrue($group->isLdapReady());
// Test non-existing group ID
- $job = (new \App\Jobs\Group\CreateJob(123))->withFakeQueueInteractions();
+ $job = (new CreateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertReleased(delay: 5);
}
diff --git a/src/tests/Feature/Jobs/Group/DeleteTest.php b/src/tests/Feature/Jobs/Group/DeleteTest.php
--- a/src/tests/Feature/Jobs/Group/DeleteTest.php
+++ b/src/tests/Feature/Jobs/Group/DeleteTest.php
@@ -3,23 +3,22 @@
namespace Tests\Feature\Jobs\Group;
use App\Group;
+use App\Jobs\Group\DeleteJob;
+use App\Jobs\Group\UpdateJob;
use App\Support\Facades\LDAP;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group@kolab.org');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group@kolab.org');
@@ -32,8 +31,8 @@
public function testHandle(): void
{
$group = $this->getTestGroup('group@kolab.org', [
- 'members' => [],
- 'status' => Group::STATUS_NEW | Group::STATUS_LDAP_READY
+ 'members' => [],
+ 'status' => Group::STATUS_NEW | Group::STATUS_LDAP_READY,
]);
\config(['app.with_ldap' => true]);
@@ -42,7 +41,7 @@
$this->assertFalse($group->isDeleted());
// Test group that is not deleted yet
- $job = (new \App\Jobs\Group\DeleteJob($group->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Group {$group->id} is not deleted.");
@@ -53,7 +52,7 @@
Queue::fake();
LDAP::shouldReceive('deleteGroup')->once()->with($group)->andReturn(true);
- $job = (new \App\Jobs\Group\DeleteJob($group->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -62,20 +61,20 @@
$this->assertFalse($group->isLdapReady());
$this->assertTrue($group->isDeleted());
- Queue::assertPushed(\App\Jobs\Group\UpdateJob::class, 0);
-/*
- Queue::assertPushed(\App\Jobs\IMAP\AclCleanupJob::class, 1);
- Queue::assertPushed(
- \App\Jobs\IMAP\AclCleanupJob::class,
- function ($job) {
- $ident = TestCase::getObjectProperty($job, 'ident');
- $domain = TestCase::getObjectProperty($job, 'domain');
- return $ident == 'group' && $domain === 'kolab.org';
- }
- );
-*/
+ Queue::assertPushed(UpdateJob::class, 0);
+ /*
+ Queue::assertPushed(\App\Jobs\IMAP\AclCleanupJob::class, 1);
+ Queue::assertPushed(
+ \App\Jobs\IMAP\AclCleanupJob::class,
+ function ($job) {
+ $ident = TestCase::getObjectProperty($job, 'ident');
+ $domain = TestCase::getObjectProperty($job, 'domain');
+ return $ident == 'group' && $domain === 'kolab.org';
+ }
+ );
+ */
// Test non-existing group ID
- $job = (new \App\Jobs\Group\DeleteJob(123))->withFakeQueueInteractions();
+ $job = (new DeleteJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Group 123 could not be found in the database.");
}
diff --git a/src/tests/Feature/Jobs/Group/UpdateTest.php b/src/tests/Feature/Jobs/Group/UpdateTest.php
--- a/src/tests/Feature/Jobs/Group/UpdateTest.php
+++ b/src/tests/Feature/Jobs/Group/UpdateTest.php
@@ -3,23 +3,21 @@
namespace Tests\Feature\Jobs\Group;
use App\Group;
+use App\Jobs\Group\UpdateJob;
use App\Support\Facades\LDAP;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UpdateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestGroup('group@kolab.org');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestGroup('group@kolab.org');
@@ -34,7 +32,7 @@
Queue::fake();
// Test non-existing group ID
- $job = (new \App\Jobs\Group\UpdateJob(123))->withFakeQueueInteractions();
+ $job = (new UpdateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Group 123 could not be found in the database.");
@@ -44,7 +42,7 @@
\config(['app.with_ldap' => true]);
// Group not LDAP_READY
- $job = (new \App\Jobs\Group\UpdateJob($group->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertDeleted();
@@ -57,7 +55,7 @@
LDAP::shouldReceive('updateGroup')->once()->with($group)->andReturn(true);
LDAP::shouldReceive('disconnect');
- $job = (new \App\Jobs\Group\UpdateJob($group->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -69,7 +67,7 @@
LDAP::shouldReceive('deleteGroup')->once()->with($group)->andReturn(true);
LDAP::shouldReceive('disconnect');
- $job = (new \App\Jobs\Group\UpdateJob($group->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -81,7 +79,7 @@
LDAP::shouldReceive('createGroup')->once()->with($group)->andReturn(true);
LDAP::shouldReceive('disconnect');
- $job = (new \App\Jobs\Group\UpdateJob($group->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($group->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
}
diff --git a/src/tests/Feature/Jobs/Mail/PasswordResetJobTest.php b/src/tests/Feature/Jobs/Mail/PasswordResetJobTest.php
--- a/src/tests/Feature/Jobs/Mail/PasswordResetJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/PasswordResetJobTest.php
@@ -4,7 +4,6 @@
use App\Jobs\Mail\PasswordResetJob;
use App\Mail\PasswordReset;
-use App\User;
use App\VerificationCode;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
@@ -12,20 +11,14 @@
class PasswordResetJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('PasswordReset@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('PasswordReset@UserAccount.com');
@@ -38,7 +31,7 @@
public function testHandle(): void
{
$code = new VerificationCode([
- 'mode' => 'password-reset',
+ 'mode' => 'password-reset',
]);
$user = $this->getTestUser('PasswordReset@UserAccount.com');
@@ -57,12 +50,12 @@
Mail::assertSent(PasswordReset::class, 1);
// Assert the mail was sent to the code's email
- Mail::assertSent(PasswordReset::class, function ($mail) use ($code) {
+ Mail::assertSent(PasswordReset::class, static function ($mail) use ($code) {
return $mail->hasTo($code->user->getSetting('external_email'));
});
// Assert sender
- Mail::assertSent(PasswordReset::class, function ($mail) {
+ Mail::assertSent(PasswordReset::class, static function ($mail) {
return $mail->hasFrom(\config('mail.sender.address'), \config('mail.sender.name'))
&& $mail->hasReplyTo(\config('mail.replyto.address'), \config('mail.replyto.name'));
});
diff --git a/src/tests/Feature/Jobs/Mail/PasswordRetentionJobTest.php b/src/tests/Feature/Jobs/Mail/PasswordRetentionJobTest.php
--- a/src/tests/Feature/Jobs/Mail/PasswordRetentionJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/PasswordRetentionJobTest.php
@@ -10,20 +10,14 @@
class PasswordRetentionJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('PasswordRetention@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('PasswordRetention@UserAccount.com');
@@ -56,12 +50,12 @@
Mail::assertSent(PasswordExpirationReminder::class, 1);
// Assert the mail was sent to the code's email
- Mail::assertSent(PasswordExpirationReminder::class, function ($mail) use ($user) {
+ Mail::assertSent(PasswordExpirationReminder::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email);
});
// Assert sender
- Mail::assertSent(PasswordExpirationReminder::class, function ($mail) {
+ Mail::assertSent(PasswordExpirationReminder::class, static function ($mail) {
return $mail->hasFrom(\config('mail.sender.address'), \config('mail.sender.name'))
&& $mail->hasReplyTo(\config('mail.replyto.address'), \config('mail.replyto.name'));
});
diff --git a/src/tests/Feature/Jobs/Mail/PaymentJobTest.php b/src/tests/Feature/Jobs/Mail/PaymentJobTest.php
--- a/src/tests/Feature/Jobs/Mail/PaymentJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/PaymentJobTest.php
@@ -12,20 +12,14 @@
class PaymentJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('PaymentEmail@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('PaymentEmail@UserAccount.com');
@@ -67,7 +61,7 @@
Mail::assertSent(PaymentSuccess::class, 1);
// Assert the mail was sent to the user's email
- Mail::assertSent(PaymentSuccess::class, function ($mail) {
+ Mail::assertSent(PaymentSuccess::class, static function ($mail) {
return $mail->hasTo('ext@email.tld') && !$mail->hasCc('ext@email.tld');
});
@@ -81,7 +75,7 @@
Mail::assertSent(PaymentFailure::class, 1);
// Assert the mail was sent to the user's email
- Mail::assertSent(PaymentFailure::class, function ($mail) {
+ Mail::assertSent(PaymentFailure::class, static function ($mail) {
return $mail->hasTo('ext@email.tld') && !$mail->hasCc('ext@email.tld');
});
diff --git a/src/tests/Feature/Jobs/Mail/PaymentMandateDisabledJobTest.php b/src/tests/Feature/Jobs/Mail/PaymentMandateDisabledJobTest.php
--- a/src/tests/Feature/Jobs/Mail/PaymentMandateDisabledJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/PaymentMandateDisabledJobTest.php
@@ -10,20 +10,14 @@
class PaymentMandateDisabledJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('PaymentEmail@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('PaymentEmail@UserAccount.com');
@@ -52,7 +46,7 @@
Mail::assertSent(PaymentMandateDisabled::class, 1);
// Assert the mail was sent to the user's email
- Mail::assertSent(PaymentMandateDisabled::class, function ($mail) {
+ Mail::assertSent(PaymentMandateDisabled::class, static function ($mail) {
return $mail->hasTo('ext@email.tld') && !$mail->hasCc('ext@email.tld');
});
}
diff --git a/src/tests/Feature/Jobs/Mail/SignupInvitationJobTest.php b/src/tests/Feature/Jobs/Mail/SignupInvitationJobTest.php
--- a/src/tests/Feature/Jobs/Mail/SignupInvitationJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/SignupInvitationJobTest.php
@@ -5,7 +5,6 @@
use App\Jobs\Mail\SignupInvitationJob;
use App\Mail\SignupInvitation;
use App\SignupInvitation as SI;
-use Illuminate\Queue\Events\JobFailed;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
@@ -14,10 +13,7 @@
{
private $invitation;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -26,10 +22,7 @@
$this->invitation = SI::create(['email' => 'SignupInvitationEmailTest@external.com']);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->invitation->delete();
}
diff --git a/src/tests/Feature/Jobs/Mail/SignupVerificationJobTest.php b/src/tests/Feature/Jobs/Mail/SignupVerificationJobTest.php
--- a/src/tests/Feature/Jobs/Mail/SignupVerificationJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/SignupVerificationJobTest.php
@@ -11,20 +11,14 @@
class SignupVerificationJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
SignupCode::where('email', 'SignupVerificationEmailTest1@' . \config('app.domain'))->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
SignupCode::where('email', 'SignupVerificationEmailTest1@' . \config('app.domain'))->delete();
@@ -59,7 +53,7 @@
Mail::assertSent(SignupVerification::class, 1);
// Assert the mail was sent to the code's email
- Mail::assertSent(SignupVerification::class, function ($mail) use ($code) {
+ Mail::assertSent(SignupVerification::class, static function ($mail) use ($code) {
return $mail->hasTo($code->email) && $mail->hasFrom('sender@tenant', 'Tenant');
});
}
diff --git a/src/tests/Feature/Jobs/Mail/TrialEndJobTest.php b/src/tests/Feature/Jobs/Mail/TrialEndJobTest.php
--- a/src/tests/Feature/Jobs/Mail/TrialEndJobTest.php
+++ b/src/tests/Feature/Jobs/Mail/TrialEndJobTest.php
@@ -10,20 +10,14 @@
class TrialEndJobTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('PaymentEmail@UserAccount.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('PaymentEmail@UserAccount.com');
@@ -51,7 +45,7 @@
Mail::assertSent(TrialEnd::class, 1);
// Assert the mail was sent to the user's email
- Mail::assertSent(TrialEnd::class, function ($mail) {
+ Mail::assertSent(TrialEnd::class, static function ($mail) {
return $mail->hasTo('paymentemail@useraccount.com') && !$mail->hasCc('ext@email.tld');
});
}
diff --git a/src/tests/Feature/Jobs/PGP/KeyCreateTest.php b/src/tests/Feature/Jobs/PGP/KeyCreateTest.php
--- a/src/tests/Feature/Jobs/PGP/KeyCreateTest.php
+++ b/src/tests/Feature/Jobs/PGP/KeyCreateTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\PGP;
+use App\Jobs\PGP\KeyCreateJob;
use App\Support\Facades\PGP;
use App\UserAlias;
use Illuminate\Support\Facades\Queue;
@@ -9,20 +10,14 @@
class KeyCreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
UserAlias::where('alias', 'test-alias@kolab.org')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
UserAlias::where('alias', 'test-alias@kolab.org')->delete();
@@ -41,7 +36,7 @@
// Test without an alias
PGP::shouldReceive('keypairCreate')->once()->with($user, $user->email);
- $job = (new \App\Jobs\PGP\KeyCreateJob($user->id, $user->email))->withFakeQueueInteractions();
+ $job = (new KeyCreateJob($user->id, $user->email))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -49,7 +44,7 @@
$alias = UserAlias::create(['user_id' => $user->id, 'alias' => 'test-alias@kolab.org']);
PGP::shouldReceive('keypairCreate')->once()->with($user, $alias->alias);
- $job = (new \App\Jobs\PGP\KeyCreateJob($user->id, 'test-alias@kolab.org'))->withFakeQueueInteractions();
+ $job = (new KeyCreateJob($user->id, 'test-alias@kolab.org'))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
}
diff --git a/src/tests/Feature/Jobs/PGP/KeyDeleteTest.php b/src/tests/Feature/Jobs/PGP/KeyDeleteTest.php
--- a/src/tests/Feature/Jobs/PGP/KeyDeleteTest.php
+++ b/src/tests/Feature/Jobs/PGP/KeyDeleteTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\PGP;
+use App\Jobs\PGP\KeyDeleteJob;
use App\Support\Facades\PGP;
use Tests\TestCase;
@@ -16,7 +17,7 @@
PGP::shouldReceive('keyDelete')->once()->with($user, $user->email);
- $job = (new \App\Jobs\PGP\KeyDeleteJob($user->id, $user->email))->withFakeQueueInteractions();
+ $job = (new KeyDeleteJob($user->id, $user->email))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
}
diff --git a/src/tests/Feature/Jobs/Resource/CreateTest.php b/src/tests/Feature/Jobs/Resource/CreateTest.php
--- a/src/tests/Feature/Jobs/Resource/CreateTest.php
+++ b/src/tests/Feature/Jobs/Resource/CreateTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\Resource;
+use App\Jobs\Resource\CreateJob;
use App\Resource;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,17 +11,14 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestResource('resource-test@' . \config('app.domain'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestResource('resource-test@' . \config('app.domain'));
@@ -35,7 +33,7 @@
Queue::fake();
// Test unknown resource
- $job = (new \App\Jobs\Resource\CreateJob(123))->withFakeQueueInteractions();
+ $job = (new CreateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertReleased();
@@ -56,7 +54,7 @@
IMAP::shouldReceive('createResource')->once()->with($resource)->andReturn(true);
LDAP::shouldReceive('createResource')->once()->with($resource)->andReturn(true);
- $job = (new \App\Jobs\Resource\CreateJob($resource->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -72,7 +70,7 @@
$resource->status |= Resource::STATUS_DELETED;
$resource->save();
- $job = (new \App\Jobs\Resource\CreateJob($resource->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource {$resource->id} is marked as deleted.");
@@ -80,7 +78,7 @@
$resource->save();
$resource->delete();
- $job = (new \App\Jobs\Resource\CreateJob($resource->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource {$resource->id} is actually deleted.");
diff --git a/src/tests/Feature/Jobs/Resource/DeleteTest.php b/src/tests/Feature/Jobs/Resource/DeleteTest.php
--- a/src/tests/Feature/Jobs/Resource/DeleteTest.php
+++ b/src/tests/Feature/Jobs/Resource/DeleteTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Jobs\Resource;
+use App\Jobs\Resource\DeleteJob;
+use App\Jobs\Resource\UpdateJob;
use App\Resource;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,17 +12,14 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestResource('resource-test@' . \config('app.domain'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestResource('resource-test@' . \config('app.domain'));
@@ -35,12 +34,12 @@
Queue::fake();
// Test non-existing resource ID
- $job = (new \App\Jobs\Resource\DeleteJob(123))->withFakeQueueInteractions();
+ $job = (new DeleteJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource 123 could not be found in the database.");
$resource = $this->getTestResource('resource-test@' . \config('app.domain'), [
- 'status' => Resource::STATUS_NEW | Resource::STATUS_IMAP_READY | Resource::STATUS_LDAP_READY,
+ 'status' => Resource::STATUS_NEW | Resource::STATUS_IMAP_READY | Resource::STATUS_LDAP_READY,
]);
$this->assertTrue($resource->isLdapReady());
@@ -48,7 +47,7 @@
$this->assertFalse($resource->isDeleted());
// Test deleting not deleted resource
- $job = (new \App\Jobs\Resource\DeleteJob($resource->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource {$resource->id} is not deleted.");
@@ -64,7 +63,7 @@
IMAP::shouldReceive('deleteResource')->once()->with($resource)->andReturn(true);
LDAP::shouldReceive('deleteResource')->once()->with($resource)->andReturn(true);
- $job = new \App\Jobs\Resource\DeleteJob($resource->id);
+ $job = new DeleteJob($resource->id);
$job->handle();
$resource->refresh();
@@ -73,10 +72,10 @@
$this->assertFalse($resource->isImapReady());
$this->assertTrue($resource->isDeleted());
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Test deleting already deleted resource
- $job = (new \App\Jobs\Resource\DeleteJob($resource->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource {$resource->id} is already marked as deleted.");
}
diff --git a/src/tests/Feature/Jobs/Resource/UpdateTest.php b/src/tests/Feature/Jobs/Resource/UpdateTest.php
--- a/src/tests/Feature/Jobs/Resource/UpdateTest.php
+++ b/src/tests/Feature/Jobs/Resource/UpdateTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\Resource;
+use App\Jobs\Resource\UpdateJob;
use App\Resource;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,20 +11,14 @@
class UpdateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestResource('resource-test@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestResource('resource-test@' . \config('app.domain'));
@@ -38,7 +33,7 @@
Queue::fake();
// Test non-existing resource ID
- $job = (new \App\Jobs\Resource\UpdateJob(123))->withFakeQueueInteractions();
+ $job = (new UpdateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource 123 could not be found in the database.");
@@ -57,7 +52,7 @@
IMAP::shouldReceive('updateResource')->once()->with($resource, [])->andReturn(true);
LDAP::shouldReceive('updateResource')->once()->with($resource)->andReturn(true);
- $job = new \App\Jobs\Resource\UpdateJob($resource->id);
+ $job = new UpdateJob($resource->id);
$job->handle();
// Test that the job is being deleted if the resource is not ldap ready or is deleted
@@ -65,7 +60,7 @@
$resource->status |= Resource::STATUS_DELETED;
$resource->save();
- $job = (new \App\Jobs\Resource\UpdateJob($resource->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($resource->id))->withFakeQueueInteractions();
$job->handle();
$job->assertDeleted();
}
diff --git a/src/tests/Feature/Jobs/Resource/VerifyTest.php b/src/tests/Feature/Jobs/Resource/VerifyTest.php
--- a/src/tests/Feature/Jobs/Resource/VerifyTest.php
+++ b/src/tests/Feature/Jobs/Resource/VerifyTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\Resource;
+use App\Jobs\Resource\VerifyJob;
use App\Resource;
use App\Support\Facades\IMAP;
use Illuminate\Support\Facades\Queue;
@@ -9,10 +10,7 @@
class VerifyTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +19,7 @@
$resource->save();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$resource = $this->getTestResource('resource-test1@kolab.org');
$resource->status |= Resource::STATUS_IMAP_READY;
@@ -41,7 +36,7 @@
Queue::fake();
// Test non-existing resource ID
- $job = (new \App\Jobs\Resource\VerifyJob(123))->withFakeQueueInteractions();
+ $job = (new VerifyJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Resource 123 could not be found in the database.");
@@ -57,7 +52,7 @@
// Test existing resource (successful verification)
IMAP::shouldReceive('verifySharedFolder')->once()->with($resource->getSetting('folder'))->andReturn(true);
- $job = new \App\Jobs\Resource\VerifyJob($resource->id);
+ $job = new VerifyJob($resource->id);
$job->handle();
$resource->refresh();
@@ -69,7 +64,7 @@
IMAP::shouldReceive('verifySharedFolder')->once()->with($resource->getSetting('folder'))->andReturn(false);
- $job = new \App\Jobs\Resource\VerifyJob($resource->id);
+ $job = new VerifyJob($resource->id);
$job->handle();
$this->assertFalse($resource->fresh()->isImapReady());
diff --git a/src/tests/Feature/Jobs/SharedFolder/CreateTest.php b/src/tests/Feature/Jobs/SharedFolder/CreateTest.php
--- a/src/tests/Feature/Jobs/SharedFolder/CreateTest.php
+++ b/src/tests/Feature/Jobs/SharedFolder/CreateTest.php
@@ -2,25 +2,23 @@
namespace Tests\Feature\Jobs\SharedFolder;
+use App\Jobs\SharedFolder\CreateJob;
use App\SharedFolder;
-use App\Support\Facades\LDAP;
use App\Support\Facades\IMAP;
+use App\Support\Facades\LDAP;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
@@ -35,7 +33,7 @@
Queue::fake();
// Test unknown folder
- $job = (new \App\Jobs\SharedFolder\CreateJob(123))->withFakeQueueInteractions();
+ $job = (new CreateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertReleased(delay: 5);
@@ -55,7 +53,7 @@
IMAP::shouldReceive('createSharedFolder')->once()->with($folder)->andReturn(true);
LDAP::shouldReceive('createSharedFolder')->once()->with($folder)->andReturn(true);
- $job = (new \App\Jobs\SharedFolder\CreateJob($folder->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -69,7 +67,7 @@
$folder->status |= SharedFolder::STATUS_DELETED;
$folder->save();
- $job = (new \App\Jobs\SharedFolder\CreateJob($folder->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder {$folder->id} is marked as deleted.");
@@ -77,7 +75,7 @@
$folder->save();
$folder->delete();
- $job = (new \App\Jobs\SharedFolder\CreateJob($folder->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder {$folder->id} is actually deleted.");
diff --git a/src/tests/Feature/Jobs/SharedFolder/DeleteTest.php b/src/tests/Feature/Jobs/SharedFolder/DeleteTest.php
--- a/src/tests/Feature/Jobs/SharedFolder/DeleteTest.php
+++ b/src/tests/Feature/Jobs/SharedFolder/DeleteTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Jobs\SharedFolder;
+use App\Jobs\SharedFolder\DeleteJob;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolder;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,17 +12,14 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
@@ -35,12 +34,12 @@
Queue::fake();
// Test non-existing folder ID
- $job = (new \App\Jobs\SharedFolder\DeleteJob(123))->withFakeQueueInteractions();
+ $job = (new DeleteJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder 123 could not be found in the database.");
$folder = $this->getTestSharedFolder('folder-test@' . \config('app.domain'), [
- 'status' => SharedFolder::STATUS_NEW | SharedFolder::STATUS_IMAP_READY | SharedFolder::STATUS_LDAP_READY
+ 'status' => SharedFolder::STATUS_NEW | SharedFolder::STATUS_IMAP_READY | SharedFolder::STATUS_LDAP_READY,
]);
// TODO: Make the test working with various with_imap/with_ldap combinations
@@ -48,7 +47,7 @@
\config(['app.with_ldap' => true]);
// Test deleting not deleted folder
- $job = (new \App\Jobs\SharedFolder\DeleteJob($folder->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder {$folder->id} is not deleted.");
@@ -60,7 +59,7 @@
IMAP::shouldReceive('deleteSharedFolder')->once()->with($folder)->andReturn(true);
LDAP::shouldReceive('deleteSharedFolder')->once()->with($folder)->andReturn(true);
- $job = new \App\Jobs\SharedFolder\DeleteJob($folder->id);
+ $job = new DeleteJob($folder->id);
$job->handle();
$folder->refresh();
@@ -69,10 +68,10 @@
$this->assertFalse($folder->isImapReady());
$this->assertTrue($folder->isDeleted());
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Test deleting already deleted folder
- $job = (new \App\Jobs\SharedFolder\DeleteJob($folder->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder {$folder->id} is already marked as deleted.");
}
diff --git a/src/tests/Feature/Jobs/SharedFolder/UpdateTest.php b/src/tests/Feature/Jobs/SharedFolder/UpdateTest.php
--- a/src/tests/Feature/Jobs/SharedFolder/UpdateTest.php
+++ b/src/tests/Feature/Jobs/SharedFolder/UpdateTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\SharedFolder;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolder;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -10,20 +11,14 @@
class UpdateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestSharedFolder('folder-test@' . \config('app.domain'));
@@ -38,7 +33,7 @@
Queue::fake();
// Test non-existing folder ID
- $job = (new \App\Jobs\SharedFolder\UpdateJob(123))->withFakeQueueInteractions();
+ $job = (new UpdateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder 123 could not be found in the database.");
@@ -55,7 +50,7 @@
IMAP::shouldReceive('updateSharedFolder')->once()->with($folder, [])->andReturn(true);
LDAP::shouldReceive('updateSharedFolder')->once()->with($folder)->andReturn(true);
- $job = (new \App\Jobs\SharedFolder\UpdateJob($folder->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -63,7 +58,7 @@
$folder->status |= SharedFolder::STATUS_DELETED;
$folder->save();
- $job = (new \App\Jobs\SharedFolder\UpdateJob($folder->id))->withFakeQueueInteractions();
+ $job = (new UpdateJob($folder->id))->withFakeQueueInteractions();
$job->handle();
$job->assertDeleted();
}
diff --git a/src/tests/Feature/Jobs/SharedFolder/VerifyTest.php b/src/tests/Feature/Jobs/SharedFolder/VerifyTest.php
--- a/src/tests/Feature/Jobs/SharedFolder/VerifyTest.php
+++ b/src/tests/Feature/Jobs/SharedFolder/VerifyTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\SharedFolder;
+use App\Jobs\SharedFolder\VerifyJob;
use App\SharedFolder;
use App\Support\Facades\IMAP;
use Illuminate\Support\Facades\Queue;
@@ -9,10 +10,7 @@
class VerifyTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +19,7 @@
$folder->save();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$folder = $this->getTestSharedFolder('folder-event@kolab.org');
$folder->status |= SharedFolder::STATUS_IMAP_READY;
@@ -41,7 +36,7 @@
Queue::fake();
// Test non-existing folder ID
- $job = (new \App\Jobs\SharedFolder\VerifyJob(123))->withFakeQueueInteractions();
+ $job = (new VerifyJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("Shared folder 123 could not be found in the database.");
@@ -58,7 +53,7 @@
// Test successful verification
IMAP::shouldReceive('verifySharedFolder')->once()->with($folder->getSetting('folder'))->andReturn(true);
- $job = new \App\Jobs\SharedFolder\VerifyJob($folder->id);
+ $job = new VerifyJob($folder->id);
$job->handle();
$folder->refresh();
@@ -70,7 +65,7 @@
// Test unsuccessful verification
IMAP::shouldReceive('verifySharedFolder')->once()->with($folder->getSetting('folder'))->andReturn(false);
- $job = new \App\Jobs\SharedFolder\VerifyJob($folder->id);
+ $job = new VerifyJob($folder->id);
$job->handle();
$folder->refresh();
diff --git a/src/tests/Feature/Jobs/User/CreateTest.php b/src/tests/Feature/Jobs/User/CreateTest.php
--- a/src/tests/Feature/Jobs/User/CreateTest.php
+++ b/src/tests/Feature/Jobs/User/CreateTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Jobs\User;
+use App\Domain;
+use App\Jobs\User\CreateJob;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
@@ -11,17 +13,14 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
@@ -36,8 +35,8 @@
Queue::fake();
$user = $this->getTestUser('new-job-user@' . \config('app.domain'), ['status' => User::STATUS_NEW]);
- $domain = \App\Domain::where('namespace', \config('app.domain'))->first();
- $domain->status |= \App\Domain::STATUS_LDAP_READY;
+ $domain = Domain::where('namespace', \config('app.domain'))->first();
+ $domain->status |= Domain::STATUS_LDAP_READY;
$domain->save();
// TODO: Make the test working with various with_imap/with_ldap combinations
@@ -53,7 +52,7 @@
IMAP::shouldReceive('createUser')->once()->with($user)->andReturn(true);
LDAP::shouldReceive('createUser')->once()->with($user)->andReturn(true);
- $job = (new \App\Jobs\User\CreateJob($user->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -67,7 +66,7 @@
$user->status |= User::STATUS_DELETED;
$user->save();
- $job = (new \App\Jobs\User\CreateJob($user->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("User {$user->id} is marked as deleted.");
@@ -76,12 +75,12 @@
$user->save();
$user->delete();
- $job = (new \App\Jobs\User\CreateJob($user->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("User {$user->id} is actually deleted.");
// Test job failure (user unknown), the job will be released
- $job = (new \App\Jobs\User\CreateJob(123))->withFakeQueueInteractions();
+ $job = (new CreateJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertReleased(delay: 5);
diff --git a/src/tests/Feature/Jobs/User/Delegation/CreateTest.php b/src/tests/Feature/Jobs/User/Delegation/CreateTest.php
--- a/src/tests/Feature/Jobs/User/Delegation/CreateTest.php
+++ b/src/tests/Feature/Jobs/User/Delegation/CreateTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Jobs\User\Delegation;
use App\Delegation;
+use App\Jobs\User\Delegation\CreateJob;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
use App\Support\Facades\Roundcube;
@@ -12,10 +13,7 @@
class CreateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -23,10 +21,7 @@
$this->deleteTestUser('delegation-user2@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('delegation-user1@' . \config('app.domain'));
$this->deleteTestUser('delegation-user2@' . \config('app.domain'));
@@ -60,7 +55,7 @@
DAV::shouldReceive('shareDefaultFolders')->once()->with($user, $delegatee, $delegation->options);
Roundcube::shouldReceive('createDelegatedIdentities')->once()->with($delegatee, $user);
- $job = (new \App\Jobs\User\Delegation\CreateJob($delegation->id))->withFakeQueueInteractions();
+ $job = (new CreateJob($delegation->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
diff --git a/src/tests/Feature/Jobs/User/Delegation/DeleteTest.php b/src/tests/Feature/Jobs/User/Delegation/DeleteTest.php
--- a/src/tests/Feature/Jobs/User/Delegation/DeleteTest.php
+++ b/src/tests/Feature/Jobs/User/Delegation/DeleteTest.php
@@ -3,6 +3,7 @@
namespace Tests\Feature\Jobs\User\Delegation;
use App\Delegation;
+use App\Jobs\User\Delegation\DeleteJob;
use App\Support\Facades\DAV;
use App\Support\Facades\IMAP;
use App\Support\Facades\Roundcube;
@@ -12,10 +13,7 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -23,10 +21,7 @@
$this->deleteTestUser('delegation-user2@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('delegation-user1@' . \config('app.domain'));
$this->deleteTestUser('delegation-user2@' . \config('app.domain'));
@@ -57,14 +52,14 @@
DAV::shouldReceive('unshareFolders')->once()->with($user, $delegatee->email);
Roundcube::shouldReceive('resetIdentities')->once()->with($delegatee);
- $job = (new \App\Jobs\User\Delegation\DeleteJob($user->email, $delegatee->email))->withFakeQueueInteractions();
+ $job = (new DeleteJob($user->email, $delegatee->email))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
// Test that we do nothing if delegation exists
Delegation::create(['user_id' => $user->id, 'delegatee_id' => $delegatee->id]);
- $job = (new \App\Jobs\User\Delegation\DeleteJob($user->email, $delegatee->email))->withFakeQueueInteractions();
+ $job = (new DeleteJob($user->email, $delegatee->email))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
}
diff --git a/src/tests/Feature/Jobs/User/DeleteTest.php b/src/tests/Feature/Jobs/User/DeleteTest.php
--- a/src/tests/Feature/Jobs/User/DeleteTest.php
+++ b/src/tests/Feature/Jobs/User/DeleteTest.php
@@ -2,6 +2,8 @@
namespace Tests\Feature\Jobs\User;
+use App\Jobs\User\DeleteJob;
+use App\Jobs\User\UpdateJob;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
use App\Support\Facades\Roundcube;
@@ -11,20 +13,14 @@
class DeleteTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
@@ -50,7 +46,7 @@
\config(['app.with_imap' => true]);
// Test job failure (user not yet deleted)
- $job = (new \App\Jobs\User\DeleteJob($user->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("User {$user->id} is not deleted.");
@@ -59,7 +55,7 @@
$user->deleted_at = \now();
$user->saveQuietly();
- $job = (new \App\Jobs\User\DeleteJob($user->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("User {$user->id} is already marked as deleted.");
@@ -76,7 +72,7 @@
LDAP::shouldReceive('deleteUser')->once()->with($user)->andReturn(true);
Roundcube::shouldReceive('deleteUser')->once()->with($user->email);
- $job = (new \App\Jobs\User\DeleteJob($user->id))->withFakeQueueInteractions();
+ $job = (new DeleteJob($user->id))->withFakeQueueInteractions();
$job->handle();
$job->assertNotFailed();
@@ -86,7 +82,7 @@
$this->assertFalse($user->isImapReady());
$this->assertTrue($user->isDeleted());
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
/*
if (\config('app.with_imap')) {
diff --git a/src/tests/Feature/Jobs/User/ResyncTest.php b/src/tests/Feature/Jobs/User/ResyncTest.php
--- a/src/tests/Feature/Jobs/User/ResyncTest.php
+++ b/src/tests/Feature/Jobs/User/ResyncTest.php
@@ -3,6 +3,8 @@
namespace Tests\Feature\Jobs\User;
use App\Domain;
+use App\Jobs\Domain\CreateJob;
+use App\Jobs\User\ResyncJob;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
use App\User;
@@ -11,10 +13,7 @@
class ResyncTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -22,10 +21,7 @@
$this->deleteTestDomain('resync-job.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user@resync-job.com');
$this->deleteTestDomain('resync-job.com');
@@ -61,7 +57,7 @@
LDAP::shouldReceive('getUser')->once()->with($user->email)->andReturn(false);
IMAP::shouldReceive('verifyAccount')->once()->with($user->email)->andReturn(false);
- $job = new \App\Jobs\User\ResyncJob($user->id);
+ $job = new ResyncJob($user->id);
$job->handle();
$user->refresh();
@@ -71,10 +67,10 @@
$this->assertFalse($user->isImapReady());
$this->assertFalse($domain->isLdapReady());
- Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Domain\CreateJob::class,
- function ($job) use ($domain) {
+ CreateJob::class,
+ static function ($job) use ($domain) {
return $domain->id == TestCase::getObjectProperty($job, 'domainId');
}
);
@@ -82,7 +78,7 @@
Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
Queue::assertPushed(
\App\Jobs\User\CreateJob::class,
- function ($job) use ($user) {
+ static function ($job) use ($user) {
return $user->id == TestCase::getObjectProperty($job, 'userId');
}
);
diff --git a/src/tests/Feature/Jobs/User/UpdateTest.php b/src/tests/Feature/Jobs/User/UpdateTest.php
--- a/src/tests/Feature/Jobs/User/UpdateTest.php
+++ b/src/tests/Feature/Jobs/User/UpdateTest.php
@@ -3,28 +3,22 @@
namespace Tests\Feature\Jobs\User;
use App\Jobs\User\UpdateJob;
-use App\User;
use App\Support\Facades\IMAP;
use App\Support\Facades\LDAP;
+use App\User;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class UpdateTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('new-job-user@' . \config('app.domain'));
diff --git a/src/tests/Feature/Jobs/User/VerifyTest.php b/src/tests/Feature/Jobs/User/VerifyTest.php
--- a/src/tests/Feature/Jobs/User/VerifyTest.php
+++ b/src/tests/Feature/Jobs/User/VerifyTest.php
@@ -2,6 +2,7 @@
namespace Tests\Feature\Jobs\User;
+use App\Jobs\User\VerifyJob;
use App\Support\Facades\IMAP;
use App\User;
use Illuminate\Support\Facades\Queue;
@@ -9,10 +10,7 @@
class VerifyTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +19,7 @@
$ned->save();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$ned = $this->getTestUser('ned@kolab.org');
$ned->status |= User::STATUS_IMAP_READY;
@@ -41,7 +36,7 @@
Queue::fake();
// Test non-existing user ID
- $job = (new \App\Jobs\User\VerifyJob(123))->withFakeQueueInteractions();
+ $job = (new VerifyJob(123))->withFakeQueueInteractions();
$job->handle();
$job->assertFailedWith("User 123 could not be found in the database.");
@@ -57,7 +52,7 @@
IMAP::shouldReceive('verifyAccount')->once()->with($user->email)->andReturn(true);
- $job = new \App\Jobs\User\VerifyJob($user->id);
+ $job = new VerifyJob($user->id);
$job->handle();
$user->refresh();
@@ -69,7 +64,7 @@
IMAP::shouldReceive('verifyAccount')->once()->with($user->email)->andReturn(false);
- $job = new \App\Jobs\User\VerifyJob($user->id);
+ $job = new VerifyJob($user->id);
$job->handle();
$this->assertFalse($user->fresh()->isImapReady());
diff --git a/src/tests/Feature/Jobs/Wallet/CheckTest.php b/src/tests/Feature/Jobs/Wallet/CheckTest.php
--- a/src/tests/Feature/Jobs/Wallet/CheckTest.php
+++ b/src/tests/Feature/Jobs/Wallet/CheckTest.php
@@ -3,6 +3,11 @@
namespace Tests\Feature\Jobs\Wallet;
use App\Jobs\Wallet\CheckJob;
+use App\Mail\DegradedAccountReminder;
+use App\Mail\NegativeBalance;
+use App\Mail\NegativeBalanceDegraded;
+use App\Mail\NegativeBalanceReminderDegrade;
+use App\Package;
use App\User;
use App\Wallet;
use Carbon\Carbon;
@@ -12,21 +17,15 @@
class CheckTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
$this->deleteTestUser('wallet-check@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('wallet-check@kolabnow.com');
@@ -83,8 +82,8 @@
$job->handle();
// Assert the mail was sent to the user's email, but not to his external email
- Mail::assertSent(\App\Mail\NegativeBalance::class, 1);
- Mail::assertSent(\App\Mail\NegativeBalance::class, function ($mail) use ($user) {
+ Mail::assertSent(NegativeBalance::class, 1);
+ Mail::assertSent(NegativeBalance::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email) && !$mail->hasCc('external@test.com');
});
@@ -104,8 +103,8 @@
$job->handle();
// Assert the mail was sent to the user's email, but not to his external email
- Mail::assertSent(\App\Mail\NegativeBalance::class, 1);
- Mail::assertSent(\App\Mail\NegativeBalance::class, function ($mail) use ($user) {
+ Mail::assertSent(NegativeBalance::class, 1);
+ Mail::assertSent(NegativeBalance::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email) && !$mail->hasCc('external@test.com');
});
@@ -166,8 +165,8 @@
$job->handle();
// Assert the mail was sent to the user's email and to his external email
- Mail::assertSent(\App\Mail\NegativeBalanceReminderDegrade::class, 1);
- Mail::assertSent(\App\Mail\NegativeBalanceReminderDegrade::class, function ($mail) use ($user) {
+ Mail::assertSent(NegativeBalanceReminderDegrade::class, 1);
+ Mail::assertSent(NegativeBalanceReminderDegrade::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email) && $mail->hasCc('external@test.com');
});
@@ -211,8 +210,8 @@
$job->handle();
// Assert the mail was sent to the user's email, and his external email
- Mail::assertSent(\App\Mail\NegativeBalanceDegraded::class, 1);
- Mail::assertSent(\App\Mail\NegativeBalanceDegraded::class, function ($mail) use ($user) {
+ Mail::assertSent(NegativeBalanceDegraded::class, 1);
+ Mail::assertSent(NegativeBalanceDegraded::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email) && $mail->hasCc('external@test.com');
});
@@ -277,8 +276,8 @@
$res = $job->handle();
// Assert the mail was sent to the user's email, and his external email
- Mail::assertSent(\App\Mail\DegradedAccountReminder::class, 1);
- Mail::assertSent(\App\Mail\DegradedAccountReminder::class, function ($mail) use ($user) {
+ Mail::assertSent(DegradedAccountReminder::class, 1);
+ Mail::assertSent(DegradedAccountReminder::class, static function ($mail) use ($user) {
return $mail->hasTo($user->email) && !$mail->hasCc('external@test.com');
});
@@ -308,7 +307,7 @@
$user->setSetting('external_email', 'external@test.com');
$wallet = $user->wallets()->first();
- $package = \App\Package::withObjectTenantContext($user)->where('title', 'kolab')->first();
+ $package = Package::withObjectTenantContext($user)->where('title', 'kolab')->first();
$user->assignPackage($package);
$wallet->balance = -100;
diff --git a/src/tests/Feature/MeetRoomTest.php b/src/tests/Feature/MeetRoomTest.php
--- a/src/tests/Feature/MeetRoomTest.php
+++ b/src/tests/Feature/MeetRoomTest.php
@@ -8,10 +8,7 @@
class MeetRoomTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -19,10 +16,7 @@
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('room-test@' . \config('app.domain'));
Room::withTrashed()->whereNotIn('name', ['shared', 'john'])->forceDelete();
@@ -61,9 +55,9 @@
$user = $this->getTestUser('room-test@' . \config('app.domain'));
$wallet = $user->wallets()->first();
$room = $this->getTestRoom('test', $wallet, [], [
- 'password' => 'test',
- 'acl' => ['john@kolab.org, full'],
- ], 'group-room');
+ 'password' => 'test',
+ 'acl' => ['john@kolab.org, full'],
+ ], 'group-room');
$this->assertCount(1, $room->entitlements()->get());
$this->assertCount(1, $room->permissions()->get());
@@ -84,9 +78,9 @@
// Now test if deleting a user deletes the room
$room = $this->getTestRoom('test', $wallet, [], [
- 'password' => 'test',
- 'acl' => ['john@kolab.org, full'],
- ], 'group-room');
+ 'password' => 'test',
+ 'acl' => ['john@kolab.org, full'],
+ ], 'group-room');
$user->delete();
@@ -129,7 +123,7 @@
'password' => 'test-pass',
'nomedia' => true,
'locked' => true,
- 'acl' => ['john@kolab.org, full']
+ 'acl' => ['john@kolab.org, full'],
]);
$config = $room->getConfig();
diff --git a/src/tests/Feature/PackageTest.php b/src/tests/Feature/PackageTest.php
--- a/src/tests/Feature/PackageTest.php
+++ b/src/tests/Feature/PackageTest.php
@@ -2,7 +2,6 @@
namespace Tests\Feature;
-use App\Entitlement;
use App\Package;
use App\PackageSku;
use App\Sku;
@@ -10,20 +9,14 @@
class PackageTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Package::where('title', 'test-package')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Package::where('title', 'test-package')->delete();
@@ -40,17 +33,17 @@
$skuStorage = Sku::withEnvTenantContext()->where('title', 'storage')->first(); // cost: 25
$package = Package::create([
- 'title' => 'test-package',
- 'name' => 'Test Account',
- 'description' => 'Test account.',
- 'discount_rate' => 0,
+ 'title' => 'test-package',
+ 'name' => 'Test Account',
+ 'description' => 'Test account.',
+ 'discount_rate' => 0,
]);
// WARNING: saveMany() sets package_skus.cost = skus.cost, the next line will reset it to NULL
$package->skus()->saveMany([
- $skuMailbox,
- $skuGroupware,
- $skuStorage
+ $skuMailbox,
+ $skuGroupware,
+ $skuStorage,
]);
PackageSku::where('package_id', $package->id)->update(['cost' => null]);
diff --git a/src/tests/Feature/PaymentTest.php b/src/tests/Feature/PaymentTest.php
--- a/src/tests/Feature/PaymentTest.php
+++ b/src/tests/Feature/PaymentTest.php
@@ -4,17 +4,14 @@
use App\Payment;
use App\Transaction;
-use App\Wallet;
use App\VatRate;
+use App\Wallet;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class PaymentTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -23,10 +20,7 @@
VatRate::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('jane@kolabnow.com');
Payment::query()->delete();
@@ -106,9 +100,9 @@
$wallet = $user->wallets()->first();
$vatRate = VatRate::create([
- 'start' => now()->subDay(),
- 'country' => 'US',
- 'rate' => 7.5,
+ 'start' => now()->subDay(),
+ 'country' => 'US',
+ 'rate' => 7.5,
]);
// Test required properties only
@@ -126,7 +120,7 @@
$this->assertSame($payment1Array['id'], $payment1->id);
$this->assertSame('', $payment1->provider);
$this->assertSame('', $payment1->description);
- $this->assertSame(null, $payment1->vat_rate_id);
+ $this->assertNull($payment1->vat_rate_id);
$this->assertSame($payment1Array['amount'], $payment1->amount);
$this->assertSame($payment1Array['amount'], $payment1->credit_amount);
$this->assertSame($payment1Array['currency_amount'], $payment1->currency_amount);
diff --git a/src/tests/Feature/PlanTest.php b/src/tests/Feature/PlanTest.php
--- a/src/tests/Feature/PlanTest.php
+++ b/src/tests/Feature/PlanTest.php
@@ -2,27 +2,20 @@
namespace Tests\Feature;
-use App\Entitlement;
use App\Plan;
-use App\Sku;
+use App\Tenant;
use Tests\TestCase;
class PlanTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Plan::where('title', 'test-plan')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Plan::where('title', 'test-plan')->delete();
@@ -114,12 +107,12 @@
$tenant = $plan->tenant()->first();
- $this->assertInstanceof(\App\Tenant::class, $tenant);
+ $this->assertInstanceof(Tenant::class, $tenant);
$this->assertSame((int) \config('app.tenant_id'), $tenant->id);
$tenant = $plan->tenant;
- $this->assertInstanceof(\App\Tenant::class, $tenant);
+ $this->assertInstanceof(Tenant::class, $tenant);
$this->assertSame((int) \config('app.tenant_id'), $tenant->id);
}
}
diff --git a/src/tests/Feature/Policy/GreylistTest.php b/src/tests/Feature/Policy/GreylistTest.php
--- a/src/tests/Feature/Policy/GreylistTest.php
+++ b/src/tests/Feature/Policy/GreylistTest.php
@@ -3,7 +3,10 @@
namespace Tests\Feature\Policy;
use App\Domain;
+use App\IP4Net;
use App\Policy\Greylist;
+use App\User;
+use Carbon\Carbon;
use Tests\TestCase;
/**
@@ -14,20 +17,20 @@
private $clientAddress;
private $net;
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->clientAddress = '212.103.80.148';
- $this->net = \App\IP4Net::getNet($this->clientAddress);
+ $this->net = IP4Net::getNet($this->clientAddress);
$this->domainHosted = $this->getTestDomain('test.domain', [
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]);
$this->getTestDomain('test2.domain2', [
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]);
$this->domainOwner = $this->getTestUser('john@test.domain');
@@ -36,7 +39,7 @@
Greylist\Whitelist::where('sender_domain', 'sender.domain')->delete();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
Greylist\Connect::where('sender_domain', 'sender.domain')->delete();
Greylist\Whitelist::where('sender_domain', 'sender.domain')->delete();
@@ -51,20 +54,20 @@
{
// Test no net
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => '127.128.129.130',
- 'client_name' => 'some.mx'
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => '127.128.129.130',
+ 'client_name' => 'some.mx',
]);
$this->assertTrue($request->shouldDefer());
// Test IPv6 net
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => '2a00:1450:400a:803::2005',
- 'client_name' => 'some.mx'
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => '2a00:1450:400a:803::2005',
+ 'client_name' => 'some.mx',
]);
$this->assertTrue($request->shouldDefer());
@@ -76,11 +79,11 @@
for ($i = 0; $i < 5; $i++) {
$request = new Greylist([
- 'sender' => "someone{$i}@sender.domain",
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx',
- 'timestamp' => \Carbon\Carbon::now()->subDays(1)
+ 'sender' => "someone{$i}@sender.domain",
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
+ 'client_name' => 'some.mx',
+ 'timestamp' => Carbon::now()->subDays(1),
]);
$this->assertTrue($request->shouldDefer());
@@ -91,11 +94,11 @@
$this->assertNotNull($whitelist);
$request = new Greylist([
- 'sender' => "someone5@sender.domain",
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx',
- 'timestamp' => \Carbon\Carbon::now()->subDays(1)
+ 'sender' => "someone5@sender.domain",
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
+ 'client_name' => 'some.mx',
+ 'timestamp' => Carbon::now()->subDays(1),
]);
$this->assertFalse($request->shouldDefer());
@@ -106,11 +109,11 @@
// Test a stale whitelist
for ($i = 0; $i < 5; $i++) {
$request = new Greylist([
- 'sender' => "someone{$i}@sender.domain",
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx',
- 'timestamp' => \Carbon\Carbon::now()->subDays(1)
+ 'sender' => "someone{$i}@sender.domain",
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
+ 'client_name' => 'some.mx',
+ 'timestamp' => Carbon::now()->subDays(1),
]);
$this->assertTrue($request->shouldDefer());
@@ -121,16 +124,16 @@
$this->assertNotNull($whitelist);
$request = new Greylist([
- 'sender' => "someone5@sender.domain",
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx',
- 'timestamp' => \Carbon\Carbon::now()->subDays(1)
+ 'sender' => "someone5@sender.domain",
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
+ 'client_name' => 'some.mx',
+ 'timestamp' => Carbon::now()->subDays(1),
]);
$this->assertFalse($request->shouldDefer());
- $whitelist->updated_at = \Carbon\Carbon::now()->subMonthsWithoutOverflow(2);
+ $whitelist->updated_at = Carbon::now()->subMonthsWithoutOverflow(2);
$whitelist->save(['timestamps' => false]);
$this->assertTrue($request->shouldDefer());
@@ -140,23 +143,23 @@
// test retry
$connect = Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $this->domainOwner->email),
- 'recipient_id' => $this->domainOwner->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $this->domainOwner->email),
+ 'recipient_id' => $this->domainOwner->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
- $connect->created_at = \Carbon\Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(6);
$connect->save();
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
]);
$this->assertFalse($request->shouldDefer());
@@ -165,20 +168,20 @@
// Test invalid recipient
$connect = Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $this->domainOwner->email),
- 'recipient_id' => 1234,
- 'recipient_type' => \App\Domain::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $this->domainOwner->email),
+ 'recipient_id' => 1234,
+ 'recipient_type' => Domain::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => 'not.someone@that.exists',
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => 'not.someone@that.exists',
+ 'client_address' => $this->clientAddress,
]);
$this->assertTrue($request->shouldDefer());
@@ -187,22 +190,22 @@
// Test user disabled
$connect = Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $this->domainOwner->email),
- 'recipient_id' => $this->domainOwner->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $this->domainOwner->email),
+ 'recipient_id' => $this->domainOwner->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
$this->domainOwner->setSetting('greylist_enabled', 'false');
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
]);
$this->assertFalse($request->shouldDefer());
@@ -211,9 +214,9 @@
$this->domainOwner->setAliases(['alias1@test2.domain2']);
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => 'alias1@test2.domain2',
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => 'alias1@test2.domain2',
+ 'client_address' => $this->clientAddress,
]);
$this->assertFalse($request->shouldDefer());
@@ -222,27 +225,27 @@
// Test user enabled
$connect = Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $this->domainOwner->email),
- 'recipient_id' => $this->domainOwner->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $this->domainOwner->email),
+ 'recipient_id' => $this->domainOwner->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
$this->domainOwner->setSetting('greylist_enabled', 'true');
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
]);
$this->assertTrue($request->shouldDefer());
- $connect->created_at = \Carbon\Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(6);
$connect->save();
$this->assertFalse($request->shouldDefer());
@@ -254,7 +257,7 @@
'sender' => 'someone@sender.domain',
'recipient' => $this->domainOwner->email,
'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx'
+ 'client_name' => 'some.mx',
]);
$this->assertTrue($request->shouldDefer());
@@ -264,24 +267,24 @@
// test controller not new
$connect = Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $this->domainOwner->email),
- 'recipient_id' => $this->domainOwner->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $this->domainOwner->email),
+ 'recipient_id' => $this->domainOwner->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
- $connect->created_at = \Carbon\Carbon::now()->subMinutes(6);
+ $connect->created_at = Carbon::now()->subMinutes(6);
$connect->save();
$request = new Greylist([
'sender' => 'someone@sender.domain',
'recipient' => $this->domainOwner->email,
'client_address' => $this->clientAddress,
- 'client_name' => 'some.mx'
+ 'client_name' => 'some.mx',
]);
$this->assertFalse($request->shouldDefer());
@@ -295,21 +298,21 @@
$this->setUpTest();
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
]);
foreach ($this->domainUsers as $user) {
Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $user->email),
- 'recipient_id' => $user->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $user->email),
+ 'recipient_id' => $user->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
$user->setSetting('greylist_enabled', 'false');
@@ -319,9 +322,9 @@
}
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $user->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $user->email,
+ 'client_address' => $this->clientAddress,
]);
$this->assertFalse($request->shouldDefer());
@@ -336,21 +339,21 @@
$this->setUpTest();
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $this->domainOwner->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $this->domainOwner->email,
+ 'client_address' => $this->clientAddress,
]);
foreach ($this->domainUsers as $user) {
Greylist\Connect::create([
- 'sender_local' => 'someone',
- 'sender_domain' => 'sender.domain',
- 'recipient_hash' => hash('sha256', $user->email),
- 'recipient_id' => $user->id,
- 'recipient_type' => \App\User::class,
- 'connect_count' => 1,
- 'net_id' => $this->net->id,
- 'net_type' => \App\IP4Net::class
+ 'sender_local' => 'someone',
+ 'sender_domain' => 'sender.domain',
+ 'recipient_hash' => hash('sha256', $user->email),
+ 'recipient_id' => $user->id,
+ 'recipient_type' => User::class,
+ 'connect_count' => 1,
+ 'net_id' => $this->net->id,
+ 'net_type' => IP4Net::class,
]);
$user->setSetting('greylist_enabled', ($user->id == $this->jack->id) ? 'true' : 'false');
@@ -360,9 +363,9 @@
}
$request = new Greylist([
- 'sender' => 'someone@sender.domain',
- 'recipient' => $user->email,
- 'client_address' => $this->clientAddress
+ 'sender' => 'someone@sender.domain',
+ 'recipient' => $user->email,
+ 'client_address' => $this->clientAddress,
]);
if ($user->id == $this->jack->id) {
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ExternalSenderModuleTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ExternalSenderModuleTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ExternalSenderModuleTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ExternalSenderModuleTest.php
@@ -3,7 +3,6 @@
namespace Tests\Feature\Policy\Mailfilter\Modules;
use App\Policy\Mailfilter\Modules\ExternalSenderModule;
-use App\Policy\Mailfilter\Result;
use Tests\TestCase;
use Tests\Unit\Policy\Mailfilter\MailParserTest;
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/CancelHandlerTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/CancelHandlerTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/CancelHandlerTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/CancelHandlerTest.php
@@ -61,7 +61,7 @@
Notification::assertCount(1);
Notification::assertSentTo(
$user,
- function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
+ static function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
return $notifiable->id == $user->id
&& $notification->params->mode == 'cancel'
&& $notification->params->senderEmail == 'jack@kolab.org'
@@ -108,7 +108,7 @@
Notification::assertCount(1);
Notification::assertSentTo(
$user,
- function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
+ static function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
return $notifiable->id == $user->id
&& $notification->params->mode == 'cancel'
&& $notification->params->senderEmail == 'jack@kolab.org'
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/ReplyHandlerTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/ReplyHandlerTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/ReplyHandlerTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/ReplyHandlerTest.php
@@ -64,7 +64,7 @@
Notification::assertCount(1);
Notification::assertSentTo(
$user,
- function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
+ static function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
return $notifiable->id == $user->id
&& $notification->params->mode == 'reply'
&& $notification->params->senderEmail == 'john@kolab.org'
@@ -145,7 +145,7 @@
Notification::assertCount(1);
Notification::assertSentTo(
$user,
- function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
+ static function (ItipNotification $notification, array $channels, object $notifiable) use ($user) {
return $notifiable->id == $user->id
&& $notification->params->mode == 'reply'
&& $notification->params->senderEmail == 'john@kolab.org'
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
@@ -4,8 +4,6 @@
use App\DataMigrator\Account;
use App\Policy\Mailfilter\Modules\ItipModule;
-use App\Policy\Mailfilter\Notifications\ItipNotification;
-use App\Policy\Mailfilter\Result;
use Illuminate\Support\Facades\Notification;
use Tests\BackendsTrait;
use Tests\TestCase;
@@ -108,7 +106,7 @@
$this->assertNull($result);
$list = $this->davList($account, 'Calendar', 'event');
- $list = array_filter($list, fn ($event) => $event->uid == '5464F1DDF6DA264A3FC70E7924B729A5-333333');
+ $list = array_filter($list, static fn ($event) => $event->uid == '5464F1DDF6DA264A3FC70E7924B729A5-333333');
$event = $list[array_key_first($list)];
$this->assertCount(2, $attendees = $event->attendees);
diff --git a/src/tests/Feature/Policy/RateLimitTest.php b/src/tests/Feature/Policy/RateLimitTest.php
--- a/src/tests/Feature/Policy/RateLimitTest.php
+++ b/src/tests/Feature/Policy/RateLimitTest.php
@@ -2,11 +2,12 @@
namespace Tests\Feature\Policy;
+use App\Discount;
+use App\Domain;
use App\Policy\RateLimit;
use App\Policy\Response;
use App\Transaction;
use App\User;
-use Illuminate\Support\Facades\DB;
use Tests\TestCase;
/**
@@ -14,7 +15,7 @@
*/
class RateLimitTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -24,7 +25,7 @@
Transaction::query()->delete();
}
- public function tearDown(): void
+ protected function tearDown(): void
{
RateLimit::query()->delete();
Transaction::query()->delete();
@@ -47,8 +48,8 @@
// Verify a whitelisted individual account is in fact whitelisted
RateLimit::truncate();
RateLimit\Whitelist::create([
- 'whitelistable_id' => $this->publicDomainUser->id,
- 'whitelistable_type' => User::class
+ 'whitelistable_id' => $this->publicDomainUser->id,
+ 'whitelistable_type' => User::class,
]);
// first 9 requests
@@ -151,7 +152,7 @@
// Verify a 100% discount for individual account does not simply run out of messages
RateLimit::truncate();
$wallet = $this->publicDomainUser->wallets()->first();
- $wallet->discount()->associate(\App\Discount::where('description', 'Free Account')->first());
+ $wallet->discount()->associate(Discount::where('description', 'Free Account')->first());
$wallet->save();
// first 9 requests
@@ -396,13 +397,13 @@
// Verify a whitelisted group domain is in fact whitelisted
RateLimit::truncate();
RateLimit\Whitelist::create([
- 'whitelistable_id' => $this->domainHosted->id,
- 'whitelistable_type' => \App\Domain::class
+ 'whitelistable_id' => $this->domainHosted->id,
+ 'whitelistable_type' => Domain::class,
]);
$request = [
'sender' => $this->domainUsers[0]->email,
- 'recipients' => []
+ 'recipients' => [],
];
// first 9 requests
diff --git a/src/tests/Feature/Policy/SPFTest.php b/src/tests/Feature/Policy/SPFTest.php
--- a/src/tests/Feature/Policy/SPFTest.php
+++ b/src/tests/Feature/Policy/SPFTest.php
@@ -14,19 +14,19 @@
private $testDomain;
private $testUser;
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->testDomain = $this->getTestDomain('test.domain', [
- 'type' => Domain::TYPE_EXTERNAL,
- 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]);
$this->testUser = $this->getTestUser('john@test.domain');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser($this->testUser->email);
$this->deleteTestDomain($this->testDomain->namespace);
@@ -47,7 +47,7 @@
'client_name' => 'mx.kolabnow.com',
// actually IN AAAA gmail.com.
'client_address' => '2a00:1450:400a:801::2005',
- 'recipient' => $this->testUser->email
+ 'recipient' => $this->testUser->email,
]);
$this->assertSame(403, $response->code);
@@ -77,7 +77,7 @@
'sender' => 'sender@spf-none.kolab.org',
'client_name' => 'mx.kolabnow.com',
'client_address' => '256.0.0.1',
- 'recipient' => $this->testUser->email
+ 'recipient' => $this->testUser->email,
]);
$this->assertSame(403, $response->code);
@@ -251,7 +251,7 @@
return;
}
- $headers = array_filter($response->prepends, fn ($h) => str_starts_with($h, 'Received-SPF:'));
+ $headers = array_filter($response->prepends, static fn ($h) => str_starts_with($h, 'Received-SPF:'));
$this->assertCount(1, $headers);
if ($content) {
diff --git a/src/tests/Feature/Policy/SmtpAccessTest.php b/src/tests/Feature/Policy/SmtpAccessTest.php
--- a/src/tests/Feature/Policy/SmtpAccessTest.php
+++ b/src/tests/Feature/Policy/SmtpAccessTest.php
@@ -10,10 +10,7 @@
class SmtpAccessTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -26,10 +23,7 @@
$jack->save();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Delegation::query()->delete();
$john = $this->getTestUser('john@kolab.org');
diff --git a/src/tests/Feature/PowerDNS/DomainTest.php b/src/tests/Feature/PowerDNS/DomainTest.php
--- a/src/tests/Feature/PowerDNS/DomainTest.php
+++ b/src/tests/Feature/PowerDNS/DomainTest.php
@@ -8,23 +8,17 @@
class DomainTest extends TestCase
{
- /** @var \App\PowerDNS\Domain $domain */
- private $domain = null;
+ /** @var Domain */
+ private $domain;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->domain = Domain::firstOrCreate(['name' => 'test-domain.com']);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->domain->delete();
diff --git a/src/tests/Feature/PowerDNS/RecordTest.php b/src/tests/Feature/PowerDNS/RecordTest.php
--- a/src/tests/Feature/PowerDNS/RecordTest.php
+++ b/src/tests/Feature/PowerDNS/RecordTest.php
@@ -8,23 +8,17 @@
class RecordTest extends TestCase
{
- /** @var \App\PowerDNS\Domain $domain */
- private $domain = null;
+ /** @var Domain */
+ private $domain;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->domain = Domain::firstOrCreate(['name' => 'test-domain.com']);
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->domain->delete();
@@ -39,10 +33,10 @@
$before = $this->domain->getSerial();
Record::create([
- 'domain_id' => $this->domain->id,
- 'name' => $this->domain->{'name'},
- 'type' => "MX",
- 'content' => '10 mx01.' . $this->domain->{'name'} . '.'
+ 'domain_id' => $this->domain->id,
+ 'name' => $this->domain->{'name'},
+ 'type' => "MX",
+ 'content' => '10 mx01.' . $this->domain->{'name'} . '.',
]);
$after = $this->domain->getSerial();
@@ -56,10 +50,10 @@
public function testUpdateRecord(): void
{
$record = Record::create([
- 'domain_id' => $this->domain->id,
- 'name' => $this->domain->{'name'},
- 'type' => "MX",
- 'content' => '10 mx01.' . $this->domain->{'name'} . '.'
+ 'domain_id' => $this->domain->id,
+ 'name' => $this->domain->{'name'},
+ 'type' => "MX",
+ 'content' => '10 mx01.' . $this->domain->{'name'} . '.',
]);
$before = $this->domain->getSerial();
@@ -78,10 +72,10 @@
public function testDeleteRecord(): void
{
$record = Record::create([
- 'domain_id' => $this->domain->id,
- 'name' => $this->domain->{'name'},
- 'type' => "MX",
- 'content' => '10 mx01.' . $this->domain->{'name'} . '.'
+ 'domain_id' => $this->domain->id,
+ 'name' => $this->domain->{'name'},
+ 'type' => "MX",
+ 'content' => '10 mx01.' . $this->domain->{'name'} . '.',
]);
$before = $this->domain->getSerial();
diff --git a/src/tests/Feature/ReferralProgramTest.php b/src/tests/Feature/ReferralProgramTest.php
--- a/src/tests/Feature/ReferralProgramTest.php
+++ b/src/tests/Feature/ReferralProgramTest.php
@@ -11,10 +11,7 @@
class ReferralProgramTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -23,10 +20,7 @@
ReferralProgram::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('referrer@kolabnow.com');
$this->deleteTestUser('referree@kolabnow.com');
@@ -66,7 +60,7 @@
$referrer_wallet->refresh();
$this->assertSame(0, $referrer_wallet->balance);
- Carbon::setTestNow(Carbon::createFromDate(2024, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2024, 2, 2));
// A single payment below the threshold
Payment::createFromArray([
@@ -107,7 +101,7 @@
$this->assertSame(Transaction::WALLET_AWARD, $transaction->type);
// Award redeemed already
- Carbon::setTestNow(Carbon::createFromDate(2024, 02, 04));
+ Carbon::setTestNow(Carbon::createFromDate(2024, 2, 4));
ReferralProgram::accounting($referree);
$referrer_wallet->refresh();
diff --git a/src/tests/Feature/ResourceTest.php b/src/tests/Feature/ResourceTest.php
--- a/src/tests/Feature/ResourceTest.php
+++ b/src/tests/Feature/ResourceTest.php
@@ -2,13 +2,17 @@
namespace Tests\Feature;
+use App\Entitlement;
+use App\Jobs\Resource\CreateJob;
+use App\Jobs\Resource\DeleteJob;
+use App\Jobs\Resource\UpdateJob;
use App\Resource;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class ResourceTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,7 +22,7 @@
});
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-test@kolabnow.com');
Resource::withTrashed()->where('email', 'like', '%@kolabnow.com')->each(function ($resource) {
@@ -124,8 +128,8 @@
$this->assertSame('shared/Resources/Reśo@kolabnow.com', $settings[0]->value);
Queue::assertPushed(
- \App\Jobs\Resource\CreateJob::class,
- function ($job) use ($resource) {
+ CreateJob::class,
+ static function ($job) use ($resource) {
$resourceEmail = TestCase::getObjectProperty($job, 'resourceEmail');
$resourceId = TestCase::getObjectProperty($job, 'resourceId');
@@ -146,7 +150,7 @@
$resource = $this->getTestResource('resource-test@kolabnow.com');
$resource->assignToWallet($user->wallets->first());
- $entitlements = \App\Entitlement::where('entitleable_id', $resource->id);
+ $entitlements = Entitlement::where('entitleable_id', $resource->id);
$this->assertSame(1, $entitlements->count());
@@ -156,11 +160,11 @@
$this->assertSame(0, $entitlements->count());
$this->assertSame(1, $entitlements->withTrashed()->count());
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\Resource\DeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Resource\DeleteJob::class,
- function ($job) use ($resource) {
+ DeleteJob::class,
+ static function ($job) use ($resource) {
$resourceEmail = TestCase::getObjectProperty($job, 'resourceEmail');
$resourceId = TestCase::getObjectProperty($job, 'resourceId');
@@ -176,8 +180,8 @@
$this->assertSame(0, $entitlements->withTrashed()->count());
$this->assertCount(0, Resource::withTrashed()->where('id', $resource->id)->get());
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\Resource\DeleteJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 0);
}
/**
@@ -213,20 +217,20 @@
$resource = $this->getTestResource('resource-test@kolabnow.com');
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting
$resource->setSetting('unknown', 'test');
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting that is synced to LDAP
$resource->setSetting('invitation_policy', 'accept');
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Resource\UpdateJob::class,
- function ($job) use ($resource) {
+ UpdateJob::class,
+ static function ($job) use ($resource) {
return $resource->id === TestCase::getObjectProperty($job, 'resourceId')
&& ['invitation_policy' => null] === TestCase::getObjectProperty($job, 'properties');
}
@@ -242,15 +246,15 @@
// Update a setting
$resource->setSetting('unknown', 'test1');
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Update a setting that is synced to LDAP
$resource->setSetting('invitation_policy', 'reject');
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Resource\UpdateJob::class,
- function ($job) use ($resource) {
+ UpdateJob::class,
+ static function ($job) use ($resource) {
return $resource->id === TestCase::getObjectProperty($job, 'resourceId')
&& ['invitation_policy' => 'accept'] === TestCase::getObjectProperty($job, 'properties');
}
@@ -264,22 +268,22 @@
// Delete a setting (null)
$resource->setSetting('unknown', null);
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Delete a setting that is synced to LDAP
$resource->setSetting('invitation_policy', null);
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Resource\UpdateJob::class,
- function ($job) use ($resource) {
+ UpdateJob::class,
+ static function ($job) use ($resource) {
return $resource->id === TestCase::getObjectProperty($job, 'resourceId')
&& ['invitation_policy' => 'reject'] === TestCase::getObjectProperty($job, 'properties');
}
);
- $this->assertSame(null, $resource->getSetting('unknown'));
- $this->assertSame(null, $resource->fresh()->getSetting('invitation_policy'));
+ $this->assertNull($resource->getSetting('unknown'));
+ $this->assertNull($resource->fresh()->getSetting('invitation_policy'));
}
/**
@@ -289,51 +293,51 @@
{
$resource = new Resource();
- $this->assertSame(false, $resource->isNew());
- $this->assertSame(false, $resource->isActive());
- $this->assertSame(false, $resource->isDeleted());
- $this->assertSame(false, $resource->isLdapReady());
- $this->assertSame(false, $resource->isImapReady());
+ $this->assertFalse($resource->isNew());
+ $this->assertFalse($resource->isActive());
+ $this->assertFalse($resource->isDeleted());
+ $this->assertFalse($resource->isLdapReady());
+ $this->assertFalse($resource->isImapReady());
$resource->status = Resource::STATUS_NEW;
- $this->assertSame(true, $resource->isNew());
- $this->assertSame(false, $resource->isActive());
- $this->assertSame(false, $resource->isDeleted());
- $this->assertSame(false, $resource->isLdapReady());
- $this->assertSame(false, $resource->isImapReady());
+ $this->assertTrue($resource->isNew());
+ $this->assertFalse($resource->isActive());
+ $this->assertFalse($resource->isDeleted());
+ $this->assertFalse($resource->isLdapReady());
+ $this->assertFalse($resource->isImapReady());
$resource->status |= Resource::STATUS_ACTIVE;
- $this->assertSame(true, $resource->isNew());
- $this->assertSame(true, $resource->isActive());
- $this->assertSame(false, $resource->isDeleted());
- $this->assertSame(false, $resource->isLdapReady());
- $this->assertSame(false, $resource->isImapReady());
+ $this->assertTrue($resource->isNew());
+ $this->assertTrue($resource->isActive());
+ $this->assertFalse($resource->isDeleted());
+ $this->assertFalse($resource->isLdapReady());
+ $this->assertFalse($resource->isImapReady());
$resource->status |= Resource::STATUS_LDAP_READY;
- $this->assertSame(true, $resource->isNew());
- $this->assertSame(true, $resource->isActive());
- $this->assertSame(false, $resource->isDeleted());
- $this->assertSame(true, $resource->isLdapReady());
- $this->assertSame(false, $resource->isImapReady());
+ $this->assertTrue($resource->isNew());
+ $this->assertTrue($resource->isActive());
+ $this->assertFalse($resource->isDeleted());
+ $this->assertTrue($resource->isLdapReady());
+ $this->assertFalse($resource->isImapReady());
$resource->status |= Resource::STATUS_DELETED;
- $this->assertSame(true, $resource->isNew());
- $this->assertSame(true, $resource->isActive());
- $this->assertSame(true, $resource->isDeleted());
- $this->assertSame(true, $resource->isLdapReady());
- $this->assertSame(false, $resource->isImapReady());
+ $this->assertTrue($resource->isNew());
+ $this->assertTrue($resource->isActive());
+ $this->assertTrue($resource->isDeleted());
+ $this->assertTrue($resource->isLdapReady());
+ $this->assertFalse($resource->isImapReady());
$resource->status |= Resource::STATUS_IMAP_READY;
- $this->assertSame(true, $resource->isNew());
- $this->assertSame(true, $resource->isActive());
- $this->assertSame(true, $resource->isDeleted());
- $this->assertSame(true, $resource->isLdapReady());
- $this->assertSame(true, $resource->isImapReady());
+ $this->assertTrue($resource->isNew());
+ $this->assertTrue($resource->isActive());
+ $this->assertTrue($resource->isDeleted());
+ $this->assertTrue($resource->isLdapReady());
+ $this->assertTrue($resource->isImapReady());
// Unknown status value
$this->expectException(\Exception::class);
@@ -357,10 +361,10 @@
$this->assertCount(1, $settings);
$this->assertSame('shared/Resources/New@kolabnow.com', $settings[0]->value);
- Queue::assertPushed(\App\Jobs\Resource\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Resource\UpdateJob::class,
- function ($job) use ($resource) {
+ UpdateJob::class,
+ static function ($job) use ($resource) {
$resourceEmail = TestCase::getObjectProperty($job, 'resourceEmail');
$resourceId = TestCase::getObjectProperty($job, 'resourceId');
diff --git a/src/tests/Feature/SharedFolderTest.php b/src/tests/Feature/SharedFolderTest.php
--- a/src/tests/Feature/SharedFolderTest.php
+++ b/src/tests/Feature/SharedFolderTest.php
@@ -2,13 +2,17 @@
namespace Tests\Feature;
+use App\Entitlement;
+use App\Jobs\SharedFolder\CreateJob;
+use App\Jobs\SharedFolder\DeleteJob;
+use App\Jobs\SharedFolder\UpdateJob;
use App\SharedFolder;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SharedFolderTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -18,7 +22,7 @@
});
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('user-test@kolabnow.com');
SharedFolder::withTrashed()->where('email', 'like', '%@kolabnow.com')->each(function ($folder) {
@@ -43,7 +47,7 @@
// Add an alias
$folder->setAliases(['FolderAlias1@kolabnow.com']);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
$aliases = $folder->aliases()->get();
@@ -54,7 +58,7 @@
// Add another alias
$folder->setAliases(['FolderAlias1@kolabnow.com', 'FolderAlias2@kolabnow.com']);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 2);
+ Queue::assertPushed(UpdateJob::class, 2);
$aliases = $folder->aliases()->orderBy('alias')->get();
$this->assertCount(2, $aliases);
@@ -64,7 +68,7 @@
// Remove an alias
$folder->setAliases(['FolderAlias1@kolabnow.com']);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 3);
+ Queue::assertPushed(UpdateJob::class, 3);
$aliases = $folder->aliases()->get();
@@ -75,7 +79,7 @@
// Remove all aliases
$folder->setAliases([]);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 4);
+ Queue::assertPushed(UpdateJob::class, 4);
$this->assertCount(0, $folder->aliases()->get());
$this->assertFalse(SharedFolder::aliasExists('folderalias1@kolabnow.com'));
@@ -188,8 +192,8 @@
$this->assertSame('shared/Reśo@kolabnow.com', $settings[0]->value);
Queue::assertPushed(
- \App\Jobs\SharedFolder\CreateJob::class,
- function ($job) use ($folder) {
+ CreateJob::class,
+ static function ($job) use ($folder) {
$folderEmail = TestCase::getObjectProperty($job, 'folderEmail');
$folderId = TestCase::getObjectProperty($job, 'folderId');
@@ -210,7 +214,7 @@
$folder = $this->getTestSharedFolder('folder-test@kolabnow.com');
$folder->assignToWallet($user->wallets->first());
- $entitlements = \App\Entitlement::where('entitleable_id', $folder->id);
+ $entitlements = Entitlement::where('entitleable_id', $folder->id);
$this->assertSame(1, $entitlements->count());
@@ -220,11 +224,11 @@
$this->assertSame(0, $entitlements->count());
$this->assertSame(1, $entitlements->withTrashed()->count());
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\SharedFolder\DeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\SharedFolder\DeleteJob::class,
- function ($job) use ($folder) {
+ DeleteJob::class,
+ static function ($job) use ($folder) {
$folderEmail = TestCase::getObjectProperty($job, 'folderEmail');
$folderId = TestCase::getObjectProperty($job, 'folderId');
@@ -240,8 +244,8 @@
$this->assertSame(0, $entitlements->withTrashed()->count());
$this->assertCount(0, SharedFolder::withTrashed()->where('id', $folder->id)->get());
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
- Queue::assertPushed(\App\Jobs\SharedFolder\DeleteJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 0);
}
/**
@@ -277,20 +281,20 @@
$folder = $this->getTestSharedFolder('folder-test@kolabnow.com');
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting
$folder->setSetting('unknown', 'test');
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Add a setting that is synced to LDAP
$folder->setSetting('acl', 'test');
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\SharedFolder\UpdateJob::class,
- function ($job) use ($folder) {
+ UpdateJob::class,
+ static function ($job) use ($folder) {
return $folder->id === TestCase::getObjectProperty($job, 'folderId')
&& ['acl' => null] === TestCase::getObjectProperty($job, 'properties');
}
@@ -306,15 +310,15 @@
// Update a setting
$folder->setSetting('unknown', 'test1');
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Update a setting that is synced to LDAP
$folder->setSetting('acl', 'test1');
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\SharedFolder\UpdateJob::class,
- function ($job) use ($folder) {
+ UpdateJob::class,
+ static function ($job) use ($folder) {
return $folder->id === TestCase::getObjectProperty($job, 'folderId')
&& ['acl' => 'test'] === TestCase::getObjectProperty($job, 'properties');
}
@@ -328,22 +332,22 @@
// Delete a setting (null)
$folder->setSetting('unknown', null);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Delete a setting that is synced to LDAP
$folder->setSetting('acl', null);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\SharedFolder\UpdateJob::class,
- function ($job) use ($folder) {
+ UpdateJob::class,
+ static function ($job) use ($folder) {
return $folder->id === TestCase::getObjectProperty($job, 'folderId')
&& ['acl' => 'test1'] === TestCase::getObjectProperty($job, 'properties');
}
);
- $this->assertSame(null, $folder->getSetting('unknown'));
- $this->assertSame(null, $folder->fresh()->getSetting('acl'));
+ $this->assertNull($folder->getSetting('unknown'));
+ $this->assertNull($folder->fresh()->getSetting('acl'));
}
/**
@@ -363,10 +367,10 @@
$this->assertCount(1, $settings);
$this->assertSame('shared/New@kolabnow.com', $settings[0]->value);
- Queue::assertPushed(\App\Jobs\SharedFolder\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\SharedFolder\UpdateJob::class,
- function ($job) use ($folder) {
+ UpdateJob::class,
+ static function ($job) use ($folder) {
$folderEmail = TestCase::getObjectProperty($job, 'folderEmail');
$folderId = TestCase::getObjectProperty($job, 'folderId');
diff --git a/src/tests/Feature/SignupCodeTest.php b/src/tests/Feature/SignupCodeTest.php
--- a/src/tests/Feature/SignupCodeTest.php
+++ b/src/tests/Feature/SignupCodeTest.php
@@ -10,8 +10,6 @@
{
/**
* Test SignupCode creation
- *
- * @return void
*/
public function testSignupCodeCreate()
{
@@ -19,7 +17,7 @@
'email' => 'User@email.org',
];
- Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
$now = Carbon::now();
$code = SignupCode::create($data);
diff --git a/src/tests/Feature/SignupInvitationTest.php b/src/tests/Feature/SignupInvitationTest.php
--- a/src/tests/Feature/SignupInvitationTest.php
+++ b/src/tests/Feature/SignupInvitationTest.php
@@ -2,26 +2,21 @@
namespace Tests\Feature;
+use App\Jobs\Mail\SignupInvitationJob;
use App\SignupInvitation as SI;
use Illuminate\Support\Facades\Queue;
use Tests\TestCase;
class SignupInvitationTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
SI::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
SI::truncate();
@@ -42,11 +37,11 @@
$this->assertSame(\config('app.tenant_id'), $invitation->tenant_id);
$this->assertTrue(preg_match('/^[a-f0-9-]{36}$/', $invitation->id) > 0);
- Queue::assertPushed(\App\Jobs\Mail\SignupInvitationJob::class, 1);
+ Queue::assertPushed(SignupInvitationJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Mail\SignupInvitationJob::class,
- function ($job) use ($invitation) {
+ SignupInvitationJob::class,
+ static function ($job) use ($invitation) {
$inv = TestCase::getObjectProperty($job, 'invitation');
return $inv->id === $invitation->id && $inv->email === $invitation->email;
@@ -85,11 +80,11 @@
$invitation->status = SI::STATUS_NEW;
$invitation->save();
- Queue::assertPushed(\App\Jobs\Mail\SignupInvitationJob::class, 1);
+ Queue::assertPushed(SignupInvitationJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Mail\SignupInvitationJob::class,
- function ($job) use ($invitation) {
+ SignupInvitationJob::class,
+ static function ($job) use ($invitation) {
$inv = TestCase::getObjectProperty($job, 'invitation');
return $inv->id === $invitation->id && $inv->email === $invitation->email;
@@ -104,11 +99,11 @@
$invitation->status = SI::STATUS_NEW;
$invitation->save();
- Queue::assertPushed(\App\Jobs\Mail\SignupInvitationJob::class, 1);
+ Queue::assertPushed(SignupInvitationJob::class, 1);
Queue::assertPushed(
- \App\Jobs\Mail\SignupInvitationJob::class,
- function ($job) use ($invitation) {
+ SignupInvitationJob::class,
+ static function ($job) use ($invitation) {
$inv = TestCase::getObjectProperty($job, 'invitation');
return $inv->id === $invitation->id && $inv->email === $invitation->email;
diff --git a/src/tests/Feature/SkuTest.php b/src/tests/Feature/SkuTest.php
--- a/src/tests/Feature/SkuTest.php
+++ b/src/tests/Feature/SkuTest.php
@@ -2,29 +2,23 @@
namespace Tests\Feature;
-use App\Entitlement;
use App\Handlers;
use App\Package;
use App\Sku;
+use App\Tenant;
use Carbon\Carbon;
use Tests\TestCase;
class SkuTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('jane@kolabnow.com');
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('jane@kolabnow.com');
@@ -100,10 +94,10 @@
$tenant = $sku->tenant()->first();
- $this->assertInstanceof(\App\Tenant::class, $tenant);
+ $this->assertInstanceof(Tenant::class, $tenant);
$tenant = $sku->tenant;
- $this->assertInstanceof(\App\Tenant::class, $tenant);
+ $this->assertInstanceof(Tenant::class, $tenant);
}
}
diff --git a/src/tests/Feature/TenantTest.php b/src/tests/Feature/TenantTest.php
--- a/src/tests/Feature/TenantTest.php
+++ b/src/tests/Feature/TenantTest.php
@@ -4,24 +4,20 @@
use App\Tenant;
use App\TenantSetting;
+use App\User;
+use App\Wallet;
use Tests\TestCase;
class TenantTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
TenantSetting::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
TenantSetting::truncate();
@@ -36,7 +32,7 @@
// No tenant id specified
$this->assertSame(\config('app.name'), Tenant::getConfig(null, 'app.name'));
$this->assertSame(\config('app.env'), Tenant::getConfig(null, 'app.env'));
- $this->assertSame(null, Tenant::getConfig(null, 'app.unknown'));
+ $this->assertNull(Tenant::getConfig(null, 'app.unknown'));
$tenant = Tenant::whereNotIn('id', [\config('app.tenant_id')])->first();
$tenant->setSetting('app.test', 'test');
@@ -45,7 +41,7 @@
$this->assertSame($tenant->title, Tenant::getConfig($tenant->id, 'app.name'));
$this->assertSame('test', Tenant::getConfig($tenant->id, 'app.test'));
$this->assertSame(\config('app.env'), Tenant::getConfig($tenant->id, 'app.env'));
- $this->assertSame(null, Tenant::getConfig($tenant->id, 'app.unknown'));
+ $this->assertNull(Tenant::getConfig($tenant->id, 'app.unknown'));
}
/**
@@ -54,11 +50,11 @@
public function testWallet(): void
{
$tenant = Tenant::find(\config('app.tenant_id'));
- $user = \App\User::where('email', 'reseller@' . \config('app.domain'))->first();
+ $user = User::where('email', 'reseller@' . \config('app.domain'))->first();
$wallet = $tenant->wallet();
- $this->assertInstanceof(\App\Wallet::class, $wallet);
+ $this->assertInstanceof(Wallet::class, $wallet);
$this->assertSame($user->wallets->first()->id, $wallet->id);
}
}
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -2,16 +2,27 @@
namespace Tests\Feature;
+use App\Auth\Utils as AuthUtils;
use App\Delegation;
use App\Domain;
+use App\Entitlement;
use App\EventLog;
use App\Group;
+use App\Jobs\PGP\KeyCreateJob;
+use App\Jobs\PGP\KeyDeleteJob;
+use App\Jobs\User\CreateJob;
+use App\Jobs\User\DeleteJob;
+use App\Jobs\User\UpdateJob;
use App\Package;
-use App\PackageSku;
use App\Plan;
+use App\Resource;
+use App\SharedFolder;
use App\Sku;
+use App\Tenant;
+use App\TenantSetting;
+use App\Transaction;
use App\User;
-use App\Auth\Utils as AuthUtils;
+use App\Wallet;
use Carbon\Carbon;
use Illuminate\Support\Benchmark;
use Illuminate\Support\Facades\Queue;
@@ -19,10 +30,7 @@
class UserTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -38,12 +46,9 @@
Package::where('title', 'test-package')->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
Package::where('title', 'test-package')->delete();
$this->deleteTestUser('user-test@' . \config('app.domain'));
$this->deleteTestUser('UserAccountA@UserAccount.com');
@@ -69,17 +74,17 @@
$skuMailbox = Sku::withEnvTenantContext()->where('title', 'mailbox')->first(); // cost: 500
$skuStorage = Sku::withEnvTenantContext()->where('title', 'storage')->first(); // cost: 25
$package = Package::create([
- 'title' => 'test-package',
- 'name' => 'Test Account',
- 'description' => 'Test account.',
- 'discount_rate' => 0,
+ 'title' => 'test-package',
+ 'name' => 'Test Account',
+ 'description' => 'Test account.',
+ 'discount_rate' => 0,
]);
// WARNING: saveMany() sets package_skus.cost = skus.cost
$package->skus()->saveMany([
- $skuMailbox,
- $skuGroupware,
- $skuStorage
+ $skuMailbox,
+ $skuGroupware,
+ $skuStorage,
]);
$package->skus()->updateExistingPivot($skuStorage, ['qty' => 2, 'cost' => null], false);
@@ -93,22 +98,22 @@
$entitlement = $wallet->entitlements()->where('sku_id', $skuMailbox->id)->first();
$this->assertSame($skuMailbox->id, $entitlement->sku->id);
$this->assertSame($wallet->id, $entitlement->wallet->id);
- $this->assertEquals($user->id, $entitlement->entitleable_id);
- $this->assertTrue($entitlement->entitleable instanceof \App\User);
+ $this->assertSame($user->id, $entitlement->entitleable_id);
+ $this->assertTrue($entitlement->entitleable instanceof User);
$this->assertSame($skuMailbox->cost, $entitlement->cost);
$entitlement = $wallet->entitlements()->where('sku_id', $skuGroupware->id)->first();
$this->assertSame($skuGroupware->id, $entitlement->sku->id);
$this->assertSame($wallet->id, $entitlement->wallet->id);
- $this->assertEquals($user->id, $entitlement->entitleable_id);
- $this->assertTrue($entitlement->entitleable instanceof \App\User);
+ $this->assertSame($user->id, $entitlement->entitleable_id);
+ $this->assertTrue($entitlement->entitleable instanceof User);
$this->assertSame(100, $entitlement->cost);
$entitlement = $wallet->entitlements()->where('sku_id', $skuStorage->id)->first();
$this->assertSame($skuStorage->id, $entitlement->sku->id);
$this->assertSame($wallet->id, $entitlement->wallet->id);
- $this->assertEquals($user->id, $entitlement->entitleable_id);
- $this->assertTrue($entitlement->entitleable instanceof \App\User);
+ $this->assertSame($user->id, $entitlement->entitleable_id);
+ $this->assertTrue($entitlement->entitleable instanceof User);
$this->assertSame(0, $entitlement->cost);
}
@@ -118,8 +123,8 @@
public function testAssignPlan(): void
{
$domain = $this->getTestDomain('useraccount.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
+ 'type' => Domain::TYPE_EXTERNAL,
]);
$user = $this->getTestUser('useraccounta@' . $domain->namespace);
$plan = Plan::withObjectTenantContext($user)->where('title', 'group')->first();
@@ -166,8 +171,8 @@
$entitlement = $wallet->entitlements()->where('sku_id', $skuMailbox->id)->first();
$this->assertSame($skuMailbox->id, $entitlement->sku->id);
$this->assertSame($wallet->id, $entitlement->wallet->id);
- $this->assertEquals($user->id, $entitlement->entitleable_id);
- $this->assertTrue($entitlement->entitleable instanceof \App\User);
+ $this->assertSame($user->id, $entitlement->entitleable_id);
+ $this->assertTrue($entitlement->entitleable instanceof User);
$this->assertSame($skuMailbox->cost, $entitlement->cost);
// Test units_free handling
@@ -198,7 +203,7 @@
$this->assertTrue($userA->wallets()->count() == 1);
$userA->wallets()->each(
- function ($wallet) use ($userB) {
+ static function ($wallet) use ($userB) {
$wallet->addController($userB);
}
);
@@ -410,25 +415,25 @@
$domain = \config('app.domain');
- \App\Tenant::find(\config('app.tenant_id'))->setSetting('pgp.enable', '0');
+ Tenant::find(\config('app.tenant_id'))->setSetting('pgp.enable', '0');
$user = User::create([
- 'email' => 'USER-test@' . \strtoupper($domain),
- 'password' => 'test',
+ 'email' => 'USER-test@' . \strtoupper($domain),
+ 'password' => 'test',
]);
- $result = User::where('email', "user-test@$domain")->first();
+ $result = User::where('email', "user-test@{$domain}")->first();
- $this->assertSame("user-test@$domain", $result->email);
+ $this->assertSame("user-test@{$domain}", $result->email);
$this->assertSame($user->id, $result->id);
$this->assertSame(User::STATUS_NEW, $result->status);
$this->assertSame(0, $user->passwords()->count());
- Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
- Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 0);
+ Queue::assertPushed(CreateJob::class, 1);
+ Queue::assertPushed(KeyCreateJob::class, 0);
Queue::assertPushed(
- \App\Jobs\User\CreateJob::class,
- function ($job) use ($user) {
+ CreateJob::class,
+ static function ($job) use ($user) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
$userId = TestCase::getObjectProperty($job, 'userId');
@@ -438,17 +443,17 @@
);
// Test invoking KeyCreateJob
- $this->deleteTestUser("user-test@$domain");
+ $this->deleteTestUser("user-test@{$domain}");
- \App\Tenant::find(\config('app.tenant_id'))->setSetting('pgp.enable', '1');
+ Tenant::find(\config('app.tenant_id'))->setSetting('pgp.enable', '1');
- $user = User::create(['email' => "user-test@$domain", 'password' => 'test']);
+ $user = User::create(['email' => "user-test@{$domain}", 'password' => 'test']);
- Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 1);
+ Queue::assertPushed(KeyCreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\PGP\KeyCreateJob::class,
- function ($job) use ($user) {
+ KeyCreateJob::class,
+ static function ($job) use ($user) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
$userId = TestCase::getObjectProperty($job, 'userId');
@@ -463,7 +468,7 @@
$user->password = 'test123';
$user->save();
- $this->assertNotEquals($oldPassword, $user->password);
+ $this->assertNotSame($oldPassword, $user->password);
$this->assertSame(0, $user->passwords()->count());
$this->assertNull($user->getSetting('password_expiration_warning'));
$this->assertMatchesRegularExpression(
@@ -471,10 +476,10 @@
$user->getSetting('password_update')
);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($user) {
+ UpdateJob::class,
+ static function ($job) use ($user) {
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
$userId = TestCase::getObjectProperty($job, 'userId');
@@ -510,8 +515,8 @@
$user = $this->getTestUser('john@kolab.org');
$domain = $this->getTestDomain('useraccount.com', [
- 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
- 'type' => Domain::TYPE_PUBLIC,
+ 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE,
+ 'type' => Domain::TYPE_PUBLIC,
]);
$domains = $user->domains()->pluck('namespace')->all();
@@ -530,7 +535,7 @@
$this->assertNotContains('kolab.org', $domains);
// Public domains of other tenants should not be returned
- $tenant = \App\Tenant::where('id', '!=', \config('app.tenant_id'))->first();
+ $tenant = Tenant::where('id', '!=', \config('app.tenant_id'))->first();
$domain->tenant_id = $tenant->id;
$domain->save();
@@ -560,43 +565,43 @@
$user->setSetting('limit_geo', null);
// greylist_enabled
- $this->assertSame(true, $user->getConfig()['greylist_enabled']);
+ $this->assertTrue($user->getConfig()['greylist_enabled']);
$result = $user->setConfig(['greylist_enabled' => false, 'unknown' => false]);
$this->assertSame(['unknown' => "The requested configuration parameter is not supported."], $result);
- $this->assertSame(false, $user->getConfig()['greylist_enabled']);
+ $this->assertFalse($user->getConfig()['greylist_enabled']);
$this->assertSame('false', $user->getSetting('greylist_enabled'));
$result = $user->setConfig(['greylist_enabled' => true]);
$this->assertSame([], $result);
- $this->assertSame(true, $user->getConfig()['greylist_enabled']);
+ $this->assertTrue($user->getConfig()['greylist_enabled']);
$this->assertSame('true', $user->getSetting('greylist_enabled'));
// guam_enabled
- $this->assertSame(false, $user->getConfig()['guam_enabled']);
+ $this->assertFalse($user->getConfig()['guam_enabled']);
$result = $user->setConfig(['guam_enabled' => false]);
$this->assertSame([], $result);
- $this->assertSame(false, $user->getConfig()['guam_enabled']);
- $this->assertSame(null, $user->getSetting('guam_enabled'));
+ $this->assertFalse($user->getConfig()['guam_enabled']);
+ $this->assertNull($user->getSetting('guam_enabled'));
$result = $user->setConfig(['guam_enabled' => true]);
$this->assertSame([], $result);
- $this->assertSame(true, $user->getConfig()['guam_enabled']);
+ $this->assertTrue($user->getConfig()['guam_enabled']);
$this->assertSame('true', $user->getSetting('guam_enabled'));
// max_apssword_age
- $this->assertSame(null, $user->getConfig()['max_password_age']);
+ $this->assertNull($user->getConfig()['max_password_age']);
$result = $user->setConfig(['max_password_age' => -1]);
$this->assertSame([], $result);
- $this->assertSame(null, $user->getConfig()['max_password_age']);
- $this->assertSame(null, $user->getSetting('max_password_age'));
+ $this->assertNull($user->getConfig()['max_password_age']);
+ $this->assertNull($user->getSetting('max_password_age'));
$result = $user->setConfig(['max_password_age' => 12]);
@@ -608,8 +613,8 @@
$result = $user->setConfig(['password_policy' => true]);
$this->assertSame(['password_policy' => "Specified password policy is invalid."], $result);
- $this->assertSame(null, $user->getConfig()['password_policy']);
- $this->assertSame(null, $user->getSetting('password_policy'));
+ $this->assertNull($user->getConfig()['password_policy']);
+ $this->assertNull($user->getSetting('password_policy'));
$result = $user->setConfig(['password_policy' => 'min:-1']);
@@ -647,17 +652,17 @@
$err = "Specified configuration is invalid. Expected a list of two-letter country codes.";
$this->assertSame(['limit_geo' => $err], $result);
- $this->assertSame(null, $user->getSetting('limit_geo'));
+ $this->assertNull($user->getSetting('limit_geo'));
$result = $user->setConfig(['limit_geo' => ['usa']]);
$this->assertSame(['limit_geo' => $err], $result);
- $this->assertSame(null, $user->getSetting('limit_geo'));
+ $this->assertNull($user->getSetting('limit_geo'));
$result = $user->setConfig(['limit_geo' => []]);
$this->assertSame([], $result);
- $this->assertSame(null, $user->getSetting('limit_geo'));
+ $this->assertNull($user->getSetting('limit_geo'));
$result = $user->setConfig(['limit_geo' => ['US', 'ru']]);
@@ -681,19 +686,19 @@
// Test an account with users, domain
$userA = $this->getTestUser('UserAccountA@UserAccount.com');
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$domain = $this->getTestDomain('UserAccount.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$userA->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $userA);
$userA->assignPackage($package_kolab, $userB);
- $entitlementsA = \App\Entitlement::where('entitleable_id', $userA->id);
- $entitlementsB = \App\Entitlement::where('entitleable_id', $userB->id);
- $entitlementsDomain = \App\Entitlement::where('entitleable_id', $domain->id);
+ $entitlementsA = Entitlement::where('entitleable_id', $userA->id);
+ $entitlementsB = Entitlement::where('entitleable_id', $userB->id);
+ $entitlementsDomain = Entitlement::where('entitleable_id', $domain->id);
$yesterday = Carbon::now()->subDays(1);
@@ -713,8 +718,8 @@
// Degrade the account/wallet owner
$userA->degrade();
- $entitlementsA = \App\Entitlement::where('entitleable_id', $userA->id);
- $entitlementsB = \App\Entitlement::where('entitleable_id', $userB->id);
+ $entitlementsA = Entitlement::where('entitleable_id', $userA->id);
+ $entitlementsB = Entitlement::where('entitleable_id', $userB->id);
$this->assertTrue($userA->fresh()->isDegraded());
$this->assertTrue($userA->fresh()->isDegraded(true));
@@ -728,7 +733,7 @@
// Expect one update job for every user
// @phpstan-ignore-next-line
- $userIds = Queue::pushed(\App\Jobs\User\UpdateJob::class)->map(function ($job) {
+ $userIds = Queue::pushed(UpdateJob::class)->map(static function ($job) {
return TestCase::getObjectProperty($job, 'userId');
})->all();
@@ -736,8 +741,8 @@
// Un-Degrade the account/wallet owner
- $entitlementsA = \App\Entitlement::where('entitleable_id', $userA->id);
- $entitlementsB = \App\Entitlement::where('entitleable_id', $userB->id);
+ $entitlementsA = Entitlement::where('entitleable_id', $userA->id);
+ $entitlementsB = Entitlement::where('entitleable_id', $userB->id);
$yesterday = Carbon::now()->subDays(1);
@@ -760,7 +765,7 @@
// Expect one update job for every user
// @phpstan-ignore-next-line
- $userIds = Queue::pushed(\App\Jobs\User\UpdateJob::class)->map(function ($job) {
+ $userIds = Queue::pushed(UpdateJob::class)->map(static function ($job) {
return TestCase::getObjectProperty($job, 'userId');
})->all();
@@ -775,7 +780,7 @@
Queue::fake();
$user = $this->getTestUser('user-test@' . \config('app.domain'));
- $package = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package = Package::withEnvTenantContext()->where('title', 'kolab')->first();
$user->assignPackage($package);
$id = $user->id;
@@ -790,11 +795,11 @@
$this->assertTrue($user->fresh()->trashed());
$this->assertFalse($user->fresh()->isDeleted());
- Queue::assertPushed(\App\Jobs\User\DeleteJob::class, 1);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 0);
// Delete the user for real
- $job = new \App\Jobs\User\DeleteJob($id);
+ $job = new DeleteJob($id);
$job->handle();
$this->assertTrue(User::withTrashed()->where('id', $id)->first()->isDeleted());
@@ -805,18 +810,18 @@
$this->assertCount(0, User::withTrashed()->where('id', $id)->get());
- Queue::assertPushed(\App\Jobs\User\DeleteJob::class, 0);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(DeleteJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Test an account with users, domain, and group, and resource
$userA = $this->getTestUser('UserAccountA@UserAccount.com');
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
$userC = $this->getTestUser('UserAccountC@UserAccount.com');
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$domain = $this->getTestDomain('UserAccount.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$userA->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $userA);
@@ -829,13 +834,13 @@
$folder = $this->getTestSharedFolder('test-folder@UserAccount.com', ['name' => 'test']);
$folder->assignToWallet($userA->wallets->first());
- $entitlementsA = \App\Entitlement::where('entitleable_id', $userA->id);
- $entitlementsB = \App\Entitlement::where('entitleable_id', $userB->id);
- $entitlementsC = \App\Entitlement::where('entitleable_id', $userC->id);
- $entitlementsDomain = \App\Entitlement::where('entitleable_id', $domain->id);
- $entitlementsGroup = \App\Entitlement::where('entitleable_id', $group->id);
- $entitlementsResource = \App\Entitlement::where('entitleable_id', $resource->id);
- $entitlementsFolder = \App\Entitlement::where('entitleable_id', $folder->id);
+ $entitlementsA = Entitlement::where('entitleable_id', $userA->id);
+ $entitlementsB = Entitlement::where('entitleable_id', $userB->id);
+ $entitlementsC = Entitlement::where('entitleable_id', $userC->id);
+ $entitlementsDomain = Entitlement::where('entitleable_id', $domain->id);
+ $entitlementsGroup = Entitlement::where('entitleable_id', $group->id);
+ $entitlementsResource = Entitlement::where('entitleable_id', $resource->id);
+ $entitlementsFolder = Entitlement::where('entitleable_id', $folder->id);
$this->assertSame(7, $entitlementsA->count());
$this->assertSame(7, $entitlementsB->count());
@@ -883,8 +888,8 @@
$userA->forceDelete();
- $all_entitlements = \App\Entitlement::where('wallet_id', $userA->wallets->first()->id);
- $transactions = \App\Transaction::where('object_id', $userA->wallets->first()->id);
+ $all_entitlements = Entitlement::where('wallet_id', $userA->wallets->first()->id);
+ $transactions = Transaction::where('object_id', $userA->wallets->first()->id);
$this->assertSame(0, $all_entitlements->withTrashed()->count());
$this->assertSame(0, $transactions->count());
@@ -893,8 +898,8 @@
$this->assertCount(0, User::withTrashed()->where('id', $userC->id)->get());
$this->assertCount(0, Domain::withTrashed()->where('id', $domain->id)->get());
$this->assertCount(0, Group::withTrashed()->where('id', $group->id)->get());
- $this->assertCount(0, \App\Resource::withTrashed()->where('id', $resource->id)->get());
- $this->assertCount(0, \App\SharedFolder::withTrashed()->where('id', $folder->id)->get());
+ $this->assertCount(0, Resource::withTrashed()->where('id', $resource->id)->get());
+ $this->assertCount(0, SharedFolder::withTrashed()->where('id', $folder->id)->get());
}
/**
@@ -921,13 +926,14 @@
* Test user deletion vs. group membership
*
* The first Queue::assertPushed is sometimes 1 and sometimes 2
+ *
* @group skipci
*/
public function testDeleteAndGroups(): void
{
Queue::fake();
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
$userA = $this->getTestUser('UserAccountA@UserAccount.com');
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
$userA->assignPackage($package_kolab, $userB);
@@ -973,7 +979,7 @@
Queue::assertPushed(\App\Jobs\User\Delegation\DeleteJob::class, 1);
Queue::assertPushed(
\App\Jobs\User\Delegation\DeleteJob::class,
- function ($job) use ($userA, $userB) {
+ static function ($job) use ($userA, $userB) {
$delegator = TestCase::getObjectProperty($job, 'delegatorEmail');
$delegatee = TestCase::getObjectProperty($job, 'delegateeEmail');
return $delegator === $userA->email && $delegatee === $userB->email;
@@ -998,7 +1004,7 @@
Queue::assertPushed(\App\Jobs\User\Delegation\DeleteJob::class, 1);
Queue::assertPushed(
\App\Jobs\User\Delegation\DeleteJob::class,
- function ($job) use ($userA, $userB) {
+ static function ($job) use ($userA, $userB) {
$delegator = TestCase::getObjectProperty($job, 'delegatorEmail');
$delegatee = TestCase::getObjectProperty($job, 'delegateeEmail');
return $delegator === $userA->email && $delegatee === $userB->email;
@@ -1019,7 +1025,7 @@
$user->tenant->setSetting('pgp.enable', 0);
$user->delete();
- Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 0);
+ Queue::assertPushed(KeyDeleteJob::class, 0);
// Test with PGP enabled
$this->deleteTestUser('user-test@' . \config('app.domain'));
@@ -1029,10 +1035,10 @@
$user->delete();
$user->tenant->setSetting('pgp.enable', 0);
- Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 1);
+ Queue::assertPushed(KeyDeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\PGP\KeyDeleteJob::class,
- function ($job) use ($user) {
+ KeyDeleteJob::class,
+ static function ($job) use ($user) {
$userId = TestCase::getObjectProperty($job, 'userId');
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
return $userId == $user->id && $userEmail === $user->email;
@@ -1209,40 +1215,40 @@
// Test an account with users and domain
$userA = $this->getTestUser('UserAccountA@UserAccount.com', [
- 'status' => User::STATUS_LDAP_READY | User::STATUS_IMAP_READY | User::STATUS_SUSPENDED,
+ 'status' => User::STATUS_LDAP_READY | User::STATUS_IMAP_READY | User::STATUS_SUSPENDED,
]);
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$domainA = $this->getTestDomain('UserAccount.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$domainB = $this->getTestDomain('UserAccountAdd.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$userA->assignPackage($package_kolab);
$domainA->assignPackage($package_domain, $userA);
$domainB->assignPackage($package_domain, $userA);
$userA->assignPackage($package_kolab, $userB);
- $storage_sku = \App\Sku::withEnvTenantContext()->where('title', 'storage')->first();
- $now = \Carbon\Carbon::now();
+ $storage_sku = Sku::withEnvTenantContext()->where('title', 'storage')->first();
+ $now = Carbon::now();
$wallet_id = $userA->wallets->first()->id;
// add an extra storage entitlement
- $ent1 = \App\Entitlement::create([
- 'wallet_id' => $wallet_id,
- 'sku_id' => $storage_sku->id,
- 'cost' => 0,
- 'entitleable_id' => $userA->id,
- 'entitleable_type' => User::class,
+ $ent1 = Entitlement::create([
+ 'wallet_id' => $wallet_id,
+ 'sku_id' => $storage_sku->id,
+ 'cost' => 0,
+ 'entitleable_id' => $userA->id,
+ 'entitleable_type' => User::class,
]);
- $entitlementsA = \App\Entitlement::where('entitleable_id', $userA->id);
- $entitlementsB = \App\Entitlement::where('entitleable_id', $userB->id);
- $entitlementsDomain = \App\Entitlement::where('entitleable_id', $domainA->id);
+ $entitlementsA = Entitlement::where('entitleable_id', $userA->id);
+ $entitlementsB = Entitlement::where('entitleable_id', $userB->id);
+ $entitlementsDomain = Entitlement::where('entitleable_id', $domainA->id);
// First delete the user
$userA->delete();
@@ -1259,11 +1265,11 @@
$this->assertFalse($domainA->isDeleted());
// Backdate one storage entitlement (it's not expected to be restored)
- \App\Entitlement::withTrashed()->where('id', $ent1->id)
+ Entitlement::withTrashed()->where('id', $ent1->id)
->update(['deleted_at' => $now->copy()->subMinutes(2)]);
// Backdate entitlements to assert that they were restored with proper updated_at timestamp
- \App\Entitlement::withTrashed()->where('wallet_id', $wallet_id)
+ Entitlement::withTrashed()->where('wallet_id', $wallet_id)
->update(['updated_at' => $now->subMinutes(10)]);
$this->fakeQueueReset();
@@ -1288,7 +1294,7 @@
$this->assertSame(7, $entitlementsA->count()); // mailbox + groupware + 5 x storage
$this->assertTrue($ent1->fresh()->trashed());
$entitlementsA->get()->each(function ($ent) {
- $this->assertTrue($ent->updated_at->greaterThan(\Carbon\Carbon::now()->subSeconds(5)));
+ $this->assertTrue($ent->updated_at->greaterThan(Carbon::now()->subSeconds(5)));
});
// We expect only CreateJob + UpdateJob pair for both user and domain.
@@ -1298,11 +1304,11 @@
$this->assertCount(4, Queue::pushedJobs()); // @phpstan-ignore-line
Queue::assertPushed(\App\Jobs\Domain\UpdateJob::class, 1);
Queue::assertPushed(\App\Jobs\Domain\CreateJob::class, 1);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
- Queue::assertPushed(\App\Jobs\User\CreateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
+ Queue::assertPushed(CreateJob::class, 1);
Queue::assertPushed(
- \App\Jobs\User\CreateJob::class,
- function ($job) use ($userA) {
+ CreateJob::class,
+ static function ($job) use ($userA) {
return $userA->id === TestCase::getObjectProperty($job, 'userId');
}
);
@@ -1318,11 +1324,11 @@
// Test an account with users, domain
$user = $this->getTestUser('UserAccountA@UserAccount.com');
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
- $package_kolab = \App\Package::withEnvTenantContext()->where('title', 'kolab')->first();
- $package_domain = \App\Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
+ $package_kolab = Package::withEnvTenantContext()->where('title', 'kolab')->first();
+ $package_domain = Package::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$domain = $this->getTestDomain('UserAccount.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$user->assignPackage($package_kolab);
$domain->assignPackage($package_domain, $user);
@@ -1337,8 +1343,8 @@
$this->assertFalse($userB->fresh()->isRestricted());
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($user) {
+ UpdateJob::class,
+ static function ($job) use ($user) {
return TestCase::getObjectProperty($job, 'userId') == $user->id;
}
);
@@ -1355,8 +1361,8 @@
$this->assertTrue($userB->fresh()->isRestricted());
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($user) {
+ UpdateJob::class,
+ static function ($job) use ($user) {
return TestCase::getObjectProperty($job, 'userId') == $user->id;
}
);
@@ -1369,8 +1375,8 @@
$this->assertFalse($userB->fresh()->isRestricted());
Queue::assertPushed(
- \App\Jobs\User\UpdateJob::class,
- function ($job) use ($userB) {
+ UpdateJob::class,
+ static function ($job) use ($userB) {
return TestCase::getObjectProperty($job, 'userId') == $userB->id;
}
);
@@ -1385,8 +1391,8 @@
$user = $this->getTestUser('UserAccountA@UserAccount.com');
$domain = $this->getTestDomain('UserAccount.com', [
- 'status' => Domain::STATUS_NEW,
- 'type' => Domain::TYPE_HOSTED,
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_HOSTED,
]);
$this->assertCount(0, $user->aliases->all());
@@ -1396,8 +1402,8 @@
// Add an alias
$user->setAliases(['UserAlias1@UserAccount.com']);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
- Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
+ Queue::assertPushed(KeyCreateJob::class, 1);
$user->tenant->setSetting('pgp.enable', 0);
@@ -1409,8 +1415,8 @@
$this->fakeQueueReset();
$user->setAliases(['UserAlias1@UserAccount.com', 'UserAlias2@UserAccount.com']);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
- Queue::assertPushed(\App\Jobs\PGP\KeyCreateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 1);
+ Queue::assertPushed(KeyCreateJob::class, 0);
$aliases = $user->aliases()->orderBy('alias')->get();
$this->assertCount(2, $aliases);
@@ -1425,11 +1431,11 @@
$user->tenant->setSetting('pgp.enable', 0);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
- Queue::assertPushed(\App\Jobs\PGP\KeyDeleteJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
+ Queue::assertPushed(KeyDeleteJob::class, 1);
Queue::assertPushed(
- \App\Jobs\PGP\KeyDeleteJob::class,
- function ($job) use ($user) {
+ KeyDeleteJob::class,
+ static function ($job) use ($user) {
$userId = TestCase::getObjectProperty($job, 'userId');
$userEmail = TestCase::getObjectProperty($job, 'userEmail');
return $userId == $user->id && $userEmail === 'useralias2@useraccount.com';
@@ -1444,7 +1450,7 @@
$this->fakeQueueReset();
$user->setAliases([]);
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
$this->assertCount(0, $user->aliases()->get());
}
@@ -1470,7 +1476,7 @@
$resource_sku = Sku::withEnvTenantContext()->where('title', 'resource')->first();
$userB = $this->getTestUser('UserAccountB@UserAccount.com');
$userB->assignSku($mailbox_sku, 1, $wallet);
- $domain = $this->getTestDomain('UserAccount.com', ['type' => \App\Domain::TYPE_PUBLIC]);
+ $domain = $this->getTestDomain('UserAccount.com', ['type' => Domain::TYPE_PUBLIC]);
$domain->assignSku($domain_sku, 1, $wallet);
$group = $this->getTestGroup('test-group@UserAccount.com');
$group->assignSku($group_sku, 1, $wallet);
@@ -1501,7 +1507,7 @@
$user = $this->getTestUser('UserAccountA@UserAccount.com');
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 0);
+ Queue::assertPushed(UpdateJob::class, 0);
// Test default settings
// Note: Technicly this tests UserObserver::created() behavior
@@ -1516,7 +1522,7 @@
$user->setSetting('first_name', 'Firstname');
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current user as well as fresh user object
@@ -1529,7 +1535,7 @@
$user->setSetting('first_name', 'Firstname1');
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current user as well as fresh user object
@@ -1542,13 +1548,13 @@
$user->setSetting('first_name', null);
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current user as well as fresh user object
// to make sure cache works as expected
- $this->assertSame(null, $user->getSetting('first_name'));
- $this->assertSame(null, $user->fresh()->getSetting('first_name'));
+ $this->assertNull($user->getSetting('first_name'));
+ $this->assertNull($user->fresh()->getSetting('first_name'));
// Delete a setting (empty string)
$this->fakeQueueReset();
@@ -1556,25 +1562,25 @@
$user->setSetting('first_name', '');
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current user as well as fresh user object
// to make sure cache works as expected
- $this->assertSame(null, $user->getSetting('first_name'));
- $this->assertSame(null, $user->fresh()->getSetting('first_name'));
+ $this->assertNull($user->getSetting('first_name'));
+ $this->assertNull($user->fresh()->getSetting('first_name'));
// Set multiple settings at once
$this->fakeQueueReset();
$user->setSettings([
- 'first_name' => 'Firstname2',
- 'last_name' => 'Lastname2',
- 'country' => null,
+ 'first_name' => 'Firstname2',
+ 'last_name' => 'Lastname2',
+ 'country' => null,
]);
// Thanks to job locking it creates a single UserUpdate job
if (\config('app.with_ldap')) {
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 1);
+ Queue::assertPushed(UpdateJob::class, 1);
}
// Note: We test both current user as well as fresh user object
@@ -1583,8 +1589,8 @@
$this->assertSame('Firstname2', $user->fresh()->getSetting('first_name'));
$this->assertSame('Lastname2', $user->getSetting('last_name'));
$this->assertSame('Lastname2', $user->fresh()->getSetting('last_name'));
- $this->assertSame(null, $user->getSetting('country'));
- $this->assertSame(null, $user->fresh()->getSetting('country'));
+ $this->assertNull($user->getSetting('country'));
+ $this->assertNull($user->fresh()->getSetting('country'));
$expected = [
'currency' => 'CHF',
@@ -1617,10 +1623,10 @@
$users = $john->users()->orderBy('email')->get();
$this->assertCount(4, $users);
- $this->assertEquals($jack->id, $users[0]->id);
- $this->assertEquals($joe->id, $users[1]->id);
- $this->assertEquals($john->id, $users[2]->id);
- $this->assertEquals($ned->id, $users[3]->id);
+ $this->assertSame($jack->id, $users[0]->id);
+ $this->assertSame($joe->id, $users[1]->id);
+ $this->assertSame($john->id, $users[2]->id);
+ $this->assertSame($ned->id, $users[3]->id);
$users = $jack->users()->orderBy('email')->get();
@@ -1659,11 +1665,11 @@
$this->assertSame(1, $john->wallets()->count());
$this->assertCount(1, $john->wallets);
- $this->assertInstanceOf(\App\Wallet::class, $john->wallets->first());
+ $this->assertInstanceOf(Wallet::class, $john->wallets->first());
$this->assertSame(1, $ned->wallets()->count());
$this->assertCount(1, $ned->wallets);
- $this->assertInstanceOf(\App\Wallet::class, $ned->wallets->first());
+ $this->assertInstanceOf(Wallet::class, $ned->wallets->first());
}
/**
@@ -1739,7 +1745,7 @@
// Seed the cache
User::findAndAuthenticate($user->email, "test");
- $time = Benchmark::measure(function () use (&$user) {
+ $time = Benchmark::measure(static function () use (&$user) {
User::findAndAuthenticate($user->email, "test");
}, 10);
// print("\nTime: $time ms\n");
@@ -1759,7 +1765,7 @@
// Seed the cache
User::findAndAuthenticate($user->email, $token);
- $time = Benchmark::measure(function () use ($user, $token) {
+ $time = Benchmark::measure(static function () use ($user, $token) {
User::findAndAuthenticate($user->email, $token);
}, 10);
// print("\nTime: $time ms\n");
diff --git a/src/tests/Feature/VerificationCodeTest.php b/src/tests/Feature/VerificationCodeTest.php
--- a/src/tests/Feature/VerificationCodeTest.php
+++ b/src/tests/Feature/VerificationCodeTest.php
@@ -2,21 +2,20 @@
namespace Tests\Feature;
-use App\User;
use App\VerificationCode;
use Carbon\Carbon;
use Tests\TestCase;
class VerificationCodeTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('UserAccountA@UserAccount.com');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('UserAccountA@UserAccount.com');
@@ -47,7 +46,7 @@
$this->assertTrue(strlen($code->short_code) === $code_length);
$this->assertTrue($code->active);
$this->assertSame($data['mode'], $code->mode);
- $this->assertEquals($user->id, $code->user->id);
+ $this->assertSame($user->id, $code->user->id);
$this->assertInstanceOf(\DateTime::class, $code->expires_at);
$this->assertSame($code->expires_at->toDateTimeString(), $exp->toDateTimeString());
diff --git a/src/tests/Feature/WalletTest.php b/src/tests/Feature/WalletTest.php
--- a/src/tests/Feature/WalletTest.php
+++ b/src/tests/Feature/WalletTest.php
@@ -4,14 +4,16 @@
use App\Discount;
use App\Entitlement;
-use App\Payment;
+use App\Jobs\User\UpdateJob;
use App\Package;
+use App\Payment;
use App\Plan;
-use App\User;
use App\Sku;
use App\Transaction;
-use App\Wallet;
+use App\User;
+use App\Utils;
use App\VatRate;
+use App\Wallet;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Queue;
@@ -23,17 +25,14 @@
'UserWallet1@UserWallet.com',
'UserWallet2@UserWallet.com',
'UserWallet3@UserWallet.com',
- 'jane@kolabnow.com'
+ 'jane@kolabnow.com',
];
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
- Carbon::setTestNow(Carbon::createFromDate(2022, 02, 02));
+ Carbon::setTestNow(Carbon::createFromDate(2022, 2, 2));
foreach ($this->users as $user) {
$this->deleteTestUser($user);
}
@@ -43,10 +42,7 @@
VatRate::query()->delete();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
foreach ($this->users as $user) {
$this->deleteTestUser($user);
@@ -115,7 +111,7 @@
$this->assertFalse($user1->fresh()->isRestricted());
$this->assertFalse($user2->fresh()->isRestricted());
- Queue::assertPushed(\App\Jobs\User\UpdateJob::class, 3);
+ Queue::assertPushed(UpdateJob::class, 3);
// TODO: Test group account and unsuspending domain/members/groups
}
@@ -146,13 +142,13 @@
$wallet->balance = -1000;
$until = $wallet->balanceLastsUntil();
- $this->assertSame(null, $until);
+ $this->assertNull($until);
// User/entitlements created today, balance=-9,99 CHF (monthly cost)
$wallet->balance = 990;
$until = $wallet->balanceLastsUntil();
- $daysInLastMonth = \App\Utils::daysInLastMonth();
+ $daysInLastMonth = Utils::daysInLastMonth();
$delta = (int) Carbon::now()->addMonthsWithoutOverflow(1)->addDays($daysInLastMonth)->diffInDays($until, true);
$this->assertTrue($delta <= 1);
@@ -160,12 +156,12 @@
// Old entitlements, 100% discount
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subDays(40));
- $discount = \App\Discount::withEnvTenantContext()->where('discount', 100)->first();
+ $discount = Discount::withEnvTenantContext()->where('discount', 100)->first();
$wallet->discount()->associate($discount);
$until = $wallet->refresh()->balanceLastsUntil();
- $this->assertSame(null, $until);
+ $this->assertNull($until);
// User with no entitlements
$wallet->discount()->dissociate($discount);
@@ -173,7 +169,7 @@
$until = $wallet->refresh()->balanceLastsUntil();
- $this->assertSame(null, $until);
+ $this->assertNull($until);
}
/**
@@ -196,7 +192,7 @@
$user->wallets()->each(
function ($wallet) {
- $this->assertEquals(0, $wallet->balance);
+ $this->assertSame(0, $wallet->balance);
}
);
@@ -205,7 +201,7 @@
// Verify we can not delete a user wallet that holds balance.
$user->wallets()->each(
- function ($wallet) {
+ static function ($wallet) {
$wallet->credit(100)->save();
}
);
@@ -238,7 +234,7 @@
$userB = $this->getTestUser('UserWallet2@UserWallet.com');
$userA->wallets()->each(
- function ($wallet) use ($userB) {
+ static function ($wallet) use ($userB) {
$wallet->addController($userB);
}
);
@@ -268,7 +264,7 @@
Carbon::now()->subMonthsWithoutOverflow(1)->addDays(1)
);
- $this->assertEquals(0, $wallet->expectedCharges());
+ $this->assertSame(0, $wallet->expectedCharges());
// Verify the exact end of the month's trial.
$this->backdateEntitlements(
@@ -276,7 +272,7 @@
Carbon::now()->subMonthsWithoutOverflow(1)
);
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
// Verify that over-running the trial by a single day causes charges to be incurred.
$this->backdateEntitlements(
@@ -284,7 +280,7 @@
Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
// Verify additional storage configuration entitlement created 'early' does incur additional
// charges to the wallet.
@@ -293,16 +289,16 @@
Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
$sku = Sku::withEnvTenantContext()->where('title', 'storage')->first();
$entitlement = Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $sku->id,
- 'cost' => $sku->cost,
- 'entitleable_id' => $user->id,
- 'entitleable_type' => \App\User::class
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $sku->id,
+ 'cost' => $sku->cost,
+ 'entitleable_id' => $user->id,
+ 'entitleable_type' => User::class,
]);
$this->backdateEntitlements(
@@ -310,7 +306,7 @@
Carbon::now()->subMonthsWithoutOverflow(1)->subDays(1)
);
- $this->assertEquals(1015, $wallet->expectedCharges());
+ $this->assertSame(1015, $wallet->expectedCharges());
$entitlement->forceDelete();
$wallet->refresh();
@@ -319,19 +315,19 @@
// charges to the wallet.
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
- $entitlement = \App\Entitlement::create([
- 'wallet_id' => $wallet->id,
- 'sku_id' => $sku->id,
- 'cost' => $sku->cost,
- 'entitleable_id' => $user->id,
- 'entitleable_type' => \App\User::class
+ $entitlement = Entitlement::create([
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => $sku->id,
+ 'cost' => $sku->cost,
+ 'entitleable_id' => $user->id,
+ 'entitleable_type' => User::class,
]);
$this->backdateEntitlements([$entitlement], Carbon::now()->subDays(14));
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
$entitlement->forceDelete();
$wallet->refresh();
@@ -342,7 +338,7 @@
$this->backdateEntitlements($wallet->entitlements, $targetDateA);
- $this->assertEquals(990, $wallet->expectedCharges());
+ $this->assertSame(990, $wallet->expectedCharges());
$entitlement->forceDelete();
$wallet->refresh();
@@ -352,19 +348,19 @@
$this->assertCount(7, $wallet->entitlements);
- $this->assertEquals(1980, $wallet->expectedCharges());
+ $this->assertSame(1980, $wallet->expectedCharges());
- $entitlement = \App\Entitlement::create([
- 'entitleable_id' => $user->id,
- 'entitleable_type' => \App\User::class,
- 'cost' => $sku->cost,
- 'sku_id' => $sku->id,
- 'wallet_id' => $wallet->id
+ $entitlement = Entitlement::create([
+ 'entitleable_id' => $user->id,
+ 'entitleable_type' => User::class,
+ 'cost' => $sku->cost,
+ 'sku_id' => $sku->id,
+ 'wallet_id' => $wallet->id,
]);
$this->backdateEntitlements([$entitlement], Carbon::now()->subMonthsWithoutOverflow(1));
- $this->assertEquals(2005, $wallet->expectedCharges());
+ $this->assertSame(2005, $wallet->expectedCharges());
$entitlement->forceDelete();
$wallet->refresh();
@@ -376,7 +372,7 @@
$this->backdateEntitlements($wallet->entitlements, Carbon::now()->subMonthsWithoutOverflow(1));
- $this->assertEquals(891, $wallet->expectedCharges());
+ $this->assertSame(891, $wallet->expectedCharges());
}
/**
@@ -433,7 +429,7 @@
$userB = $this->getTestUser('UserWallet2@UserWallet.com');
$userA->wallets()->each(
- function ($wallet) use ($userB) {
+ static function ($wallet) use ($userB) {
$wallet->addController($userB);
}
);
@@ -441,7 +437,7 @@
$userB->refresh();
$userB->accounts()->each(
- function ($wallet) use ($userB) {
+ static function ($wallet) use ($userB) {
$wallet->removeController($userB);
}
);
@@ -455,7 +451,7 @@
public function testChargeEntitlements(): void
{
$user = $this->getTestUser('jane@kolabnow.com');
- $discount = \App\Discount::withEnvTenantContext()->where('discount', 30)->first();
+ $discount = Discount::withEnvTenantContext()->where('discount', 30)->first();
$wallet = $user->wallets()->first();
$wallet->discount()->associate($discount);
$wallet->save();
@@ -633,9 +629,9 @@
$ent = $user->entitlements->where('sku_id', $groupware->id)->first();
Entitlement::where('id', $ent->id)->update([
- 'created_at' => $backdate,
- 'updated_at' => $backdate,
- 'deleted_at' => Carbon::now(),
+ 'created_at' => $backdate,
+ 'updated_at' => $backdate,
+ 'deleted_at' => Carbon::now(),
]);
// we expect no charges
@@ -736,7 +732,7 @@
$etransactions = Transaction::where('transaction_id', $trans->id)->get();
$this->assertCount(5, $etransactions);
$trans = $etransactions[0];
- $this->assertSame(null, $trans->description);
+ $this->assertNull($trans->description);
$this->assertSame(25, $trans->amount);
$this->assertSame(Transaction::ENTITLEMENT_BILLED, $trans->type);
@@ -791,7 +787,7 @@
$etransactions = Transaction::where('transaction_id', $trans->id)->get();
$this->assertCount(2, $etransactions);
$trans = $etransactions[0];
- $this->assertSame(null, $trans->description);
+ $this->assertNull($trans->description);
$this->assertSame(15, $trans->amount);
$this->assertSame(Transaction::ENTITLEMENT_BILLED, $trans->type);
@@ -898,7 +894,7 @@
public function testUpdateEntitlements(): void
{
$user = $this->getTestUser('jane@kolabnow.com');
- $discount = \App\Discount::withEnvTenantContext()->where('discount', 30)->first();
+ $discount = Discount::withEnvTenantContext()->where('discount', 30)->first();
$wallet = $user->wallets()->first();
$wallet->discount()->associate($discount);
$wallet->save();
@@ -1012,24 +1008,24 @@
public function testVatRate(): void
{
$rate1 = VatRate::create([
- 'start' => now()->subDay(),
- 'country' => 'US',
- 'rate' => 7.5,
+ 'start' => now()->subDay(),
+ 'country' => 'US',
+ 'rate' => 7.5,
]);
$rate2 = VatRate::create([
- 'start' => now()->subDay(),
- 'country' => 'DE',
- 'rate' => 10.0,
+ 'start' => now()->subDay(),
+ 'country' => 'DE',
+ 'rate' => 10.0,
]);
$user = $this->getTestUser('UserWallet1@UserWallet.com');
$wallet = $user->wallets()->first();
$user->setSetting('country', null);
- $this->assertSame(null, $wallet->vatRate());
+ $this->assertNull($wallet->vatRate());
$user->setSetting('country', 'PL');
- $this->assertSame(null, $wallet->vatRate());
+ $this->assertNull($wallet->vatRate());
$user->setSetting('country', 'US');
$this->assertSame($rate1->id, $wallet->vatRate()->id); // @phpstan-ignore-line
@@ -1039,13 +1035,13 @@
// Test $start argument
$rate3 = VatRate::create([
- 'start' => now()->subYear(),
- 'country' => 'DE',
- 'rate' => 5.0,
+ 'start' => now()->subYear(),
+ 'country' => 'DE',
+ 'rate' => 5.0,
]);
$this->assertSame($rate2->id, $wallet->vatRate()->id); // @phpstan-ignore-line
$this->assertSame($rate3->id, $wallet->vatRate(now()->subMonth())->id);
- $this->assertSame(null, $wallet->vatRate(now()->subYears(2)));
+ $this->assertNull($wallet->vatRate(now()->subYears(2)));
}
}
diff --git a/src/tests/Infrastructure/ActivesyncTest.php b/src/tests/Infrastructure/ActivesyncTest.php
--- a/src/tests/Infrastructure/ActivesyncTest.php
+++ b/src/tests/Infrastructure/ActivesyncTest.php
@@ -4,9 +4,11 @@
use App\Backends\Roundcube;
use App\DataMigrator\Account;
+use App\User;
+use GuzzleHttp\Client;
+use Illuminate\Support\Str;
use Tests\BackendsTrait;
use Tests\TestCase;
-use Illuminate\Support\Str;
/**
* @group dav
@@ -15,8 +17,8 @@
{
use BackendsTrait;
- private static ?\GuzzleHttp\Client $client = null;
- private static ?\App\User $user = null;
+ private static ?Client $client = null;
+ private static ?User $user = null;
private static ?string $deviceId = null;
private static ?string $deviceId2 = null;
@@ -55,14 +57,14 @@
'Content-Type' => 'application/vnd.ms-sync.wbxml',
'MS-ASProtocolVersion' => '14.0',
],
- 'body' => $body
+ 'body' => $body,
]
);
}
private function xpath($dom)
{
- $xpath = new \DOMXpath($dom);
+ $xpath = new \DOMXPath($dom);
$xpath->registerNamespace("ns", $dom->documentElement->namespaceURI);
$xpath->registerNamespace("Tasks", "uri:Tasks");
$xpath->registerNamespace("Calendar", "uri:Calendar");
@@ -71,10 +73,7 @@
return $xpath;
}
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -91,7 +90,7 @@
if (!self::$user) {
$userProps = [
'password' => 'simple123',
- 'status' => \App\User::STATUS_NEW,
+ 'status' => User::STATUS_NEW,
];
self::$user = $this->getTestUser('activesynctest@kolab.org', $userProps, true);
@@ -111,17 +110,17 @@
}
if (!self::$client) {
- self::$client = new \GuzzleHttp\Client([
- 'http_errors' => false, // No exceptions
- 'base_uri' => \config("services.activesync.uri"),
- 'verify' => false,
- 'auth' => [self::$user->email, 'simple123'],
- 'connect_timeout' => 10,
- 'timeout' => 10,
- 'headers' => [
- "Content-Type" => "application/xml; charset=utf-8",
- "Depth" => "1",
- ]
+ self::$client = new Client([
+ 'http_errors' => false, // No exceptions
+ 'base_uri' => \config("services.activesync.uri"),
+ 'verify' => false,
+ 'auth' => [self::$user->email, 'simple123'],
+ 'connect_timeout' => 10,
+ 'timeout' => 10,
+ 'headers' => [
+ "Content-Type" => "application/xml; charset=utf-8",
+ "Depth" => "1",
+ ],
]);
}
}
@@ -132,7 +131,7 @@
public function testOptions(): void
{
$response = self::$client->request('OPTIONS', '');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$this->assertStringContainsString('14', $response->getHeader('MS-Server-ActiveSync')[0]);
$this->assertStringContainsString('14.1', $response->getHeader('MS-ASProtocolVersions')[0]);
$this->assertStringContainsString('FolderSync', $response->getHeader('MS-ASProtocolCommands')[0]);
@@ -143,18 +142,18 @@
*/
public function testPartialCommand(): void
{
- $request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <FolderSync xmlns="uri:FolderHierarchy">
- <SyncKey>0</SyncKey>
- </FolderSync>
- EOF;
+ $request = <<<'EOF'
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <FolderSync xmlns="uri:FolderHierarchy">
+ <SyncKey>0</SyncKey>
+ </FolderSync>
+ EOF;
$body = self::toWbxml($request);
$deviceId = self::$deviceId;
$user = self::$user;
- $response = self::$client->request(
+ $response = self::$client->request(
'POST',
"?Cmd=FolderSync&User={$user->email}&DeviceId={$deviceId}&DeviceType=WindowsOutlook15",
[
@@ -162,12 +161,12 @@
'Content-Type' => 'application/vnd.ms-sync.wbxml',
'MS-ASProtocolVersion' => '14.0',
],
- //Truncated body
- 'body' => substr($body, 0, strlen($body) / 2)
+ // Truncated body
+ 'body' => substr($body, 0, strlen($body) / 2),
]
);
- $this->assertEquals(500, $response->getStatusCode());
+ $this->assertSame(500, $response->getStatusCode());
}
/**
@@ -175,16 +174,16 @@
*/
public function testFolderSync(): array
{
- $request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <FolderSync xmlns="uri:FolderHierarchy">
- <SyncKey>0</SyncKey>
- </FolderSync>
- EOF;
+ $request = <<<'EOF'
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <FolderSync xmlns="uri:FolderHierarchy">
+ <SyncKey>0</SyncKey>
+ </FolderSync>
+ EOF;
$response = $this->request($request, 'FolderSync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xml = $dom->saveXML();
@@ -229,44 +228,44 @@
public function testInitialSync($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Email", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Email", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
return $params;
}
@@ -277,33 +276,33 @@
public function testAdd($params): void
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
// We expect an empty response without a change
- $this->assertEquals(0, $response->getBody()->getSize());
+ $this->assertSame(0, $response->getBody()->getSize());
}
/**
@@ -312,58 +311,58 @@
public function testSyncTasks($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
return $params;
}
@@ -374,51 +373,51 @@
public function testAddTask($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId1</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task1</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId1</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task1</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Tasks", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("2", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Tasks", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("2", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
- $this->assertEquals("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
+ $this->assertSame(1, $add->length);
+ $this->assertSame("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame(0, $xpath->query("//ns:Commands")->length);
$params['serverId'] = $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue;
@@ -433,50 +432,50 @@
public function testReAddTask($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId1</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task1</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId1</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task1</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Tasks", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("3", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Tasks", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("3", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
- $this->assertEquals("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
+ $this->assertSame(1, $add->length);
+ $this->assertSame("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame(0, $xpath->query("//ns:Commands")->length);
$params['serverId'] = $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue;
@@ -491,74 +490,74 @@
public function testAddTaskContinued($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>3</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId2</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task2</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- <Add>
- <ClientId>clientId3</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task3</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- <Change>
- <ServerId>{$params['serverId']}</ServerId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task4</Subject>
- </ApplicationData>
- </Change>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>3</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId2</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task2</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ <Add>
+ <ClientId>clientId3</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task3</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ <Change>
+ <ServerId>{$params['serverId']}</ServerId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task4</Subject>
+ </ApplicationData>
+ </Change>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Tasks", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("4", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Tasks", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("4", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(2, $add->length);
- $this->assertEquals("clientId2", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals("clientId3", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(1)->nodeValue);
- $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
+ $this->assertSame(2, $add->length);
+ $this->assertSame("clientId2", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame("clientId3", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(1)->nodeValue);
+ $this->assertSame(0, $xpath->query("//ns:Commands")->length);
// The server does not have to inform about a successful change
$change = $xpath->query("//ns:Responses/ns:Change");
- $this->assertEquals(0, $change->length);
+ $this->assertSame(0, $change->length);
return $params + [
'serverId1' => $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue,
- 'serverId2' => $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(1)->nodeValue
+ 'serverId2' => $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(1)->nodeValue,
];
}
@@ -570,83 +569,83 @@
public function testAddTaskContinuedAgain($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>3</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId2</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task2</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- <Add>
- <ClientId>clientId3</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task3</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- <Change>
- <ServerId>{$params['serverId1']}</ServerId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task4</Subject>
- </ApplicationData>
- </Change>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>3</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId2</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task2</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ <Add>
+ <ClientId>clientId3</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task3</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ <Change>
+ <ServerId>{$params['serverId1']}</ServerId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task4</Subject>
+ </ApplicationData>
+ </Change>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Tasks", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("5", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Tasks", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("5", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(2, $add->length);
+ $this->assertSame(2, $add->length);
- $this->assertEquals("clientId2", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals(
+ $this->assertSame("clientId2", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame(
$params['serverId1'],
$xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue
);
- $this->assertEquals("clientId3", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(1)->nodeValue);
- $this->assertEquals(
+ $this->assertSame("clientId3", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(1)->nodeValue);
+ $this->assertSame(
$params['serverId2'],
$xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(1)->nodeValue
);
// The server does not have to inform about a successful change
$change = $xpath->query("//ns:Responses/ns:Change");
- $this->assertEquals(0, $change->length);
- $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
+ $this->assertSame(0, $change->length);
+ $this->assertSame(0, $xpath->query("//ns:Commands")->length);
return $params + [
- 'serverId2' => $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(1)->nodeValue
+ 'serverId2' => $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(1)->nodeValue,
];
}
@@ -658,35 +657,35 @@
public function testInvalidSyncKey($params): void
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>10</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId999</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task1</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>10</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId999</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task1</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("3", $status[0]->nodeValue);
+ $this->assertSame("3", $status[0]->nodeValue);
// After this we have to start from scratch
}
@@ -699,239 +698,239 @@
{
$serverId = $params['serverId2'];
// Initialize the second device
- $request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <FolderSync xmlns="uri:FolderHierarchy">
- <SyncKey>0</SyncKey>
- </FolderSync>
- EOF;
+ $request = <<<'EOF'
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <FolderSync xmlns="uri:FolderHierarchy">
+ <SyncKey>0</SyncKey>
+ </FolderSync>
+ EOF;
$response = $this->request($request, 'FolderSync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <MIMESupport>2</MIMESupport>
- <MIMETruncation>8</MIMETruncation>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>4</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <MIMESupport>2</MIMESupport>
+ <MIMETruncation>8</MIMETruncation>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>4</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
// Fetch the content
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Commands/ns:Add");
- $this->assertEquals(3, $add->length);
+ $this->assertSame(3, $add->length);
// Resend the same command
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Commands/ns:Add");
- $this->assertEquals(3, $add->length);
+ $this->assertSame(3, $add->length);
// Add another entry, delete an entry, with the original device (we have to init first again)
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <MIMESupport>2</MIMESupport>
- <MIMETruncation>8</MIMETruncation>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>4</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <MIMESupport>2</MIMESupport>
+ <MIMETruncation>8</MIMETruncation>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>4</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>2</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId4</ClientId>
- <ApplicationData>
- <Subject xmlns="uri:Tasks">task4</Subject>
- <Complete xmlns="uri:Tasks">0</Complete>
- <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
- <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
- </ApplicationData>
- </Add>
- <Delete>
- <ServerId>{$serverId}</ServerId>
- </Delete>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>2</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId4</ClientId>
+ <ApplicationData>
+ <Subject xmlns="uri:Tasks">task4</Subject>
+ <Complete xmlns="uri:Tasks">0</Complete>
+ <DueDate xmlns="uri:Tasks">2020-11-04T00:00:00.000Z</DueDate>
+ <UtcDueDate xmlns="uri:Tasks">2020-11-03T23:00:00.000Z</UtcDueDate>
+ </ApplicationData>
+ </Add>
+ <Delete>
+ <ServerId>{$serverId}</ServerId>
+ </Delete>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
+ $this->assertSame(1, $add->length);
// Delete does not have to be confirmed according to spec
$delete = $xpath->query("//ns:Responses/ns:Delete");
- $this->assertEquals(0, $delete->length);
+ $this->assertSame(0, $delete->length);
// And fetch the changes
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>3</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>3</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Commands/ns:Add");
- $this->assertEquals(1, $add->length);
+ $this->assertSame(1, $add->length);
$delete = $xpath->query("//ns:Commands/ns:Delete");
- $this->assertEquals(1, $delete->length);
+ $this->assertSame(1, $delete->length);
// and finally refetch the same changes
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>3</SyncKey>
- <CollectionId>{$params['tasksId']}</CollectionId>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>3</SyncKey>
+ <CollectionId>{$params['tasksId']}</CollectionId>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync', self::$deviceId2);
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Commands/ns:Add");
- $this->assertEquals(1, $add->length);
+ $this->assertSame(1, $add->length);
// FIXME we currently miss deletions.
$delete = $xpath->query("//ns:Commands/ns:Delete");
- $this->assertEquals(0, $delete->length);
+ $this->assertSame(0, $delete->length);
}
/**
@@ -940,58 +939,58 @@
public function testSyncCalendar($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
return $params;
}
@@ -1002,54 +1001,54 @@
public function testAddEvent($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId1</ClientId>
- <ApplicationData>
- <StartTime xmlns="uri:Calendar">20230719T200032Z</StartTime>
- <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
- <DtStamp xmlns="uri:Calendar">20230719T194232Z</DtStamp>
- <EndTime xmlns="uri:Calendar">20230719T203032Z</EndTime>
- <UID xmlns="uri:Calendar">046f2e01-e8d0-47c6-a607-ba360251761d</UID>
- <OrganizerEmail xmlns="uri:Calendar">activesynctest@kolab.org</OrganizerEmail>
- <MeetingStatus xmlns="uri:Calendar">0</MeetingStatus>
- <ResponseRequested xmlns="uri:Calendar">0</ResponseRequested>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId1</ClientId>
+ <ApplicationData>
+ <StartTime xmlns="uri:Calendar">20230719T200032Z</StartTime>
+ <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
+ <DtStamp xmlns="uri:Calendar">20230719T194232Z</DtStamp>
+ <EndTime xmlns="uri:Calendar">20230719T203032Z</EndTime>
+ <UID xmlns="uri:Calendar">046f2e01-e8d0-47c6-a607-ba360251761d</UID>
+ <OrganizerEmail xmlns="uri:Calendar">activesynctest@kolab.org</OrganizerEmail>
+ <MeetingStatus xmlns="uri:Calendar">0</MeetingStatus>
+ <ResponseRequested xmlns="uri:Calendar">0</ResponseRequested>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Calendar", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("2", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Calendar", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("2", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
- $this->assertEquals("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals("1", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
+ $this->assertSame(1, $add->length);
+ $this->assertSame("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame("1", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
// $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
$params['serverId1'] = $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue;
@@ -1063,55 +1062,55 @@
public function testReaddEvent($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>2</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <Commands>
- <Add>
- <ClientId>clientId1</ClientId>
- <ApplicationData>
- <StartTime xmlns="uri:Calendar">20230719T200032Z</StartTime>
- <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
- <DtStamp xmlns="uri:Calendar">20230719T194232Z</DtStamp>
- <EndTime xmlns="uri:Calendar">20230719T203032Z</EndTime>
- <UID xmlns="uri:Calendar">046f2e01-e8d0-47c6-a607-ba360251761d</UID>
- <OrganizerEmail xmlns="uri:Calendar">activesynctest@kolab.org</OrganizerEmail>
- <MeetingStatus xmlns="uri:Calendar">0</MeetingStatus>
- <ResponseRequested xmlns="uri:Calendar">0</ResponseRequested>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>2</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <Commands>
+ <Add>
+ <ClientId>clientId1</ClientId>
+ <ApplicationData>
+ <StartTime xmlns="uri:Calendar">20230719T200032Z</StartTime>
+ <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
+ <DtStamp xmlns="uri:Calendar">20230719T194232Z</DtStamp>
+ <EndTime xmlns="uri:Calendar">20230719T203032Z</EndTime>
+ <UID xmlns="uri:Calendar">046f2e01-e8d0-47c6-a607-ba360251761d</UID>
+ <OrganizerEmail xmlns="uri:Calendar">activesynctest@kolab.org</OrganizerEmail>
+ <MeetingStatus xmlns="uri:Calendar">0</MeetingStatus>
+ <ResponseRequested xmlns="uri:Calendar">0</ResponseRequested>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$collections = $dom->getElementsByTagName('Collection');
- $this->assertEquals(1, $collections->length);
+ $this->assertSame(1, $collections->length);
$collection = $collections->item(0);
- $this->assertEquals("Class", $collection->childNodes->item(0)->nodeName);
- $this->assertEquals("Calendar", $collection->childNodes->item(0)->nodeValue);
- $this->assertEquals("SyncKey", $collection->childNodes->item(1)->nodeName);
- $this->assertEquals("3", $collection->childNodes->item(1)->nodeValue);
- $this->assertEquals("Status", $collection->childNodes->item(3)->nodeName);
- $this->assertEquals("1", $collection->childNodes->item(3)->nodeValue);
+ $this->assertSame("Class", $collection->childNodes->item(0)->nodeName);
+ $this->assertSame("Calendar", $collection->childNodes->item(0)->nodeValue);
+ $this->assertSame("SyncKey", $collection->childNodes->item(1)->nodeName);
+ $this->assertSame("3", $collection->childNodes->item(1)->nodeValue);
+ $this->assertSame("Status", $collection->childNodes->item(3)->nodeName);
+ $this->assertSame("1", $collection->childNodes->item(3)->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
- $this->assertEquals("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
- $this->assertEquals("5", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
- $this->assertEquals(0, $xpath->query("//ns:Commands")->length);
+ $this->assertSame(1, $add->length);
+ $this->assertSame("clientId1", $xpath->query("//ns:Responses/ns:Add/ns:ClientId")->item(0)->nodeValue);
+ $this->assertSame("5", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
+ $this->assertSame(0, $xpath->query("//ns:Commands")->length);
return $params;
}
@@ -1122,30 +1121,30 @@
public function testDeleteEvent($params): array
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
- <Collections>
- <Collection>
- <SyncKey>3</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <Commands>
- <Delete>
- <ServerId>{$params['serverId1']}</ServerId>
- </Delete>
- </Commands>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Tasks="uri:Tasks">
+ <Collections>
+ <Collection>
+ <SyncKey>3</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <Commands>
+ <Delete>
+ <ServerId>{$params['serverId1']}</ServerId>
+ </Delete>
+ </Commands>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
return $params;
}
@@ -1156,493 +1155,493 @@
public function testMeetingResponse($params): void
{
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
// @codingStandardsIgnoreStart
// Add the invitation to inbox
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:Syncroton="uri:Syncroton" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Email="uri:Email" xmlns:Email2="uri:Email2" xmlns:Tasks="uri:Tasks" xmlns:Calendar="uri:Calendar">
- <Collections>
- <Collection xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <Commands xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
- <Add xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
- <ClientId>clientid1</ClientId>
- <ApplicationData>
- <Email:DateReceived xmlns="uri:Email">2023-07-24T06:53:57.000Z</Email:DateReceived>
- <Email:From xmlns="uri:Email">"Doe, John" &lt;doe@kolab1.mkpf.ch&gt;</Email:From>
- <Email:InternetCPID xmlns="uri:Email">65001</Email:InternetCPID>
- <Email:Subject xmlns="uri:Email">You've been invited to "event1"</Email:Subject>
- <Email:To xmlns="uri:Email">admin@kolab1.mkpf.ch</Email:To>
- <Email:Read xmlns="uri:Email">1</Email:Read>
- <Email:Flag xmlns="uri:Email"/>
- <AirSyncBase:Body xmlns="uri:AirSyncBase">
- <AirSyncBase:Type>4</AirSyncBase:Type>
- <AirSyncBase:Data>MIME-Version: 1.0&#13;
- From: "Doe, John" &lt;doe@kolab1.mkpf.ch&gt;&#13;
- Date: Mon, 24 Jul 2023 08:53:55 +0200&#13;
- Message-ID: &lt;9cd8885d1339b976c7cb15db086e7bbc@kolab1.mkpf.ch&gt;&#13;
- To: admin@kolab1.mkpf.ch&#13;
- Subject: You've been invited to "event1"&#13;
- Content-Type: multipart/alternative;&#13;
- boundary="=_a32392e5fc9266e3eeba97347cbfc147"&#13;
- &#13;
- --=_a32392e5fc9266e3eeba97347cbfc147&#13;
- Content-Transfer-Encoding: quoted-printable&#13;
- Content-Type: text/plain; charset=UTF-8;&#13;
- format=flowed&#13;
- &#13;
- *event1*&#13;
- &#13;
- When: 2023-07-24 11:00 - 11:30 (Europe/Vaduz)&#13;
- &#13;
- Invitees: Doe, John &lt;doe@kolab1.mkpf.ch&gt;,&#13;
- admin@kolab1.mkpf.ch&#13;
- &#13;
- Please find attached an iCalendar file with all the event details which you=&#13;
- =20&#13;
- can import to your calendar application.&#13;
- --=_a32392e5fc9266e3eeba97347cbfc147&#13;
- Content-Transfer-Encoding: 8bit&#13;
- Content-Type: text/calendar; charset=UTF-8; method=REQUEST;&#13;
- name=event.ics&#13;
- &#13;
- BEGIN:VCALENDAR&#13;
- VERSION:2.0&#13;
- PRODID:-//Roundcube 1.5.3//Sabre VObject 4.5.3//EN&#13;
- CALSCALE:GREGORIAN&#13;
- METHOD:REQUEST&#13;
- BEGIN:VTIMEZONE&#13;
- TZID:Europe/Vaduz&#13;
- BEGIN:STANDARD&#13;
- DTSTART:20221030T010000&#13;
- TZOFFSETFROM:+0200&#13;
- TZOFFSETTO:+0100&#13;
- TZNAME:CET&#13;
- END:STANDARD&#13;
- BEGIN:STANDARD&#13;
- DTSTART:20231029T010000&#13;
- TZOFFSETFROM:+0200&#13;
- TZOFFSETTO:+0100&#13;
- TZNAME:CET&#13;
- END:STANDARD&#13;
- BEGIN:DAYLIGHT&#13;
- DTSTART:20230326T010000&#13;
- TZOFFSETFROM:+0100&#13;
- TZOFFSETTO:+0200&#13;
- TZNAME:CEST&#13;
- END:DAYLIGHT&#13;
- END:VTIMEZONE&#13;
- BEGIN:VEVENT&#13;
- UID:CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2&#13;
- DTSTAMP:20230724T065355Z&#13;
- CREATED:20230724T065354Z&#13;
- LAST-MODIFIED:20230724T065354Z&#13;
- DTSTART;TZID=Europe/Vaduz:20230724T110000&#13;
- DTEND;TZID=Europe/Vaduz:20230724T113000&#13;
- SUMMARY:event1&#13;
- SEQUENCE:0&#13;
- TRANSP:OPAQUE&#13;
- ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;CUTYPE=INDIVIDUAL;RSVP=&#13;
- TRUE:mailto:admin@kolab1.mkpf.ch&#13;
- ORGANIZER;CN="Doe, John":mailto:doe@kolab1.mkpf.ch&#13;
- END:VEVENT&#13;
- END:VCALENDAR&#13;
- &#13;
- --=_a32392e5fc9266e3eeba97347cbfc147--&#13;
- </AirSyncBase:Data>
- </AirSyncBase:Body>
- <AirSyncBase:NativeBodyType xmlns="uri:AirSyncBase">1</AirSyncBase:NativeBodyType>
- <Email:MessageClass xmlns="uri:Email">IPM.Note</Email:MessageClass>
- <Email:ContentClass xmlns="uri:Email">urn:content-classes:message</Email:ContentClass>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:Syncroton="uri:Syncroton" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Email="uri:Email" xmlns:Email2="uri:Email2" xmlns:Tasks="uri:Tasks" xmlns:Calendar="uri:Calendar">
+ <Collections>
+ <Collection xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <Commands xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
+ <Add xmlns:default="uri:Email" xmlns:default1="uri:AirSyncBase">
+ <ClientId>clientid1</ClientId>
+ <ApplicationData>
+ <Email:DateReceived xmlns="uri:Email">2023-07-24T06:53:57.000Z</Email:DateReceived>
+ <Email:From xmlns="uri:Email">"Doe, John" &lt;doe@kolab1.mkpf.ch&gt;</Email:From>
+ <Email:InternetCPID xmlns="uri:Email">65001</Email:InternetCPID>
+ <Email:Subject xmlns="uri:Email">You've been invited to "event1"</Email:Subject>
+ <Email:To xmlns="uri:Email">admin@kolab1.mkpf.ch</Email:To>
+ <Email:Read xmlns="uri:Email">1</Email:Read>
+ <Email:Flag xmlns="uri:Email"/>
+ <AirSyncBase:Body xmlns="uri:AirSyncBase">
+ <AirSyncBase:Type>4</AirSyncBase:Type>
+ <AirSyncBase:Data>MIME-Version: 1.0&#13;
+ From: "Doe, John" &lt;doe@kolab1.mkpf.ch&gt;&#13;
+ Date: Mon, 24 Jul 2023 08:53:55 +0200&#13;
+ Message-ID: &lt;9cd8885d1339b976c7cb15db086e7bbc@kolab1.mkpf.ch&gt;&#13;
+ To: admin@kolab1.mkpf.ch&#13;
+ Subject: You've been invited to "event1"&#13;
+ Content-Type: multipart/alternative;&#13;
+ boundary="=_a32392e5fc9266e3eeba97347cbfc147"&#13;
+ &#13;
+ --=_a32392e5fc9266e3eeba97347cbfc147&#13;
+ Content-Transfer-Encoding: quoted-printable&#13;
+ Content-Type: text/plain; charset=UTF-8;&#13;
+ format=flowed&#13;
+ &#13;
+ *event1*&#13;
+ &#13;
+ When: 2023-07-24 11:00 - 11:30 (Europe/Vaduz)&#13;
+ &#13;
+ Invitees: Doe, John &lt;doe@kolab1.mkpf.ch&gt;,&#13;
+ admin@kolab1.mkpf.ch&#13;
+ &#13;
+ Please find attached an iCalendar file with all the event details which you=&#13;
+ =20&#13;
+ can import to your calendar application.&#13;
+ --=_a32392e5fc9266e3eeba97347cbfc147&#13;
+ Content-Transfer-Encoding: 8bit&#13;
+ Content-Type: text/calendar; charset=UTF-8; method=REQUEST;&#13;
+ name=event.ics&#13;
+ &#13;
+ BEGIN:VCALENDAR&#13;
+ VERSION:2.0&#13;
+ PRODID:-//Roundcube 1.5.3//Sabre VObject 4.5.3//EN&#13;
+ CALSCALE:GREGORIAN&#13;
+ METHOD:REQUEST&#13;
+ BEGIN:VTIMEZONE&#13;
+ TZID:Europe/Vaduz&#13;
+ BEGIN:STANDARD&#13;
+ DTSTART:20221030T010000&#13;
+ TZOFFSETFROM:+0200&#13;
+ TZOFFSETTO:+0100&#13;
+ TZNAME:CET&#13;
+ END:STANDARD&#13;
+ BEGIN:STANDARD&#13;
+ DTSTART:20231029T010000&#13;
+ TZOFFSETFROM:+0200&#13;
+ TZOFFSETTO:+0100&#13;
+ TZNAME:CET&#13;
+ END:STANDARD&#13;
+ BEGIN:DAYLIGHT&#13;
+ DTSTART:20230326T010000&#13;
+ TZOFFSETFROM:+0100&#13;
+ TZOFFSETTO:+0200&#13;
+ TZNAME:CEST&#13;
+ END:DAYLIGHT&#13;
+ END:VTIMEZONE&#13;
+ BEGIN:VEVENT&#13;
+ UID:CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2&#13;
+ DTSTAMP:20230724T065355Z&#13;
+ CREATED:20230724T065354Z&#13;
+ LAST-MODIFIED:20230724T065354Z&#13;
+ DTSTART;TZID=Europe/Vaduz:20230724T110000&#13;
+ DTEND;TZID=Europe/Vaduz:20230724T113000&#13;
+ SUMMARY:event1&#13;
+ SEQUENCE:0&#13;
+ TRANSP:OPAQUE&#13;
+ ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;CUTYPE=INDIVIDUAL;RSVP=&#13;
+ TRUE:mailto:admin@kolab1.mkpf.ch&#13;
+ ORGANIZER;CN="Doe, John":mailto:doe@kolab1.mkpf.ch&#13;
+ END:VEVENT&#13;
+ END:VCALENDAR&#13;
+ &#13;
+ --=_a32392e5fc9266e3eeba97347cbfc147--&#13;
+ </AirSyncBase:Data>
+ </AirSyncBase:Body>
+ <AirSyncBase:NativeBodyType xmlns="uri:AirSyncBase">1</AirSyncBase:NativeBodyType>
+ <Email:MessageClass xmlns="uri:Email">IPM.Note</Email:MessageClass>
+ <Email:ContentClass xmlns="uri:Email">urn:content-classes:message</Email:ContentClass>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$status = $dom->getElementsByTagName('Status');
- $this->assertEquals("1", $status[0]->nodeValue);
+ $this->assertSame("1", $status[0]->nodeValue);
$xpath = $this->xpath($dom);
$add = $xpath->query("//ns:Responses/ns:Add");
- $this->assertEquals(1, $add->length);
- $this->assertEquals("1", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
+ $this->assertSame(1, $add->length);
+ $this->assertSame("1", $xpath->query("//ns:Responses/ns:Add/ns:Status")->item(0)->nodeValue);
$serverId = $xpath->query("//ns:Responses/ns:Add/ns:ServerId")->item(0)->nodeValue;
// List the MeetingRequest
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>1</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>1</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals('IPM.Schedule.Meeting.Request', $xpath->query("//ns:Add/ns:ApplicationData/Email:MessageClass")->item(0)->nodeValue);
- $this->assertEquals('urn:content-classes:calendarmessage', $xpath->query("//ns:Add/ns:ApplicationData/Email:ContentClass")->item(0)->nodeValue);
+ $this->assertSame('IPM.Schedule.Meeting.Request', $xpath->query("//ns:Add/ns:ApplicationData/Email:MessageClass")->item(0)->nodeValue);
+ $this->assertSame('urn:content-classes:calendarmessage', $xpath->query("//ns:Add/ns:ApplicationData/Email:ContentClass")->item(0)->nodeValue);
// $this->assertEquals('BAAAAIIA4AB0xbcQGoLgCAAAAAAAAAAAAAAAAAAAAAAAAAAAPgAAAHZDYWwtVWlkAQAAAENDNTQxOTFGNjU2REZCQjI5NEJFMEFDMThFNzA5MzE1LTUyOUNCQkRENDdBQ0REQzIA', $xpath->query("//ns:Add/ns:ApplicationData/Email:MeetingRequest/Email:GlobalObjId")->item(0)->nodeValue);
- $this->assertEquals('1', $xpath->query("//ns:Add/ns:ApplicationData/Email:MeetingRequest/Email2:MeetingMessageType")->item(0)->nodeValue);
+ $this->assertSame('1', $xpath->query("//ns:Add/ns:ApplicationData/Email:MeetingRequest/Email2:MeetingMessageType")->item(0)->nodeValue);
// Send a meeting response to accept
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <MeetingResponse xmlns="uri:MeetingResponse">
- <Request>
- <CollectionId>{$params['inboxId']}</CollectionId>
- <UserResponse>1</UserResponse>
- <RequestId>{$serverId}</RequestId>
- </Request>
- </MeetingResponse>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <MeetingResponse xmlns="uri:MeetingResponse">
+ <Request>
+ <CollectionId>{$params['inboxId']}</CollectionId>
+ <UserResponse>1</UserResponse>
+ <RequestId>{$serverId}</RequestId>
+ </Request>
+ </MeetingResponse>
+ EOF;
$response = $this->request($request, 'MeetingResponse');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals("1", $xpath->query("//ns:MeetingResponse/ns:Result/ns:Status")->item(0)->nodeValue);
+ $this->assertSame("1", $xpath->query("//ns:MeetingResponse/ns:Result/ns:Status")->item(0)->nodeValue);
$this->assertStringContainsString("CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2", $xpath->query("//ns:MeetingResponse/ns:Result/ns:CalendarId")->item(0)->nodeValue);
// Fetch the event and validate
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>1</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>1</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals("CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2", $xpath->query("//ns:Add/ns:ApplicationData/Calendar:UID")->item(0)->nodeValue);
- $this->assertEquals('activesynctest@kolab.org', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:Email")->item(0)->nodeValue);
- $this->assertEquals('3', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:AttendeeStatus")->item(0)->nodeValue);
+ $this->assertSame("CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2", $xpath->query("//ns:Add/ns:ApplicationData/Calendar:UID")->item(0)->nodeValue);
+ $this->assertSame('activesynctest@kolab.org', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:Email")->item(0)->nodeValue);
+ $this->assertSame('3', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:AttendeeStatus")->item(0)->nodeValue);
$serverId = $xpath->query("//ns:Add/ns:ServerId")->item(0)->nodeValue;
$add = $xpath->query("//ns:Add");
- $this->assertEquals(1, $add->length);
+ $this->assertSame(1, $add->length);
// Send a dummy event with an invalid attendeestatus (just like outlook does)
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
- <Collections>
- <Collection>
- <SyncKey>2</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- <Commands>
- <Add>
- <Class>Calendar</Class>
- <ClientId>{B94F1272-ED5F-4613-90D6-731491596147}</ClientId>
- <ApplicationData>
- <Timezone xmlns="uri:Calendar">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Timezone>
- <DtStamp xmlns="uri:Calendar">20230724T173929Z</DtStamp>
- <StartTime xmlns="uri:Calendar">20230724T090000Z</StartTime>
- <Subject xmlns="uri:Calendar">event1</Subject>
- <UID xmlns="uri:Calendar">CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2</UID>
- <OrganizerName xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerName>
- <OrganizerEmail xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerEmail>
- <Attendees xmlns="uri:Calendar">
- <Attendee>
- <Email>activesynctest@kolab.org</Email>
- <Name>activesynctest@kolab.org</Name>
- <AttendeeStatus>0</AttendeeStatus>
- <AttendeeType>1</AttendeeType>
- </Attendee>
- </Attendees>
- <EndTime xmlns="uri:Calendar">20230724T093000Z</EndTime>
- <Sensitivity xmlns="uri:Calendar">0</Sensitivity>
- <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
- <AllDayEvent xmlns="uri:Calendar">0</AllDayEvent>
- <Reminder xmlns="uri:Calendar">15</Reminder>
- <MeetingStatus xmlns="uri:Calendar">3</MeetingStatus>
- <ResponseRequested xmlns="uri:Calendar">1</ResponseRequested>
- <DisallowNewTimeProposal xmlns="uri:Calendar">0</DisallowNewTimeProposal>
- </ApplicationData>
- </Add>
- </Commands>
- </Collection>
- </Collections>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
+ <Collections>
+ <Collection>
+ <SyncKey>2</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ <Commands>
+ <Add>
+ <Class>Calendar</Class>
+ <ClientId>{B94F1272-ED5F-4613-90D6-731491596147}</ClientId>
+ <ApplicationData>
+ <Timezone xmlns="uri:Calendar">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Timezone>
+ <DtStamp xmlns="uri:Calendar">20230724T173929Z</DtStamp>
+ <StartTime xmlns="uri:Calendar">20230724T090000Z</StartTime>
+ <Subject xmlns="uri:Calendar">event1</Subject>
+ <UID xmlns="uri:Calendar">CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2</UID>
+ <OrganizerName xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerName>
+ <OrganizerEmail xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerEmail>
+ <Attendees xmlns="uri:Calendar">
+ <Attendee>
+ <Email>activesynctest@kolab.org</Email>
+ <Name>activesynctest@kolab.org</Name>
+ <AttendeeStatus>0</AttendeeStatus>
+ <AttendeeType>1</AttendeeType>
+ </Attendee>
+ </Attendees>
+ <EndTime xmlns="uri:Calendar">20230724T093000Z</EndTime>
+ <Sensitivity xmlns="uri:Calendar">0</Sensitivity>
+ <BusyStatus xmlns="uri:Calendar">2</BusyStatus>
+ <AllDayEvent xmlns="uri:Calendar">0</AllDayEvent>
+ <Reminder xmlns="uri:Calendar">15</Reminder>
+ <MeetingStatus xmlns="uri:Calendar">3</MeetingStatus>
+ <ResponseRequested xmlns="uri:Calendar">1</ResponseRequested>
+ <DisallowNewTimeProposal xmlns="uri:Calendar">0</DisallowNewTimeProposal>
+ </ApplicationData>
+ </Add>
+ </Commands>
+ </Collection>
+ </Collections>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals("5", $xpath->query("//ns:Add/ns:Status")->item(0)->nodeValue);
+ $this->assertSame("5", $xpath->query("//ns:Add/ns:Status")->item(0)->nodeValue);
// Fetch the event and validate again
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>0</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>0</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
- <Collections>
- <Collection>
- <SyncKey>1</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>1</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- </Collection>
- </Collections>
- <WindowSize>16</WindowSize>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
+ <Collections>
+ <Collection>
+ <SyncKey>1</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>1</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ </Collection>
+ </Collections>
+ <WindowSize>16</WindowSize>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals("CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2", $xpath->query("//ns:Add/ns:ApplicationData/Calendar:UID")->item(0)->nodeValue);
- $this->assertEquals('activesynctest@kolab.org', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:Email")->item(0)->nodeValue);
- $this->assertEquals('3', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:AttendeeStatus")->item(0)->nodeValue);
+ $this->assertSame("CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2", $xpath->query("//ns:Add/ns:ApplicationData/Calendar:UID")->item(0)->nodeValue);
+ $this->assertSame('activesynctest@kolab.org', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:Email")->item(0)->nodeValue);
+ $this->assertSame('3', $xpath->query("//ns:Add/ns:ApplicationData/Calendar:Attendees/Calendar:Attendee/Calendar:AttendeeStatus")->item(0)->nodeValue);
// Send a dummy event to change to tentative (just like outlook does
$request = <<<EOF
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
- <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
- <Collections>
- <Collection>
- <SyncKey>2</SyncKey>
- <CollectionId>{$params['calendarId']}</CollectionId>
- <DeletesAsMoves>0</DeletesAsMoves>
- <GetChanges>0</GetChanges>
- <WindowSize>512</WindowSize>
- <Options>
- <FilterType>0</FilterType>
- <BodyPreference xmlns="uri:AirSyncBase">
- <Type>1</Type>
- <AllOrNone>1</AllOrNone>
- </BodyPreference>
- </Options>
- <Commands>
- <Change>
- <Class>Calendar</Class>
- <ServerId>{$serverId}</ServerId>
- <ApplicationData>
- <Timezone xmlns="uri:Calendar">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Timezone>
- <DtStamp xmlns="uri:Calendar">20230724T173929Z</DtStamp>
- <StartTime xmlns="uri:Calendar">20230724T090000Z</StartTime>
- <Subject xmlns="uri:Calendar">event1</Subject>
- <UID xmlns="uri:Calendar">CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2</UID>
- <OrganizerName xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerName>
- <OrganizerEmail xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerEmail>
- <Attendees xmlns="uri:Calendar">
- <Attendee>
- <Email>activesynctest@kolab.org</Email>
- <Name>activesynctest@kolab.org</Name>
- <AttendeeStatus>0</AttendeeStatus>
- <AttendeeType>1</AttendeeType>
- </Attendee>
- </Attendees>
- <EndTime xmlns="uri:Calendar">20230724T093000Z</EndTime>
- <Sensitivity xmlns="uri:Calendar">0</Sensitivity>
- <BusyStatus xmlns="uri:Calendar">1</BusyStatus>
- <AllDayEvent xmlns="uri:Calendar">0</AllDayEvent>
- <Reminder xmlns="uri:Calendar">15</Reminder>
- <MeetingStatus xmlns="uri:Calendar">3</MeetingStatus>
- <ResponseRequested xmlns="uri:Calendar">1</ResponseRequested>
- <DisallowNewTimeProposal xmlns="uri:Calendar">0</DisallowNewTimeProposal>
- </ApplicationData>
- </Change>
- </Commands>
- </Collection>
- </Collections>
- </Sync>
- EOF;
+ <?xml version="1.0" encoding="utf-8"?>
+ <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
+ <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase" xmlns:Calendar="uri:Calendar">
+ <Collections>
+ <Collection>
+ <SyncKey>2</SyncKey>
+ <CollectionId>{$params['calendarId']}</CollectionId>
+ <DeletesAsMoves>0</DeletesAsMoves>
+ <GetChanges>0</GetChanges>
+ <WindowSize>512</WindowSize>
+ <Options>
+ <FilterType>0</FilterType>
+ <BodyPreference xmlns="uri:AirSyncBase">
+ <Type>1</Type>
+ <AllOrNone>1</AllOrNone>
+ </BodyPreference>
+ </Options>
+ <Commands>
+ <Change>
+ <Class>Calendar</Class>
+ <ServerId>{$serverId}</ServerId>
+ <ApplicationData>
+ <Timezone xmlns="uri:Calendar">AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==</Timezone>
+ <DtStamp xmlns="uri:Calendar">20230724T173929Z</DtStamp>
+ <StartTime xmlns="uri:Calendar">20230724T090000Z</StartTime>
+ <Subject xmlns="uri:Calendar">event1</Subject>
+ <UID xmlns="uri:Calendar">CC54191F656DFBB294BE0AC18E709315-529CBBDD47ACDDC2</UID>
+ <OrganizerName xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerName>
+ <OrganizerEmail xmlns="uri:Calendar">doe@kolab1.mkpf.ch</OrganizerEmail>
+ <Attendees xmlns="uri:Calendar">
+ <Attendee>
+ <Email>activesynctest@kolab.org</Email>
+ <Name>activesynctest@kolab.org</Name>
+ <AttendeeStatus>0</AttendeeStatus>
+ <AttendeeType>1</AttendeeType>
+ </Attendee>
+ </Attendees>
+ <EndTime xmlns="uri:Calendar">20230724T093000Z</EndTime>
+ <Sensitivity xmlns="uri:Calendar">0</Sensitivity>
+ <BusyStatus xmlns="uri:Calendar">1</BusyStatus>
+ <AllDayEvent xmlns="uri:Calendar">0</AllDayEvent>
+ <Reminder xmlns="uri:Calendar">15</Reminder>
+ <MeetingStatus xmlns="uri:Calendar">3</MeetingStatus>
+ <ResponseRequested xmlns="uri:Calendar">1</ResponseRequested>
+ <DisallowNewTimeProposal xmlns="uri:Calendar">0</DisallowNewTimeProposal>
+ </ApplicationData>
+ </Change>
+ </Commands>
+ </Collection>
+ </Collections>
+ </Sync>
+ EOF;
$response = $this->request($request, 'Sync');
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$dom = self::fromWbxml($response->getBody());
$xpath = $this->xpath($dom);
- $this->assertEquals("1", $xpath->query("//ns:Collection/ns:Status")->item(0)->nodeValue);
+ $this->assertSame("1", $xpath->query("//ns:Collection/ns:Status")->item(0)->nodeValue);
// @codingStandardsIgnoreEnd
}
diff --git a/src/tests/Infrastructure/AutodiscoverTest.php b/src/tests/Infrastructure/AutodiscoverTest.php
--- a/src/tests/Infrastructure/AutodiscoverTest.php
+++ b/src/tests/Infrastructure/AutodiscoverTest.php
@@ -2,21 +2,19 @@
namespace Tests\Infrastructure;
+use GuzzleHttp\Client;
use Tests\TestCase;
class AutodiscoverTest extends TestCase
{
- private static ?\GuzzleHttp\Client $client = null;
+ private static ?Client $client = null;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
if (!self::$client) {
- self::$client = new \GuzzleHttp\Client([
+ self::$client = new Client([
'http_errors' => false, // No exceptions
'base_uri' => \config('services.autodiscover.uri'),
'verify' => false,
@@ -26,33 +24,30 @@
}
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
public function testWellKnownOutlook()
{
- $body = <<<EOF
- <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
- <Request>
- <EMailAddress>admin@example.local</EMailAddress>
- <AcceptableResponseSchema>
- http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a
- </AcceptableResponseSchema>
- </Request>
- </Autodiscover>
- EOF;
+ $body = <<<'EOF'
+ <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/outlook/requestschema/2006">
+ <Request>
+ <EMailAddress>admin@example.local</EMailAddress>
+ <AcceptableResponseSchema>
+ http://schemas.microsoft.com/exchange/autodiscover/outlook/responseschema/2006a
+ </AcceptableResponseSchema>
+ </Request>
+ </Autodiscover>
+ EOF;
$response = self::$client->request('POST', 'autodiscover/autodiscover.xml', [
'headers' => [
- "Content-Type" => "text/xml; charset=utf-8"
+ "Content-Type" => "text/xml; charset=utf-8",
],
- 'body' => $body
- ]);
- $this->assertEquals($response->getStatusCode(), 200);
+ 'body' => $body,
+ ]);
+ $this->assertSame($response->getStatusCode(), 200);
$data = $response->getBody();
$this->assertTrue(str_contains($data, '<Server>example.local</Server>'));
$this->assertTrue(str_contains($data, 'admin@example.local'));
@@ -60,23 +55,23 @@
public function testWellKnownActivesync()
{
- $body = <<<EOF
- <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006">
- <Request>
- <EMailAddress>admin@example.local</EMailAddress>
- <AcceptableResponseSchema>
- http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006
- </AcceptableResponseSchema>
- </Request>
- </Autodiscover>
- EOF;
+ $body = <<<'EOF'
+ <Autodiscover xmlns="http://schemas.microsoft.com/exchange/autodiscover/mobilesync/requestschema/2006">
+ <Request>
+ <EMailAddress>admin@example.local</EMailAddress>
+ <AcceptableResponseSchema>
+ http://schemas.microsoft.com/exchange/autodiscover/mobilesync/responseschema/2006
+ </AcceptableResponseSchema>
+ </Request>
+ </Autodiscover>
+ EOF;
$response = self::$client->request('POST', 'autodiscover/autodiscover.xml', [
'headers' => [
- "Content-Type" => "text/xml; charset=utf-8"
+ "Content-Type" => "text/xml; charset=utf-8",
],
- 'body' => $body
- ]);
- $this->assertEquals($response->getStatusCode(), 200);
+ 'body' => $body,
+ ]);
+ $this->assertSame($response->getStatusCode(), 200);
$data = $response->getBody();
$this->assertTrue(str_contains($data, '<Url>https://example.local/Microsoft-Server-ActiveSync</Url>'));
$this->assertTrue(str_contains($data, 'admin@example.local'));
@@ -88,6 +83,6 @@
'GET',
'.well-known/autoconfig/mail/config-v1.1.xml?emailaddress=fred@example.com'
);
- $this->assertEquals($response->getStatusCode(), 200);
+ $this->assertSame($response->getStatusCode(), 200);
}
}
diff --git a/src/tests/Infrastructure/DavTest.php b/src/tests/Infrastructure/DavTest.php
--- a/src/tests/Infrastructure/DavTest.php
+++ b/src/tests/Infrastructure/DavTest.php
@@ -2,6 +2,8 @@
namespace Tests\Infrastructure;
+use App\User;
+use GuzzleHttp\Client;
use Tests\TestCase;
/**
@@ -9,15 +11,12 @@
*/
class DavTest extends TestCase
{
- private ?\GuzzleHttp\Client $client = null;
- private ?\App\User $user = null;
+ private ?Client $client = null;
+ private ?User $user = null;
private bool $isCyrus;
private string $path;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -26,11 +25,11 @@
}
$baseUri = \config('services.dav.uri');
- $this->isCyrus = strpos($baseUri, '/iRony') === false;
+ $this->isCyrus = !str_contains($baseUri, '/iRony');
$this->path = $this->isCyrus ? '/dav' : '/iRony';
if (!$this->client) {
- $this->client = new \GuzzleHttp\Client([
+ $this->client = new Client([
'http_errors' => false, // No exceptions
'base_uri' => $baseUri,
'verify' => false,
@@ -40,7 +39,7 @@
'headers' => [
'Content-Type' => 'application/xml; charset=utf-8',
'Depth' => '1',
- ]
+ ],
]);
}
}
@@ -50,7 +49,7 @@
$body = "<d:propfind xmlns:d='DAV:'><d:prop><d:current-user-principal/></d:prop></d:propfind>";
$response = $this->client->request('PROPFIND', '', ['body' => $body]);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
$data = $response->getBody();
$email = $this->user->email;
@@ -73,7 +72,7 @@
'Content-Type' => 'application/xml; charset=utf-8',
'Depth' => '1',
'body' => $body,
- 'auth' => ['invaliduser@kolab.org', 'invalid']
+ 'auth' => ['invaliduser@kolab.org', 'invalid'],
];
$response = $this->client->request('PROPFIND', '', $params);
@@ -93,27 +92,27 @@
$body = "<d:propfind xmlns:d='DAV:'><d:prop><d:current-user-principal/></d:prop></d:propfind>";
$response = $this->client->request('PROPFIND', '', [
'body' => $body,
- 'auth' => ['davtest', 'simple123']
+ 'auth' => ['davtest', 'simple123'],
]);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
}
public function testDiscoverCalendarHomeset(): void
{
- $body = <<<EOF
- <d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:prop>
- <c:calendar-home-set />
- </d:prop>
- </d:propfind>
- EOF;
+ $body = <<<'EOF'
+ <d:propfind xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:prop>
+ <c:calendar-home-set />
+ </d:prop>
+ </d:propfind>
+ EOF;
$email = $this->user->email;
$href = $this->isCyrus ? "principals/user/{$email}" : '';
$response = $this->client->request('PROPFIND', $href, ['body' => $body]);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
$data = $response->getBody();
if ($this->isCyrus) {
@@ -125,16 +124,16 @@
public function testDiscoverCalendars(): string
{
- $body = <<<EOF
- <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:prop>
- <d:resourcetype />
- <d:displayname />
- <cs:getctag />
- <c:supported-calendar-component-set />
- </d:prop>
- </d:propfind>
- EOF;
+ $body = <<<'EOF'
+ <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:prop>
+ <d:resourcetype />
+ <d:displayname />
+ <cs:getctag />
+ <c:supported-calendar-component-set />
+ </d:prop>
+ </d:propfind>
+ EOF;
$params = [
'headers' => [
@@ -148,7 +147,7 @@
$response = $this->client->request('PROPFIND', $href, $params);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
$data = $response->getBody();
if ($this->isCyrus) {
@@ -162,7 +161,7 @@
$response = $doc->getElementsByTagName('response')->item(1);
$doc->getElementsByTagName('href')->item(0);
- $this->assertEquals('d:href', $response->childNodes->item(0)->nodeName);
+ $this->assertSame('d:href', $response->childNodes->item(0)->nodeName);
$href = $response->childNodes->item(0)->nodeValue;
return $href;
@@ -173,19 +172,19 @@
*/
public function testPropfindCalendar($href): void
{
- $body = <<<EOF
- <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:prop>
- <d:resourcetype />
- <d:owner/>
- <d:current-user-principal/>
- <d:current-user-privilege-set/>
- <d:supported-report-set/>
- <cs:getctag />
- <c:supported-calendar-component-set />
- </d:prop>
- </d:propfind>
- EOF;
+ $body = <<<'EOF'
+ <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:prop>
+ <d:resourcetype />
+ <d:owner/>
+ <d:current-user-principal/>
+ <d:current-user-privilege-set/>
+ <d:supported-report-set/>
+ <cs:getctag />
+ <c:supported-calendar-component-set />
+ </d:prop>
+ </d:propfind>
+ EOF;
$params = [
'headers' => [
@@ -196,9 +195,9 @@
$response = $this->client->request('PROPFIND', $href, $params);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
$data = $response->getBody();
- $this->assertStringContainsString("<d:href>$href</d:href>", $data);
+ $this->assertStringContainsString("<d:href>{$href}</d:href>", $data);
}
/**
@@ -209,19 +208,19 @@
*/
public function testPropfindCalendarWithoutAuth($href): void
{
- $body = <<<EOF
- <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:prop>
- <d:resourcetype />
- <d:owner/>
- <d:current-user-principal/>
- <d:current-user-privilege-set/>
- <d:supported-report-set/>
- <cs:getctag />
- <c:supported-calendar-component-set />
- </d:prop>
- </d:propfind>
- EOF;
+ $body = <<<'EOF'
+ <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:prop>
+ <d:resourcetype />
+ <d:owner/>
+ <d:current-user-principal/>
+ <d:current-user-privilege-set/>
+ <d:supported-report-set/>
+ <cs:getctag />
+ <c:supported-calendar-component-set />
+ </d:prop>
+ </d:propfind>
+ EOF;
$params = [
'headers' => [
@@ -233,14 +232,14 @@
$response = $this->client->request('PROPFIND', $href, $params);
- $this->assertEquals(401, $response->getStatusCode());
+ $this->assertSame(401, $response->getStatusCode());
$this->assertStringContainsString('Basic realm=', $response->getHeader('WWW-Authenticate')[0]);
$data = $response->getBody();
if ($this->isCyrus) {
$this->assertStringContainsString("Unauthorized", $data);
} else {
- $this->assertStringContainsString("<s:exception>Sabre\DAV\Exception\NotAuthenticated</s:exception>", $data);
+ $this->assertStringContainsString("<s:exception>Sabre\\DAV\\Exception\\NotAuthenticated</s:exception>", $data);
}
}
@@ -251,22 +250,22 @@
{
$response = $this->client->request('OPTIONS', "principals/{$this->user->email}");
- $this->assertEquals(200, $response->getStatusCode());
+ $this->assertSame(200, $response->getStatusCode());
$this->assertStringContainsString('PROPFIND', implode(', ', $response->getHeader('Allow')));
}
public function testWellKnown(): void
{
- $body = <<<EOF
- <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:prop>
- <d:resourcetype />
- <d:displayname />
- <cs:getctag />
- <c:supported-calendar-component-set />
- </d:prop>
- </d:propfind>
- EOF;
+ $body = <<<'EOF'
+ <d:propfind xmlns:d="DAV:" xmlns:cs="http://calendarserver.org/ns/" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:prop>
+ <d:resourcetype />
+ <d:displayname />
+ <cs:getctag />
+ <c:supported-calendar-component-set />
+ </d:prop>
+ </d:propfind>
+ EOF;
$email = $this->user->email;
$path = trim(\config('services.dav.uri'), '/');
@@ -282,29 +281,29 @@
// The base URL needs to work as a redirect
$response = $this->client->request('PROPFIND', "/.well-known/caldav/", $params);
- $this->assertEquals(301, $response->getStatusCode());
+ $this->assertSame(301, $response->getStatusCode());
$redirectTarget = $response->getHeader('location')[0];
- $this->assertEquals($path . '/calendars', trim($redirectTarget, '/'));
+ $this->assertSame($path . '/calendars', trim($redirectTarget, '/'));
// Follow the redirect
$response = $this->client->request('PROPFIND', $redirectTarget, $params);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
// Any URL should result in a redirect to the same path
$url = $this->isCyrus ? "user/{$email}" : "calendars/{$email}";
$response = $this->client->request('PROPFIND', "/.well-known/caldav/{$url}", $params);
- $this->assertEquals(301, $response->getStatusCode());
+ $this->assertSame(301, $response->getStatusCode());
$redirectTarget = $response->getHeader('location')[0];
$expected = $path . ($this->isCyrus ? "/calendars/user/{$email}" : "/calendars/{$email}");
- $this->assertEquals($expected, $redirectTarget);
+ $this->assertSame($expected, $redirectTarget);
// Follow the redirect
$response = $this->client->request('PROPFIND', $redirectTarget, $params);
- $this->assertEquals(207, $response->getStatusCode());
+ $this->assertSame(207, $response->getStatusCode());
$data = $response->getBody();
if ($this->isCyrus) {
diff --git a/src/tests/Infrastructure/IMAPTest.php b/src/tests/Infrastructure/IMAPTest.php
--- a/src/tests/Infrastructure/IMAPTest.php
+++ b/src/tests/Infrastructure/IMAPTest.php
@@ -3,6 +3,7 @@
namespace Tests\Infrastructure;
use App\Backends\IMAP;
+use App\User;
use Tests\TestCase;
/**
@@ -10,8 +11,8 @@
*/
class IMAPTest extends TestCase
{
- private static ?\App\User $user = null;
- private $imap = null;
+ private static ?User $user = null;
+ private $imap;
/**
* Get configured/initialized rcube_imap_generic instance
@@ -33,10 +34,7 @@
return $this->imap = $init->invokeArgs(null, [$config]);
}
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -53,23 +51,23 @@
$mailbox = "user/{$email}/test";
$imap->createFolder($mailbox);
- $this->assertEquals(1, count($imap->listMailboxes('', $mailbox)));
+ $this->assertSame(1, count($imap->listMailboxes('', $mailbox)));
$imap->setACL($mailbox, 'cyrus-admin', 'c');
$this->assertTrue($imap->setMetadata($mailbox, [
'/shared/vendor/kolab/folder-type' => 'event',
- '/private/vendor/kolab/folder-type' => 'event'
+ '/private/vendor/kolab/folder-type' => 'event',
]));
$metadata = $imap->getMetadata($mailbox, [
'/shared/vendor/kolab/folder-type',
- '/private/vendor/kolab/folder-type'
+ '/private/vendor/kolab/folder-type',
]);
- $this->assertEquals('event', $metadata[$mailbox]['/shared/vendor/kolab/folder-type']);
- $this->assertEquals('event', $metadata[$mailbox]['/private/vendor/kolab/folder-type']);
+ $this->assertSame('event', $metadata[$mailbox]['/shared/vendor/kolab/folder-type']);
+ $this->assertSame('event', $metadata[$mailbox]['/private/vendor/kolab/folder-type']);
$this->assertTrue($imap->deleteFolder($mailbox));
- $this->assertEquals(0, count($imap->listMailboxes('', $mailbox)));
+ $this->assertSame(0, count($imap->listMailboxes('', $mailbox)));
}
/**
diff --git a/src/tests/Infrastructure/RoundcubeTest.php b/src/tests/Infrastructure/RoundcubeTest.php
--- a/src/tests/Infrastructure/RoundcubeTest.php
+++ b/src/tests/Infrastructure/RoundcubeTest.php
@@ -2,17 +2,15 @@
namespace Tests\Infrastructure;
+use App\User;
use Tests\Browser;
use Tests\TestCaseDusk;
class RoundcubeTest extends TestCaseDusk
{
- private static ?\App\User $user = null;
+ private static ?User $user = null;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
Browser::$baseUrl = \config("services.webmail.uri");
@@ -22,17 +20,14 @@
}
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
parent::tearDown();
}
public function testLogin()
{
- $this->browse(function (Browser $browser) {
+ $this->browse(static function (Browser $browser) {
$browser->visit('/')
->type('#rcmloginuser', self::$user->email)
->type('#rcmloginpwd', 'simple123')
@@ -51,7 +46,7 @@
->waitUntil('!rcmail.busy')
->assertSee('Calendar');
- //TODO requires the default folders to be created
+ // TODO requires the default folders to be created
// $browser->press('.button-files')
// ->waitUntil('!rcmail.busy')
// ->assertSeeIn('#files-folder-list', 'Files');
diff --git a/src/tests/Infrastructure/WOPITest.php b/src/tests/Infrastructure/WOPITest.php
--- a/src/tests/Infrastructure/WOPITest.php
+++ b/src/tests/Infrastructure/WOPITest.php
@@ -2,17 +2,16 @@
namespace Tests\Infrastructure;
+use App\User;
+use GuzzleHttp\Client;
use Tests\TestCase;
class WOPITest extends TestCase
{
- private static ?\GuzzleHttp\Client $client = null;
- private static ?\App\User $user = null;
+ private static ?Client $client = null;
+ private static ?User $user = null;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,12 +20,12 @@
}
if (!self::$client) {
- self::$client = new \GuzzleHttp\Client([
+ self::$client = new Client([
'base_uri' => \config('services.wopi.uri'),
'verify' => false,
'auth' => [self::$user->email, 'simple123'],
'connect_timeout' => 10,
- 'timeout' => 10
+ 'timeout' => 10,
]);
}
}
@@ -34,23 +33,23 @@
public function testAccess()
{
$response = self::$client->request('GET', 'api/?method=authenticate&version=4');
- $this->assertEquals($response->getStatusCode(), 200);
+ $this->assertSame($response->getStatusCode(), 200);
$json = json_decode($response->getBody(), true);
- $this->assertEquals('OK', $json['status']);
+ $this->assertSame('OK', $json['status']);
$token = $json['result']['token'];
$this->assertTrue(!empty($token));
- //FIXME the session token doesn't seem to be required here?
+ // FIXME the session token doesn't seem to be required here?
$response = self::$client->request('GET', 'api/?method=mimetypes', [
'headers' => [
- 'X-Session_token' => $token
- ]
+ 'X-Session_token' => $token,
+ ],
]);
- $this->assertEquals($response->getStatusCode(), 200);
+ $this->assertSame($response->getStatusCode(), 200);
$json = json_decode($response->getBody(), true);
- $this->assertEquals('OK', $json['status']);
- $this->assertEquals('OK', $json['status']);
+ $this->assertSame('OK', $json['status']);
+ $this->assertSame('OK', $json['status']);
$this->assertContains('image/png', $json['result']['view']);
$this->assertArrayHasKey('text/plain', $json['result']['edit']);
}
diff --git a/src/tests/StripeMockClient.php b/src/tests/StripeMockClient.php
--- a/src/tests/StripeMockClient.php
+++ b/src/tests/StripeMockClient.php
@@ -11,7 +11,7 @@
public function request($method, $absUrl, $headers, $params, $hasFile)
{
if (empty($this->responses)) {
- throw new \Exception("StripeMockClient: Missing response for $absUrl.");
+ throw new \Exception("StripeMockClient: Missing response for {$absUrl}.");
}
$response = array_shift($this->responses);
diff --git a/src/tests/StripeMocksTrait.php b/src/tests/StripeMocksTrait.php
--- a/src/tests/StripeMocksTrait.php
+++ b/src/tests/StripeMocksTrait.php
@@ -9,7 +9,7 @@
/**
* Mock Stripe's HTTP client
*
- * @return \Tests\StripeMockClient
+ * @return StripeMockClient
*/
public function mockStripe()
{
diff --git a/src/tests/TestCase.php b/src/tests/TestCase.php
--- a/src/tests/TestCase.php
+++ b/src/tests/TestCase.php
@@ -2,9 +2,10 @@
namespace Tests;
+use Illuminate\Contracts\Auth\Authenticatable;
+use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Routing\Middleware\ThrottleRequests;
-use Illuminate\Contracts\Auth\Authenticatable;
use Laravel\Passport\Passport;
abstract class TestCase extends BaseTestCase
@@ -13,10 +14,7 @@
public const BASE_DIR = __DIR__;
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -24,8 +22,8 @@
$this->withoutMiddleware(ThrottleRequests::class);
\Mockery::getConfiguration()->setDefaultMatcher(
- class: \Illuminate\Database\Eloquent\Model::class,
- matcherClass: \Tests\ModelMatcher::class,
+ class: Model::class,
+ matcherClass: ModelMatcher::class,
);
}
@@ -55,7 +53,7 @@
['//admin.', '//reseller.', '//services.'],
['//', '//', '//'],
\config('app.url')
- )
+ ),
]
);
@@ -113,7 +111,6 @@
url()->forceRootUrl(config('app.url'));
}
-
/**
* The test equivalent of Http::withBody, which is not available for tests.
*
diff --git a/src/tests/TestCaseDusk.php b/src/tests/TestCaseDusk.php
--- a/src/tests/TestCaseDusk.php
+++ b/src/tests/TestCaseDusk.php
@@ -3,8 +3,8 @@
namespace Tests;
use Facebook\WebDriver\Chrome\ChromeOptions;
-use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
+use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class TestCaseDusk extends BaseTestCase
@@ -15,7 +15,6 @@
* Prepare for Dusk test execution.
*
* @beforeClass
- * @return void
*/
public static function prepare()
{
@@ -35,7 +34,6 @@
* when we switch to PHPUnit v10.
*
* @afterClass
- * @return void
*/
public static function tearDownDuskClass()
{
@@ -49,7 +47,7 @@
/**
* Create the RemoteWebDriver instance.
*
- * @return \Facebook\WebDriver\Remote\RemoteWebDriver
+ * @return RemoteWebDriver
*/
protected function driver()
{
@@ -98,7 +96,7 @@
// Make sure downloads dir exists and is empty
if (!file_exists($download_dir)) {
- mkdir($download_dir, 0777, true);
+ mkdir($download_dir, 0o777, true);
} else {
foreach (glob("{$download_dir}/*") as $file) {
@unlink($file);
diff --git a/src/tests/TestCaseTrait.php b/src/tests/TestCaseTrait.php
--- a/src/tests/TestCaseTrait.php
+++ b/src/tests/TestCaseTrait.php
@@ -2,20 +2,29 @@
namespace Tests;
+use App\Auth\SecondFactor;
use App\Backends\IMAP;
use App\Backends\LDAP;
use App\CompanionApp;
use App\Domain;
+use App\Entitlement;
use App\Group;
+use App\Jobs\User\CreateJob;
+use App\Meet\Room;
+use App\Package;
use App\Resource;
use App\SharedFolder;
use App\Sku;
use App\Transaction;
use App\User;
+use App\Utils;
+use App\Wallet;
use Carbon\Carbon;
use Illuminate\Contracts\Console\Kernel;
-use Illuminate\Support\Facades\Queue;
+use Illuminate\Foundation\Application;
+use Illuminate\Mail\Mailable;
use Illuminate\Support\Facades\Cache;
+use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Assert;
trait TestCaseTrait
@@ -23,14 +32,14 @@
/**
* A domain that is hosted.
*
- * @var ?\App\Domain
+ * @var ?Domain
*/
protected $domainHosted;
/**
* The hosted domain owner.
*
- * @var ?\App\User
+ * @var ?User
*/
protected $domainOwner;
@@ -48,42 +57,42 @@
/**
* Some users for the hosted domain, ultimately including the owner.
*
- * @var \App\User[]
+ * @var User[]
*/
protected $domainUsers = [];
/**
* A specific user that is a regular user in the hosted domain.
*
- * @var ?\App\User
+ * @var ?User
*/
protected $jack;
/**
* A specific user that is a controller on the wallet to which the hosted domain is charged.
*
- * @var ?\App\User
+ * @var ?User
*/
protected $jane;
/**
* A specific user that has a second factor configured.
*
- * @var ?\App\User
+ * @var ?User
*/
protected $joe;
/**
* One of the domains that is available for public registration.
*
- * @var ?\App\Domain
+ * @var ?Domain
*/
protected $publicDomain;
/**
* A newly generated user in a public domain.
*
- * @var ?\App\User
+ * @var ?User
*/
protected $publicDomainUser;
@@ -107,7 +116,7 @@
if (!empty($titles)) {
Sku::withEnvTenantContext()->whereIn('title', (array) $titles)->get()
- ->each(function ($sku) use ($user) {
+ ->each(static function ($sku) use ($user) {
$user->assignSku($sku);
});
}
@@ -116,14 +125,14 @@
/**
* Assert that the entitlements for the user match the expected list of entitlements.
*
- * @param \App\User|\App\Domain $object The object for which the entitlements need to be pulled.
- * @param array $expected An array of expected \App\Sku titles.
+ * @param User|Domain $object the object for which the entitlements need to be pulled
+ * @param array $expected an array of expected \App\Sku titles
*/
protected function assertEntitlements($object, $expected)
{
// Assert the user entitlements
$skus = $object->entitlements()->get()
- ->map(function ($ent) {
+ ->map(static function ($ent) {
return $ent->sku->title;
})
->toArray();
@@ -173,17 +182,17 @@
$wallets[] = $entitlement->wallet_id;
}
- \App\Entitlement::whereIn('id', $ids)->update([
- 'created_at' => $targetCreatedDate ?: $targetDate,
- 'updated_at' => $targetDate,
+ Entitlement::whereIn('id', $ids)->update([
+ 'created_at' => $targetCreatedDate ?: $targetDate,
+ 'updated_at' => $targetDate,
]);
if (!empty($wallets)) {
$wallets = array_unique($wallets);
- $owners = \App\Wallet::whereIn('id', $wallets)->pluck('user_id')->all();
+ $owners = Wallet::whereIn('id', $wallets)->pluck('user_id')->all();
- \App\User::whereIn('id', $owners)->update([
- 'created_at' => $targetCreatedDate ?: $targetDate
+ User::whereIn('id', $owners)->update([
+ 'created_at' => $targetCreatedDate ?: $targetDate,
]);
}
}
@@ -199,13 +208,13 @@
$betas = Sku::whereIn('handler_class', $beta_handlers)->pluck('id')->all();
- \App\Entitlement::whereIn('sku_id', $betas)->delete();
+ Entitlement::whereIn('sku_id', $betas)->delete();
}
/**
* Creates the application.
*
- * @return \Illuminate\Foundation\Application
+ * @return Application
*/
public function createApplication()
{
@@ -240,7 +249,7 @@
[
'user_email' => 'jeroen@jeroen.jeroen',
'object_id' => $wallet->id,
- 'object_type' => \App\Wallet::class,
+ 'object_type' => Wallet::class,
'type' => Transaction::WALLET_DEBIT,
'amount' => $debit * -1,
'description' => 'Payment',
@@ -255,7 +264,7 @@
[
'user_email' => null,
'object_id' => $wallet->id,
- 'object_type' => \App\Wallet::class,
+ 'object_type' => Wallet::class,
'type' => Transaction::WALLET_CREDIT,
'amount' => 2000,
'description' => 'Payment',
@@ -279,7 +288,7 @@
$transaction = Transaction::create([
'user_email' => 'jeroen.@jeroen.jeroen',
'object_id' => $wallet->id,
- 'object_type' => \App\Wallet::class,
+ 'object_type' => Wallet::class,
'type' => $type,
'amount' => 11 * (count($result) + 1) * ($type == Transaction::WALLET_PENALTY ? -1 : 1),
'description' => 'TRANS' . $loops,
@@ -369,7 +378,7 @@
{
Queue::fake();
- $room = \App\Meet\Room::withTrashed()->where('name', $name)->first();
+ $room = Room::withTrashed()->where('name', $name)->first();
if (!$room) {
return;
@@ -491,7 +500,7 @@
$resource = Resource::where('email', $email)->first();
if (!$resource) {
- list($local, $domain) = explode('@', $email, 2);
+ [$local, $domain] = explode('@', $email, 2);
$resource = new Resource();
$resource->email = $email;
@@ -519,7 +528,7 @@
protected function getTestRoom($name, $wallet = null, $attrib = [], $config = [], $title = null)
{
$attrib['name'] = $name;
- $room = \App\Meet\Room::create($attrib);
+ $room = Room::create($attrib);
if ($wallet) {
$room->assignToWallet($wallet, $title);
@@ -544,7 +553,7 @@
$folder = SharedFolder::where('email', $email)->first();
if (!$folder) {
- list($local, $domain) = explode('@', $email, 2);
+ [$local, $domain] = explode('@', $email, 2);
$folder = new SharedFolder();
$folder->email = $email;
@@ -583,7 +592,7 @@
}
if ($createInBackends) {
- $job = new \App\Jobs\User\CreateJob($user->id);
+ $job = new CreateJob($user->id);
$job->handle();
}
@@ -605,7 +614,7 @@
'device_id' => $deviceId,
'user_id' => $user->id,
'notification_token' => '',
- 'mfa_enabled' => 1
+ 'mfa_enabled' => 1,
],
$attrib
);
@@ -615,15 +624,15 @@
/**
* Call protected/private method of a class.
*
- * @param object $object Instantiated object that we will run method on.
+ * @param object $object instantiated object that we will run method on
* @param string $methodName Method name to call
- * @param array $parameters Array of parameters to pass into method.
+ * @param array $parameters array of parameters to pass into method
*
- * @return mixed Method return.
+ * @return mixed method return
*/
protected function invokeMethod($object, $methodName, array $parameters = [])
{
- $reflection = new \ReflectionClass(get_class($object));
+ $reflection = new \ReflectionClass($object::class);
$method = $reflection->getMethod($methodName);
$method->setAccessible(true);
@@ -640,7 +649,7 @@
$prefix = $db->getOptions()->prefix?->getPrefix();
foreach ($db->keys('*') as $key) {
- if (strpos($key, 'laravel_unique_job') !== false) {
+ if (str_contains($key, 'laravel_unique_job')) {
$db->del($prefix ? substr($key, strlen($prefix)) : $key);
}
}
@@ -651,14 +660,14 @@
/**
* Extract content of an email message.
*
- * @param \Illuminate\Mail\Mailable $mail Mailable object
+ * @param Mailable $mail Mailable object
*
* @return array Parsed message data:
* - 'plain': Plain text body
* - 'html: HTML body
* - 'subject': Mail subject
*/
- protected function renderMail(\Illuminate\Mail\Mailable $mail): array
+ protected function renderMail(Mailable $mail): array
{
$mail->build(); // @phpstan-ignore-line
@@ -676,7 +685,7 @@
*/
public function resetTestRoom(string $room_name = 'john', $config = [])
{
- $room = \App\Meet\Room::where('name', $room_name)->first();
+ $room = Room::where('name', $room_name)->first();
$room->setSettings(['password' => null, 'locked' => null, 'nomedia' => null]);
if ($room->session_id) {
@@ -693,25 +702,25 @@
protected function setUpTest()
{
- $this->userPassword = \App\Utils::generatePassphrase();
+ $this->userPassword = Utils::generatePassphrase();
$this->domainHosted = $this->getTestDomain(
'test.domain',
[
- 'type' => \App\Domain::TYPE_EXTERNAL,
- 'status' => \App\Domain::STATUS_ACTIVE | \App\Domain::STATUS_CONFIRMED | \App\Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]
);
$this->getTestDomain(
'test2.domain2',
[
- 'type' => \App\Domain::TYPE_EXTERNAL,
- 'status' => \App\Domain::STATUS_ACTIVE | \App\Domain::STATUS_CONFIRMED | \App\Domain::STATUS_VERIFIED
+ 'type' => Domain::TYPE_EXTERNAL,
+ 'status' => Domain::STATUS_ACTIVE | Domain::STATUS_CONFIRMED | Domain::STATUS_VERIFIED,
]
);
- $packageKolab = \App\Package::where('title', 'kolab')->first();
+ $packageKolab = Package::where('title', 'kolab')->first();
$this->domainOwner = $this->getTestUser('john@test.domain', ['password' => $this->userPassword]);
$this->domainOwner->assignPackage($packageKolab);
@@ -739,17 +748,17 @@
// assign second factor to joe
$this->joe->assignSku(Sku::where('title', '2fa')->first());
- \App\Auth\SecondFactor::seed($this->joe->email);
+ SecondFactor::seed($this->joe->email);
usort(
$this->domainUsers,
- function ($a, $b) {
+ static function ($a, $b) {
return $a->email <=> $b->email;
}
);
$this->domainHosted->assignPackage(
- \App\Package::where('title', 'domain-hosting')->first(),
+ Package::where('title', 'domain-hosting')->first(),
$this->domainOwner
);
@@ -757,7 +766,7 @@
$wallet->addController($this->jane);
- $this->publicDomain = \App\Domain::where('type', \App\Domain::TYPE_PUBLIC)->first();
+ $this->publicDomain = Domain::where('type', Domain::TYPE_PUBLIC)->first();
$this->publicDomainUser = $this->getTestUser(
'john@' . $this->publicDomain->namespace,
['password' => $this->userPassword]
@@ -768,7 +777,7 @@
Cache::forget('duskconfig');
}
- public function tearDown(): void
+ protected function tearDown(): void
{
foreach ($this->domainUsers as $user) {
if ($user == $this->domainOwner) {
diff --git a/src/tests/Unit/Backends/DAV/FolderTest.php b/src/tests/Unit/Backends/DAV/FolderTest.php
--- a/src/tests/Unit/Backends/DAV/FolderTest.php
+++ b/src/tests/Unit/Backends/DAV/FolderTest.php
@@ -12,35 +12,35 @@
*/
public function testFromDomElement(): void
{
- $xml = <<<XML
-<?xml version="1.0" encoding="utf-8"?>
- <d:multistatus xmlns:d="DAV:"
- xmlns:cs="http://calendarserver.org/ns/"
- xmlns:c="urn:ietf:params:xml:ns:caldav"
- xmlns:a="http://apple.com/ns/ical/"
- xmlns:k="Kolab:">
- <d:response>
- <d:href>/dav/calendars/user/alec@aphy.io/Default/</d:href>
- <d:propstat>
- <d:prop>
- <d:resourcetype>
- <d:collection/>
- <c:calendar/>
- </d:resourcetype>
- <d:displayname><![CDATA[personal]]></d:displayname>
- <cs:getctag>1665578572-16</cs:getctag>
- <c:supported-calendar-component-set>
- <c:comp name="VEVENT"/>
- <c:comp name="VTODO"/>
- <c:comp name="VJOURNAL"/>
- </c:supported-calendar-component-set>
- <a:calendar-color>#cccccc</a:calendar-color>
- </d:prop>
- <d:status>HTTP/1.1 200 OK</d:status>
- </d:propstat>
- </d:response>
-</d:multistatus>
-XML;
+ $xml = <<<'XML'
+ <?xml version="1.0" encoding="utf-8"?>
+ <d:multistatus xmlns:d="DAV:"
+ xmlns:cs="http://calendarserver.org/ns/"
+ xmlns:c="urn:ietf:params:xml:ns:caldav"
+ xmlns:a="http://apple.com/ns/ical/"
+ xmlns:k="Kolab:">
+ <d:response>
+ <d:href>/dav/calendars/user/alec@aphy.io/Default/</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:resourcetype>
+ <d:collection/>
+ <c:calendar/>
+ </d:resourcetype>
+ <d:displayname><![CDATA[personal]]></d:displayname>
+ <cs:getctag>1665578572-16</cs:getctag>
+ <c:supported-calendar-component-set>
+ <c:comp name="VEVENT"/>
+ <c:comp name="VTODO"/>
+ <c:comp name="VJOURNAL"/>
+ </c:supported-calendar-component-set>
+ <a:calendar-color>#cccccc</a:calendar-color>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+ </d:response>
+ </d:multistatus>
+ XML;
$doc = new \DOMDocument('1.0', 'UTF-8');
$doc->loadXML($xml);
diff --git a/src/tests/Unit/Backends/DAV/VcardTest.php b/src/tests/Unit/Backends/DAV/VcardTest.php
--- a/src/tests/Unit/Backends/DAV/VcardTest.php
+++ b/src/tests/Unit/Backends/DAV/VcardTest.php
@@ -14,26 +14,26 @@
{
$uid = 'A8CCF090C66A7D4D805A8B897AE75AFD-8FE68B2E68E1B348';
$vcard = <<<XML
-<?xml version="1.0" encoding="utf-8"?>
-<d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
- <d:response>
- <d:href>/dav/addressbooks/user/test@test.com/Default/$uid.vcf</d:href>
- <d:propstat>
- <d:prop>
- <d:getetag>"d27382e0b401384becb0d5b157d6b73a2c2084a2"</d:getetag>
- <c:address-data><![CDATA[BEGIN:VCARD
-VERSION:3.0
-FN:Test Test
-N:;;;;
-UID:$uid
-END:VCARD
-]]></c:address-data>
- </d:prop>
- <d:status>HTTP/1.1 200 OK</d:status>
- </d:propstat>
- </d:response>
-</d:multistatus>
-XML;
+ <?xml version="1.0" encoding="utf-8"?>
+ <d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:carddav">
+ <d:response>
+ <d:href>/dav/addressbooks/user/test@test.com/Default/{$uid}.vcf</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:getetag>"d27382e0b401384becb0d5b157d6b73a2c2084a2"</d:getetag>
+ <c:address-data><![CDATA[BEGIN:VCARD
+ VERSION:3.0
+ FN:Test Test
+ N:;;;;
+ UID:{$uid}
+ END:VCARD
+ ]]></c:address-data>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+ </d:response>
+ </d:multistatus>
+ XML;
$doc = new \DOMDocument('1.0', 'UTF-8');
$doc->loadXML($vcard);
diff --git a/src/tests/Unit/Backends/DAV/VeventTest.php b/src/tests/Unit/Backends/DAV/VeventTest.php
--- a/src/tests/Unit/Backends/DAV/VeventTest.php
+++ b/src/tests/Unit/Backends/DAV/VeventTest.php
@@ -14,42 +14,42 @@
{
$uid = 'A8CCF090C66A7D4D805A8B897AE75AFD-8FE68B2E68E1B348';
$ical = <<<XML
-<?xml version="1.0" encoding="utf-8"?>
-<d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
- <d:response>
- <d:href>/dav/calendars/user/test@test.com/Default/$uid.ics</d:href>
- <d:propstat>
- <d:prop>
- <d:getetag>"d27382e0b401384becb0d5b157d6b73a2c2084a2"</d:getetag>
- <c:calendar-data><![CDATA[BEGIN:VCALENDAR
-VERSION:2.0
-PRODID:-//Test//EN
-METHOD:PUBLISH
-CALSCALE:GREGORIAN
-BEGIN:VEVENT
-UID:$uid
-DTSTAMP:20221016T103238Z
-DTSTART;VALUE=DATE:20221013
-DTEND;VALUE=DATE:20221014
-SEQUENCE:1
-SUMMARY:My summary
-DESCRIPTION:desc
-RRULE:FREQ=WEEKLY
-TRANSP:OPAQUE
-ORGANIZER:mailto:organizer@test.com
-ATTENDEE;CN=John;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT;CUTYPE=INDI
- VIDUAL:mailto:john@kolab.org
-ATTENDEE;CN=Ned;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;CUTYPE=IND
- IVIDUAL;RSVP=TRUE:mailto:ned@kolab.org
-END:VEVENT
-END:VCALENDAR
-]]></c:calendar-data>
- </d:prop>
- <d:status>HTTP/1.1 200 OK</d:status>
- </d:propstat>
- </d:response>
-</d:multistatus>
-XML;
+ <?xml version="1.0" encoding="utf-8"?>
+ <d:multistatus xmlns:d="DAV:" xmlns:c="urn:ietf:params:xml:ns:caldav">
+ <d:response>
+ <d:href>/dav/calendars/user/test@test.com/Default/{$uid}.ics</d:href>
+ <d:propstat>
+ <d:prop>
+ <d:getetag>"d27382e0b401384becb0d5b157d6b73a2c2084a2"</d:getetag>
+ <c:calendar-data><![CDATA[BEGIN:VCALENDAR
+ VERSION:2.0
+ PRODID:-//Test//EN
+ METHOD:PUBLISH
+ CALSCALE:GREGORIAN
+ BEGIN:VEVENT
+ UID:{$uid}
+ DTSTAMP:20221016T103238Z
+ DTSTART;VALUE=DATE:20221013
+ DTEND;VALUE=DATE:20221014
+ SEQUENCE:1
+ SUMMARY:My summary
+ DESCRIPTION:desc
+ RRULE:FREQ=WEEKLY
+ TRANSP:OPAQUE
+ ORGANIZER:mailto:organizer@test.com
+ ATTENDEE;CN=John;PARTSTAT=ACCEPTED;ROLE=REQ-PARTICIPANT;CUTYPE=INDI
+ VIDUAL:mailto:john@kolab.org
+ ATTENDEE;CN=Ned;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;CUTYPE=IND
+ IVIDUAL;RSVP=TRUE:mailto:ned@kolab.org
+ END:VEVENT
+ END:VCALENDAR
+ ]]></c:calendar-data>
+ </d:prop>
+ <d:status>HTTP/1.1 200 OK</d:status>
+ </d:propstat>
+ </d:response>
+ </d:multistatus>
+ XML;
$doc = new \DOMDocument('1.0', 'UTF-8');
$doc->loadXML($ical);
@@ -79,13 +79,13 @@
];
$this->assertSame($organizer, $event->organizer);
- $this->assertSame(false, $event->attendees[0]['rsvp']);
+ $this->assertFalse($event->attendees[0]['rsvp']);
$this->assertSame('john@kolab.org', $event->attendees[0]['email']);
$this->assertSame('John', $event->attendees[0]['cn']);
$this->assertSame('ACCEPTED', $event->attendees[0]['partstat']);
$this->assertSame('REQ-PARTICIPANT', $event->attendees[0]['role']);
$this->assertSame('INDIVIDUAL', $event->attendees[0]['cutype']);
- $this->assertSame(true, $event->attendees[1]['rsvp']);
+ $this->assertTrue($event->attendees[1]['rsvp']);
$this->assertSame('ned@kolab.org', $event->attendees[1]['email']);
$this->assertSame('Ned', $event->attendees[1]['cn']);
$this->assertSame('NEEDS-ACTION', $event->attendees[1]['partstat']);
diff --git a/src/tests/Unit/DataMigrator/Driver/EWS/AppointmentTest.php b/src/tests/Unit/DataMigrator/Driver/EWS/AppointmentTest.php
--- a/src/tests/Unit/DataMigrator/Driver/EWS/AppointmentTest.php
+++ b/src/tests/Unit/DataMigrator/Driver/EWS/AppointmentTest.php
@@ -103,13 +103,13 @@
$this->assertSame('Aleksander Machniak', $event->organizer['cn']);
$this->assertSame('ORGANIZER', $event->organizer['role']);
$this->assertSame('ACCEPTED', $event->organizer['partstat']);
- $this->assertSame(false, $event->organizer['rsvp']);
+ $this->assertFalse($event->organizer['rsvp']);
$this->assertCount(1, $event->attendees);
$this->assertSame('alec@outlook.com', $event->attendees[0]['email']);
$this->assertSame('Alec Machniak', $event->attendees[0]['cn']);
$this->assertSame('REQ-PARTICIPANT', $event->attendees[0]['role']);
$this->assertSame('NEEDS-ACTION', $event->attendees[0]['partstat']);
- $this->assertSame(true, $event->attendees[0]['rsvp']);
+ $this->assertTrue($event->attendees[0]['rsvp']);
}
}
diff --git a/src/tests/Unit/DataMigrator/Driver/EWS/ContactTest.php b/src/tests/Unit/DataMigrator/Driver/EWS/ContactTest.php
--- a/src/tests/Unit/DataMigrator/Driver/EWS/ContactTest.php
+++ b/src/tests/Unit/DataMigrator/Driver/EWS/ContactTest.php
@@ -124,7 +124,7 @@
$this->assertMatchesRegularExpression('/^[a-f0-9]{40}$/', $contact->uid);
$this->assertSame('PUBLIC', $contact->class);
$this->assertSame('Nowy Nazwisko', $contact->fn);
- $this->assertSame(null, $contact->kind);
+ $this->assertNull($contact->kind);
$this->assertSame('Microsoft Exchange', $contact->prodid);
$this->assertSame('2024-07-15T11:17:39,701Z', $contact->rev);
$this->assertSame('Notatki do kontaktu', $contact->note);
diff --git a/src/tests/Unit/DataMigrator/Driver/Kolab/FilesTest.php b/src/tests/Unit/DataMigrator/Driver/Kolab/FilesTest.php
--- a/src/tests/Unit/DataMigrator/Driver/Kolab/FilesTest.php
+++ b/src/tests/Unit/DataMigrator/Driver/Kolab/FilesTest.php
@@ -43,7 +43,7 @@
$this->assertSame('text/plain', $result[0]);
$this->assertSame('a very long name for the attachment to test ććć will see how '
. 'it goes with some non-ascii kość characters.txt', $result[1]);
- $this->assertSame(null, $result[2]);
+ $this->assertNull($result[2]);
$this->assertSame('quoted-printable', $result[3]);
$headers = "Content-Type: text/plain; name=test.txt\r\n"
@@ -52,7 +52,7 @@
$result = $this->invokeMethod($files, 'parseHeaders', [$headers]);
$this->assertSame('text/plain', $result[0]);
$this->assertSame('test.txt', $result[1]);
- $this->assertSame(null, $result[2]);
- $this->assertSame(null, $result[3]);
+ $this->assertNull($result[2]);
+ $this->assertNull($result[3]);
}
}
diff --git a/src/tests/Unit/DataMigrator/Driver/TakeoutTest.php b/src/tests/Unit/DataMigrator/Driver/TakeoutTest.php
--- a/src/tests/Unit/DataMigrator/Driver/TakeoutTest.php
+++ b/src/tests/Unit/DataMigrator/Driver/TakeoutTest.php
@@ -11,10 +11,7 @@
class TakeoutTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
exec('rm -rf ' . storage_path('export/unit@gmail.com'));
@@ -30,7 +27,7 @@
[$takeout, $importer] = $this->init();
$result = [];
- $callback = function ($item) use (&$result) {
+ $callback = static function ($item) use (&$result) {
// Note: Small items don't use temp files, so we can just read the content
// Remove line-wrapping for easier testing
$result[$item->id] = $item->content;
@@ -54,7 +51,7 @@
[$takeout, $importer] = $this->init();
$result = [];
- $callback = function ($item) use (&$result) {
+ $callback = static function ($item) use (&$result) {
// Note: Small items don't use temp files, so we can just read the content
// Remove line-wrapping for easier testing
$content = str_replace(["\r\n ", "\r\n "], '', $item->content);
diff --git a/src/tests/Unit/DomainTest.php b/src/tests/Unit/DomainTest.php
--- a/src/tests/Unit/DomainTest.php
+++ b/src/tests/Unit/DomainTest.php
@@ -4,6 +4,7 @@
use App\Domain;
use Tests\TestCase;
+use Tests\Utils;
class DomainTest extends TestCase
{
@@ -22,14 +23,14 @@
Domain::STATUS_VERIFIED,
];
- $domains = \Tests\Utils::powerSet($statuses);
+ $domains = Utils::powerSet($statuses);
foreach ($domains as $domainStatuses) {
$domain = new Domain(
[
'namespace' => 'test.com',
'status' => \array_sum($domainStatuses),
- 'type' => Domain::TYPE_EXTERNAL
+ 'type' => Domain::TYPE_EXTERNAL,
]
);
@@ -92,7 +93,7 @@
Domain::TYPE_EXTERNAL,
];
- $domains = \Tests\Utils::powerSet($types);
+ $domains = Utils::powerSet($types);
foreach ($domains as $domain_types) {
$domain = new Domain(
diff --git a/src/tests/Unit/Mail/DegradedAccountReminderTest.php b/src/tests/Unit/Mail/DegradedAccountReminderTest.php
--- a/src/tests/Unit/Mail/DegradedAccountReminderTest.php
+++ b/src/tests/Unit/Mail/DegradedAccountReminderTest.php
@@ -3,8 +3,7 @@
namespace Tests\Unit\Mail;
use App\Mail\DegradedAccountReminder;
-use App\User;
-use App\Wallet;
+use App\Utils;
use Tests\TestCase;
class DegradedAccountReminderTest extends TestCase
@@ -23,22 +22,22 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $dashboardUrl = \App\Utils::serviceUrl('/dashboard');
+ $dashboardUrl = Utils::serviceUrl('/dashboard');
$dashboardLink = sprintf('<a href="%s">%s</a>', $dashboardUrl, $dashboardUrl);
$appName = $user->tenant->title;
- $this->assertSame("$appName Reminder: Your account is free", $mail['subject']);
+ $this->assertSame("{$appName} Reminder: Your account is free", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $dashboardLink) > 0);
$this->assertTrue(strpos($html, "your {$john->email} account is a free account") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $dashboardUrl) > 0);
$this->assertTrue(strpos($plain, "your {$john->email} account is a free account") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -52,7 +51,7 @@
$mail = new DegradedAccountReminder($wallet, $user);
- $this->assertSame("$appName Reminder: Your account is free", $mail->getSubject());
+ $this->assertSame("{$appName} Reminder: Your account is free", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/HelperTest.php b/src/tests/Unit/Mail/HelperTest.php
--- a/src/tests/Unit/Mail/HelperTest.php
+++ b/src/tests/Unit/Mail/HelperTest.php
@@ -4,30 +4,29 @@
use App\EventLog;
use App\Mail\Helper;
+use App\Mail\TrialEnd;
+use App\SignupInvitation;
+use App\Sku;
+use App\Tenant;
+use App\TenantSetting;
use App\User;
use Illuminate\Support\Facades\Mail;
use Tests\TestCase;
class HelperTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->deleteTestUser('mail-helper-test@kolabnow.com');
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
$this->deleteTestUser('mail-helper-test@kolabnow.com');
- \App\TenantSetting::truncate();
+ TenantSetting::truncate();
parent::tearDown();
}
@@ -40,15 +39,15 @@
EventLog::truncate();
Mail::fake();
- $tenant = \App\Tenant::whereNotIn('id', [1])->first();
- $invitation = new \App\SignupInvitation();
+ $tenant = Tenant::whereNotIn('id', [1])->first();
+ $invitation = new SignupInvitation();
$invitation->id = 'test';
$mail = new \App\Mail\SignupInvitation($invitation);
Helper::sendMail($mail, null, ['to' => 'to@test.com', 'cc' => 'cc@test.com']);
Mail::assertSent(\App\Mail\SignupInvitation::class, 1);
- Mail::assertSent(\App\Mail\SignupInvitation::class, function ($mail) {
+ Mail::assertSent(\App\Mail\SignupInvitation::class, static function ($mail) {
return $mail->hasTo('to@test.com')
&& $mail->hasCc('cc@test.com')
&& $mail->hasFrom(\config('mail.sender.address'), \config('mail.sender.name'))
@@ -64,7 +63,7 @@
Helper::sendMail($mail, $tenant->id, ['to' => 'to@test.com', 'cc' => 'cc@test.com']);
Mail::assertSent(\App\Mail\SignupInvitation::class, 1);
- Mail::assertSent(\App\Mail\SignupInvitation::class, function ($mail) {
+ Mail::assertSent(\App\Mail\SignupInvitation::class, static function ($mail) {
return $mail->hasTo('to@test.com')
&& $mail->hasCc('cc@test.com')
&& $mail->hasFrom(\config('mail.sender.address'), \config('mail.sender.name'))
@@ -86,7 +85,7 @@
Helper::sendMail($mail, $tenant->id, ['to' => 'to@test.com']);
Mail::assertSent(\App\Mail\SignupInvitation::class, 1);
- Mail::assertSent(\App\Mail\SignupInvitation::class, function ($mail) {
+ Mail::assertSent(\App\Mail\SignupInvitation::class, static function ($mail) {
return $mail->hasTo('to@test.com')
&& $mail->hasFrom('from@test.com', 'from name')
&& $mail->hasReplyTo('replyto@test.com', 'replyto name');
@@ -97,7 +96,7 @@
// Assert EventLog entry
$user = $this->getTestUser('mail-helper-test@kolabnow.com');
- $mail = new \App\Mail\TrialEnd($user);
+ $mail = new TrialEnd($user);
Helper::sendMail($mail, $tenant->id, ['to' => 'to@test.com', 'cc' => 'cc@test.com']);
@@ -118,50 +117,50 @@
$user = $this->getTestUser('mail-helper-test@kolabnow.com', ['status' => $status]);
// User with no mailbox and no external email
- list($to, $cc) = Helper::userEmails($user);
+ [$to, $cc] = Helper::userEmails($user);
- $this->assertSame(null, $to);
+ $this->assertNull($to);
$this->assertSame([], $cc);
- list($to, $cc) = Helper::userEmails($user, true);
+ [$to, $cc] = Helper::userEmails($user, true);
- $this->assertSame(null, $to);
+ $this->assertNull($to);
$this->assertSame([], $cc);
// User with no mailbox but with external email
$user->setSetting('external_email', 'external@test.com');
- list($to, $cc) = Helper::userEmails($user);
+ [$to, $cc] = Helper::userEmails($user);
$this->assertSame('external@test.com', $to);
$this->assertSame([], $cc);
- list($to, $cc) = Helper::userEmails($user, true);
+ [$to, $cc] = Helper::userEmails($user, true);
$this->assertSame('external@test.com', $to);
$this->assertSame([], $cc);
// User with mailbox and external email
- $sku = \App\Sku::withEnvTenantContext()->where('title', 'mailbox')->first();
+ $sku = Sku::withEnvTenantContext()->where('title', 'mailbox')->first();
$user->assignSku($sku);
- list($to, $cc) = Helper::userEmails($user);
+ [$to, $cc] = Helper::userEmails($user);
$this->assertSame($user->email, $to);
$this->assertSame([], $cc);
- list($to, $cc) = Helper::userEmails($user, true);
+ [$to, $cc] = Helper::userEmails($user, true);
$this->assertSame($user->email, $to);
$this->assertSame(['external@test.com'], $cc);
// User with mailbox, but no external email
$user->setSetting('external_email', null);
- list($to, $cc) = Helper::userEmails($user);
+ [$to, $cc] = Helper::userEmails($user);
$this->assertSame($user->email, $to);
$this->assertSame([], $cc);
- list($to, $cc) = Helper::userEmails($user, true);
+ [$to, $cc] = Helper::userEmails($user, true);
$this->assertSame($user->email, $to);
$this->assertSame([], $cc);
@@ -171,9 +170,9 @@
$user->status = User::STATUS_ACTIVE | User::STATUS_LDAP_READY;
$user->save();
- list($to, $cc) = Helper::userEmails($user, true);
+ [$to, $cc] = Helper::userEmails($user, true);
- $this->assertSame(null, $to);
+ $this->assertNull($to);
$this->assertSame(['external@test.com'], $cc);
}
}
diff --git a/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php b/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php
--- a/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php
+++ b/src/tests/Unit/Mail/NegativeBalanceDegradedTest.php
@@ -3,8 +3,7 @@
namespace Tests\Unit\Mail;
use App\Mail\NegativeBalanceDegraded;
-use App\User;
-use App\Wallet;
+use App\Utils;
use Tests\TestCase;
class NegativeBalanceDegradedTest extends TestCase
@@ -21,7 +20,7 @@
$wallet->save();
\config([
- 'app.support_url' => 'https://kolab.org/support',
+ 'app.support_url' => 'https://kolab.org/support',
]);
$mail = $this->renderMail(new NegativeBalanceDegraded($wallet, $user));
@@ -29,28 +28,28 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = $user->tenant->title;
- $this->assertSame("$appName Account Degraded", $mail['subject']);
+ $this->assertSame("{$appName} Account Degraded", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $walletLink) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
$this->assertTrue(strpos($html, "Your {$john->email} account has been degraded") > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
$this->assertTrue(strpos($plain, "Your {$john->email} account has been degraded") > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -64,7 +63,7 @@
$mail = new NegativeBalanceDegraded($wallet, $user);
- $this->assertSame("$appName Account Degraded", $mail->getSubject());
+ $this->assertSame("{$appName} Account Degraded", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php b/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php
--- a/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php
+++ b/src/tests/Unit/Mail/NegativeBalanceReminderDegradeTest.php
@@ -4,8 +4,7 @@
use App\Jobs\Wallet\CheckJob;
use App\Mail\NegativeBalanceReminderDegrade;
-use App\User;
-use App\Wallet;
+use App\Utils;
use Tests\TestCase;
class NegativeBalanceReminderDegradeTest extends TestCase
@@ -24,7 +23,7 @@
$threshold = CheckJob::threshold($wallet, CheckJob::THRESHOLD_DEGRADE);
\config([
- 'app.support_url' => 'https://kolab.org/support',
+ 'app.support_url' => 'https://kolab.org/support',
]);
$mail = $this->renderMail(new NegativeBalanceReminderDegrade($wallet, $user));
@@ -32,13 +31,13 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = $user->tenant->title;
- $this->assertSame("$appName Payment Reminder", $mail['subject']);
+ $this->assertSame("{$appName} Payment Reminder", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
@@ -47,8 +46,8 @@
$this->assertTrue(strpos($html, "you are behind on paying for your {$john->email} account") > 0);
$this->assertTrue(strpos($html, "your account will be degraded") > 0);
$this->assertTrue(strpos($html, $threshold->toDateString()) > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
@@ -56,8 +55,8 @@
$this->assertTrue(strpos($plain, "you are behind on paying for your {$john->email} account") > 0);
$this->assertTrue(strpos($plain, "your account will be degraded") > 0);
$this->assertTrue(strpos($plain, $threshold->toDateString()) > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -71,7 +70,7 @@
$mail = new NegativeBalanceReminderDegrade($wallet, $user);
- $this->assertSame("$appName Payment Reminder", $mail->getSubject());
+ $this->assertSame("{$appName} Payment Reminder", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/NegativeBalanceTest.php b/src/tests/Unit/Mail/NegativeBalanceTest.php
--- a/src/tests/Unit/Mail/NegativeBalanceTest.php
+++ b/src/tests/Unit/Mail/NegativeBalanceTest.php
@@ -3,8 +3,9 @@
namespace Tests\Unit\Mail;
use App\Mail\NegativeBalance;
-use App\User;
use App\Tenant;
+use App\User;
+use App\Utils;
use App\Wallet;
use Tests\TestCase;
@@ -19,7 +20,7 @@
$wallet = $user->wallets->first();
\config([
- 'app.support_url' => 'https://kolab.org/support',
+ 'app.support_url' => 'https://kolab.org/support',
]);
$mail = $this->renderMail(new NegativeBalance($wallet, $user));
@@ -27,28 +28,28 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = Tenant::getConfig($user->tenant_id, 'app.name');
- $this->assertSame("$appName Payment Required", $mail['subject']);
+ $this->assertSame("{$appName} Payment Required", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $walletLink) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
$this->assertTrue(strpos($html, "your {$user->email} account balance has run into the nega") > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
$this->assertTrue(strpos($plain, "your {$user->email} account balance has run into the nega") > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -62,7 +63,7 @@
$mail = new NegativeBalance($wallet, $user);
- $this->assertSame("$appName Payment Required", $mail->getSubject());
+ $this->assertSame("{$appName} Payment Required", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/PasswordExpirationReminderTest.php b/src/tests/Unit/Mail/PasswordExpirationReminderTest.php
--- a/src/tests/Unit/Mail/PasswordExpirationReminderTest.php
+++ b/src/tests/Unit/Mail/PasswordExpirationReminderTest.php
@@ -24,10 +24,10 @@
$plain = $mail['plain'];
$url = Utils::serviceUrl('profile');
- $link = "<a href=\"$url\">$url</a>";
+ $link = "<a href=\"{$url}\">{$url}</a>";
$appName = \config('app.name');
- $this->assertSame("$appName password expires on $expiresOn", $mail['subject']);
+ $this->assertSame("{$appName} password expires on {$expiresOn}", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $link) > 0);
@@ -52,7 +52,7 @@
$mail = new PasswordExpirationReminder($user, $expiresOn);
- $this->assertSame("$appName password expires on $expiresOn", $mail->getSubject());
+ $this->assertSame("{$appName} password expires on {$expiresOn}", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/PasswordResetTest.php b/src/tests/Unit/Mail/PasswordResetTest.php
--- a/src/tests/Unit/Mail/PasswordResetTest.php
+++ b/src/tests/Unit/Mail/PasswordResetTest.php
@@ -16,10 +16,10 @@
public function testBuild(): void
{
$code = new VerificationCode([
- 'user_id' => 123456789,
- 'mode' => 'password-reset',
- 'code' => 'code',
- 'short_code' => 'short-code',
+ 'user_id' => 123456789,
+ 'mode' => 'password-reset',
+ 'code' => 'code',
+ 'short_code' => 'short-code',
]);
// @phpstan-ignore-next-line
@@ -31,10 +31,10 @@
$plain = $mail['plain'];
$url = Utils::serviceUrl('/password-reset/' . $code->short_code . '-' . $code->code);
- $link = "<a href=\"$url\">$url</a>";
+ $link = "<a href=\"{$url}\">{$url}</a>";
$appName = \config('app.name');
- $this->assertSame("$appName Password Reset", $mail['subject']);
+ $this->assertSame("{$appName} Password Reset", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $link) > 0);
@@ -53,10 +53,10 @@
{
$appName = \config('app.name');
$code = new VerificationCode([
- 'user_id' => 123456789,
- 'mode' => 'password-reset',
- 'code' => 'code',
- 'short_code' => 'short-code',
+ 'user_id' => 123456789,
+ 'mode' => 'password-reset',
+ 'code' => 'code',
+ 'short_code' => 'short-code',
]);
// @phpstan-ignore-next-line
@@ -64,7 +64,7 @@
$mail = new PasswordReset($code);
- $this->assertSame("$appName Password Reset", $mail->getSubject());
+ $this->assertSame("{$appName} Password Reset", $mail->getSubject());
$this->assertSame($code->user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/PaymentFailureTest.php b/src/tests/Unit/Mail/PaymentFailureTest.php
--- a/src/tests/Unit/Mail/PaymentFailureTest.php
+++ b/src/tests/Unit/Mail/PaymentFailureTest.php
@@ -5,6 +5,7 @@
use App\Mail\PaymentFailure;
use App\Payment;
use App\User;
+use App\Utils;
use App\Wallet;
use Tests\TestCase;
@@ -28,28 +29,28 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = \config('app.name');
- $this->assertSame("$appName Payment Failed", $mail['subject']);
+ $this->assertSame("{$appName} Payment Failed", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $walletLink) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
$this->assertTrue(strpos($html, "Something went wrong with auto-payment for your {$user->email} account") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
$this->assertTrue(strpos($plain, "Something went wrong with auto-payment for your {$user->email} account") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -66,7 +67,7 @@
$mail = new PaymentFailure($payment, $user);
- $this->assertSame("$appName Payment Failed", $mail->getSubject());
+ $this->assertSame("{$appName} Payment Failed", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/PaymentMandateDisabledTest.php b/src/tests/Unit/Mail/PaymentMandateDisabledTest.php
--- a/src/tests/Unit/Mail/PaymentMandateDisabledTest.php
+++ b/src/tests/Unit/Mail/PaymentMandateDisabledTest.php
@@ -5,6 +5,7 @@
use App\Mail\PaymentMandateDisabled;
use App\Tenant;
use App\User;
+use App\Utils;
use App\Wallet;
use Tests\TestCase;
@@ -25,28 +26,28 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = Tenant::getConfig($user->tenant_id, 'app.name');
- $this->assertSame("$appName Auto-payment Problem", $mail['subject']);
+ $this->assertSame("{$appName} Auto-payment Problem", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $walletLink) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
$this->assertTrue(strpos($html, "Your {$user->email} account balance") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
$this->assertTrue(strpos($plain, "Your {$user->email} account balance") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -61,7 +62,7 @@
$mail = new PaymentMandateDisabled($wallet, $user);
- $this->assertSame("$appName Auto-payment Problem", $mail->getSubject());
+ $this->assertSame("{$appName} Auto-payment Problem", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/PaymentSuccessTest.php b/src/tests/Unit/Mail/PaymentSuccessTest.php
--- a/src/tests/Unit/Mail/PaymentSuccessTest.php
+++ b/src/tests/Unit/Mail/PaymentSuccessTest.php
@@ -5,7 +5,7 @@
use App\Mail\PaymentSuccess;
use App\Payment;
use App\Tenant;
-use App\User;
+use App\Utils;
use Tests\TestCase;
class PaymentSuccessTest extends TestCase
@@ -27,28 +27,28 @@
$html = $mail['html'];
$plain = $mail['plain'];
- $walletUrl = \App\Utils::serviceUrl('/wallet');
+ $walletUrl = Utils::serviceUrl('/wallet');
$walletLink = sprintf('<a href="%s">%s</a>', $walletUrl, $walletUrl);
$supportUrl = \config('app.support_url');
$supportLink = sprintf('<a href="%s">%s</a>', $supportUrl, $supportUrl);
$appName = Tenant::getConfig($user->tenant_id, 'app.name');
- $this->assertSame("$appName Payment Succeeded", $mail['subject']);
+ $this->assertSame("{$appName} Payment Succeeded", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $walletLink) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
- $this->assertTrue(strpos($html, "$appName Support") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Support") > 0);
$this->assertTrue(strpos($html, "The auto-payment for your {$user->email} account") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $walletUrl) > 0);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
- $this->assertTrue(strpos($plain, "$appName Support") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Support") > 0);
$this->assertTrue(strpos($plain, "The auto-payment for your {$user->email} account") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -65,7 +65,7 @@
$mail = new PaymentSuccess($payment, $user);
- $this->assertSame("$appName Payment Succeeded", $mail->getSubject());
+ $this->assertSame("{$appName} Payment Succeeded", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/SignupInvitationTest.php b/src/tests/Unit/Mail/SignupInvitationTest.php
--- a/src/tests/Unit/Mail/SignupInvitationTest.php
+++ b/src/tests/Unit/Mail/SignupInvitationTest.php
@@ -15,8 +15,8 @@
public function testBuild(): void
{
$invitation = new SI([
- 'id' => 'abc',
- 'email' => 'test@email',
+ 'id' => 'abc',
+ 'email' => 'test@email',
]);
$mail = $this->renderMail(new SignupInvitation($invitation));
@@ -25,17 +25,17 @@
$plain = $mail['plain'];
$url = Utils::serviceUrl('/signup/invite/' . $invitation->id);
- $link = "<a href=\"$url\">$url</a>";
+ $link = "<a href=\"{$url}\">{$url}</a>";
$appName = \config('app.name');
- $this->assertSame("$appName Invitation", $mail['subject']);
+ $this->assertSame("{$appName} Invitation", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $link) > 0);
- $this->assertTrue(strpos($html, "invited to join $appName") > 0);
+ $this->assertTrue(strpos($html, "invited to join {$appName}") > 0);
$this->assertStringStartsWith("Hi,", $plain);
- $this->assertTrue(strpos($plain, "invited to join $appName") > 0);
+ $this->assertTrue(strpos($plain, "invited to join {$appName}") > 0);
$this->assertTrue(strpos($plain, $url) > 0);
}
@@ -46,13 +46,13 @@
{
$appName = \config('app.name');
$invitation = new SI([
- 'id' => 'abc',
- 'email' => 'test@email',
+ 'id' => 'abc',
+ 'email' => 'test@email',
]);
$mail = new SignupInvitation($invitation);
- $this->assertSame("$appName Invitation", $mail->getSubject());
- $this->assertSame(null, $mail->getUser());
+ $this->assertSame("{$appName} Invitation", $mail->getSubject());
+ $this->assertNull($mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/SignupVerificationTest.php b/src/tests/Unit/Mail/SignupVerificationTest.php
--- a/src/tests/Unit/Mail/SignupVerificationTest.php
+++ b/src/tests/Unit/Mail/SignupVerificationTest.php
@@ -15,11 +15,11 @@
public function testBuild(): void
{
$code = new SignupCode([
- 'code' => 'code',
- 'short_code' => 'short-code',
- 'email' => 'test@email',
- 'first_name' => 'First',
- 'last_name' => 'Last',
+ 'code' => 'code',
+ 'short_code' => 'short-code',
+ 'email' => 'test@email',
+ 'first_name' => 'First',
+ 'last_name' => 'Last',
]);
$mail = $this->renderMail(new SignupVerification($code));
@@ -28,10 +28,10 @@
$plain = $mail['plain'];
$url = Utils::serviceUrl('/signup/' . $code->short_code . '-' . $code->code);
- $link = "<a href=\"$url\">$url</a>";
+ $link = "<a href=\"{$url}\">{$url}</a>";
$appName = \config('app.name');
- $this->assertSame("$appName Registration", $mail['subject']);
+ $this->assertSame("{$appName} Registration", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $link) > 0);
@@ -48,16 +48,16 @@
{
$appName = \config('app.name');
$code = new SignupCode([
- 'code' => 'code',
- 'short_code' => 'short-code',
- 'email' => 'test@email',
- 'first_name' => 'First',
- 'last_name' => 'Last',
+ 'code' => 'code',
+ 'short_code' => 'short-code',
+ 'email' => 'test@email',
+ 'first_name' => 'First',
+ 'last_name' => 'Last',
]);
$mail = new SignupVerification($code);
- $this->assertSame("$appName Registration", $mail->getSubject());
- $this->assertSame(null, $mail->getUser());
+ $this->assertSame("{$appName} Registration", $mail->getSubject());
+ $this->assertNull($mail->getUser());
}
}
diff --git a/src/tests/Unit/Mail/TrialEndTest.php b/src/tests/Unit/Mail/TrialEndTest.php
--- a/src/tests/Unit/Mail/TrialEndTest.php
+++ b/src/tests/Unit/Mail/TrialEndTest.php
@@ -16,8 +16,8 @@
$user = new User();
\config([
- 'app.support_url' => 'https://kolab.org/support',
- 'app.kb.payment_system' => 'https://kb.kolab.org/payment-system',
+ 'app.support_url' => 'https://kolab.org/support',
+ 'app.kb.payment_system' => 'https://kb.kolab.org/payment-system',
]);
$mail = $this->renderMail(new TrialEnd($user));
@@ -31,20 +31,20 @@
$paymentLink = sprintf('<a href="%s">%s</a>', $paymentUrl, $paymentUrl);
$appName = \config('app.name');
- $this->assertSame("$appName: Your trial phase has ended", $mail['subject']);
+ $this->assertSame("{$appName}: Your trial phase has ended", $mail['subject']);
$this->assertStringStartsWith('<!DOCTYPE html>', $html);
$this->assertTrue(strpos($html, $user->name(true)) > 0);
$this->assertTrue(strpos($html, $supportLink) > 0);
$this->assertTrue(strpos($html, $paymentLink) > 0);
- $this->assertTrue(strpos($html, "30 days of free $appName trial") > 0);
- $this->assertTrue(strpos($html, "$appName Team") > 0);
+ $this->assertTrue(strpos($html, "30 days of free {$appName} trial") > 0);
+ $this->assertTrue(strpos($html, "{$appName} Team") > 0);
$this->assertStringStartsWith('Dear ' . $user->name(true), $plain);
$this->assertTrue(strpos($plain, $supportUrl) > 0);
$this->assertTrue(strpos($plain, $paymentUrl) > 0);
- $this->assertTrue(strpos($plain, "30 days of free $appName trial") > 0);
- $this->assertTrue(strpos($plain, "$appName Team") > 0);
+ $this->assertTrue(strpos($plain, "30 days of free {$appName} trial") > 0);
+ $this->assertTrue(strpos($plain, "{$appName} Team") > 0);
}
/**
@@ -57,7 +57,7 @@
$mail = new TrialEnd($user);
- $this->assertSame("$appName: Your trial phase has ended", $mail->getSubject());
+ $this->assertSame("{$appName}: Your trial phase has ended", $mail->getSubject());
$this->assertSame($user, $mail->getUser());
}
}
diff --git a/src/tests/Unit/Policy/Mailfilter/MailParserTest.php b/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
--- a/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
+++ b/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
@@ -100,7 +100,7 @@
$this->assertSame('aa=aa', $parser->getBody(0));
$this->assertSame('multipart/alternative', $parser->getContentType());
- $this->assertSame(null, $parser->getHeader('content-transfer-encoding'));
+ $this->assertNull($parser->getHeader('content-transfer-encoding'));
$this->assertSame('aa=aa', $part->getBody());
$this->assertSame('text/plain', $part->getContentType());
$this->assertSame('quoted-printable', $part->getHeader('content-transfer-encoding'));
@@ -135,7 +135,7 @@
$parser = new MailParser($parser->getStream());
- $this->assertSame(null, $parser->getHeader('subject'));
+ $this->assertNull($parser->getHeader('subject'));
$this->assertSame('eeea', $parser->getBody());
$this->assertSame('"Sync 1" <test@kolab.org>', $parser->getHeader('from'));
}
diff --git a/src/tests/Unit/Rules/ExternalEmailTest.php b/src/tests/Unit/Rules/ExternalEmailTest.php
--- a/src/tests/Unit/Rules/ExternalEmailTest.php
+++ b/src/tests/Unit/Rules/ExternalEmailTest.php
@@ -8,30 +8,10 @@
class ExternalEmailTest extends TestCase
{
- /**
- * List of email address validation cases for testExternalEmail()
- *
- * @return array Arguments for testExternalEmail()
- */
- public static function dataExternalEmail(): array
- {
- return [
- // invalid
- ['example.org', 'The specified email address is invalid.'],
- ['@example.org', 'The specified email address is invalid.'],
- ['test@localhost', 'The specified email address is invalid.'],
- // FIXME: empty - valid ??????
- ['', null],
- // valid
- ['test@domain.tld', null],
- ['&@example.org', null],
- ];
- }
-
/**
* Test external email validation
*
- * @dataProvider dataExternalEmail
+ * @dataProvider provideExternalEmailCases
*/
public function testExternalEmail($email, $expected_result): void
{
@@ -49,4 +29,24 @@
$this->assertSame($expected_result, $result);
}
+
+ /**
+ * List of email address validation cases for testExternalEmail()
+ *
+ * @return array Arguments for testExternalEmail()
+ */
+ public static function provideExternalEmailCases(): iterable
+ {
+ return [
+ // invalid
+ ['example.org', 'The specified email address is invalid.'],
+ ['@example.org', 'The specified email address is invalid.'],
+ ['test@localhost', 'The specified email address is invalid.'],
+ // FIXME: empty - valid ??????
+ ['', null],
+ // valid
+ ['test@domain.tld', null],
+ ['&@example.org', null],
+ ];
+ }
}
diff --git a/src/tests/Unit/Rules/PasswordTest.php b/src/tests/Unit/Rules/PasswordTest.php
--- a/src/tests/Unit/Rules/PasswordTest.php
+++ b/src/tests/Unit/Rules/PasswordTest.php
@@ -3,6 +3,8 @@
namespace Tests\Unit\Rules;
use App\Rules\Password;
+use App\User;
+use App\Utils;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Tests\TestCase;
@@ -18,32 +20,32 @@
\config(['app.password_policy' => 'min:5']);
$this->assertSame($error, $this->validate('abcd'));
- $this->assertSame(null, $this->validate('abcde'));
+ $this->assertNull($this->validate('abcde'));
\config(['app.password_policy' => 'min:5,max:10']);
$this->assertSame($error, $this->validate('12345678901'));
- $this->assertSame(null, $this->validate('1234567890'));
+ $this->assertNull($this->validate('1234567890'));
\config(['app.password_policy' => 'min:5,lower']);
$this->assertSame($error, $this->validate('12345'));
$this->assertSame($error, $this->validate('AAAAA'));
- $this->assertSame(null, $this->validate('12345a'));
+ $this->assertNull($this->validate('12345a'));
\config(['app.password_policy' => 'upper']);
$this->assertSame($error, $this->validate('5'));
$this->assertSame($error, $this->validate('a'));
- $this->assertSame(null, $this->validate('A'));
+ $this->assertNull($this->validate('A'));
\config(['app.password_policy' => 'digit']);
$this->assertSame($error, $this->validate('a'));
$this->assertSame($error, $this->validate('A'));
- $this->assertSame(null, $this->validate('5'));
+ $this->assertNull($this->validate('5'));
\config(['app.password_policy' => 'special']);
$this->assertSame($error, $this->validate('a'));
$this->assertSame($error, $this->validate('5'));
- $this->assertSame(null, $this->validate('*'));
- $this->assertSame(null, $this->validate('-'));
+ $this->assertNull($this->validate('*'));
+ $this->assertNull($this->validate('-'));
// Test with an account policy
$user = $this->getTestUser('john@kolab.org');
@@ -51,7 +53,7 @@
$this->assertSame($error, $this->validate('aaa', $user));
$this->assertSame($error, $this->validate('1234567890', $user));
- $this->assertSame(null, $this->validate('1234567890A', $user));
+ $this->assertNull($this->validate('1234567890A', $user));
}
/**
@@ -68,37 +70,37 @@
$this->assertSame('min', $result['min']['label']);
$this->assertSame('Minimum password length: 5 characters', $result['min']['name']);
$this->assertSame('5', $result['min']['param']);
- $this->assertSame(true, $result['min']['enabled']);
- $this->assertSame(false, $result['min']['status']);
+ $this->assertTrue($result['min']['enabled']);
+ $this->assertFalse($result['min']['status']);
$this->assertSame('max', $result['max']['label']);
$this->assertSame('Maximum password length: 10 characters', $result['max']['name']);
$this->assertSame('10', $result['max']['param']);
- $this->assertSame(true, $result['max']['enabled']);
- $this->assertSame(true, $result['max']['status']);
+ $this->assertTrue($result['max']['enabled']);
+ $this->assertTrue($result['max']['status']);
$this->assertSame('upper', $result['upper']['label']);
$this->assertSame('Password contains an upper-case character', $result['upper']['name']);
- $this->assertSame(null, $result['upper']['param']);
- $this->assertSame(true, $result['upper']['enabled']);
- $this->assertSame(false, $result['upper']['status']);
+ $this->assertNull($result['upper']['param']);
+ $this->assertTrue($result['upper']['enabled']);
+ $this->assertFalse($result['upper']['status']);
$this->assertSame('lower', $result['lower']['label']);
$this->assertSame('Password contains a lower-case character', $result['lower']['name']);
- $this->assertSame(null, $result['lower']['param']);
- $this->assertSame(true, $result['lower']['enabled']);
- $this->assertSame(true, $result['lower']['status']);
+ $this->assertNull($result['lower']['param']);
+ $this->assertTrue($result['lower']['enabled']);
+ $this->assertTrue($result['lower']['status']);
$this->assertSame('digit', $result['digit']['label']);
$this->assertSame('Password contains a digit', $result['digit']['name']);
- $this->assertSame(null, $result['digit']['param']);
- $this->assertSame(true, $result['digit']['enabled']);
- $this->assertSame(false, $result['digit']['status']);
+ $this->assertNull($result['digit']['param']);
+ $this->assertTrue($result['digit']['enabled']);
+ $this->assertFalse($result['digit']['status']);
// Test password history check
$user = $this->getTestUser('john@kolab.org');
$user->passwords()->delete();
- $user_pass = \App\Utils::generatePassphrase(); // should be the same plain password as John already has
+ $user_pass = Utils::generatePassphrase(); // should be the same plain password as John already has
$pass = new Password(null, $user);
@@ -110,14 +112,14 @@
$this->assertSame('min', $result['min']['label']);
$this->assertSame('Minimum password length: 5 characters', $result['min']['name']);
$this->assertSame('5', $result['min']['param']);
- $this->assertSame(true, $result['min']['enabled']);
- $this->assertSame(false, $result['min']['status']);
+ $this->assertTrue($result['min']['enabled']);
+ $this->assertFalse($result['min']['status']);
$this->assertSame('last', $result['last']['label']);
$this->assertSame('Password cannot be the same as the last 1 passwords', $result['last']['name']);
$this->assertSame('1', $result['last']['param']);
- $this->assertSame(true, $result['last']['enabled']);
- $this->assertSame(true, $result['last']['status']);
+ $this->assertTrue($result['last']['enabled']);
+ $this->assertTrue($result['last']['status']);
$result = $pass->check($user_pass);
@@ -125,21 +127,21 @@
$this->assertSame('last', $result['last']['label']);
$this->assertSame('Password cannot be the same as the last 1 passwords', $result['last']['name']);
$this->assertSame('1', $result['last']['param']);
- $this->assertSame(true, $result['last']['enabled']);
- $this->assertSame(false, $result['last']['status']);
+ $this->assertTrue($result['last']['enabled']);
+ $this->assertFalse($result['last']['status']);
$user->passwords()->create(['password' => Hash::make('1234567891')]);
$user->passwords()->create(['password' => Hash::make('1234567890')]);
$result = $pass->check('1234567890');
- $this->assertSame(true, $result['last']['status']);
+ $this->assertTrue($result['last']['status']);
\config(['app.password_policy' => 'min:5,last:3']);
$result = $pass->check('1234567890');
- $this->assertSame(false, $result['last']['status']);
+ $this->assertFalse($result['last']['status']);
}
/**
@@ -160,12 +162,12 @@
$this->assertSame('min', $result['min']['label']);
$this->assertSame('Minimum password length: 10 characters', $result['min']['name']);
$this->assertSame('10', $result['min']['param']);
- $this->assertSame(true, $result['min']['enabled']);
+ $this->assertTrue($result['min']['enabled']);
$this->assertSame('upper', $result['upper']['label']);
$this->assertSame('Password contains an upper-case character', $result['upper']['name']);
- $this->assertSame(null, $result['upper']['param']);
- $this->assertSame(true, $result['upper']['enabled']);
+ $this->assertNull($result['upper']['param']);
+ $this->assertTrue($result['upper']['enabled']);
// Expect to see all supported policy rules
$result = $pass->rules(true);
@@ -174,44 +176,44 @@
$this->assertSame('min', $result['min']['label']);
$this->assertSame('Minimum password length: 10 characters', $result['min']['name']);
$this->assertSame('10', $result['min']['param']);
- $this->assertSame(true, $result['min']['enabled']);
+ $this->assertTrue($result['min']['enabled']);
$this->assertSame('max', $result['max']['label']);
$this->assertSame('Maximum password length: 255 characters', $result['max']['name']);
$this->assertSame('255', $result['max']['param']);
- $this->assertSame(false, $result['max']['enabled']);
+ $this->assertFalse($result['max']['enabled']);
$this->assertSame('upper', $result['upper']['label']);
$this->assertSame('Password contains an upper-case character', $result['upper']['name']);
- $this->assertSame(null, $result['upper']['param']);
- $this->assertSame(true, $result['upper']['enabled']);
+ $this->assertNull($result['upper']['param']);
+ $this->assertTrue($result['upper']['enabled']);
$this->assertSame('lower', $result['lower']['label']);
$this->assertSame('Password contains a lower-case character', $result['lower']['name']);
- $this->assertSame(null, $result['lower']['param']);
- $this->assertSame(false, $result['lower']['enabled']);
+ $this->assertNull($result['lower']['param']);
+ $this->assertFalse($result['lower']['enabled']);
$this->assertSame('digit', $result['digit']['label']);
$this->assertSame('Password contains a digit', $result['digit']['name']);
- $this->assertSame(null, $result['digit']['param']);
- $this->assertSame(false, $result['digit']['enabled']);
+ $this->assertNull($result['digit']['param']);
+ $this->assertFalse($result['digit']['enabled']);
$this->assertSame('special', $result['special']['label']);
$this->assertSame('Password contains a special character', $result['special']['name']);
- $this->assertSame(null, $result['digit']['param']);
- $this->assertSame(false, $result['digit']['enabled']);
+ $this->assertNull($result['digit']['param']);
+ $this->assertFalse($result['digit']['enabled']);
$this->assertSame('last', $result['last']['label']);
$this->assertSame('Password cannot be the same as the last 3 passwords', $result['last']['name']);
$this->assertSame('3', $result['last']['param']);
- $this->assertSame(false, $result['last']['enabled']);
+ $this->assertFalse($result['last']['enabled']);
}
/**
* Validates the password using Laravel Validator API
*
- * @param string $password The password to validate
- * @param ?\App\User $owner The account owner
+ * @param string $password The password to validate
+ * @param ?User $owner The account owner
*
* @return ?string Validation error message on error, NULL otherwise
*/
diff --git a/src/tests/Unit/Rules/SharedFolderTypeTest.php b/src/tests/Unit/Rules/SharedFolderTypeTest.php
--- a/src/tests/Unit/Rules/SharedFolderTypeTest.php
+++ b/src/tests/Unit/Rules/SharedFolderTypeTest.php
@@ -3,6 +3,7 @@
namespace Tests\Unit\Rules;
use App\Rules\SharedFolderType;
+use App\SharedFolder;
use Illuminate\Support\Facades\Validator;
use Tests\TestCase;
@@ -26,7 +27,7 @@
$this->assertSame(['type' => ["The specified type is invalid."]], $v->errors()->toArray());
// Valid type
- foreach (\App\SharedFolder::SUPPORTED_TYPES as $type) {
+ foreach (SharedFolder::SUPPORTED_TYPES as $type) {
$v = Validator::make(['type' => $type], $rules);
$this->assertSame([], $v->errors()->toArray());
}
diff --git a/src/tests/Unit/Rules/SignupTokenTest.php b/src/tests/Unit/Rules/SignupTokenTest.php
--- a/src/tests/Unit/Rules/SignupTokenTest.php
+++ b/src/tests/Unit/Rules/SignupTokenTest.php
@@ -10,10 +10,7 @@
class SignupTokenTest extends TestCase
{
- /**
- * {@inheritDoc}
- */
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
@@ -21,10 +18,7 @@
SignupToken::truncate();
}
- /**
- * {@inheritDoc}
- */
- public function tearDown(): void
+ protected function tearDown(): void
{
Plan::where('title', 'test-plan')->delete();
SignupToken::truncate();
@@ -41,10 +35,10 @@
$plan = Plan::where('title', 'individual')->first();
$tokenPlan = Plan::create([
- 'title' => 'test-plan',
- 'description' => 'test',
- 'name' => 'Test',
- 'mode' => Plan::MODE_TOKEN,
+ 'title' => 'test-plan',
+ 'description' => 'test',
+ 'name' => 'Test',
+ 'mode' => Plan::MODE_TOKEN,
]);
$plan->signupTokens()->create(['id' => $tokens[0]]);
diff --git a/src/tests/Unit/Rules/UserEmailLocalTest.php b/src/tests/Unit/Rules/UserEmailLocalTest.php
--- a/src/tests/Unit/Rules/UserEmailLocalTest.php
+++ b/src/tests/Unit/Rules/UserEmailLocalTest.php
@@ -8,12 +8,31 @@
class UserEmailLocalTest extends TestCase
{
+ /**
+ * Test validation of email local part
+ *
+ * @dataProvider provideUserEmailLocalCases
+ */
+ public function testUserEmailLocal($user, $external, $error): void
+ {
+ $rules = ['user' => [new UserEmailLocal($external)]];
+
+ $v = Validator::make(['user' => $user], $rules);
+
+ if ($error) {
+ $this->assertTrue($v->fails());
+ $this->assertSame(['user' => [$error]], $v->errors()->toArray());
+ } else {
+ $this->assertFalse($v->fails());
+ }
+ }
+
/**
* List of email address validation cases for testUserEmailLocal()
*
* @return array Arguments for testUserEmailLocal()
*/
- public static function dataUserEmailLocal(): array
+ public static function provideUserEmailLocalCases(): iterable
{
return [
// non-string input
@@ -40,23 +59,4 @@
['Webmaster', true, null],
];
}
-
- /**
- * Test validation of email local part
- *
- * @dataProvider dataUserEmailLocal
- */
- public function testUserEmailLocal($user, $external, $error): void
- {
- $rules = ['user' => [new UserEmailLocal($external)]];
-
- $v = Validator::make(['user' => $user], $rules);
-
- if ($error) {
- $this->assertTrue($v->fails());
- $this->assertSame(['user' => [$error]], $v->errors()->toArray());
- } else {
- $this->assertFalse($v->fails());
- }
- }
}
diff --git a/src/tests/Unit/SharedFolderTest.php b/src/tests/Unit/SharedFolderTest.php
--- a/src/tests/Unit/SharedFolderTest.php
+++ b/src/tests/Unit/SharedFolderTest.php
@@ -4,6 +4,7 @@
use App\SharedFolder;
use Tests\TestCase;
+use Tests\Utils;
class SharedFolderTest extends TestCase
{
@@ -20,7 +21,7 @@
SharedFolder::STATUS_IMAP_READY,
];
- $folders = \Tests\Utils::powerSet($statuses);
+ $folders = Utils::powerSet($statuses);
$folder = new SharedFolder(['name' => 'test']);
diff --git a/src/tests/Unit/SignupCodeTest.php b/src/tests/Unit/SignupCodeTest.php
--- a/src/tests/Unit/SignupCodeTest.php
+++ b/src/tests/Unit/SignupCodeTest.php
@@ -3,20 +3,19 @@
namespace Tests\Unit;
use App\SignupCode;
+use App\Utils;
use Tests\TestCase;
class SignupCodeTest extends TestCase
{
/**
* Test SignupCode::generateShortCode()
- *
- * @return void
*/
public function testGenerateShortCode()
{
$code = SignupCode::generateShortCode();
$this->assertTrue(strlen($code) === env('SIGNUP_CODE_LENGTH', SignupCode::SHORTCODE_LENGTH));
- $this->assertTrue(strspn($code, env('SIGNUP_CODE_CHARS', \App\Utils::CHARS)) === strlen($code));
+ $this->assertTrue(strspn($code, env('SIGNUP_CODE_CHARS', Utils::CHARS)) === strlen($code));
}
}
diff --git a/src/tests/Unit/SignupInvitationTest.php b/src/tests/Unit/SignupInvitationTest.php
--- a/src/tests/Unit/SignupInvitationTest.php
+++ b/src/tests/Unit/SignupInvitationTest.php
@@ -9,8 +9,6 @@
{
/**
* Test is*() methods
- *
- * @return void
*/
public function testStatus()
{
diff --git a/src/tests/Unit/TransactionTest.php b/src/tests/Unit/TransactionTest.php
--- a/src/tests/Unit/TransactionTest.php
+++ b/src/tests/Unit/TransactionTest.php
@@ -23,63 +23,63 @@
// Create transactions
$transaction = Transaction::create([
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_PENALTY,
- 'amount' => -10,
- 'description' => "A test penalty"
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_PENALTY,
+ 'amount' => -10,
+ 'description' => "A test penalty",
]);
$transaction = Transaction::create([
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_DEBIT,
- 'amount' => -9
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_DEBIT,
+ 'amount' => -9,
]);
$transaction = Transaction::create([
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_CREDIT,
- 'amount' => 11
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_CREDIT,
+ 'amount' => 11,
]);
$transaction = Transaction::create([
- 'object_id' => $wallet->id,
- 'object_type' => Wallet::class,
- 'type' => Transaction::WALLET_AWARD,
- 'amount' => 12,
- 'description' => "A test award"
+ 'object_id' => $wallet->id,
+ 'object_type' => Wallet::class,
+ 'type' => Transaction::WALLET_AWARD,
+ 'amount' => 12,
+ 'description' => "A test award",
]);
$sku = Sku::withEnvTenantContext()->where('title', 'mailbox')->first();
$entitlement = Entitlement::where('sku_id', $sku->id)->first();
$transaction = Transaction::create([
- 'user_email' => 'test@test.com',
- 'object_id' => $entitlement->id,
- 'object_type' => Entitlement::class,
- 'type' => Transaction::ENTITLEMENT_CREATED,
- 'amount' => 13
+ 'user_email' => 'test@test.com',
+ 'object_id' => $entitlement->id,
+ 'object_type' => Entitlement::class,
+ 'type' => Transaction::ENTITLEMENT_CREATED,
+ 'amount' => 13,
]);
$sku = Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first();
$entitlement = Entitlement::where('sku_id', $sku->id)->first();
$transaction = Transaction::create([
- 'user_email' => 'test@test.com',
- 'object_id' => $entitlement->id,
- 'object_type' => Entitlement::class,
- 'type' => Transaction::ENTITLEMENT_BILLED,
- 'amount' => 14
+ 'user_email' => 'test@test.com',
+ 'object_id' => $entitlement->id,
+ 'object_type' => Entitlement::class,
+ 'type' => Transaction::ENTITLEMENT_BILLED,
+ 'amount' => 14,
]);
$sku = Sku::withEnvTenantContext()->where('title', 'storage')->first();
$entitlement = Entitlement::where('sku_id', $sku->id)->first();
$transaction = Transaction::create([
- 'user_email' => 'test@test.com',
- 'object_id' => $entitlement->id,
- 'object_type' => Entitlement::class,
- 'type' => Transaction::ENTITLEMENT_DELETED,
- 'amount' => 15
+ 'user_email' => 'test@test.com',
+ 'object_id' => $entitlement->id,
+ 'object_type' => Entitlement::class,
+ 'type' => Transaction::ENTITLEMENT_DELETED,
+ 'amount' => 15,
]);
$transactions = Transaction::where('amount', '<', 20)->orderBy('amount')->get();
@@ -177,15 +177,15 @@
'object_id' => 'fake-id',
'object_type' => Wallet::class,
'type' => 'invalid',
- 'amount' => 9
+ 'amount' => 9,
]
);
}
public function testEntitlementForWallet(): void
{
- $transaction = \App\Transaction::where('object_type', \App\Wallet::class)
- ->whereIn('object_id', \App\Wallet::pluck('id'))->first();
+ $transaction = Transaction::where('object_type', Wallet::class)
+ ->whereIn('object_id', Wallet::pluck('id'))->first();
$entitlement = $transaction->entitlement();
$this->assertNull($entitlement);
@@ -194,8 +194,8 @@
public function testWalletForEntitlement(): void
{
- $transaction = \App\Transaction::where('object_type', \App\Entitlement::class)
- ->whereIn('object_id', \App\Entitlement::pluck('id'))->first();
+ $transaction = Transaction::where('object_type', Entitlement::class)
+ ->whereIn('object_id', Entitlement::pluck('id'))->first();
$wallet = $transaction->wallet();
$this->assertNull($wallet);
diff --git a/src/tests/Unit/UserTest.php b/src/tests/Unit/UserTest.php
--- a/src/tests/Unit/UserTest.php
+++ b/src/tests/Unit/UserTest.php
@@ -3,8 +3,8 @@
namespace Tests\Unit;
use App\User;
-use App\Wallet;
use Tests\TestCase;
+use Tests\Utils;
class UserTest extends TestCase
{
@@ -54,7 +54,7 @@
$this->assertSame(User::ROLE_RESELLER, $user->role);
$user->role = null;
- $this->assertSame(null, $user->role);
+ $this->assertNull($user->role);
$this->expectException(\Exception::class);
$user->role = 'unknown';
@@ -76,7 +76,7 @@
User::STATUS_RESTRICTED,
];
- $users = \Tests\Utils::powerSet($statuses);
+ $users = Utils::powerSet($statuses);
foreach ($users as $user_statuses) {
$user = new User(
diff --git a/src/tests/Unit/UtilsTest.php b/src/tests/Unit/UtilsTest.php
--- a/src/tests/Unit/UtilsTest.php
+++ b/src/tests/Unit/UtilsTest.php
@@ -2,7 +2,11 @@
namespace Tests\Unit;
+use App\IP4Net;
+use App\IP6Net;
+use App\User;
use App\Utils;
+use App\Wallet;
use Tests\TestCase;
class UtilsTest extends TestCase
@@ -13,30 +17,30 @@
public function testCountryForIP(): void
{
// Create some network records, the tables might be empty
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
- \App\IP6Net::where('net_number', inet_pton('2001:db8::ff00:42:0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP6Net::where('net_number', inet_pton('2001:db8::ff00:42:0'))->delete();
$this->assertSame('', Utils::countryForIP('127.0.0.1', ''));
$this->assertSame('CH', Utils::countryForIP('127.0.0.1'));
$this->assertSame('', Utils::countryForIP('2001:db8::ff00:42:1', ''));
$this->assertSame('CH', Utils::countryForIP('2001:db8::ff00:42:1'));
- \App\IP4Net::create([
- 'net_number' => '127.0.0.0',
- 'net_broadcast' => '127.255.255.255',
- 'net_mask' => 8,
- 'country' => 'US',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP4Net::create([
+ 'net_number' => '127.0.0.0',
+ 'net_broadcast' => '127.255.255.255',
+ 'net_mask' => 8,
+ 'country' => 'US',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
- \App\IP6Net::create([
- 'net_number' => '2001:db8::ff00:42:0',
- 'net_broadcast' => \App\Utils::ip6Broadcast('2001:db8::ff00:42:0', 8),
- 'net_mask' => 8,
- 'country' => 'PL',
- 'rir_name' => 'test',
- 'serial' => 1,
+ IP6Net::create([
+ 'net_number' => '2001:db8::ff00:42:0',
+ 'net_broadcast' => Utils::ip6Broadcast('2001:db8::ff00:42:0', 8),
+ 'net_mask' => 8,
+ 'country' => 'PL',
+ 'rir_name' => 'test',
+ 'serial' => 1,
]);
$this->assertSame('US', Utils::countryForIP('127.0.0.1', ''));
@@ -44,8 +48,8 @@
$this->assertSame('PL', Utils::countryForIP('2001:db8::ff00:42:1', ''));
$this->assertSame('PL', Utils::countryForIP('2001:db8::ff00:42:1'));
- \App\IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
- \App\IP6Net::where('net_number', inet_pton('2001:db8::ff00:42:0'))->delete();
+ IP4Net::where('net_number', inet_pton('127.0.0.0'))->delete();
+ IP6Net::where('net_number', inet_pton('2001:db8::ff00:42:0'))->delete();
}
/**
@@ -97,11 +101,11 @@
*/
public function testIsSoftDeletable(): void
{
- $this->assertTrue(Utils::isSoftDeletable(\App\User::class));
- $this->assertFalse(Utils::isSoftDeletable(\App\Wallet::class));
+ $this->assertTrue(Utils::isSoftDeletable(User::class));
+ $this->assertFalse(Utils::isSoftDeletable(Wallet::class));
- $this->assertTrue(Utils::isSoftDeletable(new \App\User()));
- $this->assertFalse(Utils::isSoftDeletable(new \App\Wallet()));
+ $this->assertTrue(Utils::isSoftDeletable(new User()));
+ $this->assertFalse(Utils::isSoftDeletable(new Wallet()));
}
/**
@@ -243,10 +247,10 @@
// Exchange rates are volatile, can't test with high accuracy.
$this->assertTrue(Utils::exchangeRate("CHF", "EUR") >= 0.88);
- //$this->assertEqualsWithDelta(0.90503424978382, Utils::exchangeRate("CHF", "EUR"), PHP_FLOAT_EPSILON);
+ // $this->assertEqualsWithDelta(0.90503424978382, Utils::exchangeRate("CHF", "EUR"), PHP_FLOAT_EPSILON);
$this->assertTrue(Utils::exchangeRate("EUR", "CHF") <= 1.12);
- //$this->assertEqualsWithDelta(1.1049305595217682, Utils::exchangeRate("EUR", "CHF"), PHP_FLOAT_EPSILON);
+ // $this->assertEqualsWithDelta(1.1049305595217682, Utils::exchangeRate("EUR", "CHF"), PHP_FLOAT_EPSILON);
$this->expectException(\Exception::class);
$this->assertSame(1.0, Utils::exchangeRate("CHF", "FOO"));
diff --git a/src/tests/Unit/VerificationCodeTest.php b/src/tests/Unit/VerificationCodeTest.php
--- a/src/tests/Unit/VerificationCodeTest.php
+++ b/src/tests/Unit/VerificationCodeTest.php
@@ -2,6 +2,7 @@
namespace Tests\Unit;
+use App\Utils;
use App\VerificationCode;
use Tests\TestCase;
@@ -9,8 +10,6 @@
{
/**
* Test VerificationCode::generateShortCode()
- *
- * @return void
*/
public function testGenerateShortCode()
{
@@ -19,6 +18,6 @@
$code_length = env('VERIFICATION_CODE_LENGTH', VerificationCode::SHORTCODE_LENGTH);
$this->assertTrue(strlen($code) === $code_length);
- $this->assertTrue(strspn($code, \App\Utils::CHARS) === strlen($code));
+ $this->assertTrue(strspn($code, Utils::CHARS) === strlen($code));
}
}
diff --git a/src/tests/Unit/WalletTest.php b/src/tests/Unit/WalletTest.php
--- a/src/tests/Unit/WalletTest.php
+++ b/src/tests/Unit/WalletTest.php
@@ -2,6 +2,9 @@
namespace Tests\Unit;
+use App\Discount;
+use App\Entitlement;
+use App\User;
use App\Wallet;
use Carbon\Carbon;
use Tests\TestCase;
@@ -32,15 +35,15 @@
*/
public function testEntitlementCosts()
{
- $discount = \App\Discount::where('discount', 30)->first();
+ $discount = Discount::where('discount', 30)->first();
$wallet = new Wallet(['currency' => 'CHF', 'id' => 123]);
- $ent = new \App\Entitlement([
- 'wallet_id' => $wallet->id,
- 'sku_id' => 456,
- 'cost' => 100,
- 'fee' => 50,
- 'entitleable_id' => 789,
- 'entitleable_type' => \App\User::class,
+ $ent = new Entitlement([
+ 'wallet_id' => $wallet->id,
+ 'sku_id' => 456,
+ 'cost' => 100,
+ 'fee' => 50,
+ 'entitleable_id' => 789,
+ 'entitleable_type' => User::class,
]);
$wallet->discount = $discount; // @phpstan-ignore-line
diff --git a/src/tests/Utils.php b/src/tests/Utils.php
--- a/src/tests/Utils.php
+++ b/src/tests/Utils.php
@@ -2,8 +2,6 @@
namespace Tests;
-use Illuminate\Support\Str;
-
/**
* Small utility functions for tests
*/
@@ -12,7 +10,7 @@
/**
* Provide all unique combinations of elements in $input, with order and duplicates irrelevant.
*
- * @param array $input The input array of elements.
+ * @param array $input the input array of elements
*
* @return array[]
*/

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 7:32 AM (1 d, 7 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c0/d1/9f8e19fa0d914d36577b48649c94
Default Alt Text
D5238.1775287928.diff (2 MB)

Event Timeline