laravel-workers 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/bin/laravel-workers.mjs +141 -141
- package/build.mjs +2599 -2599
- package/compiler/bin/controller.mjs +92 -92
- package/kernel/cache.mjs +405 -405
- package/kernel/db.mjs +703 -703
- package/kernel/encrypter.mjs +1 -1
- package/kernel/hash.mjs +113 -113
- package/kernel/multipart.mjs +161 -161
- package/kernel/router.mjs +276 -276
- package/kernel/scheduler.mjs +236 -236
- package/kernel/str.mjs +445 -445
- package/kernel/tests/cache.test.mjs +290 -290
- package/kernel/tests/db.test.mjs +1068 -1068
- package/kernel/tests/encrypter.test.mjs +1 -1
- package/kernel/tests/hash.test.mjs +149 -149
- package/kernel/tests/http.test.mjs +1182 -1182
- package/kernel/tests/php-json.test.mjs +263 -263
- package/kernel/tests/router.test.mjs +281 -281
- package/kernel/tests/services.test.mjs +474 -474
- package/kernel/tests/str.test.mjs +83 -83
- package/kernel/tests/validation.test.mjs +340 -340
- package/kernel/validation.mjs +123 -123
- package/package.json +69 -69
- package/tools/schema-dump.php +158 -158
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
// kernel/tests/str.test.mjs - the Str family, verified against the real
|
|
2
|
-
// Laravel (the oracle: the fixture app's vendor, PHP 8.3). The expected values
|
|
3
|
-
// below are PHP's, not ours.
|
|
4
|
-
import { test } from 'node:test';
|
|
5
|
-
import assert from 'node:assert/strict';
|
|
6
|
-
import { str, ascii } from '../str.mjs';
|
|
7
|
-
|
|
8
|
-
test('Str: the values match PHP 8.3 / Laravel 13.37', () => {
|
|
9
|
-
// slug
|
|
10
|
-
assert.equal(str.slug('Hello World'), 'hello-world');
|
|
11
|
-
assert.equal(str.slug('H\u00e9llo W\u00f6rld'), 'hello-world');
|
|
12
|
-
assert.equal(str.slug('A B--c'), 'a-b-c');
|
|
13
|
-
// limit
|
|
14
|
-
assert.equal(str.limit('Hello World', 5), 'Hello...');
|
|
15
|
-
assert.equal(str.limit('Hello', 10), 'Hello');
|
|
16
|
-
assert.equal(str.limit('Hello World', 5, '...'), 'Hello...');
|
|
17
|
-
// upper / lower
|
|
18
|
-
assert.equal(str.upper('hello'), 'HELLO');
|
|
19
|
-
assert.equal(str.lower('HELLO'), 'hello');
|
|
20
|
-
// studly / camel / snake / kebab / title
|
|
21
|
-
assert.equal(str.studly('hello_world'), 'HelloWorld');
|
|
22
|
-
assert.equal(str.camel('hello_world'), 'helloWorld');
|
|
23
|
-
assert.equal(str.snake('HelloWorld'), 'hello_world');
|
|
24
|
-
assert.equal(str.kebab('HelloWorld'), 'hello-world');
|
|
25
|
-
assert.equal(str.title('hello world'), 'Hello World');
|
|
26
|
-
// contains / startsWith / endsWith (case sensitive)
|
|
27
|
-
assert.equal(str.contains('Hello World', 'world'), false);
|
|
28
|
-
assert.equal(str.contains('Hello World', 'World'), true);
|
|
29
|
-
assert.equal(str.startsWith('Hello World', 'Hello'), true);
|
|
30
|
-
assert.equal(str.endsWith('Hello World', 'World'), true);
|
|
31
|
-
// after / before / length
|
|
32
|
-
assert.equal(str.after('Hello World', 'Hello '), 'World');
|
|
33
|
-
assert.equal(str.before('Hello World', ' World'), 'Hello');
|
|
34
|
-
assert.equal(str.length('Hello World'), 11);
|
|
35
|
-
// replace / replaceFirst / replaceLast
|
|
36
|
-
assert.equal(str.replace('Hello World', 'World', 'Edge'), 'Edge');
|
|
37
|
-
assert.equal(str.replaceFirst('Hello World', 'World', 'Edge'), 'Edge');
|
|
38
|
-
assert.equal(str.replaceLast('Hello World', 'l', 'L'), 'L');
|
|
39
|
-
// squish / ucfirst / ucwords / ascii
|
|
40
|
-
assert.equal(str.squish(' Hello World '), 'Hello World');
|
|
41
|
-
assert.equal(str.ucfirst('hello world'), 'Hello world');
|
|
42
|
-
assert.equal(str.ucwords('hello world'), 'Hello World');
|
|
43
|
-
assert.equal(str.ascii('H\u00e9llo W\u00f6rld'), 'Hello World');
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test('Str: the family answers like Laravel 13.37 (the probed values)', () => {
|
|
47
|
-
// title: mb_convert_case(MB_CASE_TITLE) - a word is a run of CASED letters;
|
|
48
|
-
// a case-ignorable character does not end it ('a.b' -> 'A.b'), any other
|
|
49
|
-
// character does ('a1b2' -> 'A1B2').
|
|
50
|
-
assert.equal(str.title('hello-world'), 'Hello-World');
|
|
51
|
-
assert.equal(str.title('HELLO WORLD'), 'Hello World');
|
|
52
|
-
assert.equal(str.title('a1b2'), 'A1B2');
|
|
53
|
-
assert.equal(str.title('hello.world'), 'Hello.world');
|
|
54
|
-
assert.equal(str.title("o'brien"), "O'brien");
|
|
55
|
-
assert.equal(str.title('\u00fcn\u00efcode stra\u00dfe'), '\u00dcn\u00efcode Stra\u00dfe');
|
|
56
|
-
assert.equal(str.title('\u01c6ungla'), '\u01c5ungla');
|
|
57
|
-
assert.equal(str.title('\u00df'), 'Ss');
|
|
58
|
-
// ucwords: only a LOWERCASE letter right after a separator is uppercased.
|
|
59
|
-
assert.equal(str.ucwords('foo_bar'), 'Foo_bar');
|
|
60
|
-
assert.equal(str.ucwords('\u00e9cole'), '\u00c9cole');
|
|
61
|
-
assert.equal(str.ucwords('HELLO WORLD'), 'HELLO WORLD');
|
|
62
|
-
assert.equal(str.ucwords('hello-world'), 'Hello-world');
|
|
63
|
-
// snake / kebab: ctype_lower is true only for a lowercase ASCII string.
|
|
64
|
-
assert.equal(str.snake('hello world'), 'hello_world');
|
|
65
|
-
assert.equal(str.snake('HELLO WORLD'), 'h_e_l_l_o_w_o_r_l_d');
|
|
66
|
-
assert.equal(str.snake('hello-world'), 'hello-world');
|
|
67
|
-
assert.equal(str.kebab('HelloWorld'), 'hello-world');
|
|
68
|
-
// slug: Laravel's dictionary ('@' -> 'at').
|
|
69
|
-
assert.equal(str.slug('a@b'), 'a-at-b');
|
|
70
|
-
assert.equal(str.slug('a@b c'), 'a-at-b-c');
|
|
71
|
-
// contains / startsWith / endsWith: an empty needle is false.
|
|
72
|
-
assert.equal(str.contains('hello', ''), false);
|
|
73
|
-
assert.equal(str.startsWith('hello', ''), false);
|
|
74
|
-
assert.equal(str.endsWith('hello', ''), false);
|
|
75
|
-
// limit: the limit is a DISPLAY width (a CJK glyph is two columns).
|
|
76
|
-
assert.equal(str.limit('\u65e5\u672c\u8a9e\u30c6\u30ad\u30b9\u30c8', 10), '\u65e5\u672c\u8a9e\u30c6\u30ad...');
|
|
77
|
-
assert.equal(str.limit('\u65e5\u672c\u8a9e\u30c6\u30ad\u30b9\u30c8', 4), '\u65e5\u672c...');
|
|
78
|
-
// ucfirst / camel: mb_ucfirst / mb_lcfirst (the first CHARACTER).
|
|
79
|
-
assert.equal(str.ucfirst('\u01c6ungla'), '\u01c5ungla');
|
|
80
|
-
assert.equal(str.ucfirst('\u00df'), 'Ss');
|
|
81
|
-
assert.equal(str.camel('\u00e9t\u00e9'), '\u00e9t\u00e9');
|
|
82
|
-
assert.equal(str.camel('\u00df'), 'ss');
|
|
83
|
-
});
|
|
1
|
+
// kernel/tests/str.test.mjs - the Str family, verified against the real
|
|
2
|
+
// Laravel (the oracle: the fixture app's vendor, PHP 8.3). The expected values
|
|
3
|
+
// below are PHP's, not ours.
|
|
4
|
+
import { test } from 'node:test';
|
|
5
|
+
import assert from 'node:assert/strict';
|
|
6
|
+
import { str, ascii } from '../str.mjs';
|
|
7
|
+
|
|
8
|
+
test('Str: the values match PHP 8.3 / Laravel 13.37', () => {
|
|
9
|
+
// slug
|
|
10
|
+
assert.equal(str.slug('Hello World'), 'hello-world');
|
|
11
|
+
assert.equal(str.slug('H\u00e9llo W\u00f6rld'), 'hello-world');
|
|
12
|
+
assert.equal(str.slug('A B--c'), 'a-b-c');
|
|
13
|
+
// limit
|
|
14
|
+
assert.equal(str.limit('Hello World', 5), 'Hello...');
|
|
15
|
+
assert.equal(str.limit('Hello', 10), 'Hello');
|
|
16
|
+
assert.equal(str.limit('Hello World', 5, '...'), 'Hello...');
|
|
17
|
+
// upper / lower
|
|
18
|
+
assert.equal(str.upper('hello'), 'HELLO');
|
|
19
|
+
assert.equal(str.lower('HELLO'), 'hello');
|
|
20
|
+
// studly / camel / snake / kebab / title
|
|
21
|
+
assert.equal(str.studly('hello_world'), 'HelloWorld');
|
|
22
|
+
assert.equal(str.camel('hello_world'), 'helloWorld');
|
|
23
|
+
assert.equal(str.snake('HelloWorld'), 'hello_world');
|
|
24
|
+
assert.equal(str.kebab('HelloWorld'), 'hello-world');
|
|
25
|
+
assert.equal(str.title('hello world'), 'Hello World');
|
|
26
|
+
// contains / startsWith / endsWith (case sensitive)
|
|
27
|
+
assert.equal(str.contains('Hello World', 'world'), false);
|
|
28
|
+
assert.equal(str.contains('Hello World', 'World'), true);
|
|
29
|
+
assert.equal(str.startsWith('Hello World', 'Hello'), true);
|
|
30
|
+
assert.equal(str.endsWith('Hello World', 'World'), true);
|
|
31
|
+
// after / before / length
|
|
32
|
+
assert.equal(str.after('Hello World', 'Hello '), 'World');
|
|
33
|
+
assert.equal(str.before('Hello World', ' World'), 'Hello');
|
|
34
|
+
assert.equal(str.length('Hello World'), 11);
|
|
35
|
+
// replace / replaceFirst / replaceLast
|
|
36
|
+
assert.equal(str.replace('Hello World', 'World', 'Edge'), 'Edge');
|
|
37
|
+
assert.equal(str.replaceFirst('Hello World', 'World', 'Edge'), 'Edge');
|
|
38
|
+
assert.equal(str.replaceLast('Hello World', 'l', 'L'), 'L');
|
|
39
|
+
// squish / ucfirst / ucwords / ascii
|
|
40
|
+
assert.equal(str.squish(' Hello World '), 'Hello World');
|
|
41
|
+
assert.equal(str.ucfirst('hello world'), 'Hello world');
|
|
42
|
+
assert.equal(str.ucwords('hello world'), 'Hello World');
|
|
43
|
+
assert.equal(str.ascii('H\u00e9llo W\u00f6rld'), 'Hello World');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('Str: the family answers like Laravel 13.37 (the probed values)', () => {
|
|
47
|
+
// title: mb_convert_case(MB_CASE_TITLE) - a word is a run of CASED letters;
|
|
48
|
+
// a case-ignorable character does not end it ('a.b' -> 'A.b'), any other
|
|
49
|
+
// character does ('a1b2' -> 'A1B2').
|
|
50
|
+
assert.equal(str.title('hello-world'), 'Hello-World');
|
|
51
|
+
assert.equal(str.title('HELLO WORLD'), 'Hello World');
|
|
52
|
+
assert.equal(str.title('a1b2'), 'A1B2');
|
|
53
|
+
assert.equal(str.title('hello.world'), 'Hello.world');
|
|
54
|
+
assert.equal(str.title("o'brien"), "O'brien");
|
|
55
|
+
assert.equal(str.title('\u00fcn\u00efcode stra\u00dfe'), '\u00dcn\u00efcode Stra\u00dfe');
|
|
56
|
+
assert.equal(str.title('\u01c6ungla'), '\u01c5ungla');
|
|
57
|
+
assert.equal(str.title('\u00df'), 'Ss');
|
|
58
|
+
// ucwords: only a LOWERCASE letter right after a separator is uppercased.
|
|
59
|
+
assert.equal(str.ucwords('foo_bar'), 'Foo_bar');
|
|
60
|
+
assert.equal(str.ucwords('\u00e9cole'), '\u00c9cole');
|
|
61
|
+
assert.equal(str.ucwords('HELLO WORLD'), 'HELLO WORLD');
|
|
62
|
+
assert.equal(str.ucwords('hello-world'), 'Hello-world');
|
|
63
|
+
// snake / kebab: ctype_lower is true only for a lowercase ASCII string.
|
|
64
|
+
assert.equal(str.snake('hello world'), 'hello_world');
|
|
65
|
+
assert.equal(str.snake('HELLO WORLD'), 'h_e_l_l_o_w_o_r_l_d');
|
|
66
|
+
assert.equal(str.snake('hello-world'), 'hello-world');
|
|
67
|
+
assert.equal(str.kebab('HelloWorld'), 'hello-world');
|
|
68
|
+
// slug: Laravel's dictionary ('@' -> 'at').
|
|
69
|
+
assert.equal(str.slug('a@b'), 'a-at-b');
|
|
70
|
+
assert.equal(str.slug('a@b c'), 'a-at-b-c');
|
|
71
|
+
// contains / startsWith / endsWith: an empty needle is false.
|
|
72
|
+
assert.equal(str.contains('hello', ''), false);
|
|
73
|
+
assert.equal(str.startsWith('hello', ''), false);
|
|
74
|
+
assert.equal(str.endsWith('hello', ''), false);
|
|
75
|
+
// limit: the limit is a DISPLAY width (a CJK glyph is two columns).
|
|
76
|
+
assert.equal(str.limit('\u65e5\u672c\u8a9e\u30c6\u30ad\u30b9\u30c8', 10), '\u65e5\u672c\u8a9e\u30c6\u30ad...');
|
|
77
|
+
assert.equal(str.limit('\u65e5\u672c\u8a9e\u30c6\u30ad\u30b9\u30c8', 4), '\u65e5\u672c...');
|
|
78
|
+
// ucfirst / camel: mb_ucfirst / mb_lcfirst (the first CHARACTER).
|
|
79
|
+
assert.equal(str.ucfirst('\u01c6ungla'), '\u01c5ungla');
|
|
80
|
+
assert.equal(str.ucfirst('\u00df'), 'Ss');
|
|
81
|
+
assert.equal(str.camel('\u00e9t\u00e9'), '\u00e9t\u00e9');
|
|
82
|
+
assert.equal(str.camel('\u00df'), 'ss');
|
|
83
|
+
});
|