File tree Expand file tree Collapse file tree 7 files changed +50
-11
lines changed Expand file tree Collapse file tree 7 files changed +50
-11
lines changed Original file line number Diff line number Diff line change 2
2
<html >
3
3
4
4
<head >
5
- <title >{{ Scalar:: pageTitle () } } </title >
5
+ <title >{{ \ Scalar \ Scalar:: pageTitle () } } </title >
6
6
<meta charset =" utf-8" />
7
7
<meta name =" viewport" content =" width=device-width, initial-scale=1" />
8
8
@if (config (' scalar.configuration.theme' ) === ' laravel' )
Original file line number Diff line number Diff line change 1
1
@extends (' scalar::layout' )
2
2
3
3
@section (' content' )
4
- <script id =" api-reference" data-url =" {{ Scalar:: url () } }" ></script >
4
+ <script id =" api-reference" data-url =" {{ \ Scalar \ Scalar:: url () } }" ></script >
5
5
6
6
<script >
7
7
document .getElementById (' api-reference' ).dataset .configuration =
8
- JSON .stringify ({!! Scalar:: configuration () ! !} )
8
+ JSON .stringify ({!! \ Scalar \ Scalar:: configuration () ! !} )
9
9
</script >
10
10
11
- <script src =" {{ Scalar:: cdn () } }" ></script >
11
+ <script src =" {{ \ Scalar \ Scalar:: cdn () } }" ></script >
12
12
@endsection
Original file line number Diff line number Diff line change 8
8
'prefix ' => config ('scalar.path ' ),
9
9
'middleware ' => config ('scalar.middleware ' , 'web ' ),
10
10
], function () {
11
- Route::get ('/ ' , ScalarController::class);
11
+ Route::get ('/ ' , ScalarController::class)-> name ( ' scalar ' ) ;
12
12
});
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class ScalarController extends Controller
9
9
{
10
10
public function __invoke ()
11
11
{
12
- if (! Gate::check ('viewScalar ' ) && ! app ()->environment ('local ' )) {
12
+ if (! Gate::check ('viewScalar ' ) && ! app ()->environment ('local ' ) && ! app ()-> environment ( ' testing ' ) ) {
13
13
return abort (403 );
14
14
}
15
15
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ use Illuminate \Support \Facades \Route ;
4
+ use Scalar \Controllers \ScalarController ;
5
+
6
+ it ('registers the route ' , function () {
7
+ $ routes = Route::getRoutes ();
8
+ $ route = $ routes ->getByName ('scalar ' );
9
+
10
+ expect ($ route )->not ->toBeNull ()
11
+ ->and ('/ ' .$ route ->uri ())->toBe (config ('scalar.path ' ))
12
+ ->and ($ route ->getAction ('controller ' ))->toBe (ScalarController::class);
13
+ });
14
+
15
+ it ('returns a view ' , function () {
16
+ $ response = $ this ->get (config ('scalar.path ' ));
17
+
18
+ $ response ->assertViewIs ('scalar::reference ' );
19
+ });
20
+
21
+ it ('contains the jsDelivr URL ' , function () {
22
+ $ response = $ this ->get (config ('scalar.path ' ));
23
+
24
+ $ response ->assertSee (config ('scalar.cdn ' ));
25
+ });
26
+
27
+ it ('reflects changes in the config ' , function () {
28
+ // Original config
29
+ $ originalCdn = config ('scalar.cdn ' );
30
+
31
+ // Modify config
32
+ config ()->set ('scalar.cdn ' , 'https://example.com/cdn ' );
33
+
34
+ $ response = $ this ->get ('/reference ' );
35
+
36
+ $ response ->assertOk ()
37
+ ->assertViewIs ('scalar::reference ' )
38
+ ->assertSee ('https://example.com/cdn ' )
39
+ ->assertDontSee ($ originalCdn );
40
+
41
+ // Reset config
42
+ config (['scalar.cdn ' => $ originalCdn ]);
43
+ });
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ protected function getPackageProviders($app)
26
26
27
27
public function getEnvironmentSetUp ($ app )
28
28
{
29
+ config ()->set ('app.key ' , 'base64: ' .base64_encode (random_bytes (32 )));
29
30
config ()->set ('database.default ' , 'testing ' );
30
31
31
32
/*
You can’t perform that action at this time.
0 commit comments