mirror of
https://github.com/usetrmnl/byos_laravel.git
synced 2026-01-13 23:18:10 +00:00
This commit is contained in:
parent
c67a182cf2
commit
b4b6286172
89 changed files with 672 additions and 666 deletions
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
test('that true is true', function () {
|
||||
test('that true is true', function (): void {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
use App\Liquid\Filters\Data;
|
||||
|
||||
test('json filter converts arrays to JSON', function () {
|
||||
test('json filter converts arrays to JSON', function (): void {
|
||||
$filter = new Data();
|
||||
$array = ['foo' => 'bar', 'baz' => 'qux'];
|
||||
|
||||
expect($filter->json($array))->toBe('{"foo":"bar","baz":"qux"}');
|
||||
});
|
||||
|
||||
test('json filter converts objects to JSON', function () {
|
||||
test('json filter converts objects to JSON', function (): void {
|
||||
$filter = new Data();
|
||||
$object = new stdClass();
|
||||
$object->foo = 'bar';
|
||||
|
|
@ -18,7 +18,7 @@ test('json filter converts objects to JSON', function () {
|
|||
expect($filter->json($object))->toBe('{"foo":"bar","baz":"qux"}');
|
||||
});
|
||||
|
||||
test('json filter handles nested structures', function () {
|
||||
test('json filter handles nested structures', function (): void {
|
||||
$filter = new Data();
|
||||
$nested = [
|
||||
'foo' => 'bar',
|
||||
|
|
@ -31,7 +31,7 @@ test('json filter handles nested structures', function () {
|
|||
expect($filter->json($nested))->toBe('{"foo":"bar","nested":{"baz":"qux","items":[1,2,3]}}');
|
||||
});
|
||||
|
||||
test('json filter handles scalar values', function () {
|
||||
test('json filter handles scalar values', function (): void {
|
||||
$filter = new Data();
|
||||
|
||||
expect($filter->json('string'))->toBe('"string"');
|
||||
|
|
@ -40,21 +40,21 @@ test('json filter handles scalar values', function () {
|
|||
expect($filter->json(null))->toBe('null');
|
||||
});
|
||||
|
||||
test('json filter preserves unicode characters', function () {
|
||||
test('json filter preserves unicode characters', function (): void {
|
||||
$filter = new Data();
|
||||
$data = ['message' => 'Hello, 世界'];
|
||||
|
||||
expect($filter->json($data))->toBe('{"message":"Hello, 世界"}');
|
||||
});
|
||||
|
||||
test('json filter does not escape slashes', function () {
|
||||
test('json filter does not escape slashes', function (): void {
|
||||
$filter = new Data();
|
||||
$data = ['url' => 'https://example.com/path'];
|
||||
|
||||
expect($filter->json($data))->toBe('{"url":"https://example.com/path"}');
|
||||
});
|
||||
|
||||
test('find_by filter finds object by key-value pair', function () {
|
||||
test('find_by filter finds object by key-value pair', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -66,7 +66,7 @@ test('find_by filter finds object by key-value pair', function () {
|
|||
expect($result)->toBe(['name' => 'Ryan', 'age' => 35]);
|
||||
});
|
||||
|
||||
test('find_by filter returns null when no match found', function () {
|
||||
test('find_by filter returns null when no match found', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -78,7 +78,7 @@ test('find_by filter returns null when no match found', function () {
|
|||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('find_by filter returns fallback when no match found', function () {
|
||||
test('find_by filter returns fallback when no match found', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -90,7 +90,7 @@ test('find_by filter returns fallback when no match found', function () {
|
|||
expect($result)->toBe('Not Found');
|
||||
});
|
||||
|
||||
test('find_by filter finds by age', function () {
|
||||
test('find_by filter finds by age', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -102,7 +102,7 @@ test('find_by filter finds by age', function () {
|
|||
expect($result)->toBe(['name' => 'Sara', 'age' => 29]);
|
||||
});
|
||||
|
||||
test('find_by filter handles empty collection', function () {
|
||||
test('find_by filter handles empty collection', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [];
|
||||
|
||||
|
|
@ -110,7 +110,7 @@ test('find_by filter handles empty collection', function () {
|
|||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('find_by filter handles collection with non-array items', function () {
|
||||
test('find_by filter handles collection with non-array items', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
'not an array',
|
||||
|
|
@ -122,7 +122,7 @@ test('find_by filter handles collection with non-array items', function () {
|
|||
expect($result)->toBe(['name' => 'Ryan', 'age' => 35]);
|
||||
});
|
||||
|
||||
test('find_by filter handles items without the specified key', function () {
|
||||
test('find_by filter handles items without the specified key', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['age' => 35],
|
||||
|
|
@ -134,7 +134,7 @@ test('find_by filter handles items without the specified key', function () {
|
|||
expect($result)->toBe(['name' => 'Ryan', 'age' => 35]);
|
||||
});
|
||||
|
||||
test('group_by filter groups collection by age', function () {
|
||||
test('group_by filter groups collection by age', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -153,7 +153,7 @@ test('group_by filter groups collection by age', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('group_by filter groups collection by name', function () {
|
||||
test('group_by filter groups collection by name', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'age' => 35],
|
||||
|
|
@ -172,7 +172,7 @@ test('group_by filter groups collection by name', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('group_by filter handles empty collection', function () {
|
||||
test('group_by filter handles empty collection', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [];
|
||||
|
||||
|
|
@ -180,7 +180,7 @@ test('group_by filter handles empty collection', function () {
|
|||
expect($result)->toBe([]);
|
||||
});
|
||||
|
||||
test('group_by filter handles collection with non-array items', function () {
|
||||
test('group_by filter handles collection with non-array items', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
'not an array',
|
||||
|
|
@ -197,7 +197,7 @@ test('group_by filter handles collection with non-array items', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('group_by filter handles items without the specified key', function () {
|
||||
test('group_by filter handles items without the specified key', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['age' => 35],
|
||||
|
|
@ -217,7 +217,7 @@ test('group_by filter handles items without the specified key', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('group_by filter handles mixed data types as keys', function () {
|
||||
test('group_by filter handles mixed data types as keys', function (): void {
|
||||
$filter = new Data();
|
||||
$collection = [
|
||||
['name' => 'Ryan', 'active' => true],
|
||||
|
|
@ -238,7 +238,7 @@ test('group_by filter handles mixed data types as keys', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('sample filter returns a random element from array', function () {
|
||||
test('sample filter returns a random element from array', function (): void {
|
||||
$filter = new Data();
|
||||
$array = ['1', '2', '3', '4', '5'];
|
||||
|
||||
|
|
@ -246,7 +246,7 @@ test('sample filter returns a random element from array', function () {
|
|||
expect($result)->toBeIn($array);
|
||||
});
|
||||
|
||||
test('sample filter returns a random element from string array', function () {
|
||||
test('sample filter returns a random element from string array', function (): void {
|
||||
$filter = new Data();
|
||||
$array = ['cat', 'dog'];
|
||||
|
||||
|
|
@ -254,7 +254,7 @@ test('sample filter returns a random element from string array', function () {
|
|||
expect($result)->toBeIn($array);
|
||||
});
|
||||
|
||||
test('sample filter returns null for empty array', function () {
|
||||
test('sample filter returns null for empty array', function (): void {
|
||||
$filter = new Data();
|
||||
$array = [];
|
||||
|
||||
|
|
@ -262,7 +262,7 @@ test('sample filter returns null for empty array', function () {
|
|||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('sample filter returns the only element from single element array', function () {
|
||||
test('sample filter returns the only element from single element array', function (): void {
|
||||
$filter = new Data();
|
||||
$array = ['single'];
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ test('sample filter returns the only element from single element array', functio
|
|||
expect($result)->toBe('single');
|
||||
});
|
||||
|
||||
test('sample filter works with mixed data types', function () {
|
||||
test('sample filter works with mixed data types', function (): void {
|
||||
$filter = new Data();
|
||||
$array = [1, 'string', true, null, ['nested']];
|
||||
|
||||
|
|
@ -278,7 +278,7 @@ test('sample filter works with mixed data types', function () {
|
|||
expect($result)->toBeIn($array);
|
||||
});
|
||||
|
||||
test('parse_json filter parses JSON string to array', function () {
|
||||
test('parse_json filter parses JSON string to array', function (): void {
|
||||
$filter = new Data();
|
||||
$jsonString = '[{"a":1,"b":"c"},"d"]';
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ test('parse_json filter parses JSON string to array', function () {
|
|||
expect($result)->toBe([['a' => 1, 'b' => 'c'], 'd']);
|
||||
});
|
||||
|
||||
test('parse_json filter parses simple JSON object', function () {
|
||||
test('parse_json filter parses simple JSON object', function (): void {
|
||||
$filter = new Data();
|
||||
$jsonString = '{"name":"John","age":30,"city":"New York"}';
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ test('parse_json filter parses simple JSON object', function () {
|
|||
expect($result)->toBe(['name' => 'John', 'age' => 30, 'city' => 'New York']);
|
||||
});
|
||||
|
||||
test('parse_json filter parses JSON array', function () {
|
||||
test('parse_json filter parses JSON array', function (): void {
|
||||
$filter = new Data();
|
||||
$jsonString = '["apple","banana","cherry"]';
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ test('parse_json filter parses JSON array', function () {
|
|||
expect($result)->toBe(['apple', 'banana', 'cherry']);
|
||||
});
|
||||
|
||||
test('parse_json filter parses nested JSON structure', function () {
|
||||
test('parse_json filter parses nested JSON structure', function (): void {
|
||||
$filter = new Data();
|
||||
$jsonString = '{"users":[{"id":1,"name":"Alice"},{"id":2,"name":"Bob"}],"total":2}';
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ test('parse_json filter parses nested JSON structure', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('parse_json filter handles primitive values', function () {
|
||||
test('parse_json filter handles primitive values', function (): void {
|
||||
$filter = new Data();
|
||||
|
||||
expect($filter->parse_json('"hello"'))->toBe('hello');
|
||||
|
|
|
|||
|
|
@ -3,28 +3,28 @@
|
|||
use App\Liquid\Filters\Date;
|
||||
use Carbon\Carbon;
|
||||
|
||||
test('days_ago filter returns correct date', function () {
|
||||
test('days_ago filter returns correct date', function (): void {
|
||||
$filter = new Date();
|
||||
$threeDaysAgo = Carbon::now()->subDays(3)->toDateString();
|
||||
|
||||
expect($filter->days_ago(3))->toBe($threeDaysAgo);
|
||||
});
|
||||
|
||||
test('days_ago filter handles string input', function () {
|
||||
test('days_ago filter handles string input', function (): void {
|
||||
$filter = new Date();
|
||||
$fiveDaysAgo = Carbon::now()->subDays(5)->toDateString();
|
||||
|
||||
expect($filter->days_ago('5'))->toBe($fiveDaysAgo);
|
||||
});
|
||||
|
||||
test('days_ago filter with zero days returns today', function () {
|
||||
test('days_ago filter with zero days returns today', function (): void {
|
||||
$filter = new Date();
|
||||
$today = Carbon::now()->toDateString();
|
||||
|
||||
expect($filter->days_ago(0))->toBe($today);
|
||||
});
|
||||
|
||||
test('days_ago filter with large number works correctly', function () {
|
||||
test('days_ago filter with large number works correctly', function (): void {
|
||||
$filter = new Date();
|
||||
$hundredDaysAgo = Carbon::now()->subDays(100)->toDateString();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use App\Liquid\Filters\Localization;
|
||||
|
||||
test('l_date formats date with default format', function () {
|
||||
test('l_date formats date with default format', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = '2025-01-11';
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ test('l_date formats date with default format', function () {
|
|||
expect($result)->toContain('11');
|
||||
});
|
||||
|
||||
test('l_date formats date with custom format', function () {
|
||||
test('l_date formats date with custom format', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = '2025-01-11';
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ test('l_date formats date with custom format', function () {
|
|||
// We can't check for 'Jan' specifically as it might be localized
|
||||
});
|
||||
|
||||
test('l_date handles DateTime objects', function () {
|
||||
test('l_date handles DateTime objects', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = new DateTimeImmutable('2025-01-11');
|
||||
|
||||
|
|
@ -36,32 +36,32 @@ test('l_date handles DateTime objects', function () {
|
|||
expect($result)->toContain('2025-01-11');
|
||||
});
|
||||
|
||||
test('l_word translates common words', function () {
|
||||
test('l_word translates common words', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('today', 'de'))->toBe('heute');
|
||||
});
|
||||
|
||||
test('l_word returns original word if no translation exists', function () {
|
||||
test('l_word returns original word if no translation exists', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('hello', 'es-ES'))->toBe('hello');
|
||||
expect($filter->l_word('world', 'ko'))->toBe('world');
|
||||
});
|
||||
|
||||
test('l_word is case-insensitive', function () {
|
||||
test('l_word is case-insensitive', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('TODAY', 'de'))->toBe('heute');
|
||||
});
|
||||
|
||||
test('l_word returns original word for unknown locales', function () {
|
||||
test('l_word returns original word for unknown locales', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('today', 'unknown-locale'))->toBe('today');
|
||||
});
|
||||
|
||||
test('l_date handles locale parameter', function () {
|
||||
test('l_date handles locale parameter', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = '2025-01-11';
|
||||
|
||||
|
|
@ -73,7 +73,7 @@ test('l_date handles locale parameter', function () {
|
|||
expect($result)->toContain('11');
|
||||
});
|
||||
|
||||
test('l_date handles null locale parameter', function () {
|
||||
test('l_date handles null locale parameter', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = '2025-01-11';
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ test('l_date handles null locale parameter', function () {
|
|||
expect($result)->toContain('11');
|
||||
});
|
||||
|
||||
test('l_date handles different date formats with locale', function () {
|
||||
test('l_date handles different date formats with locale', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = '2025-01-11';
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ test('l_date handles different date formats with locale', function () {
|
|||
expect($result)->toContain('11');
|
||||
});
|
||||
|
||||
test('l_date handles DateTimeInterface objects with locale', function () {
|
||||
test('l_date handles DateTimeInterface objects with locale', function (): void {
|
||||
$filter = new Localization();
|
||||
$date = new DateTimeImmutable('2025-01-11');
|
||||
|
||||
|
|
@ -108,29 +108,29 @@ test('l_date handles DateTimeInterface objects with locale', function () {
|
|||
expect($result)->toContain('11');
|
||||
});
|
||||
|
||||
test('l_date handles invalid date gracefully', function () {
|
||||
test('l_date handles invalid date gracefully', function (): void {
|
||||
$filter = new Localization();
|
||||
$invalidDate = 'invalid-date';
|
||||
|
||||
// This should throw an exception or return a default value
|
||||
// The exact behavior depends on Carbon's implementation
|
||||
expect(fn () => $filter->l_date($invalidDate))->toThrow(Exception::class);
|
||||
expect(fn (): string => $filter->l_date($invalidDate))->toThrow(Exception::class);
|
||||
});
|
||||
|
||||
test('l_word handles empty string', function () {
|
||||
test('l_word handles empty string', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('', 'de'))->toBe('');
|
||||
});
|
||||
|
||||
test('l_word handles special characters', function () {
|
||||
test('l_word handles special characters', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
// Test with a word that has special characters
|
||||
expect($filter->l_word('café', 'de'))->toBe('café');
|
||||
});
|
||||
|
||||
test('l_word handles numeric strings', function () {
|
||||
test('l_word handles numeric strings', function (): void {
|
||||
$filter = new Localization();
|
||||
|
||||
expect($filter->l_word('123', 'de'))->toBe('123');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use App\Liquid\Filters\Numbers;
|
||||
|
||||
test('number_with_delimiter formats numbers with commas by default', function () {
|
||||
test('number_with_delimiter formats numbers with commas by default', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(1234))->toBe('1,234');
|
||||
|
|
@ -10,21 +10,21 @@ test('number_with_delimiter formats numbers with commas by default', function ()
|
|||
expect($filter->number_with_delimiter(0))->toBe('0');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles custom delimiters', function () {
|
||||
test('number_with_delimiter handles custom delimiters', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(1234, '.'))->toBe('1.234');
|
||||
expect($filter->number_with_delimiter(1000000, ' '))->toBe('1 000 000');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles decimal values with custom separators', function () {
|
||||
test('number_with_delimiter handles decimal values with custom separators', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(1234.57, ' ', ','))->toBe('1 234,57');
|
||||
expect($filter->number_with_delimiter(1234.5, '.', ','))->toBe('1.234,50');
|
||||
});
|
||||
|
||||
test('number_to_currency formats numbers with dollar sign by default', function () {
|
||||
test('number_to_currency formats numbers with dollar sign by default', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(1234))->toBe('$1,234');
|
||||
|
|
@ -32,14 +32,14 @@ test('number_to_currency formats numbers with dollar sign by default', function
|
|||
expect($filter->number_to_currency(0))->toBe('$0');
|
||||
});
|
||||
|
||||
test('number_to_currency handles custom currency symbols', function () {
|
||||
test('number_to_currency handles custom currency symbols', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(1234, '£'))->toBe('£1,234');
|
||||
expect($filter->number_to_currency(152350.69, '€'))->toBe('€152,350.69');
|
||||
});
|
||||
|
||||
test('number_to_currency handles custom delimiters and separators', function () {
|
||||
test('number_to_currency handles custom delimiters and separators', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
$result1 = $filter->number_to_currency(1234.57, '£', '.', ',');
|
||||
|
|
@ -51,56 +51,56 @@ test('number_to_currency handles custom delimiters and separators', function ()
|
|||
expect($result2)->toContain('€');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles string numbers', function () {
|
||||
test('number_with_delimiter handles string numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter('1234'))->toBe('1,234');
|
||||
expect($filter->number_with_delimiter('1234.56'))->toBe('1,234.56');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles negative numbers', function () {
|
||||
test('number_with_delimiter handles negative numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(-1234))->toBe('-1,234');
|
||||
expect($filter->number_with_delimiter(-1234.56))->toBe('-1,234.56');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles zero', function () {
|
||||
test('number_with_delimiter handles zero', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(0))->toBe('0');
|
||||
expect($filter->number_with_delimiter(0.0))->toBe('0.00');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles very small numbers', function () {
|
||||
test('number_with_delimiter handles very small numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(0.01))->toBe('0.01');
|
||||
expect($filter->number_with_delimiter(0.001))->toBe('0.00');
|
||||
});
|
||||
|
||||
test('number_to_currency handles string numbers', function () {
|
||||
test('number_to_currency handles string numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency('1234'))->toBe('$1,234');
|
||||
expect($filter->number_to_currency('1234.56'))->toBe('$1,234.56');
|
||||
});
|
||||
|
||||
test('number_to_currency handles negative numbers', function () {
|
||||
test('number_to_currency handles negative numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(-1234))->toBe('-$1,234');
|
||||
expect($filter->number_to_currency(-1234.56))->toBe('-$1,234.56');
|
||||
});
|
||||
|
||||
test('number_to_currency handles zero', function () {
|
||||
test('number_to_currency handles zero', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(0))->toBe('$0');
|
||||
expect($filter->number_to_currency(0.0))->toBe('$0.00');
|
||||
});
|
||||
|
||||
test('number_to_currency handles currency code conversion', function () {
|
||||
test('number_to_currency handles currency code conversion', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(1234, '$'))->toBe('$1,234');
|
||||
|
|
@ -108,7 +108,7 @@ test('number_to_currency handles currency code conversion', function () {
|
|||
expect($filter->number_to_currency(1234, '£'))->toBe('£1,234');
|
||||
});
|
||||
|
||||
test('number_to_currency handles German locale formatting', function () {
|
||||
test('number_to_currency handles German locale formatting', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
// When delimiter is '.' and separator is ',', it should use German locale
|
||||
|
|
@ -116,21 +116,21 @@ test('number_to_currency handles German locale formatting', function () {
|
|||
expect($result)->toContain('1.234,56');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles different decimal separators', function () {
|
||||
test('number_with_delimiter handles different decimal separators', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(1234.56, ',', ','))->toBe('1,234,56');
|
||||
expect($filter->number_with_delimiter(1234.56, ' ', ','))->toBe('1 234,56');
|
||||
});
|
||||
|
||||
test('number_to_currency handles very large numbers', function () {
|
||||
test('number_to_currency handles very large numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_to_currency(1000000))->toBe('$1,000,000');
|
||||
expect($filter->number_to_currency(1000000.50))->toBe('$1,000,000.50');
|
||||
});
|
||||
|
||||
test('number_with_delimiter handles very large numbers', function () {
|
||||
test('number_with_delimiter handles very large numbers', function (): void {
|
||||
$filter = new Numbers();
|
||||
|
||||
expect($filter->number_with_delimiter(1000000))->toBe('1,000,000');
|
||||
|
|
|
|||
|
|
@ -2,35 +2,35 @@
|
|||
|
||||
use App\Liquid\Filters\StringMarkup;
|
||||
|
||||
test('pluralize returns singular form with count 1', function () {
|
||||
test('pluralize returns singular form with count 1', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('book', 1))->toBe('1 book');
|
||||
expect($filter->pluralize('person', 1))->toBe('1 person');
|
||||
});
|
||||
|
||||
test('pluralize returns plural form with count greater than 1', function () {
|
||||
test('pluralize returns plural form with count greater than 1', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('book', 2))->toBe('2 books');
|
||||
expect($filter->pluralize('person', 4))->toBe('4 people');
|
||||
});
|
||||
|
||||
test('pluralize handles irregular plurals correctly', function () {
|
||||
test('pluralize handles irregular plurals correctly', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('child', 3))->toBe('3 children');
|
||||
expect($filter->pluralize('sheep', 5))->toBe('5 sheep');
|
||||
});
|
||||
|
||||
test('pluralize uses default count of 2 when not specified', function () {
|
||||
test('pluralize uses default count of 2 when not specified', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('book'))->toBe('2 books');
|
||||
expect($filter->pluralize('person'))->toBe('2 people');
|
||||
});
|
||||
|
||||
test('markdown_to_html converts basic markdown to HTML', function () {
|
||||
test('markdown_to_html converts basic markdown to HTML', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$markdown = 'This is *italic* and **bold**.';
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ test('markdown_to_html converts basic markdown to HTML', function () {
|
|||
expect($result)->toContain('<strong>bold</strong>');
|
||||
});
|
||||
|
||||
test('markdown_to_html converts links correctly', function () {
|
||||
test('markdown_to_html converts links correctly', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$markdown = 'This is [a link](https://example.com).';
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ test('markdown_to_html converts links correctly', function () {
|
|||
expect($result)->toContain('<a href="https://example.com">a link</a>');
|
||||
});
|
||||
|
||||
test('markdown_to_html handles fallback when Parsedown is not available', function () {
|
||||
test('markdown_to_html handles fallback when Parsedown is not available', function (): void {
|
||||
// Create a mock that simulates Parsedown not being available
|
||||
$filter = new class extends StringMarkup
|
||||
{
|
||||
|
|
@ -68,28 +68,28 @@ test('markdown_to_html handles fallback when Parsedown is not available', functi
|
|||
expect($result)->toBe('This is *italic* and [a link](https://example.com).');
|
||||
});
|
||||
|
||||
test('strip_html removes HTML tags', function () {
|
||||
test('strip_html removes HTML tags', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$html = '<p>This is <strong>bold</strong> and <em>italic</em>.</p>';
|
||||
|
||||
expect($filter->strip_html($html))->toBe('This is bold and italic.');
|
||||
});
|
||||
|
||||
test('strip_html preserves text content', function () {
|
||||
test('strip_html preserves text content', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$html = '<div>Hello, <span>world</span>!</div>';
|
||||
|
||||
expect($filter->strip_html($html))->toBe('Hello, world!');
|
||||
});
|
||||
|
||||
test('strip_html handles nested tags', function () {
|
||||
test('strip_html handles nested tags', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$html = '<div><p>Paragraph <strong>with <em>nested</em> tags</strong>.</p></div>';
|
||||
|
||||
expect($filter->strip_html($html))->toBe('Paragraph with nested tags.');
|
||||
});
|
||||
|
||||
test('markdown_to_html handles CommonMarkException gracefully', function () {
|
||||
test('markdown_to_html handles CommonMarkException gracefully', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
// Create a mock that throws CommonMarkException
|
||||
|
|
@ -113,7 +113,7 @@ test('markdown_to_html handles CommonMarkException gracefully', function () {
|
|||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('markdown_to_html handles empty string', function () {
|
||||
test('markdown_to_html handles empty string', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
$result = $filter->markdown_to_html('');
|
||||
|
|
@ -121,7 +121,7 @@ test('markdown_to_html handles empty string', function () {
|
|||
expect($result)->toBe('');
|
||||
});
|
||||
|
||||
test('markdown_to_html handles complex markdown', function () {
|
||||
test('markdown_to_html handles complex markdown', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$markdown = "# Heading\n\nThis is a paragraph with **bold** and *italic* text.\n\n- List item 1\n- List item 2\n\n[Link](https://example.com)";
|
||||
|
||||
|
|
@ -135,34 +135,34 @@ test('markdown_to_html handles complex markdown', function () {
|
|||
expect($result)->toContain('<a href="https://example.com">Link</a>');
|
||||
});
|
||||
|
||||
test('strip_html handles empty string', function () {
|
||||
test('strip_html handles empty string', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->strip_html(''))->toBe('');
|
||||
});
|
||||
|
||||
test('strip_html handles string without HTML tags', function () {
|
||||
test('strip_html handles string without HTML tags', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$text = 'This is plain text without any HTML tags.';
|
||||
|
||||
expect($filter->strip_html($text))->toBe($text);
|
||||
});
|
||||
|
||||
test('strip_html handles self-closing tags', function () {
|
||||
test('strip_html handles self-closing tags', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
$html = '<p>Text with <br/> line break and <hr/> horizontal rule.</p>';
|
||||
|
||||
expect($filter->strip_html($html))->toBe('Text with line break and horizontal rule.');
|
||||
});
|
||||
|
||||
test('pluralize handles zero count', function () {
|
||||
test('pluralize handles zero count', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('book', 0))->toBe('0 books');
|
||||
expect($filter->pluralize('person', 0))->toBe('0 people');
|
||||
});
|
||||
|
||||
test('pluralize handles negative count', function () {
|
||||
test('pluralize handles negative count', function (): void {
|
||||
$filter = new StringMarkup();
|
||||
|
||||
expect($filter->pluralize('book', -1))->toBe('-1 book');
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use App\Liquid\Filters\Uniqueness;
|
||||
|
||||
test('append_random appends a random string with 4 characters', function () {
|
||||
test('append_random appends a random string with 4 characters', function (): void {
|
||||
$filter = new Uniqueness();
|
||||
$result = $filter->append_random('chart-');
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
|||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
test('device log belongs to a device', function () {
|
||||
test('device log belongs to a device', function (): void {
|
||||
$device = Device::factory()->create();
|
||||
$log = DeviceLog::factory()->create(['device_id' => $device->id]);
|
||||
|
||||
|
|
@ -14,7 +14,7 @@ test('device log belongs to a device', function () {
|
|||
->and($log->device->id)->toBe($device->id);
|
||||
});
|
||||
|
||||
test('device log casts log_entry to array', function () {
|
||||
test('device log casts log_entry to array', function (): void {
|
||||
Device::factory()->create();
|
||||
$log = DeviceLog::factory()->create([
|
||||
'log_entry' => [
|
||||
|
|
@ -29,7 +29,7 @@ test('device log casts log_entry to array', function () {
|
|||
->and($log->log_entry['level'])->toBe('info');
|
||||
});
|
||||
|
||||
test('device log casts device_timestamp to datetime', function () {
|
||||
test('device log casts device_timestamp to datetime', function (): void {
|
||||
Device::factory()->create();
|
||||
$timestamp = now();
|
||||
$log = DeviceLog::factory()->create([
|
||||
|
|
@ -40,7 +40,7 @@ test('device log casts device_timestamp to datetime', function () {
|
|||
->and($log->device_timestamp->timestamp)->toBe($timestamp->timestamp);
|
||||
});
|
||||
|
||||
test('device log factory creates valid data', function () {
|
||||
test('device log factory creates valid data', function (): void {
|
||||
Device::factory()->create();
|
||||
$log = DeviceLog::factory()->create();
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ test('device log factory creates valid data', function () {
|
|||
->and($log->log_entry)->toHaveKeys(['creation_timestamp', 'device_status_stamp', 'log_id', 'log_message', 'log_codeline', 'log_sourcefile', 'additional_info']);
|
||||
});
|
||||
|
||||
test('device log can be created with minimal required fields', function () {
|
||||
test('device log can be created with minimal required fields', function (): void {
|
||||
$device = Device::factory()->create();
|
||||
$log = DeviceLog::create([
|
||||
'device_id' => $device->id,
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
use App\Models\DeviceModel;
|
||||
|
||||
test('device model has required attributes', function () {
|
||||
test('device model has required attributes', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create([
|
||||
'name' => 'Test Model',
|
||||
'width' => 800,
|
||||
|
|
@ -28,7 +28,7 @@ test('device model has required attributes', function () {
|
|||
expect($deviceModel->offset_y)->toBe(0);
|
||||
});
|
||||
|
||||
test('device model casts attributes correctly', function () {
|
||||
test('device model casts attributes correctly', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create([
|
||||
'width' => '800',
|
||||
'height' => '480',
|
||||
|
|
@ -50,61 +50,61 @@ test('device model casts attributes correctly', function () {
|
|||
expect($deviceModel->offset_y)->toBeInt();
|
||||
});
|
||||
|
||||
test('get color depth attribute returns correct format for bit depth 2', function () {
|
||||
test('get color depth attribute returns correct format for bit depth 2', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['bit_depth' => 2]);
|
||||
|
||||
expect($deviceModel->getColorDepthAttribute())->toBe('2bit');
|
||||
});
|
||||
|
||||
test('get color depth attribute returns correct format for bit depth 4', function () {
|
||||
test('get color depth attribute returns correct format for bit depth 4', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['bit_depth' => 4]);
|
||||
|
||||
expect($deviceModel->getColorDepthAttribute())->toBe('4bit');
|
||||
});
|
||||
|
||||
test('get color depth attribute returns 4bit for bit depth greater than 4', function () {
|
||||
test('get color depth attribute returns 4bit for bit depth greater than 4', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['bit_depth' => 8]);
|
||||
|
||||
expect($deviceModel->getColorDepthAttribute())->toBe('4bit');
|
||||
});
|
||||
|
||||
test('get color depth attribute returns null when bit depth is null', function () {
|
||||
test('get color depth attribute returns null when bit depth is null', function (): void {
|
||||
$deviceModel = new DeviceModel(['bit_depth' => null]);
|
||||
|
||||
expect($deviceModel->getColorDepthAttribute())->toBeNull();
|
||||
});
|
||||
|
||||
test('get scale level attribute returns null for width 800 or less', function () {
|
||||
test('get scale level attribute returns null for width 800 or less', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['width' => 800]);
|
||||
|
||||
expect($deviceModel->getScaleLevelAttribute())->toBeNull();
|
||||
});
|
||||
|
||||
test('get scale level attribute returns large for width between 801 and 1000', function () {
|
||||
test('get scale level attribute returns large for width between 801 and 1000', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['width' => 900]);
|
||||
|
||||
expect($deviceModel->getScaleLevelAttribute())->toBe('large');
|
||||
});
|
||||
|
||||
test('get scale level attribute returns xlarge for width between 1001 and 1400', function () {
|
||||
test('get scale level attribute returns xlarge for width between 1001 and 1400', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['width' => 1200]);
|
||||
|
||||
expect($deviceModel->getScaleLevelAttribute())->toBe('xlarge');
|
||||
});
|
||||
|
||||
test('get scale level attribute returns xxlarge for width greater than 1400', function () {
|
||||
test('get scale level attribute returns xxlarge for width greater than 1400', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create(['width' => 1500]);
|
||||
|
||||
expect($deviceModel->getScaleLevelAttribute())->toBe('xxlarge');
|
||||
});
|
||||
|
||||
test('get scale level attribute returns null when width is null', function () {
|
||||
test('get scale level attribute returns null when width is null', function (): void {
|
||||
$deviceModel = new DeviceModel(['width' => null]);
|
||||
|
||||
expect($deviceModel->getScaleLevelAttribute())->toBeNull();
|
||||
});
|
||||
|
||||
test('device model factory creates valid data', function () {
|
||||
test('device model factory creates valid data', function (): void {
|
||||
$deviceModel = DeviceModel::factory()->create();
|
||||
|
||||
expect($deviceModel->name)->not->toBeEmpty();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use App\Models\Playlist;
|
|||
use App\Models\PlaylistItem;
|
||||
use App\Models\Plugin;
|
||||
|
||||
test('playlist item belongs to playlist', function () {
|
||||
test('playlist item belongs to playlist', function (): void {
|
||||
$playlist = Playlist::factory()->create();
|
||||
$playlistItem = PlaylistItem::factory()->create(['playlist_id' => $playlist->id]);
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ test('playlist item belongs to playlist', function () {
|
|||
->id->toBe($playlist->id);
|
||||
});
|
||||
|
||||
test('playlist item belongs to plugin', function () {
|
||||
test('playlist item belongs to plugin', function (): void {
|
||||
$plugin = Plugin::factory()->create();
|
||||
$playlistItem = PlaylistItem::factory()->create(['plugin_id' => $plugin->id]);
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ test('playlist item belongs to plugin', function () {
|
|||
->id->toBe($plugin->id);
|
||||
});
|
||||
|
||||
test('playlist item can check if it is a mashup', function () {
|
||||
test('playlist item can check if it is a mashup', function (): void {
|
||||
$plugin = Plugin::factory()->create();
|
||||
$regularItem = PlaylistItem::factory()->create([
|
||||
'mashup' => null,
|
||||
|
|
@ -44,7 +44,7 @@ test('playlist item can check if it is a mashup', function () {
|
|||
->and($mashupItem->isMashup())->toBeTrue();
|
||||
});
|
||||
|
||||
test('playlist item can get mashup name', function () {
|
||||
test('playlist item can get mashup name', function (): void {
|
||||
$plugin1 = Plugin::factory()->create();
|
||||
$plugin2 = Plugin::factory()->create();
|
||||
$mashupItem = PlaylistItem::factory()->create([
|
||||
|
|
@ -59,7 +59,7 @@ test('playlist item can get mashup name', function () {
|
|||
expect($mashupItem->getMashupName())->toBe('Test Mashup');
|
||||
});
|
||||
|
||||
test('playlist item can get mashup layout type', function () {
|
||||
test('playlist item can get mashup layout type', function (): void {
|
||||
$plugin1 = Plugin::factory()->create();
|
||||
$plugin2 = Plugin::factory()->create();
|
||||
$mashupItem = PlaylistItem::factory()->create([
|
||||
|
|
@ -74,7 +74,7 @@ test('playlist item can get mashup layout type', function () {
|
|||
expect($mashupItem->getMashupLayoutType())->toBe('1Lx1R');
|
||||
});
|
||||
|
||||
test('playlist item can get mashup plugin ids', function () {
|
||||
test('playlist item can get mashup plugin ids', function (): void {
|
||||
$plugin1 = Plugin::factory()->create();
|
||||
$plugin2 = Plugin::factory()->create();
|
||||
$mashupItem = PlaylistItem::factory()->create([
|
||||
|
|
@ -89,7 +89,7 @@ test('playlist item can get mashup plugin ids', function () {
|
|||
expect($mashupItem->getMashupPluginIds())->toBe([$plugin1->id, $plugin2->id]);
|
||||
});
|
||||
|
||||
test('playlist item can get required plugin count for different layouts', function () {
|
||||
test('playlist item can get required plugin count for different layouts', function (): void {
|
||||
$layouts = [
|
||||
'1Lx1R' => 2,
|
||||
'1Tx1B' => 2,
|
||||
|
|
@ -117,7 +117,7 @@ test('playlist item can get required plugin count for different layouts', functi
|
|||
}
|
||||
});
|
||||
|
||||
test('playlist item can get layout type', function () {
|
||||
test('playlist item can get layout type', function (): void {
|
||||
$layoutTypes = [
|
||||
'1Lx1R' => 'vertical',
|
||||
'1Lx2R' => 'vertical',
|
||||
|
|
@ -144,7 +144,7 @@ test('playlist item can get layout type', function () {
|
|||
}
|
||||
});
|
||||
|
||||
test('playlist item can get layout size for different positions', function () {
|
||||
test('playlist item can get layout size for different positions', function (): void {
|
||||
$plugin1 = Plugin::factory()->create();
|
||||
$plugin2 = Plugin::factory()->create();
|
||||
$plugin3 = Plugin::factory()->create();
|
||||
|
|
@ -163,7 +163,7 @@ test('playlist item can get layout size for different positions', function () {
|
|||
->and($mashupItem->getLayoutSize(2))->toBe('half_vertical');
|
||||
});
|
||||
|
||||
test('playlist item can get available layouts', function () {
|
||||
test('playlist item can get available layouts', function (): void {
|
||||
$layouts = PlaylistItem::getAvailableLayouts();
|
||||
|
||||
expect($layouts)->toBeArray()
|
||||
|
|
@ -171,7 +171,7 @@ test('playlist item can get available layouts', function () {
|
|||
->and($layouts['1Lx1R'])->toBe('1 Left - 1 Right (2 plugins)');
|
||||
});
|
||||
|
||||
test('playlist item can get required plugin count for layout', function () {
|
||||
test('playlist item can get required plugin count for layout', function (): void {
|
||||
$layouts = [
|
||||
'1Lx1R' => 2,
|
||||
'1Tx1B' => 2,
|
||||
|
|
@ -187,7 +187,7 @@ test('playlist item can get required plugin count for layout', function () {
|
|||
}
|
||||
});
|
||||
|
||||
test('playlist item can create mashup', function () {
|
||||
test('playlist item can create mashup', function (): void {
|
||||
$playlist = Playlist::factory()->create();
|
||||
$plugins = Plugin::factory()->count(3)->create();
|
||||
$pluginIds = $plugins->pluck('id')->toArray();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use App\Models\Device;
|
|||
use App\Models\Playlist;
|
||||
use App\Models\PlaylistItem;
|
||||
|
||||
test('playlist has required attributes', function () {
|
||||
test('playlist has required attributes', function (): void {
|
||||
$playlist = Playlist::factory()->create([
|
||||
'name' => 'Test Playlist',
|
||||
'is_active' => true,
|
||||
|
|
@ -21,7 +21,7 @@ test('playlist has required attributes', function () {
|
|||
->active_until->format('H:i')->toBe('17:00');
|
||||
});
|
||||
|
||||
test('playlist belongs to device', function () {
|
||||
test('playlist belongs to device', function (): void {
|
||||
$device = Device::factory()->create();
|
||||
$playlist = Playlist::factory()->create(['device_id' => $device->id]);
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ test('playlist belongs to device', function () {
|
|||
->id->toBe($device->id);
|
||||
});
|
||||
|
||||
test('playlist has many items', function () {
|
||||
test('playlist has many items', function (): void {
|
||||
$playlist = Playlist::factory()->create();
|
||||
$items = PlaylistItem::factory()->count(3)->create(['playlist_id' => $playlist->id]);
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ test('playlist has many items', function () {
|
|||
->each->toBeInstanceOf(PlaylistItem::class);
|
||||
});
|
||||
|
||||
test('getNextPlaylistItem returns null when playlist is inactive', function () {
|
||||
test('getNextPlaylistItem returns null when playlist is inactive', function (): void {
|
||||
$playlist = Playlist::factory()->create(['is_active' => false]);
|
||||
|
||||
expect($playlist->getNextPlaylistItem())->toBeNull();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Http;
|
|||
|
||||
uses(Illuminate\Foundation\Testing\RefreshDatabase::class);
|
||||
|
||||
test('plugin has required attributes', function () {
|
||||
test('plugin has required attributes', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'name' => 'Test Plugin',
|
||||
'data_payload' => ['key' => 'value'],
|
||||
|
|
@ -18,7 +18,7 @@ test('plugin has required attributes', function () {
|
|||
->uuid->toMatch('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/');
|
||||
});
|
||||
|
||||
test('plugin automatically generates uuid on creation', function () {
|
||||
test('plugin automatically generates uuid on creation', function (): void {
|
||||
$plugin = Plugin::factory()->create();
|
||||
|
||||
expect($plugin->uuid)
|
||||
|
|
@ -26,14 +26,14 @@ test('plugin automatically generates uuid on creation', function () {
|
|||
->toMatch('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/');
|
||||
});
|
||||
|
||||
test('plugin can have custom uuid', function () {
|
||||
test('plugin can have custom uuid', function (): void {
|
||||
$uuid = Illuminate\Support\Str::uuid();
|
||||
$plugin = Plugin::factory()->create(['uuid' => $uuid]);
|
||||
|
||||
expect($plugin->uuid)->toBe($uuid);
|
||||
});
|
||||
|
||||
test('plugin data_payload is cast to array', function () {
|
||||
test('plugin data_payload is cast to array', function (): void {
|
||||
$data = ['key' => 'value'];
|
||||
$plugin = Plugin::factory()->create(['data_payload' => $data]);
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ test('plugin data_payload is cast to array', function () {
|
|||
->toBe($data);
|
||||
});
|
||||
|
||||
test('plugin can have polling body for POST requests', function () {
|
||||
test('plugin can have polling body for POST requests', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'polling_verb' => 'post',
|
||||
'polling_body' => '{"query": "query { user { id name } }"}',
|
||||
|
|
@ -51,7 +51,7 @@ test('plugin can have polling body for POST requests', function () {
|
|||
expect($plugin->polling_body)->toBe('{"query": "query { user { id name } }"}');
|
||||
});
|
||||
|
||||
test('updateDataPayload sends POST request with body when polling_verb is post', function () {
|
||||
test('updateDataPayload sends POST request with body when polling_verb is post', function (): void {
|
||||
Http::fake([
|
||||
'https://example.com/api' => Http::response(['success' => true], 200),
|
||||
]);
|
||||
|
|
@ -65,14 +65,12 @@ test('updateDataPayload sends POST request with body when polling_verb is post',
|
|||
|
||||
$plugin->updateDataPayload();
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return $request->url() === 'https://example.com/api' &&
|
||||
$request->method() === 'POST' &&
|
||||
$request->body() === '{"query": "query { user { id name } }"}';
|
||||
});
|
||||
Http::assertSent(fn ($request): bool => $request->url() === 'https://example.com/api' &&
|
||||
$request->method() === 'POST' &&
|
||||
$request->body() === '{"query": "query { user { id name } }"}');
|
||||
});
|
||||
|
||||
test('updateDataPayload handles multiple URLs with IDX_ prefixes', function () {
|
||||
test('updateDataPayload handles multiple URLs with IDX_ prefixes', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'polling',
|
||||
'polling_url' => "https://api1.example.com/data\nhttps://api2.example.com/weather\nhttps://api3.example.com/news",
|
||||
|
|
@ -99,7 +97,7 @@ test('updateDataPayload handles multiple URLs with IDX_ prefixes', function () {
|
|||
expect($plugin->data_payload['IDX_2'])->toBe(['headline' => 'test']);
|
||||
});
|
||||
|
||||
test('updateDataPayload handles single URL without nesting', function () {
|
||||
test('updateDataPayload handles single URL without nesting', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'polling',
|
||||
'polling_url' => 'https://api.example.com/data',
|
||||
|
|
@ -120,7 +118,7 @@ test('updateDataPayload handles single URL without nesting', function () {
|
|||
expect($plugin->data_payload)->not->toHaveKey('IDX_0');
|
||||
});
|
||||
|
||||
test('updateDataPayload resolves Liquid variables in polling_header', function () {
|
||||
test('updateDataPayload resolves Liquid variables in polling_header', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'polling',
|
||||
'polling_url' => 'https://api.example.com/data',
|
||||
|
|
@ -139,15 +137,13 @@ test('updateDataPayload resolves Liquid variables in polling_header', function (
|
|||
|
||||
$plugin->updateDataPayload();
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
return $request->url() === 'https://api.example.com/data' &&
|
||||
$request->method() === 'GET' &&
|
||||
$request->header('Authorization')[0] === 'Bearer test123' &&
|
||||
$request->header('X-Custom-Header')[0] === 'custom_header_value';
|
||||
});
|
||||
Http::assertSent(fn ($request): bool => $request->url() === 'https://api.example.com/data' &&
|
||||
$request->method() === 'GET' &&
|
||||
$request->header('Authorization')[0] === 'Bearer test123' &&
|
||||
$request->header('X-Custom-Header')[0] === 'custom_header_value');
|
||||
});
|
||||
|
||||
test('updateDataPayload resolves Liquid variables in polling_body', function () {
|
||||
test('updateDataPayload resolves Liquid variables in polling_body', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'polling',
|
||||
'polling_url' => 'https://api.example.com/data',
|
||||
|
|
@ -166,7 +162,7 @@ test('updateDataPayload resolves Liquid variables in polling_body', function ()
|
|||
|
||||
$plugin->updateDataPayload();
|
||||
|
||||
Http::assertSent(function ($request) {
|
||||
Http::assertSent(function ($request): bool {
|
||||
$expectedBody = '{"query": "query { user { id name } }", "api_key": "test123", "user_id": "456"}';
|
||||
|
||||
return $request->url() === 'https://api.example.com/data' &&
|
||||
|
|
@ -175,7 +171,7 @@ test('updateDataPayload resolves Liquid variables in polling_body', function ()
|
|||
});
|
||||
});
|
||||
|
||||
test('webhook plugin is stale if webhook event occurred', function () {
|
||||
test('webhook plugin is stale if webhook event occurred', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'webhook',
|
||||
'data_payload_updated_at' => now()->subMinutes(10),
|
||||
|
|
@ -186,7 +182,7 @@ test('webhook plugin is stale if webhook event occurred', function () {
|
|||
|
||||
});
|
||||
|
||||
test('webhook plugin data not stale if no webhook event occurred for 1 hour', function () {
|
||||
test('webhook plugin data not stale if no webhook event occurred for 1 hour', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'data_strategy' => 'webhook',
|
||||
'data_payload_updated_at' => now()->subMinutes(60),
|
||||
|
|
@ -197,7 +193,7 @@ test('webhook plugin data not stale if no webhook event occurred for 1 hour', fu
|
|||
|
||||
});
|
||||
|
||||
test('plugin configuration is cast to array', function () {
|
||||
test('plugin configuration is cast to array', function (): void {
|
||||
$config = ['timezone' => 'UTC', 'refresh_interval' => 30];
|
||||
$plugin = Plugin::factory()->create(['configuration' => $config]);
|
||||
|
||||
|
|
@ -206,7 +202,7 @@ test('plugin configuration is cast to array', function () {
|
|||
->toBe($config);
|
||||
});
|
||||
|
||||
test('plugin can get configuration value by key', function () {
|
||||
test('plugin can get configuration value by key', function (): void {
|
||||
$config = ['timezone' => 'UTC', 'refresh_interval' => 30];
|
||||
$plugin = Plugin::factory()->create(['configuration' => $config]);
|
||||
|
||||
|
|
@ -215,7 +211,7 @@ test('plugin can get configuration value by key', function () {
|
|||
expect($plugin->getConfiguration('nonexistent', 'default'))->toBe('default');
|
||||
});
|
||||
|
||||
test('plugin configuration template is cast to array', function () {
|
||||
test('plugin configuration template is cast to array', function (): void {
|
||||
$template = [
|
||||
'custom_fields' => [
|
||||
[
|
||||
|
|
@ -233,7 +229,7 @@ test('plugin configuration template is cast to array', function () {
|
|||
->toBe($template);
|
||||
});
|
||||
|
||||
test('resolveLiquidVariables resolves variables from configuration', function () {
|
||||
test('resolveLiquidVariables resolves variables from configuration', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'configuration' => [
|
||||
'api_key' => '12345',
|
||||
|
|
@ -263,7 +259,7 @@ test('resolveLiquidVariables resolves variables from configuration', function ()
|
|||
expect($result)->toBe('High');
|
||||
});
|
||||
|
||||
test('resolveLiquidVariables handles invalid Liquid syntax gracefully', function () {
|
||||
test('resolveLiquidVariables handles invalid Liquid syntax gracefully', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'configuration' => [
|
||||
'api_key' => '12345',
|
||||
|
|
@ -277,7 +273,7 @@ test('resolveLiquidVariables handles invalid Liquid syntax gracefully', function
|
|||
->toThrow(Keepsuit\Liquid\Exceptions\SyntaxException::class);
|
||||
});
|
||||
|
||||
test('plugin can extract default values from custom fields configuration template', function () {
|
||||
test('plugin can extract default values from custom fields configuration template', function (): void {
|
||||
$configurationTemplate = [
|
||||
'custom_fields' => [
|
||||
[
|
||||
|
|
@ -323,7 +319,7 @@ test('plugin can extract default values from custom fields configuration templat
|
|||
expect($plugin->getConfiguration('timezone'))->toBeNull();
|
||||
});
|
||||
|
||||
test('resolveLiquidVariables resolves configuration variables correctly', function () {
|
||||
test('resolveLiquidVariables resolves configuration variables correctly', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'configuration' => [
|
||||
'Latitude' => '48.2083',
|
||||
|
|
@ -338,7 +334,7 @@ test('resolveLiquidVariables resolves configuration variables correctly', functi
|
|||
expect($plugin->resolveLiquidVariables($template))->toBe($expected);
|
||||
});
|
||||
|
||||
test('resolveLiquidVariables handles missing variables gracefully', function () {
|
||||
test('resolveLiquidVariables handles missing variables gracefully', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'configuration' => [
|
||||
'Latitude' => '48.2083',
|
||||
|
|
@ -351,7 +347,7 @@ test('resolveLiquidVariables handles missing variables gracefully', function ()
|
|||
expect($plugin->resolveLiquidVariables($template))->toBe($expected);
|
||||
});
|
||||
|
||||
test('resolveLiquidVariables handles empty configuration', function () {
|
||||
test('resolveLiquidVariables handles empty configuration', function (): void {
|
||||
$plugin = Plugin::factory()->create([
|
||||
'configuration' => [],
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -8,14 +8,14 @@ use App\Notifications\BatteryLow;
|
|||
use App\Notifications\Channels\WebhookChannel;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
|
||||
test('battery low notification has correct via channels', function () {
|
||||
test('battery low notification has correct via channels', function (): void {
|
||||
$device = Device::factory()->create();
|
||||
$notification = new BatteryLow($device);
|
||||
|
||||
expect($notification->via(new User()))->toBe(['mail', WebhookChannel::class]);
|
||||
});
|
||||
|
||||
test('battery low notification creates correct mail message', function () {
|
||||
test('battery low notification creates correct mail message', function (): void {
|
||||
$device = Device::factory()->create([
|
||||
'name' => 'Test Device',
|
||||
'last_battery_voltage' => 3.0,
|
||||
|
|
@ -29,7 +29,7 @@ test('battery low notification creates correct mail message', function () {
|
|||
expect($mailMessage->viewData['device'])->toBe($device);
|
||||
});
|
||||
|
||||
test('battery low notification creates correct webhook message', function () {
|
||||
test('battery low notification creates correct webhook message', function (): void {
|
||||
config([
|
||||
'services.webhook.notifications.topic' => 'battery.low',
|
||||
'app.name' => 'Test App',
|
||||
|
|
@ -60,7 +60,7 @@ test('battery low notification creates correct webhook message', function () {
|
|||
]);
|
||||
});
|
||||
|
||||
test('battery low notification creates correct array representation', function () {
|
||||
test('battery low notification creates correct array representation', function (): void {
|
||||
$device = Device::factory()->create([
|
||||
'name' => 'Test Device',
|
||||
'last_battery_voltage' => 3.0,
|
||||
|
|
|
|||
|
|
@ -11,13 +11,13 @@ use GuzzleHttp\Exception\GuzzleException;
|
|||
use GuzzleHttp\Psr7\Response;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
test('webhook channel returns null when no webhook url is configured', function () {
|
||||
test('webhook channel returns null when no webhook url is configured', function (): void {
|
||||
$client = Mockery::mock(Client::class);
|
||||
$channel = new WebhookChannel($client);
|
||||
|
||||
$user = new class extends User
|
||||
{
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
public function routeNotificationFor($driver, $notification = null): null
|
||||
{
|
||||
return null; // No webhook URL configured
|
||||
}
|
||||
|
|
@ -30,13 +30,13 @@ test('webhook channel returns null when no webhook url is configured', function
|
|||
expect($result)->toBeNull();
|
||||
});
|
||||
|
||||
test('webhook channel throws exception when notification does not implement toWebhook', function () {
|
||||
test('webhook channel throws exception when notification does not implement toWebhook', function (): void {
|
||||
$client = Mockery::mock(Client::class);
|
||||
$channel = new WebhookChannel($client);
|
||||
|
||||
$user = new class extends User
|
||||
{
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
public function routeNotificationFor($driver, $notification = null): string
|
||||
{
|
||||
return 'https://example.com/webhook';
|
||||
}
|
||||
|
|
@ -44,23 +44,23 @@ test('webhook channel throws exception when notification does not implement toWe
|
|||
|
||||
$notification = new class extends Notification
|
||||
{
|
||||
public function via($notifiable)
|
||||
public function via($notifiable): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
expect(fn () => $channel->send($user, $notification))
|
||||
expect(fn (): ?\GuzzleHttp\Psr7\Response => $channel->send($user, $notification))
|
||||
->toThrow(Exception::class, 'Notification does not implement toWebhook method.');
|
||||
});
|
||||
|
||||
test('webhook channel sends successful webhook request', function () {
|
||||
test('webhook channel sends successful webhook request', function (): void {
|
||||
$client = Mockery::mock(Client::class);
|
||||
$channel = new WebhookChannel($client);
|
||||
|
||||
$user = new class extends User
|
||||
{
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
public function routeNotificationFor($driver, $notification = null): string
|
||||
{
|
||||
return 'https://example.com/webhook';
|
||||
}
|
||||
|
|
@ -86,13 +86,13 @@ test('webhook channel sends successful webhook request', function () {
|
|||
expect($result)->toBe($expectedResponse);
|
||||
});
|
||||
|
||||
test('webhook channel throws exception when response status is not successful', function () {
|
||||
test('webhook channel throws exception when response status is not successful', function (): void {
|
||||
$client = Mockery::mock(Client::class);
|
||||
$channel = new WebhookChannel($client);
|
||||
|
||||
$user = new class extends User
|
||||
{
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
public function routeNotificationFor($driver, $notification = null): string
|
||||
{
|
||||
return 'https://example.com/webhook';
|
||||
}
|
||||
|
|
@ -107,17 +107,17 @@ test('webhook channel throws exception when response status is not successful',
|
|||
->once()
|
||||
->andReturn($errorResponse);
|
||||
|
||||
expect(fn () => $channel->send($user, $notification))
|
||||
expect(fn (): ?\GuzzleHttp\Psr7\Response => $channel->send($user, $notification))
|
||||
->toThrow(Exception::class, 'Webhook request failed with status code: 400');
|
||||
});
|
||||
|
||||
test('webhook channel handles guzzle exceptions', function () {
|
||||
test('webhook channel handles guzzle exceptions', function (): void {
|
||||
$client = Mockery::mock(Client::class);
|
||||
$channel = new WebhookChannel($client);
|
||||
|
||||
$user = new class extends User
|
||||
{
|
||||
public function routeNotificationFor($driver, $notification = null)
|
||||
public function routeNotificationFor($driver, $notification = null): string
|
||||
{
|
||||
return 'https://example.com/webhook';
|
||||
}
|
||||
|
|
@ -130,6 +130,6 @@ test('webhook channel handles guzzle exceptions', function () {
|
|||
->once()
|
||||
->andThrow(new class extends Exception implements GuzzleException {});
|
||||
|
||||
expect(fn () => $channel->send($user, $notification))
|
||||
expect(fn (): ?\GuzzleHttp\Psr7\Response => $channel->send($user, $notification))
|
||||
->toThrow(Exception::class);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,26 +4,26 @@ declare(strict_types=1);
|
|||
|
||||
use App\Notifications\Messages\WebhookMessage;
|
||||
|
||||
test('webhook message can be created with static method', function () {
|
||||
test('webhook message can be created with static method', function (): void {
|
||||
$message = WebhookMessage::create('test data');
|
||||
|
||||
expect($message)->toBeInstanceOf(WebhookMessage::class);
|
||||
});
|
||||
|
||||
test('webhook message can be created with constructor', function () {
|
||||
test('webhook message can be created with constructor', function (): void {
|
||||
$message = new WebhookMessage('test data');
|
||||
|
||||
expect($message)->toBeInstanceOf(WebhookMessage::class);
|
||||
});
|
||||
|
||||
test('webhook message can set query parameters', function () {
|
||||
test('webhook message can set query parameters', function (): void {
|
||||
$message = WebhookMessage::create()
|
||||
->query(['param1' => 'value1', 'param2' => 'value2']);
|
||||
|
||||
expect($message->toArray()['query'])->toBe(['param1' => 'value1', 'param2' => 'value2']);
|
||||
});
|
||||
|
||||
test('webhook message can set data', function () {
|
||||
test('webhook message can set data', function (): void {
|
||||
$data = ['key' => 'value', 'nested' => ['array' => 'data']];
|
||||
$message = WebhookMessage::create()
|
||||
->data($data);
|
||||
|
|
@ -31,7 +31,7 @@ test('webhook message can set data', function () {
|
|||
expect($message->toArray()['data'])->toBe($data);
|
||||
});
|
||||
|
||||
test('webhook message can add headers', function () {
|
||||
test('webhook message can add headers', function (): void {
|
||||
$message = WebhookMessage::create()
|
||||
->header('X-Custom-Header', 'custom-value')
|
||||
->header('Authorization', 'Bearer token');
|
||||
|
|
@ -41,7 +41,7 @@ test('webhook message can add headers', function () {
|
|||
expect($headers['Authorization'])->toBe('Bearer token');
|
||||
});
|
||||
|
||||
test('webhook message can set user agent', function () {
|
||||
test('webhook message can set user agent', function (): void {
|
||||
$message = WebhookMessage::create()
|
||||
->userAgent('Test App/1.0');
|
||||
|
||||
|
|
@ -49,20 +49,20 @@ test('webhook message can set user agent', function () {
|
|||
expect($headers['User-Agent'])->toBe('Test App/1.0');
|
||||
});
|
||||
|
||||
test('webhook message can set verify option', function () {
|
||||
test('webhook message can set verify option', function (): void {
|
||||
$message = WebhookMessage::create()
|
||||
->verify(true);
|
||||
|
||||
expect($message->toArray()['verify'])->toBeTrue();
|
||||
});
|
||||
|
||||
test('webhook message verify defaults to false', function () {
|
||||
test('webhook message verify defaults to false', function (): void {
|
||||
$message = WebhookMessage::create();
|
||||
|
||||
expect($message->toArray()['verify'])->toBeFalse();
|
||||
});
|
||||
|
||||
test('webhook message can chain methods', function () {
|
||||
test('webhook message can chain methods', function (): void {
|
||||
$message = WebhookMessage::create(['initial' => 'data'])
|
||||
->query(['param' => 'value'])
|
||||
->data(['updated' => 'data'])
|
||||
|
|
@ -79,7 +79,7 @@ test('webhook message can chain methods', function () {
|
|||
expect($array['verify'])->toBeTrue();
|
||||
});
|
||||
|
||||
test('webhook message toArray returns correct structure', function () {
|
||||
test('webhook message toArray returns correct structure', function (): void {
|
||||
$message = WebhookMessage::create(['test' => 'data']);
|
||||
|
||||
$array = $message->toArray();
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use Illuminate\Foundation\Testing\RefreshDatabase;
|
|||
|
||||
uses(RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
beforeEach(function (): void {
|
||||
TrmnlPipeline::fake();
|
||||
});
|
||||
|
||||
|
|
@ -37,7 +37,6 @@ it('get_image_settings returns device model settings when available', function (
|
|||
// Use reflection to access private method
|
||||
$reflection = new ReflectionClass(ImageGenerationService::class);
|
||||
$method = $reflection->getMethod('getImageSettings');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$settings = $method->invoke(null, $device);
|
||||
|
||||
|
|
@ -66,7 +65,6 @@ it('get_image_settings falls back to device settings when no device model', func
|
|||
// Use reflection to access private method
|
||||
$reflection = new ReflectionClass(ImageGenerationService::class);
|
||||
$method = $reflection->getMethod('getImageSettings');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$settings = $method->invoke(null, $device);
|
||||
|
||||
|
|
@ -90,7 +88,6 @@ it('get_image_settings uses defaults for missing device properties', function ()
|
|||
// Use reflection to access private method
|
||||
$reflection = new ReflectionClass(ImageGenerationService::class);
|
||||
$method = $reflection->getMethod('getImageSettings');
|
||||
$method->setAccessible(true);
|
||||
|
||||
$settings = $method->invoke(null, $device);
|
||||
|
||||
|
|
@ -112,7 +109,6 @@ it('determine_image_format_from_model returns correct formats', function (): voi
|
|||
// Use reflection to access private method
|
||||
$reflection = new ReflectionClass(ImageGenerationService::class);
|
||||
$method = $reflection->getMethod('determineImageFormatFromModel');
|
||||
$method->setAccessible(true);
|
||||
|
||||
// Test BMP format
|
||||
$bmpModel = DeviceModel::factory()->create([
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ use GuzzleHttp\Psr7\Response;
|
|||
use Illuminate\Http\Request;
|
||||
use Laravel\Socialite\Two\User;
|
||||
|
||||
test('oidc provider throws exception when endpoint is not configured', function () {
|
||||
test('oidc provider throws exception when endpoint is not configured', function (): void {
|
||||
config(['services.oidc.endpoint' => null]);
|
||||
|
||||
expect(fn () => new OidcProvider(
|
||||
expect(fn (): OidcProvider => new OidcProvider(
|
||||
new Request(),
|
||||
'client-id',
|
||||
'client-secret',
|
||||
|
|
@ -20,7 +20,7 @@ test('oidc provider throws exception when endpoint is not configured', function
|
|||
))->toThrow(Exception::class, 'OIDC endpoint is not configured');
|
||||
});
|
||||
|
||||
test('oidc provider handles well-known endpoint url', function () {
|
||||
test('oidc provider handles well-known endpoint url', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com/.well-known/openid-configuration']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -48,7 +48,7 @@ test('oidc provider handles well-known endpoint url', function () {
|
|||
expect($provider)->toBeInstanceOf(OidcProvider::class);
|
||||
});
|
||||
|
||||
test('oidc provider handles base url endpoint', function () {
|
||||
test('oidc provider handles base url endpoint', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -76,7 +76,7 @@ test('oidc provider handles base url endpoint', function () {
|
|||
expect($provider)->toBeInstanceOf(OidcProvider::class);
|
||||
});
|
||||
|
||||
test('oidc provider throws exception when configuration is empty', function () {
|
||||
test('oidc provider throws exception when configuration is empty', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -90,7 +90,7 @@ test('oidc provider throws exception when configuration is empty', function () {
|
|||
|
||||
$this->app->instance(Client::class, $mockClient);
|
||||
|
||||
expect(fn () => new OidcProvider(
|
||||
expect(fn (): OidcProvider => new OidcProvider(
|
||||
new Request(),
|
||||
'client-id',
|
||||
'client-secret',
|
||||
|
|
@ -98,7 +98,7 @@ test('oidc provider throws exception when configuration is empty', function () {
|
|||
))->toThrow(Exception::class, 'OIDC configuration is empty or invalid JSON');
|
||||
});
|
||||
|
||||
test('oidc provider throws exception when authorization endpoint is missing', function () {
|
||||
test('oidc provider throws exception when authorization endpoint is missing', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -115,7 +115,7 @@ test('oidc provider throws exception when authorization endpoint is missing', fu
|
|||
|
||||
$this->app->instance(Client::class, $mockClient);
|
||||
|
||||
expect(fn () => new OidcProvider(
|
||||
expect(fn (): OidcProvider => new OidcProvider(
|
||||
new Request(),
|
||||
'client-id',
|
||||
'client-secret',
|
||||
|
|
@ -123,7 +123,7 @@ test('oidc provider throws exception when authorization endpoint is missing', fu
|
|||
))->toThrow(Exception::class, 'authorization_endpoint not found in OIDC configuration');
|
||||
});
|
||||
|
||||
test('oidc provider throws exception when configuration request fails', function () {
|
||||
test('oidc provider throws exception when configuration request fails', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -133,7 +133,7 @@ test('oidc provider throws exception when configuration request fails', function
|
|||
|
||||
$this->app->instance(Client::class, $mockClient);
|
||||
|
||||
expect(fn () => new OidcProvider(
|
||||
expect(fn (): OidcProvider => new OidcProvider(
|
||||
new Request(),
|
||||
'client-id',
|
||||
'client-secret',
|
||||
|
|
@ -141,7 +141,7 @@ test('oidc provider throws exception when configuration request fails', function
|
|||
))->toThrow(Exception::class, 'Failed to load OIDC configuration');
|
||||
});
|
||||
|
||||
test('oidc provider uses default scopes when none provided', function () {
|
||||
test('oidc provider uses default scopes when none provided', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -169,7 +169,7 @@ test('oidc provider uses default scopes when none provided', function () {
|
|||
expect($provider)->toBeInstanceOf(OidcProvider::class);
|
||||
});
|
||||
|
||||
test('oidc provider uses custom scopes when provided', function () {
|
||||
test('oidc provider uses custom scopes when provided', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -198,7 +198,7 @@ test('oidc provider uses custom scopes when provided', function () {
|
|||
expect($provider)->toBeInstanceOf(OidcProvider::class);
|
||||
});
|
||||
|
||||
test('oidc provider maps user data correctly', function () {
|
||||
test('oidc provider maps user data correctly', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
@ -241,7 +241,7 @@ test('oidc provider maps user data correctly', function () {
|
|||
expect($user->getAvatar())->toBe('https://example.com/avatar.jpg');
|
||||
});
|
||||
|
||||
test('oidc provider handles missing user fields gracefully', function () {
|
||||
test('oidc provider handles missing user fields gracefully', function (): void {
|
||||
config(['services.oidc.endpoint' => 'https://example.com']);
|
||||
|
||||
$mockClient = Mockery::mock(Client::class);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue