Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

BaseTestClass::setupUserCreateRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Backpack\CRUD\Tests;
4
5
use Backpack\Basset\BassetServiceProvider;
6
use Backpack\CRUD\BackpackServiceProvider;
7
use Backpack\CRUD\Tests\config\TestsServiceProvider;
8
use Illuminate\Routing\Route as RouteInstance;
9
use Illuminate\Support\Facades\Route;
10
use Orchestra\Testbench\TestCase;
11
use Prologue\Alerts\AlertsServiceProvider;
12
13
abstract class BaseTestClass extends TestCase
14
{
15
    /**
16
     * Setup the test environment.
17
     *
18
     * @return void
19
     */
20
    protected function setUp(): void
21
    {
22
        parent::setUp();
23
24
        Route::group([
25
            (array) config('backpack.base.web_middleware', 'web'),
26
            (array) config('backpack.base.middleware_key', 'admin'),
27
            'prefix' => config('backpack.base.route_prefix', 'admin'),
28
        ],
29
            function () {
30
                Route::get('articles/{id}/show/{detail}', ['as' => 'article.show.detail', 'action' => 'Backpack\CRUD\Tests\config\Http\Controllers\ArticleCrudController@detail']);
31
                Route::crud('users', 'Backpack\CRUD\Tests\config\Http\Controllers\UserCrudController');
32
                Route::crud('articles', 'Backpack\CRUD\Tests\config\Http\Controllers\ArticleCrudController');
33
            }
34
        );
35
    }
36
37
    protected function getPackageProviders($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
    protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        return [
40
            BassetServiceProvider::class,
41
            BackpackServiceProvider::class,
42
            AlertsServiceProvider::class,
43
            TestsServiceProvider::class,
44
            \Spatie\Translatable\TranslatableServiceProvider::class,
45
        ];
46
    }
47
48
    protected function setupUserCreateRequest()
49
    {
50
        $request = request()->create('/admin/users/create', 'POST', ['name' => 'foo']);
51
        $request->setRouteResolver(function () use ($request) {
52
            return (new RouteInstance('POST', 'admin/users/create', ['UserCrudController', 'create']))->bind($request);
53
        });
54
        $this->crudPanel->setRequest($request);
55
    }
56
57
    protected function makeAnArticleModel(array $attributes = [])
58
    {
59
        $attributes = array_merge([
60
            'id' => 1,
61
            'content' => 'Some Content',
62
        ], $attributes);
63
64
        return \Backpack\CRUD\Tests\config\Models\Article::make($attributes);
65
    }
66
67
    protected function makeAUserModel(array $attributes = [])
68
    {
69
        $attributes = array_merge([
70
            'id' => 1,
71
            'name' => 'user',
72
            'email' => '[email protected]',
73
        ], $attributes);
74
75
        return \Backpack\CRUD\Tests\config\Models\User::make($attributes);
76
    }
77
78
    // allow us to run crud panel private/protected methods like `inferFieldTypeFromDbColumnType`
79
    public function invokeMethod(&$object, $methodName, array $parameters = [])
80
    {
81
        $reflection = new \ReflectionClass(get_class($object));
82
        $method = $reflection->getMethod($methodName);
83
        $method->setAccessible(true);
84
85
        return $method->invokeArgs($object, $parameters);
86
    }
87
}
88