Skip to content

Commit 65b9420

Browse files
committed
Apply fixes from StyleCI
[ci skip] [skip ci]
1 parent 8dd05ed commit 65b9420

File tree

9 files changed

+56
-59
lines changed

9 files changed

+56
-59
lines changed

tests/BaseTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ protected function getPackageProviders($app)
2323
BackpackServiceProvider::class,
2424
];
2525
}
26-
27-
// allow us to run crud panel private/protected methods like `inferFieldTypeFromDbColumnType`
28-
public function invokeMethod(&$object, $methodName, array $parameters = [])
29-
{
30-
$reflection = new \ReflectionClass(get_class($object));
31-
$method = $reflection->getMethod($methodName);
32-
$method->setAccessible(true);
33-
34-
return $method->invokeArgs($object, $parameters);
35-
}
26+
27+
// allow us to run crud panel private/protected methods like `inferFieldTypeFromDbColumnType`
28+
public function invokeMethod(&$object, $methodName, array $parameters = [])
29+
{
30+
$reflection = new \ReflectionClass(get_class($object));
31+
$method = $reflection->getMethod($methodName);
32+
$method->setAccessible(true);
33+
34+
return $method->invokeArgs($object, $parameters);
35+
}
3636
}
Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<?php
2+
23
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
34

45
/**
56
* @covers Backpack\CRUD\app\Library\CrudPanel\Traits\Autofocus
67
*/
78
class CrudPanelAutofocusTest extends BaseCrudPanelTest
89
{
9-
public function testItCanEnableAndDisableAutofocus()
10-
{
11-
$this->crudPanel->setOperation('create');
12-
$this->crudPanel->enableAutoFocus();
13-
$this->assertTrue($this->crudPanel->getAutoFocusOnFirstField());
14-
$this->crudPanel->disableAutofocus();
15-
$this->assertFalse($this->crudPanel->getAutoFocusOnFirstField());
16-
}
10+
public function testItCanEnableAndDisableAutofocus()
11+
{
12+
$this->crudPanel->setOperation('create');
13+
$this->crudPanel->enableAutoFocus();
14+
$this->assertTrue($this->crudPanel->getAutoFocusOnFirstField());
15+
$this->crudPanel->disableAutofocus();
16+
$this->assertFalse($this->crudPanel->getAutoFocusOnFirstField());
17+
}
1718
}

tests/Unit/CrudPanel/CrudPanelCreateTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Backpack\CRUD\Tests\Unit\Models\PlanetNonNullable;
1010
use Backpack\CRUD\Tests\Unit\Models\Universe;
1111
use Backpack\CRUD\Tests\Unit\Models\User;
12-
use Backpack\CRUD\Tests\Unit\Models\Bill;
1312
use Faker\Factory;
1413
use Illuminate\Support\Arr;
1514

@@ -384,7 +383,7 @@ public function testGetRelationFieldsWithPivotNoRelations()
384383

385384
$this->assertEmpty($relationFields);
386385
}
387-
386+
388387
public function testMorphToManySelectableRelationship()
389388
{
390389
$this->crudPanel->setModel(User::class);
@@ -401,7 +400,7 @@ public function testMorphToManySelectableRelationship()
401400
];
402401

403402
$entry = $this->crudPanel->create($inputData);
404-
403+
405404
$updateFields = $this->crudPanel->getUpdateFields($entry->id);
406405

407406
$this->assertCount(1, $entry->bills);
@@ -501,7 +500,7 @@ public function testBelongsToManyWithPivotDataRelationship()
501500

502501
$entry = $this->crudPanel->create($inputData);
503502
$updateFields = $this->crudPanel->getUpdateFields($entry->id);
504-
503+
505504
$this->assertCount(1, $entry->fresh()->superArticles);
506505
$this->assertEquals('my first article note', $entry->fresh()->superArticles->first()->pivot->notes);
507506
}
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
34

45
/**
@@ -12,15 +13,15 @@ public function testItCanEnableAndDisableInlineErrors()
1213
$this->crudPanel->enableInlineErrors();
1314
$this->assertTrue($this->crudPanel->inlineErrorsEnabled());
1415
$this->crudPanel->disableInlineErrors();
15-
$this->assertFalse($this->crudPanel->inlineErrorsEnabled());
16+
$this->assertFalse($this->crudPanel->inlineErrorsEnabled());
1617
}
1718

1819
public function testItCanEnableAndDisableGroupedErrors()
1920
{
20-
$this->crudPanel->setOperation('create');
21-
$this->crudPanel->enableGroupedErrors();
22-
$this->assertTrue($this->crudPanel->groupedErrorsEnabled());
23-
$this->crudPanel->disableGroupedErrors();
24-
$this->assertFalse($this->crudPanel->groupedErrorsEnabled());
21+
$this->crudPanel->setOperation('create');
22+
$this->crudPanel->enableGroupedErrors();
23+
$this->assertTrue($this->crudPanel->groupedErrorsEnabled());
24+
$this->crudPanel->disableGroupedErrors();
25+
$this->assertFalse($this->crudPanel->groupedErrorsEnabled());
2526
}
2627
}

tests/Unit/CrudPanel/CrudPanelFieldsTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -654,30 +654,31 @@ public function testItAbortsOnUnexpectedEntity()
654654
new \Symfony\Component\HttpKernel\Exception\HttpException(500, 'Looks like field <code>doesNotExist</code> is not properly defined. The <code>doesNotExist()</code> relationship doesn\'t seem to exist on the <code>Backpack\CRUD\Tests\Unit\Models\TestModel</code> model.'),
655655
$e
656656
);
657-
}
657+
}
658658

659-
public function testItCanRemoveAllFields() {
659+
public function testItCanRemoveAllFields()
660+
{
660661
$this->crudPanel->addFields([
661662
['name' => 'test1'],
662-
['name' => 'test2']
663+
['name' => 'test2'],
663664
]);
664665

665666
$this->assertCount(2, $this->crudPanel->fieldS());
666667
$this->crudPanel->removeAllFields();
667668
$this->assertCount(0, $this->crudPanel->fieldS());
668-
669-
670669
}
671670

672-
public function testItCanRemoveAnAttributeFromAField() {
671+
public function testItCanRemoveAnAttributeFromAField()
672+
{
673673
$this->crudPanel->addField(['name' => 'test', 'tab' => 'test']);
674674

675675
$this->assertEquals('test', $this->crudPanel->fieldS()['test']['tab']);
676676
$this->crudPanel->removeFieldAttribute('test', 'tab');
677677
$this->assertNull($this->crudPanel->fieldS()['test']['tab'] ?? null);
678678
}
679679

680-
public function testItCanSetALabelForAField() {
680+
public function testItCanSetALabelForAField()
681+
{
681682
$this->crudPanel->addField(['name' => 'test', 'tab' => 'test']);
682683
$this->crudPanel->setFieldLabel('test', 'my-test-label');
683684
$this->assertEquals('my-test-label', $this->crudPanel->fieldS()['test']['label']);
@@ -690,7 +691,6 @@ public function testItCanMakeAFieldFirst()
690691
$this->assertEquals(['test1', 'test2'], array_keys($this->crudPanel->fields()));
691692
$secondField->makeFirstField();
692693
$this->assertEquals(['test2', 'test1'], array_keys($this->crudPanel->fields()));
693-
694694
}
695695

696696
public function testItCanGetTheCurrentFields()
@@ -714,7 +714,7 @@ public function testItCanGetUploadFields()
714714
public function testItCanGetTheFieldTypeWithViewNamespace()
715715
{
716716
$this->crudPanel->addField(['name' => 'test', 'view_namespace' => 'test_namespace']);
717-
$this->assertEquals('test_namespace.text', $this->crudPanel->getFieldTypeWithNamespace($this->crudPanel->fields()['test']));
717+
$this->assertEquals('test_namespace.text', $this->crudPanel->getFieldTypeWithNamespace($this->crudPanel->fields()['test']));
718718
}
719719

720720
public function testItCanGetAllFieldNames()

tests/Unit/CrudPanel/CrudPanelMacroTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@
77
*/
88
class CrudPanelMacroTest extends BaseCrudPanelTest
99
{
10-
public function testItCanRegisterMacro()
11-
{
12-
$this->crudPanel::macro('validMacro',function() {
13-
return true;
14-
});
15-
16-
$this->assertTrue($this->crudPanel->validMacro());
17-
}
10+
public function testItCanRegisterMacro()
11+
{
12+
$this->crudPanel::macro('validMacro', function () {
13+
return true;
14+
});
15+
16+
$this->assertTrue($this->crudPanel->validMacro());
17+
}
1818

1919
public function testThrowsErrorIfMacroExists()
2020
{
21-
try {
22-
$this->crudPanel::macro('setModel',function() {
23-
return true;
24-
});
25-
} catch (\Throwable $e) {
26-
}
27-
$this->assertEquals(
21+
try {
22+
$this->crudPanel::macro('setModel', function () {
23+
return true;
24+
});
25+
} catch (\Throwable $e) {
26+
}
27+
$this->assertEquals(
2828
new \Symfony\Component\HttpKernel\Exception\HttpException(500, 'Cannot register \'setModel\' macro. \'setModel()\' already exists on Backpack\CRUD\app\Library\CrudPanel\CrudPanel'),
2929
$e
3030
);

tests/Unit/CrudPanel/CrudPanelTitlesAndHeadingsTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111
class CrudPanelTitlesAndHeadingsTest extends BaseDBCrudPanelTest
1212
{
13-
1413
public function testItCanSetAndGetTheTitleFromTheAction()
1514
{
1615
$this->crudPanel->setTitle('test', 'create');
@@ -73,7 +72,7 @@ public function testItCanSetAndGetTheTitle()
7372

7473
$this->crudPanel->setOperation('create');
7574
$this->crudPanel->setTitle('test');
76-
75+
7776
$this->assertEquals('test', $this->crudPanel->getTitle());
7877
$this->assertEquals($this->crudPanel->get('create.title'), $this->crudPanel->getTitle());
7978
}

tests81/Unit/CrudPanel/CrudPanelFieldsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testCheckReturnTypesForWhenInferingRelation()
1515
$this->crudPanel->setModel(\Backpack\CRUD\Tests81\Unit\Models\UserWithReturnTypes::class);
1616
$this->crudPanel->addField('isAnAttribute');
1717
$this->crudPanel->addField('isARelation');
18-
18+
1919
$this->assertEquals(false, $this->crudPanel->fields()['isAnAttribute']['entity']);
2020
$this->assertEquals(true, $this->crudPanel->fields()['isARelation']['entity']);
2121
}

tests81/Unit/Models/UserWithReturnTypes.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace Backpack\CRUD\Tests81\Unit\Models;
44

5-
use Backpack\CRUD\app\Models\Traits\CrudTrait;
6-
use Illuminate\Database\Eloquent\Model;
7-
85
class UserWithReturnTypes extends \Backpack\CRUD\Tests\Unit\Models\User
96
{
107
public function isAnAttribute(): \Illuminate\Database\Eloquent\Casts\Attribute
@@ -16,4 +13,4 @@ public function isARelation(): \Illuminate\Database\Eloquent\Relations\BelongsTo
1613
{
1714
return $this->bang();
1815
}
19-
}
16+
}

0 commit comments

Comments
 (0)