We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
1 | <?php |
||||
2 | |||||
3 | namespace Backpack\CRUD\Tests\Unit\Http; |
||||
4 | |||||
5 | use Backpack\CRUD\app\Library\CrudPanel\CrudPanel; |
||||
6 | use Backpack\CRUD\Tests\BaseTestClass; |
||||
7 | |||||
8 | /** |
||||
9 | * @covers Backpack\CRUD\app\Http\Controllers\CrudController |
||||
10 | * @covers Backpack\CRUD\app\Library\CrudPanel\CrudPanel |
||||
11 | */ |
||||
12 | class CrudControllerTest extends BaseTestClass |
||||
13 | { |
||||
14 | private $crudPanel; |
||||
15 | |||||
16 | /** |
||||
17 | * Define environment setup. |
||||
18 | * |
||||
19 | * @param \Illuminate\Foundation\Application $app |
||||
20 | * @return void |
||||
21 | */ |
||||
22 | protected function getEnvironmentSetUp($app) |
||||
23 | { |
||||
24 | parent::getEnvironmentSetUp($app); |
||||
25 | |||||
26 | $app->singleton('crud', function ($app) { |
||||
27 | return new CrudPanel($app); |
||||
0 ignored issues
–
show
|
|||||
28 | }); |
||||
29 | |||||
30 | $this->crudPanel = app('crud'); |
||||
31 | } |
||||
32 | |||||
33 | public function testSetRouteName() |
||||
34 | { |
||||
35 | $this->crudPanel->setRouteName('users'); |
||||
36 | |||||
37 | $this->assertEquals(url('admin/users'), $this->crudPanel->getRoute()); |
||||
38 | } |
||||
39 | |||||
40 | public function testSetRoute() |
||||
41 | { |
||||
42 | $this->crudPanel->setRoute(backpack_url('users')); |
||||
43 | $this->crudPanel->setEntityNameStrings('singular', 'plural'); |
||||
44 | $this->assertEquals(route('users.index'), $this->crudPanel->getRoute()); |
||||
45 | } |
||||
46 | |||||
47 | public function testCrudRequestUpdatesOnEachRequest() |
||||
48 | { |
||||
49 | // create a first request |
||||
50 | $firstRequest = request()->create('admin/users/1/edit', 'GET'); |
||||
51 | app()->handle($firstRequest); |
||||
0 ignored issues
–
show
The method
handle() does not exist on Illuminate\Container\Container . Are you sure you never get this type here, but always one of the subclasses?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
52 | $firstRequest = app()->request; |
||||
53 | |||||
54 | // see if the first global request has been passed to the CRUD object |
||||
55 | $this->assertSame($this->crudPanel->getRequest(), $firstRequest); |
||||
56 | |||||
57 | // create a second request |
||||
58 | $secondRequest = request()->create('admin/users/1', 'PUT', ['name' => 'foo']); |
||||
59 | app()->handle($secondRequest); |
||||
60 | $secondRequest = app()->request; |
||||
61 | |||||
62 | // see if the second global request has been passed to the CRUD object |
||||
63 | $this->assertSame($this->crudPanel->getRequest(), $secondRequest); |
||||
64 | |||||
65 | // the CRUD object's request should no longer hold the first request, but the second one |
||||
66 | $this->assertNotSame($this->crudPanel->getRequest(), $firstRequest); |
||||
67 | } |
||||
68 | } |
||||
69 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.