Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a761d42

Browse files
authored
Laravel 12.x Support (#66)
1 parent a48948c commit a761d42

File tree

3 files changed

+49
-41
lines changed

3 files changed

+49
-41
lines changed

.github/workflows/run-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ jobs:
1010
matrix:
1111
os: [ubuntu-latest]
1212
php: [8.4, 8.3, 8.2, 8.1, 8.0]
13-
laravel: [11.*, 10.*, 9.*, 8.*]
13+
laravel: [12.*, 11.*, 10.*, 9.*, 8.*]
1414
dependency-version: [prefer-stable]
1515
include:
16+
- laravel: 12.*
17+
testbench: 10.*
1618
- laravel: 11.*
1719
testbench: 9.*
1820
- laravel: 10.*
@@ -22,6 +24,10 @@ jobs:
2224
- laravel: 8.*
2325
testbench: 6.*
2426
exclude:
27+
- laravel: 12.*
28+
php: 8.1
29+
- laravel: 12.*
30+
php: 8.0
2531
- laravel: 11.*
2632
php: 8.1
2733
- laravel: 11.*
@@ -50,7 +56,7 @@ jobs:
5056

5157
- name: Install dependencies
5258
run: |
53-
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.62.1" --no-interaction --no-update
59+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:>=2.72.6" --no-interaction --no-update
5460
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest
5561
5662
- name: Execute tests

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
],
2828
"require": {
2929
"php": "^8.0",
30-
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0",
31-
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
30+
"illuminate/contracts": "^8.0|^9.0|^10.0|^11.0|^12.0",
31+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0|^12.0"
3232
},
3333
"require-dev": {
34-
"phpunit/phpunit": "^9.5|^10.5",
35-
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0",
36-
"pestphp/pest": "^1.22|^2.28"
34+
"phpunit/phpunit": "^9.5|^10.5|^11.5",
35+
"orchestra/testbench": "^6.0|^7.0|^8.0|^9.0|^10.0",
36+
"pestphp/pest": "^1.22|^2.28|^3.0"
3737
},
3838
"autoload": {
3939
"psr-4": {

tests/BladeTest.php

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,90 +13,92 @@
1313
})
1414
->with([
1515
'an array' => [
16-
'parameter' => ['key' => 'value'],
17-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'key\'] = \'value\';</script>',
16+
['key' => 'value'],
17+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'key\'] = \'value\';</script>',
1818
],
1919
'a boolean with value of `true`' => [
20-
'parameter' => ['boolean' => true],
21-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'boolean\'] = true;</script>',
20+
['boolean' => true],
21+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'boolean\'] = true;</script>',
2222
],
2323
'a boolean with value of `false`' => [
24-
'parameter' => ['boolean' => false],
25-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'boolean\'] = false;</script>',
24+
['boolean' => false],
25+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'boolean\'] = false;</script>',
2626
],
2727
'an integer' => [
28-
'parameter' => ['number' => 5],
29-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'number\'] = 5;</script>',
28+
['number' => 5],
29+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'number\'] = 5;</script>',
3030
],
3131
'an float' => [
32-
'parameter' => ['number' => 5.5],
33-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'number\'] = 5.5;</script>',
32+
['number' => 5.5],
33+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'number\'] = 5.5;</script>',
3434
],
3535
'null' => [
36-
'parameter' => ['nothing' => null],
37-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'nothing\'] = null;</script>',
36+
['nothing' => null],
37+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'nothing\'] = null;</script>',
3838
],
3939
'a string with line breaks' => [
40-
'parameter' => ['string' => "This is\r\n a test"],
41-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'string\'] = \'This is\\r\\n a test\';</script>',
40+
['string' => "This is\r\n a test"],
41+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'string\'] = \'This is\\r\\n a test\';</script>',
4242
],
4343
'a numeric string as a string' => [
44-
'parameter' => ['socialSecurity' => '123456789'],
45-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'socialSecurity\'] = \'123456789\';</script>',
44+
['socialSecurity' => '123456789'],
45+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'socialSecurity\'] = \'123456789\';</script>',
4646
],
4747
'escapes tags in a string' => [
48-
'parameter' => ['string' => "This is a <tag>"],
49-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'string\'] = \'This is a \<tag\>\';</script>',
48+
['string' => "This is a <tag>"],
49+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'string\'] = \'This is a \<tag\>\';</script>',
5050
],
5151
'arrayable objects' => [
52-
'parameter' => new class () implements Arrayable {
52+
new class () implements Arrayable {
5353
public function toArray()
5454
{
5555
return ['arrayableKey' => 'arrayableValue'];
5656
}
5757
},
58-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'arrayableKey\'] = \'arrayableValue\';</script>',
58+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'arrayableKey\'] = \'arrayableValue\';</script>',
5959
],
6060
'JSON serializable objects' => [
61-
'parameter' => new class () implements JsonSerializable {
61+
new class () implements JsonSerializable {
6262
public function jsonSerialize()
6363
{
6464
return ['jsonKey' => 'jsonValue'];
6565
}
6666
},
67-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = {"jsonKey":"jsonValue"};</script>',
67+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = {"jsonKey":"jsonValue"};</script>',
6868
],
6969
'an object that implements `toJson`' => [
70-
'parameter' => new class () {
70+
new class () {
7171
public function toJson()
7272
{
7373
return json_encode(['jsonKey' => 'jsonValue']);
7474
}
7575
},
76-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = {"jsonKey":"jsonValue"};</script>',
76+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = {"jsonKey":"jsonValue"};</script>',
7777
],
7878
'an object that implements `toString`' => [
79-
'parameter' => new class () {
79+
new class () {
8080
public function __toString()
8181
{
8282
return 'string';
8383
}
8484
},
85-
'expected' => '<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = \'string\';</script>',
85+
'<script>window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'0\'] = \'string\';</script>',
8686
],
8787

8888
]);
8989

90-
it('can render data without a namespace')
91-
->tap(fn () => config()->set('blade-javascript.namespace', ''))
92-
->expect(fn () => renderView('keyValue'))
93-
->toEqual('<script>window[\'key\'] = \'value\';</script>');
90+
it('can render data without a namespace', function () {
91+
config()->set('blade-javascript.namespace', '');
92+
expect(renderView('keyValue'))
93+
->toEqual('<script>window[\'key\'] = \'value\';</script>');
94+
});
9495

9596
it('cannot translate resources to Javascript')
9697
->tap(fn () => renderView('variable', ['parameter' => fopen(__FILE__, 'r')]))
9798
->throws(ErrorException::class);
9899

99-
it('can render a customized view')
100-
->tap(fn () => view()->replaceNamespace('bladeJavaScript', [__DIR__ . '/resources/views/override']))
101-
->expect(fn () => renderView('keyValue'))
102-
->toEqual('<script type="application/javascript">window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'key\'] = \'value\';</script>');
100+
it('can render a customized view', function () {
101+
view()->replaceNamespace('bladeJavaScript', [__DIR__ . '/resources/views/override']);
102+
expect(renderView('keyValue'))
103+
->toEqual('<script type="application/javascript">window[\'js\'] = window[\'js\'] || {};window[\'js\'][\'key\'] = \'value\';</script>');
104+
});

0 commit comments

Comments
 (0)