From b7e5556dfd5afa8c4515593dbe1181ab4af89af9 Mon Sep 17 00:00:00 2001
From: Lorand Gombos
Date: Wed, 13 Mar 2024 12:38:22 +0200
Subject: [PATCH] Laravel 11 (#120)
* Laravel 11 support
---
.github/workflows/test.yml | 25 +--
.gitignore | 3 +-
.scrutinizer.yml | 38 -----
.styleci.yml | 3 -
.travis.yml | 15 --
CHANGELOG.md | 5 +
README.md | 15 +-
composer.json | 16 +-
phpunit.xml.dist | 17 +-
tests/CommonFunctionalityTest.php | 157 +++++++-----------
...CreateSettingsFieldForModelConsoleTest.php | 10 +-
tests/CreateSettingsTableConsoleTest.php | 10 +-
tests/FieldSettingsManagerTest.php | 10 +-
tests/ParentChildSettingsTest.php | 6 +-
tests/RedisSettingsManagerTest.php | 6 +-
tests/TableSettingsManagerTest.php | 12 +-
tests/TestCase.php | 2 +-
tests/TestWrongModelTest.php | 6 +-
tests/TextFieldSettingsManagerTest.php | 12 +-
19 files changed, 135 insertions(+), 233 deletions(-)
delete mode 100644 .scrutinizer.yml
delete mode 100644 .styleci.yml
delete mode 100644 .travis.yml
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 2e43614..8fbe2b6 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -2,35 +2,36 @@ name: Test
on:
push:
- branches: [ master ]
+ branches:
+ - master
pull_request:
- branches: [ master ]
+ branches:
+ - master
jobs:
test:
-
runs-on: ubuntu-latest
+
strategy:
fail-fast: false
matrix:
- php: [8.1]
- laravel: [10.*]
+ php: ['8.1', '8.2', '8.3']
+ laravel: ['10.*', '11.*']
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 10.*
testbench: 8.*
+ - laravel: 11.*
+ testbench: 9.*
+ exclude:
+ - laravel: 11.*
+ php: 8.1
name: P ${{ matrix.php }} - L ${{ matrix.laravel }} - ${{ matrix.dependency-version }}
steps:
- name: Checkout code
- uses: actions/checkout@v2
-
- - name: Cache dependencies
- uses: actions/cache@v2
- with:
- path: ~/.composer/cache/files
- key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
+ uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
diff --git a/.gitignore b/.gitignore
index 2c572f2..6519128 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,8 @@ vendor/
/.idea
.php_cs.cache
composer.lock
-/.phpunit.result.cache
+/.phpunit.cache
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
# composer.lock
+/.php-cs-fixer.cache
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
deleted file mode 100644
index 7559a5a..0000000
--- a/.scrutinizer.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-build:
- nodes:
- analysis:
- tests:
- override:
- - php-scrutinizer-run
- - command: phpcs-run
- use_website_config: true
-filter:
- excluded_paths:
- - 'tests/*'
-checks:
- php:
- remove_extra_empty_lines: true
- remove_php_closing_tag: true
- remove_trailing_whitespace: true
- fix_use_statements:
- remove_unused: true
- preserve_multiple: false
- preserve_blanklines: true
- order_alphabetically: true
- fix_php_opening_tag: true
- fix_linefeed: true
- fix_line_ending: true
- fix_identation_4spaces: true
- fix_doc_comments: true
-
-coding_style:
- php:
- spaces:
- around_operators:
- concatenation: true
- other:
- after_type_cast: false
-tools:
- external_code_coverage:
- timeout: 600
- runs: 3
diff --git a/.styleci.yml b/.styleci.yml
deleted file mode 100644
index 57244be..0000000
--- a/.styleci.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-preset: psr2
-enabled:
- - phpdoc_annotation_without_dot
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 0358bd6..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-language: php
-
-php:
- - 8.0
-
-before_script:
- - composer selfupdate
- - composer install
-
-script:
- - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
-
-after_script:
- - wget https://scrutinizer-ci.com/ocular.phar
- - php ocular.phar code-coverage:upload --format=php-clover coverage.clover
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 61a824c..053e6d4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,11 @@
All notable changes to `glorand/laravel-model-settings` will be documented in this file
+## 7.0.0 - 2024-03-13
+### Added
+- Add support for Laravel 11
+- 8.1 min. php version
+
## 5.0.0 - 2022-02-10
### Added
- Add support for Laravel 9 by @belzaaron
diff --git a/README.md b/README.md
index 75738e9..aee5718 100644
--- a/README.md
+++ b/README.md
@@ -23,25 +23,12 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-The package requires PHP 7.3+ and follows the FIG standards PSR-1, PSR-2, PSR-4 and PSR-12
+The package requires PHP 8.1+ and follows the FIG standards PSR-1, PSR-2, PSR-4 and PSR-12
to ensure a high level of interoperability between shared PHP.
Bug reports, feature requests, and pull requests can be submitted by following our [Contribution Guide](CONTRIBUTING.md).
diff --git a/composer.json b/composer.json
index a3462c9..093f658 100644
--- a/composer.json
+++ b/composer.json
@@ -18,17 +18,17 @@
],
"require": {
"php": "^8.1",
- "illuminate/config": "^10.0",
- "illuminate/database": "^10.0",
- "illuminate/support": "^10.0",
- "illuminate/console": "^10.0",
- "illuminate/filesystem": "^10.0",
- "illuminate/cache": "^10.0",
+ "illuminate/config": "^10.0|^11.0",
+ "illuminate/database": "^10.0|^11.0",
+ "illuminate/support": "^10.0|^11.0",
+ "illuminate/console": "^10.0|^11.0",
+ "illuminate/filesystem": "^10.0|^11.0",
+ "illuminate/cache": "^10.0|^11.0",
"ext-json": "*"
},
"require-dev": {
- "phpunit/phpunit": "^9.5.10",
- "orchestra/testbench": "^8.0",
+ "phpunit/phpunit": "^10.5|^11.0",
+ "orchestra/testbench": "^8.0|^9.0",
"friendsofphp/php-cs-fixer": "^3.14",
"josiasmontag/laravel-redis-mock": "^1.2"
},
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 08e987b..5590526 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -2,20 +2,10 @@
-
-
- src
-
-
+ xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
tests
@@ -27,4 +17,9 @@
+
diff --git a/tests/CommonFunctionalityTest.php b/tests/CommonFunctionalityTest.php
index 2cd0de4..3a88030 100644
--- a/tests/CommonFunctionalityTest.php
+++ b/tests/CommonFunctionalityTest.php
@@ -2,6 +2,7 @@
namespace Glorand\Model\Settings\Tests;
+use PHPUnit\Framework\Attributes\DataProvider;
use Glorand\Model\Settings\Traits\HasSettingsField;
use Glorand\Model\Settings\Traits\HasSettingsRedis;
use Glorand\Model\Settings\Traits\HasSettingsTable;
@@ -9,17 +10,17 @@
use Illuminate\Validation\ValidationException;
use Lunaweb\RedisMock\MockPredisConnection;
-class CommonFunctionalityTest extends TestCase
+final class CommonFunctionalityTest extends TestCase
{
/** @var string[] */
- protected $modelTypes = [
+ protected static array $modelTypes = [
'field',
'text_field',
'table',
'redis',
];
/** @var \string[][] */
- protected $testArray = [
+ protected static array $testArray = [
'user' => [
'first_name' => "John",
'last_name' => "Doe",
@@ -52,22 +53,22 @@ class CommonFunctionalityTest extends TestCase
'user.age' => 'integer',
];
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
}
- public function modelTypesProvider(): array
+ public static function modelTypesProvider(): array
{
$modelTypes = [];
- foreach ($this->modelTypes as $modelType) {
+ foreach (self::$modelTypes as $modelType) {
$modelTypes[$modelType] = [$modelType];
}
return $modelTypes;
}
- public function testInit()
+ public function testInit(): void
{
$traits = class_uses($this->getModelByType('redis'));
$this->assertTrue(array_key_exists(HasSettingsRedis::class, $traits));
@@ -84,48 +85,40 @@ public function testInit()
$this->assertInstanceOf(MockPredisConnection::class, Redis::connection());
}
- /**
- * @dataProvider modelTypesProvider
- */
+ #[DataProvider('modelTypesProvider')]
public function testEmpty(string $modelType): void
{
$model = $this->getModelByType($modelType);
$this->assertTrue($model->settings()->clear()->empty());
- $this->assertFalse($model->settings()->apply($this->testArray)->empty());
+ $this->assertFalse($model->settings()->apply(self::$testArray)->empty());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testExist(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testExist(string $modelType): void
{
$model = $this->getModelByType($modelType);
$this->assertFalse($model->settings()->clear()->exist());
- $this->assertTrue($model->settings()->apply($this->testArray)->exist());
+ $this->assertTrue($model->settings()->apply(self::$testArray)->exist());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testHas(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testHas(string $modelType): void
{
$model = $this->getModelByType($modelType);
$this->assertEquals(
- $this->testArray,
- $model->settings()->apply($this->testArray)->all()
+ self::$testArray,
+ $model->settings()->apply(self::$testArray)->all()
);
$this->assertTrue($model->settings()->has('user.first_name'));
$this->assertFalse($model->settings()->has('user.role'));
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testAll(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testAll(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -135,28 +128,24 @@ public function testAll(string $modelType)
);
$this->assertEquals(
- $this->testArray,
- $model->settings()->apply($this->testArray)->all()
+ self::$testArray,
+ $model->settings()->apply(self::$testArray)->all()
);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testGet(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testGet(string $modelType): void
{
$model = $this->getModelByType($modelType);
$model->settings()->clear();
$this->assertEquals([], $model->settings()->all());
$this->assertEquals(null, $model->settings()->get('user'));
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
$this->assertEquals('John', $model->settings()->get('user.first_name'));
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testGetMultiple(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testGetMultiple(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -173,7 +162,7 @@ public function testGetMultiple(string $modelType)
$values
);
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
$values = $model->settings()->getMultiple(
['user', 'project.name', 'date'],
'def_val'
@@ -195,20 +184,16 @@ public function testGetMultiple(string $modelType)
);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testApply(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testApply(string $modelType): void
{
$model = $this->getModelByType($modelType);
- $model->settings()->apply($this->testArray);
- $this->assertEquals($this->testArray, $model->fresh()->settings()->all());
+ $model->settings()->apply(self::$testArray);
+ $this->assertEquals(self::$testArray, $model->fresh()->settings()->all());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testUpdate(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testUpdate(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -222,10 +207,8 @@ public function testUpdate(string $modelType)
$this->assertEquals(['user' => ['age' => 19]], $model->settings()->all());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testSet(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testSet(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -236,10 +219,8 @@ public function testSet(string $modelType)
$this->assertEquals(['user' => ['age' => 18]], $model->settings()->all());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testSetMultiple(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testSetMultiple(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -252,36 +233,32 @@ public function testSetMultiple(string $modelType)
$model->settings()->setMultiple($testData);
$this->assertEquals($model->settings()->all(), $testData);
- $model->settings()->setMultiple($this->testArray);
+ $model->settings()->setMultiple(self::$testArray);
$this->assertEquals(
- array_merge($testData, $this->testArray),
+ array_merge($testData, self::$testArray),
$model->settings()->all()
);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testClear(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testClear(string $modelType): void
{
$model = $this->getModelByType($modelType);
- $model->settings()->clear()->apply($this->testArray);
- $this->assertEquals($this->testArray, $model->settings()->all());
+ $model->settings()->clear()->apply(self::$testArray);
+ $this->assertEquals(self::$testArray, $model->settings()->all());
$model->settings()->clear();
$this->assertEquals([], $model->settings()->all());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testDelete(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testDelete(string $modelType): void
{
$model = $this->getModelByType($modelType);
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
- $this->assertEquals($this->testArray, $model->settings()->all());
+ $this->assertEquals(self::$testArray, $model->settings()->all());
$this->assertEquals('John', $model->settings()->get('user.first_name'));
$model->settings()->delete('user.first_name');
@@ -291,14 +268,12 @@ public function testDelete(string $modelType)
$this->assertEquals([], $model->settings()->all());
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testDeleteMultiple(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testDeleteMultiple(string $modelType): void
{
$model = $this->getModelByType($modelType);
- $model->settings()->apply($this->testArray);
- $this->assertEquals($this->testArray, $model->settings()->all());
+ $model->settings()->apply(self::$testArray);
+ $this->assertEquals(self::$testArray, $model->settings()->all());
$model->settings()->deleteMultiple(['user.first_name', 'user.last_name']);
$testData = $model->settings()->get('user');
@@ -307,19 +282,17 @@ public function testDeleteMultiple(string $modelType)
$this->assertArrayHasKey('email', $testData);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testDefaultValue(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testDefaultValue(string $modelType): void
{
$model = $this->getModelByType($modelType);
$model->settings()->clear();
$model->defaultSettings = $this->defaultSettingsTestArray;
$this->assertEquals($this->defaultSettingsTestArray, $model->settings()->all());
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
$this->assertEquals(
- array_merge($this->defaultSettingsTestArray, $this->testArray),
+ array_merge($this->defaultSettingsTestArray, self::$testArray),
$model->settings()->all()
);
@@ -356,10 +329,8 @@ public function testDefaultValue(string $modelType)
);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testDefaultValueFromConfig(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testDefaultValueFromConfig(string $modelType): void
{
$model = $this->getModelByType($modelType);
@@ -370,17 +341,15 @@ public function testDefaultValueFromConfig(string $modelType)
config()->set('model_settings.defaultSettings.' . $model->getTable(), $this->defaultSettingsTestArray);
$this->assertEquals($this->defaultSettingsTestArray, $model->settings()->all());
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
$this->assertEquals(
- array_merge($this->defaultSettingsTestArray, $this->testArray),
+ array_merge($this->defaultSettingsTestArray, self::$testArray),
$model->settings()->all()
);
}
- /**
- * @dataProvider modelTypesProvider
- */
- public function testValidateData(string $modelType)
+ #[DataProvider('modelTypesProvider')]
+ public function testValidateData(string $modelType): void
{
$model = $this->getModelByType($modelType);
$model->settingsRules = $this->rules;
@@ -388,7 +357,7 @@ public function testValidateData(string $modelType)
$model->settings()->clear();
$this->assertEquals([], $model->settings()->all());
- $model->settings()->apply($this->testArray);
+ $model->settings()->apply(self::$testArray);
$model->settings()->clear();
$this->assertEquals([], $model->settings()->all());
@@ -399,7 +368,7 @@ public function testValidateData(string $modelType)
$this->assertArrayHasKey('user.age', $e->errors());
}
- $testArray = $this->testArray;
+ $testArray = self::$testArray;
$testArray['user']['age'] = 'string';
$this->expectException(ValidationException::class);
$model->settings()->apply($testArray);
diff --git a/tests/CreateSettingsFieldForModelConsoleTest.php b/tests/CreateSettingsFieldForModelConsoleTest.php
index 4f0e2a2..8a50995 100644
--- a/tests/CreateSettingsFieldForModelConsoleTest.php
+++ b/tests/CreateSettingsFieldForModelConsoleTest.php
@@ -2,13 +2,13 @@
namespace Glorand\Model\Settings\Tests;
-class CreateSettingsFieldForModelConsoleTest extends TestCase
+final class CreateSettingsFieldForModelConsoleTest extends TestCase
{
private $table = 'users_with_field';
private $fieldName = 'custom_settings_field';
private $alreadyExistsFieldName = 'settings';
- public function testEmptyTable()
+ public function testEmptyTable(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -19,7 +19,7 @@ public function testEmptyTable()
->assertExitCode(1);
}
- public function testMissingTable()
+ public function testMissingTable(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -30,7 +30,7 @@ public function testMissingTable()
->assertExitCode(2);
}
- public function testAlreadyExistsField()
+ public function testAlreadyExistsField(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -42,7 +42,7 @@ public function testAlreadyExistsField()
->assertExitCode(3);
}
- public function testCreateMigrationFile()
+ public function testCreateMigrationFile(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
diff --git a/tests/CreateSettingsTableConsoleTest.php b/tests/CreateSettingsTableConsoleTest.php
index 4340919..f495259 100644
--- a/tests/CreateSettingsTableConsoleTest.php
+++ b/tests/CreateSettingsTableConsoleTest.php
@@ -4,9 +4,9 @@
use Illuminate\Support\Facades\Schema;
-class CreateSettingsTableConsoleTest extends TestCase
+final class CreateSettingsTableConsoleTest extends TestCase
{
- public function testEmptyTable()
+ public function testEmptyTable(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -18,7 +18,7 @@ public function testEmptyTable()
->assertExitCode(1);
}
- public function testAlreadyExistsTable()
+ public function testAlreadyExistsTable(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -29,7 +29,7 @@ public function testAlreadyExistsTable()
->assertExitCode(2);
}
- public function testCreateMigration()
+ public function testCreateMigration(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
@@ -41,7 +41,7 @@ public function testCreateMigration()
->assertExitCode(0);
}
- public function testWithUpdateConfig()
+ public function testWithUpdateConfig(): void
{
if (version_compare(PHP_VERSION, '8.0', '>=')) {
$this->markTestAsPassed();
diff --git a/tests/FieldSettingsManagerTest.php b/tests/FieldSettingsManagerTest.php
index 0919c33..75803b5 100644
--- a/tests/FieldSettingsManagerTest.php
+++ b/tests/FieldSettingsManagerTest.php
@@ -5,7 +5,7 @@
use Glorand\Model\Settings\Exceptions\ModelSettingsException;
use Glorand\Model\Settings\Tests\Models\UserWithField as User;
-class FieldSettingsManagerTest extends TestCase
+final class FieldSettingsManagerTest extends TestCase
{
/** @var \Glorand\Model\Settings\Tests\Models\UserWithField */
protected $model;
@@ -22,7 +22,7 @@ class FieldSettingsManagerTest extends TestCase
],
];
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->model = User::first();
@@ -31,7 +31,7 @@ public function setUp(): void
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testModelArraySettings()
+ public function testModelArraySettings(): void
{
$testArray = ['a' => 'b'];
$this->model->settings = $testArray;
@@ -39,7 +39,7 @@ public function testModelArraySettings()
$this->assertEquals($this->model->settings()->all(), $testArray);
}
- public function testSettingsMissingSettingsField()
+ public function testSettingsMissingSettingsField(): void
{
$this->expectException(ModelSettingsException::class);
$this->expectExceptionMessage('Unknown field');
@@ -50,7 +50,7 @@ public function testSettingsMissingSettingsField()
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testPersistence()
+ public function testPersistence(): void
{
$this->model->settings()->apply($this->testArray);
$this->assertEquals($this->testArray, $this->model->fresh()->settings()->all());
diff --git a/tests/ParentChildSettingsTest.php b/tests/ParentChildSettingsTest.php
index 614641a..b2d2596 100644
--- a/tests/ParentChildSettingsTest.php
+++ b/tests/ParentChildSettingsTest.php
@@ -5,15 +5,15 @@
use Glorand\Model\Settings\Tests\Models\UsersWithParentModelWithField;
use Glorand\Model\Settings\Tests\Models\UserWithField as User;
-class ParentChildSettingsTest extends TestCase
+final class ParentChildSettingsTest extends TestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->model = UsersWithParentModelWithField::first();
}
- public function testSettingsForChild()
+ public function testSettingsForChild(): void
{
$testArray = ['a' => 'b'];
$this->model->settings = $testArray;
diff --git a/tests/RedisSettingsManagerTest.php b/tests/RedisSettingsManagerTest.php
index 9044b0d..3bc4ae6 100644
--- a/tests/RedisSettingsManagerTest.php
+++ b/tests/RedisSettingsManagerTest.php
@@ -4,18 +4,18 @@
use Glorand\Model\Settings\Tests\Models\UserWithRedis as User;
-class RedisSettingsManagerTest extends TestCase
+final class RedisSettingsManagerTest extends TestCase
{
/** @var \Glorand\Model\Settings\Tests\Models\UserWithRedis */
protected $model;
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->model = User::first();
}
- public function testMarker()
+ public function testMarker(): void
{
$this->assertTrue(true);
}
diff --git a/tests/TableSettingsManagerTest.php b/tests/TableSettingsManagerTest.php
index cc09535..67628a6 100644
--- a/tests/TableSettingsManagerTest.php
+++ b/tests/TableSettingsManagerTest.php
@@ -5,7 +5,7 @@
use Glorand\Model\Settings\Models\ModelSettings;
use Glorand\Model\Settings\Tests\Models\UsersWithTable as User;
-class TableSettingsManagerTest extends TestCase
+final class TableSettingsManagerTest extends TestCase
{
/** @var \Glorand\Model\Settings\Tests\Models\UsersWithTable */
private $model;
@@ -22,7 +22,7 @@ class TableSettingsManagerTest extends TestCase
'project' => 'Main Project',
];
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->model = User::first();
@@ -33,7 +33,7 @@ public function setUp(): void
* @throws \Exception
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
- public function testSpecificDefaultValue()
+ public function testSpecificDefaultValue(): void
{
$this->model->defaultSettings = $this->defaultSettingsTestArray;
$this->assertEquals(
@@ -68,7 +68,7 @@ public function testSpecificDefaultValue()
);
}
- public function testSettingsTableCount()
+ public function testSettingsTableCount(): void
{
$this->model->settings()->apply($this->testArray);
$this->assertEquals(1, ModelSettings::all()->count());
@@ -91,12 +91,12 @@ public function testSettingsTableCount()
$this->assertEquals(0, $this->model->modelSettings()->count());
}
- public function testAddEagerConstraints()
+ public function testAddEagerConstraints(): void
{
$this->model->settings()->apply($this->testArray);
$this->assertEquals(1, ModelSettings::all()->count());
- $this->expectErrorMessage('addEagerConstraints');
+ $this->expectExceptionMessage('addEagerConstraints');
$this->model->load('settings')->settings()->set('test', 'test');
$this->model->load('modelSettings')->settings()->set('test', 'test');
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 4712a44..9cfba6c 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -20,7 +20,7 @@
abstract class TestCase extends OrchestraTestCase
{
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/TestWrongModelTest.php b/tests/TestWrongModelTest.php
index ba240d8..2bb99b0 100644
--- a/tests/TestWrongModelTest.php
+++ b/tests/TestWrongModelTest.php
@@ -7,19 +7,19 @@
use Glorand\Model\Settings\Tests\Models\WrongUser;
use Glorand\Model\Settings\Tests\Models\WrongUserWithField;
-class TestWrongModelTest extends TestCase
+final class TestWrongModelTest extends TestCase
{
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testSettingsFieldUndefined()
+ public function testSettingsFieldUndefined(): void
{
$this->expectException(ModelSettingsException::class);
$this->expectExceptionMessage('missing HasSettings');
new FieldSettingsManager(WrongUser::first());
}
- public function testSettingsMissingSettingsField()
+ public function testSettingsMissingSettingsField(): void
{
$this->expectException(ModelSettingsException::class);
$this->expectExceptionMessage('Unknown field');
diff --git a/tests/TextFieldSettingsManagerTest.php b/tests/TextFieldSettingsManagerTest.php
index 09935bb..363b0e7 100644
--- a/tests/TextFieldSettingsManagerTest.php
+++ b/tests/TextFieldSettingsManagerTest.php
@@ -5,7 +5,7 @@
use Glorand\Model\Settings\Exceptions\ModelSettingsException;
use Glorand\Model\Settings\Tests\Models\UserWithTextField as User;
-class TextFieldSettingsManagerTest extends TestCase
+final class TextFieldSettingsManagerTest extends TestCase
{
/** @var \Glorand\Model\Settings\Tests\Models\UserWithTextField */
protected $model;
@@ -22,7 +22,7 @@ class TextFieldSettingsManagerTest extends TestCase
'project' => 'Main Project',
];
- public function setUp(): void
+ protected function setUp(): void
{
parent::setUp();
$this->model = User::first();
@@ -31,7 +31,7 @@ public function setUp(): void
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testIfSettingsIsNotValidJson()
+ public function testIfSettingsIsNotValidJson(): void
{
$this->model->settings = 'Invalid Json';
$this->model->save();
@@ -42,7 +42,7 @@ public function testIfSettingsIsNotValidJson()
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testModelArraySettings()
+ public function testModelArraySettings(): void
{
$testArray = ['a' => 'b'];
$this->model->settings = $testArray;
@@ -50,7 +50,7 @@ public function testModelArraySettings()
$this->assertEquals($testArray, $this->model->settings()->all());
}
- public function testSettingsMissingSettingsField()
+ public function testSettingsMissingSettingsField(): void
{
$this->expectException(ModelSettingsException::class);
$this->expectExceptionMessage('Unknown field');
@@ -61,7 +61,7 @@ public function testSettingsMissingSettingsField()
/**
* @throws \Glorand\Model\Settings\Exceptions\ModelSettingsException
*/
- public function testPersistence()
+ public function testPersistence(): void
{
$this->model->settings()->apply($this->testArray);
$this->assertEquals($this->testArray, $this->model->fresh()->settings()->all());