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
|
|
@ -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-');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue