summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml17
-rw-r--r--README.md8
-rw-r--r--composer.json1
-rw-r--r--db/migrations/2018_01_01_000001_import_install_sql.php3
-rw-r--r--db/migrations/2018_01_01_000003_fix_old_tables.php3
-rw-r--r--db/migrations/2018_10_01_000000_create_users_tables.php25
-rw-r--r--db/migrations/ChangesReferences.php6
-rw-r--r--resources/lang/de_DE/default.po4
-rw-r--r--resources/lang/en_US/default.po5
-rw-r--r--src/Controllers/Metrics/MetricsEngine.php6
-rw-r--r--src/Controllers/PasswordResetController.php8
-rw-r--r--src/Database/Migration/Migrate.php7
-rw-r--r--src/Exceptions/Handler.php7
-rw-r--r--src/Exceptions/Handlers/Legacy.php2
-rw-r--r--src/Exceptions/Handlers/LegacyDevelopment.php6
-rw-r--r--src/Http/Validation/ValidatesRequest.php6
-rw-r--r--src/Middleware/LegacyMiddleware.php5
-rw-r--r--src/Models/LogEntry.php2
-rw-r--r--src/Models/User/PasswordReset.php2
-rw-r--r--src/helpers.php1
-rw-r--r--tests/Feature/Model/LogEntryTest.php20
-rw-r--r--tests/Unit/Controllers/PasswordResetControllerTest.php2
-rw-r--r--tests/Unit/Helpers/AuthenticatorTest.php4
-rw-r--r--tests/Unit/Helpers/Translation/TranslatorTest.php13
-rw-r--r--tests/Unit/Http/Psr7ServiceProviderTest.php2
-rw-r--r--tests/Unit/Logger/EngelsystemLoggerTest.php5
-rw-r--r--tests/Unit/Models/LogEntryTest.php20
-rw-r--r--tests/Unit/Models/User/UserTest.php2
28 files changed, 127 insertions, 65 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 2590a0b3..82c9fd6d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -70,13 +70,24 @@ test:
- apk add ${PHPIZE_DEPS} && pecl install xdebug && docker-php-ext-enable xdebug
- curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
- cp -R tests/ phpunit.xml "${DOCROOT}"
- - HOMEDIR=$(pwd)
+ - HOMEDIR=$PWD
- cd "${DOCROOT}"
- composer --no-ansi install
- ./bin/migrate
script:
- - vendor/bin/phpunit -v --colors=never --coverage-text --coverage-html "${HOMEDIR}/coverage/" --log-junit "${HOMEDIR}/unittests.xml"
- - bin/migrate down
+ - ./vendor/bin/phpunit -v --colors=never --coverage-text --coverage-html "${HOMEDIR}/coverage/" --log-junit "${HOMEDIR}/unittests.xml"
+ - ./bin/migrate down
+
+check-style:
+ image: ${TEST_IMAGE}
+ stage: test
+ before_script:
+ - curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
+ - cp -R tests/ "${DOCROOT}"
+ - cd "${DOCROOT}"
+ - composer --no-ansi install
+ script:
+ - ./vendor/bin/phpcs --no-colors --basepath="$PWD" -p --standard=PSR12 config/ db/ public/index.php src/ tests/
release-image:
<<: *docker_definition
diff --git a/README.md b/README.md
index 037a9e75..7fc3e5ed 100644
--- a/README.md
+++ b/README.md
@@ -196,5 +196,9 @@ For more information on how to use it call `./bin/migrate help`
### Translation
We use gettext. You may use POEdit to extract new texts from the sourcecode. Please config POEdit to extract also the twig template files using the following settings: https://gist.github.com/jlambe/a868d9b63d70902a12254ce47069d0e6
-### Codestyle
-Please ensure that your pull requests follow [PSR-2](http://www.php-fig.org/psr/psr-2/) and [PSR-4](http://www.php-fig.org/psr/psr-4/).
+### Code style
+Please ensure that your pull requests follows the [PSR-12](http://www.php-fig.org/psr/psr-12/) coding style guide.
+You can check that by running
+```php
+vendor/bin/phpcs --standard=PSR12 config/ db/ public/index.php src/ tests/
+```
diff --git a/composer.json b/composer.json
index a1f2101b..2f20655f 100644
--- a/composer.json
+++ b/composer.json
@@ -44,6 +44,7 @@
"dms/phpunit-arraysubset-asserts": "^0.1.0",
"filp/whoops": "^2.3",
"phpunit/phpunit": "^8.1",
+ "squizlabs/php_codesniffer": "^3.5",
"symfony/var-dumper": "^4.3"
},
"autoload": {
diff --git a/db/migrations/2018_01_01_000001_import_install_sql.php b/db/migrations/2018_01_01_000001_import_install_sql.php
index eae8c810..7f1619e3 100644
--- a/db/migrations/2018_01_01_000001_import_install_sql.php
+++ b/db/migrations/2018_01_01_000001_import_install_sql.php
@@ -47,8 +47,7 @@ class ImportInstallSql extends Migration
/**
* Reverse the migration
*/
- public
- function down()
+ public function down()
{
$this->schema->getConnection()->statement('SET FOREIGN_KEY_CHECKS=0;');
diff --git a/db/migrations/2018_01_01_000003_fix_old_tables.php b/db/migrations/2018_01_01_000003_fix_old_tables.php
index 0ae9a1a5..822846db 100644
--- a/db/migrations/2018_01_01_000003_fix_old_tables.php
+++ b/db/migrations/2018_01_01_000003_fix_old_tables.php
@@ -18,7 +18,8 @@ class FixOldTables extends Migration
[
'User' => 'CreateDate',
'NewsComments' => 'Datum',
- ] as $table => $column) {
+ ] as $table => $column
+ ) {
if (!$this->schema->hasTable($table)) {
continue;
}
diff --git a/db/migrations/2018_10_01_000000_create_users_tables.php b/db/migrations/2018_10_01_000000_create_users_tables.php
index 52b3658f..40721286 100644
--- a/db/migrations/2018_10_01_000000_create_users_tables.php
+++ b/db/migrations/2018_10_01_000000_create_users_tables.php
@@ -83,8 +83,10 @@ class CreateUsersTables extends Migration
});
if ($this->schema->hasTable('User')) {
+ $emptyDates = ['0000-00-00 00:00:00', '0001-01-01 00:00:00', '1000-01-01 00:00:00'];
/** @var stdClass[] $users */
$users = $this->schema->getConnection()->table('User')->get();
+
foreach ($users as $data) {
$user = new User([
'name' => $data->Nick,
@@ -94,10 +96,7 @@ class CreateUsersTables extends Migration
'last_login_at' => Carbon::createFromTimestamp($data->lastLogIn),
]);
$user->setAttribute('id', $data->UID);
- if (!in_array(
- $data->CreateDate,
- ['0000-00-00 00:00:00', '0001-01-01 00:00:00', '1000-01-01 00:00:00']
- )) {
+ if (!in_array($data->CreateDate, $emptyDates)) {
$user->setAttribute('created_at', new Carbon($data->CreateDate));
}
$user->save();
@@ -114,8 +113,12 @@ class CreateUsersTables extends Migration
'first_name' => $data->Vorname ?: null,
'last_name' => $data->Name ?: null,
'shirt_size' => $data->Size ?: null,
- 'planned_arrival_date' => $data->planned_arrival_date ? Carbon::createFromTimestamp($data->planned_arrival_date) : null,
- 'planned_departure_date' => $data->planned_departure_date ? Carbon::createFromTimestamp($data->planned_departure_date) : null,
+ 'planned_arrival_date' => $data->planned_arrival_date
+ ? Carbon::createFromTimestamp($data->planned_arrival_date)
+ : null,
+ 'planned_departure_date' => $data->planned_departure_date
+ ? Carbon::createFromTimestamp($data->planned_departure_date)
+ : null,
]);
$personalData->user()
->associate($user)
@@ -181,7 +184,7 @@ class CreateUsersTables extends Migration
$table->string('DECT', 5)->nullable();
$table->string('Handy', 40)->nullable();
$table->string('email', 123)->nullable();
- $table->boolean('email_shiftinfo')->default(false)->comment('User wants to be informed by mail about changes in his shifts');
+ $table->boolean('email_shiftinfo')->default(false);
$table->string('jabber', 200)->nullable();
$table->string('Size', 4)->nullable();
$table->string('Passwort', 128)->nullable();
@@ -244,8 +247,12 @@ class CreateUsersTables extends Migration
'api_key' => $user->api_key,
'got_voucher' => $state->got_voucher,
'arrival_date' => $state->arrival_date ? $state->arrival_date->getTimestamp() : null,
- 'planned_arrival_date' => $personal->planned_arrival_date ? $personal->planned_arrival_date->getTimestamp() : null,
- 'planned_departure_date' => $personal->planned_departure_date ? $personal->planned_departure_date->getTimestamp() : null,
+ 'planned_arrival_date' => $personal->planned_arrival_date
+ ? $personal->planned_arrival_date->getTimestamp()
+ : null,
+ 'planned_departure_date' => $personal->planned_departure_date
+ ? $personal->planned_departure_date->getTimestamp()
+ : null,
'email_by_human_allowed' => $settings->email_human,
]);
}
diff --git a/db/migrations/ChangesReferences.php b/db/migrations/ChangesReferences.php
index 6bdd187d..1e7a5f10 100644
--- a/db/migrations/ChangesReferences.php
+++ b/db/migrations/ChangesReferences.php
@@ -24,14 +24,16 @@ trait ChangesReferences
$table->dropForeign($reference->constraint);
});
- $this->schema->table($reference->table,
+ $this->schema->table(
+ $reference->table,
function (Blueprint $table) use ($reference, $targetTable, $targetColumn, $type) {
$table->{$type}($reference->column)->change();
$table->foreign($reference->column)
->references($targetColumn)->on($targetTable)
->onDelete('cascade');
- });
+ }
+ );
}
}
diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po
index 1370fca2..cb39e5b2 100644
--- a/resources/lang/de_DE/default.po
+++ b/resources/lang/de_DE/default.po
@@ -2754,9 +2754,7 @@ msgid "Development Platform"
msgstr "Entwicklerplattform"
#: src/Middleware/LegacyMiddleware.php
-msgid ""
-"This page could not be found or you don't have permission to view it. You "
-"probably have to sign in or register in order to gain access!"
+msgid "page.404.text"
msgstr ""
"Diese Seite existiert nicht oder Du hast keinen Zugriff. Melde Dich an um "
"Zugriff zu erhalten!"
diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po
index 0119865b..cfb587f1 100644
--- a/resources/lang/en_US/default.po
+++ b/resources/lang/en_US/default.po
@@ -25,6 +25,11 @@ msgstr ""
msgid "form.submit"
msgstr "Submit"
+msgid "page.404.text"
+msgstr ""
+"This page could not be found or you don't have permission to view it. "
+"You probably have to sign in or register in order to gain access!"
+
msgid "credits.credit"
msgstr ""
"The original engelsystem was written by "
diff --git a/src/Controllers/Metrics/MetricsEngine.php b/src/Controllers/Metrics/MetricsEngine.php
index 21ae8fd0..8301e388 100644
--- a/src/Controllers/Metrics/MetricsEngine.php
+++ b/src/Controllers/Metrics/MetricsEngine.php
@@ -137,10 +137,12 @@ class MetricsEngine implements EngineInterface
}
/**
- * Does nothing as shared data will onyly result in unexpected behaviour
+ * Does nothing as shared data will only result in unexpected behaviour
*
* @param string|mixed[] $key
* @param mixed $value
*/
- public function share($key, $value = null) { }
+ public function share($key, $value = null)
+ {
+ }
}
diff --git a/src/Controllers/PasswordResetController.php b/src/Controllers/PasswordResetController.php
index a1460104..6ceadec1 100644
--- a/src/Controllers/PasswordResetController.php
+++ b/src/Controllers/PasswordResetController.php
@@ -74,7 +74,7 @@ class PasswordResetController extends BaseController
/** @var User $user */
$user = User::whereEmail($data['email'])->first();
if ($user) {
- $reset = (new PasswordReset)->findOrNew($user->id);
+ $reset = (new PasswordReset())->findOrNew($user->id);
$reset->user_id = $user->id;
$reset->token = md5(random_bytes(64));
$reset->save();
@@ -120,8 +120,10 @@ class PasswordResetController extends BaseController
]);
if ($data['password'] !== $data['password_confirmation']) {
- $this->session->set('errors',
- array_merge($this->session->get('errors', []), ['validation.password.confirmed']));
+ $this->session->set(
+ 'errors',
+ array_merge($this->session->get('errors', []), ['validation.password.confirmed'])
+ );
return $this->showView('pages/password/reset-form');
}
diff --git a/src/Database/Migration/Migrate.php b/src/Database/Migration/Migrate.php
index 214903e4..a0d5d4b0 100644
--- a/src/Database/Migration/Migrate.php
+++ b/src/Database/Migration/Migrate.php
@@ -11,8 +11,11 @@ use Illuminate\Support\Str;
class Migrate
{
- const UP = 'up';
- const DOWN = 'down';
+ /** @var string */
+ public const UP = 'up';
+
+ /** @var string */
+ public const DOWN = 'down';
/** @var Application */
protected $app;
diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php
index b3d840c0..f8905531 100644
--- a/src/Exceptions/Handler.php
+++ b/src/Exceptions/Handler.php
@@ -18,8 +18,11 @@ class Handler
/** @var Request */
protected $request;
- const ENV_PRODUCTION = 'prod';
- const ENV_DEVELOPMENT = 'dev';
+ /** @var string */
+ public const ENV_PRODUCTION = 'prod';
+
+ /** @var string */
+ public const ENV_DEVELOPMENT = 'dev';
/**
* Handler constructor.
diff --git a/src/Exceptions/Handlers/Legacy.php b/src/Exceptions/Handlers/Legacy.php
index 461dabe1..45285a8d 100644
--- a/src/Exceptions/Handlers/Legacy.php
+++ b/src/Exceptions/Handlers/Legacy.php
@@ -13,7 +13,7 @@ class Legacy implements HandlerInterface
*/
public function render($request, Throwable $e)
{
- echo 'An <del>un</del>expected error occurred, a team of untrained monkeys has been dispatched to deal with it.';
+ echo 'An <del>un</del>expected error occurred. A team of untrained monkeys has been dispatched to fix it.';
}
/**
diff --git a/src/Exceptions/Handlers/LegacyDevelopment.php b/src/Exceptions/Handlers/LegacyDevelopment.php
index cfa4efa4..d6a11949 100644
--- a/src/Exceptions/Handlers/LegacyDevelopment.php
+++ b/src/Exceptions/Handlers/LegacyDevelopment.php
@@ -15,7 +15,11 @@ class LegacyDevelopment extends Legacy
{
$file = $this->stripBasePath($e->getFile());
- echo '<pre style="background-color:#333;color:#ccc;z-index:1000;position:fixed;bottom:1em;padding:1em;width:97%;max-height: 90%;overflow-y:auto;">';
+ echo sprintf(
+ '<pre style="%s">',
+ 'background-color:#333;color:#ccc;z-index:1000;position:fixed;'
+ . 'bottom:1em;padding:1em;width:97%;max-height:90%;overflow-y:auto;'
+ );
echo sprintf('%s: (%s)' . PHP_EOL, get_class($e), $e->getCode());
$data = [
'string' => $e->getMessage(),
diff --git a/src/Http/Validation/ValidatesRequest.php b/src/Http/Validation/ValidatesRequest.php
index 33ff76af..142bd129 100644
--- a/src/Http/Validation/ValidatesRequest.php
+++ b/src/Http/Validation/ValidatesRequest.php
@@ -17,10 +17,12 @@ trait ValidatesRequest
*/
protected function validate(Request $request, array $rules)
{
- if (!$this->validator->validate(
+ $isValid = $this->validator->validate(
(array)$request->getParsedBody(),
$rules
- )) {
+ );
+
+ if (!$isValid) {
throw new ValidationException($this->validator);
}
diff --git a/src/Middleware/LegacyMiddleware.php b/src/Middleware/LegacyMiddleware.php
index 478ffab1..f652e766 100644
--- a/src/Middleware/LegacyMiddleware.php
+++ b/src/Middleware/LegacyMiddleware.php
@@ -82,7 +82,7 @@ class LegacyMiddleware implements MiddlewareInterface
$page = 404;
$title = $translator->translate('Page not found');
- $content = $translator->translate('This page could not be found or you don\'t have permission to view it. You probably have to sign in or register in order to gain access!');
+ $content = $translator->translate('page.404.text');
}
return $this->renderPage($page, $title, $content);
@@ -103,14 +103,17 @@ class LegacyMiddleware implements MiddlewareInterface
case 'ical':
require_once realpath(__DIR__ . '/../../includes/pages/user_ical.php');
user_ical();
+ break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'atom':
require_once realpath(__DIR__ . '/../../includes/pages/user_atom.php');
user_atom();
+ break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'shifts_json_export':
require_once realpath(__DIR__ . '/../../includes/controller/shifts_controller.php');
shifts_json_export_controller();
+ break;
case 'public_dashboard':
return public_dashboard_controller();
case 'angeltypes':
diff --git a/src/Models/LogEntry.php b/src/Models/LogEntry.php
index 53f72b65..8a73d305 100644
--- a/src/Models/LogEntry.php
+++ b/src/Models/LogEntry.php
@@ -24,7 +24,7 @@ class LogEntry extends BaseModel
public $timestamps = true;
/** @var null Disable updated_at */
- const UPDATED_AT = null;
+ public const UPDATED_AT = null;
/**
* The attributes that are mass assignable.
diff --git a/src/Models/User/PasswordReset.php b/src/Models/User/PasswordReset.php
index 82f44add..7f694268 100644
--- a/src/Models/User/PasswordReset.php
+++ b/src/Models/User/PasswordReset.php
@@ -18,7 +18,7 @@ class PasswordReset extends HasUserModel
public $timestamps = true;
/** @var null Disable updated_at */
- const UPDATED_AT = null;
+ public const UPDATED_AT = null;
/** The attributes that are mass assignable */
protected $fillable = [
diff --git a/src/helpers.php b/src/helpers.php
index 796b8764..de140c4e 100644
--- a/src/helpers.php
+++ b/src/helpers.php
@@ -1,5 +1,4 @@
<?php
-// Some useful functions
use Engelsystem\Application;
use Engelsystem\Config\Config;
diff --git a/tests/Feature/Model/LogEntryTest.php b/tests/Feature/Model/LogEntryTest.php
index 7fad8232..a8dd6961 100644
--- a/tests/Feature/Model/LogEntryTest.php
+++ b/tests/Feature/Model/LogEntryTest.php
@@ -13,15 +13,17 @@ class LogEntryTest extends TestCase
*/
public function testFilter()
{
- foreach ([
- 'Lorem Ipsum' => LogLevel::INFO,
- 'Some test content' => LogLevel::ERROR,
- 'Foo bar bartz!' => LogLevel::INFO,
- 'Someone did something?' => LogLevel::NOTICE,
- 'This is a Test!' => LogLevel::INFO,
- 'I\'m verbose notice!' => LogLevel::DEBUG,
- 'The newest stuff!!' => LogLevel::ERROR,
- ] as $message => $level) {
+ foreach (
+ [
+ 'Lorem Ipsum' => LogLevel::INFO,
+ 'Some test content' => LogLevel::ERROR,
+ 'Foo bar bartz!' => LogLevel::INFO,
+ 'Someone did something?' => LogLevel::NOTICE,
+ 'This is a Test!' => LogLevel::INFO,
+ 'I\'m verbose notice!' => LogLevel::DEBUG,
+ 'The newest stuff!!' => LogLevel::ERROR,
+ ] as $message => $level
+ ) {
$entry = new LogEntry(['level' => $level, 'message' => $message]);
$entry->save();
}
diff --git a/tests/Unit/Controllers/PasswordResetControllerTest.php b/tests/Unit/Controllers/PasswordResetControllerTest.php
index 09538416..c83b06b9 100644
--- a/tests/Unit/Controllers/PasswordResetControllerTest.php
+++ b/tests/Unit/Controllers/PasswordResetControllerTest.php
@@ -152,7 +152,7 @@ class PasswordResetControllerTest extends TestCase
$response = $controller->postResetPassword($request);
$this->assertEquals(200, $response->getStatusCode());
- $this->assertEmpty((new PasswordReset)->find($user->id));
+ $this->assertEmpty((new PasswordReset())->find($user->id));
$this->assertNotNull(auth()->authenticate($user->name, $password));
}
diff --git a/tests/Unit/Helpers/AuthenticatorTest.php b/tests/Unit/Helpers/AuthenticatorTest.php
index 1dc39a28..03033858 100644
--- a/tests/Unit/Helpers/AuthenticatorTest.php
+++ b/tests/Unit/Helpers/AuthenticatorTest.php
@@ -259,7 +259,9 @@ class AuthenticatorTest extends ServiceProviderTest
return new class extends Authenticator
{
/** @noinspection PhpMissingParentConstructorInspection */
- public function __construct() { }
+ public function __construct()
+ {
+ }
};
}
}
diff --git a/tests/Unit/Helpers/Translation/TranslatorTest.php b/tests/Unit/Helpers/Translation/TranslatorTest.php
index afb1aabc..5e341cfd 100644
--- a/tests/Unit/Helpers/Translation/TranslatorTest.php
+++ b/tests/Unit/Helpers/Translation/TranslatorTest.php
@@ -32,7 +32,7 @@ class TranslatorTest extends ServiceProviderTest
->method('__invoke')
->withConsecutive(['te_ST'], ['fo_OO']);
- $translator = new Translator($locale, 'fo_OO', function () { }, $locales, $localeChange);
+ $translator = new Translator($locale, 'fo_OO', [$this, 'doNothing'], $locales, $localeChange);
$this->assertEquals($locales, $translator->getLocales());
$this->assertEquals($locale, $translator->getLocale());
@@ -55,7 +55,7 @@ class TranslatorTest extends ServiceProviderTest
{
/** @var Translator|MockObject $translator */
$translator = $this->getMockBuilder(Translator::class)
- ->setConstructorArgs(['de_DE', 'en_US', function () { }, ['de_DE' => 'Deutsch']])
+ ->setConstructorArgs(['de_DE', 'en_US', [$this, 'doNothing'], ['de_DE' => 'Deutsch']])
->onlyMethods(['translateText'])
->getMock();
$translator->expects($this->exactly(2))
@@ -77,7 +77,7 @@ class TranslatorTest extends ServiceProviderTest
{
/** @var Translator|MockObject $translator */
$translator = $this->getMockBuilder(Translator::class)
- ->setConstructorArgs(['de_DE', 'en_US', function () { }, ['de_DE' => 'Deutsch']])
+ ->setConstructorArgs(['de_DE', 'en_US', [$this, 'doNothing'], ['de_DE' => 'Deutsch']])
->onlyMethods(['translateText'])
->getMock();
$translator->expects($this->once())
@@ -131,4 +131,11 @@ class TranslatorTest extends ServiceProviderTest
// Successful translation
$this->assertEquals('Lorem test3!', $translator->translatePlural('foo.barf', 'foo.bar2', 3, ['test3']));
}
+
+ /**
+ * Does nothing
+ */
+ public function doNothing()
+ {
+ }
}
diff --git a/tests/Unit/Http/Psr7ServiceProviderTest.php b/tests/Unit/Http/Psr7ServiceProviderTest.php
index 25c2f6e3..d0df726b 100644
--- a/tests/Unit/Http/Psr7ServiceProviderTest.php
+++ b/tests/Unit/Http/Psr7ServiceProviderTest.php
@@ -20,7 +20,7 @@ class Psr7ServiceProviderTest extends ServiceProviderTest
*/
public function testRegister()
{
- $app = new Application;
+ $app = new Application();
$serviceProvider = new Psr7ServiceProvider($app);
$serviceProvider->register();
diff --git a/tests/Unit/Logger/EngelsystemLoggerTest.php b/tests/Unit/Logger/EngelsystemLoggerTest.php
index 3b67aa29..6343717c 100644
--- a/tests/Unit/Logger/EngelsystemLoggerTest.php
+++ b/tests/Unit/Logger/EngelsystemLoggerTest.php
@@ -69,7 +69,10 @@ class EngelsystemLoggerTest extends ServiceProviderTest
'user' =>
new class
{
- public function __toString() { return 'Bar'; }
+ public function __toString()
+ {
+ return 'Bar';
+ }
}
]);
}
diff --git a/tests/Unit/Models/LogEntryTest.php b/tests/Unit/Models/LogEntryTest.php
index 4b772cd0..d4cef2e0 100644
--- a/tests/Unit/Models/LogEntryTest.php
+++ b/tests/Unit/Models/LogEntryTest.php
@@ -16,15 +16,17 @@ class LogEntryTest extends TestCase
*/
public function testFilter()
{
- foreach ([
- 'I\'m an info' => LogLevel::INFO,
- '*Insert explosion here*' => LogLevel::EMERGENCY,
- 'Tracing along' => LogLevel::DEBUG,
- 'Oops' => LogLevel::ERROR,
- 'It\'s happening' => LogLevel::INFO,
- 'Something is wrong' => LogLevel::ERROR,
- 'Ohi' => LogLevel::INFO,
- ] as $message => $level) {
+ foreach (
+ [
+ 'I\'m an info' => LogLevel::INFO,
+ '*Insert explosion here*' => LogLevel::EMERGENCY,
+ 'Tracing along' => LogLevel::DEBUG,
+ 'Oops' => LogLevel::ERROR,
+ 'It\'s happening' => LogLevel::INFO,
+ 'Something is wrong' => LogLevel::ERROR,
+ 'Ohi' => LogLevel::INFO,
+ ] as $message => $level
+ ) {
(new LogEntry(['level' => $level, 'message' => $message]))->save();
}
diff --git a/tests/Unit/Models/User/UserTest.php b/tests/Unit/Models/User/UserTest.php
index da121a4f..5cb8745d 100644
--- a/tests/Unit/Models/User/UserTest.php
+++ b/tests/Unit/Models/User/UserTest.php
@@ -113,7 +113,7 @@ class UserTest extends TestCase
foreach ($modelData as $data) {
/** @var BaseModel $model */
- $model = (new $class);
+ $model = $this->app->make($class);
$stored = $model->create($data + ['user_id' => $user->id]);
$relatedModelIds[] = $stored->id;
}