Skip to content

Commit a451b52

Browse files
committed
unit test fix
1 parent 5adff2e commit a451b52

20 files changed

+175
-345
lines changed

composer.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
"doctrine/dbal": "2.*"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "~6.0|~8.0",
2322
"laravel/laravel": ">=5.5",
24-
"symfony/css-selector": "~3.1",
2523
"fzaninotto/faker": "~1.4",
2624
"intervention/image": "~2.3",
27-
"laravel/browser-kit-testing": "^2.0"
25+
"laravel/browser-kit-testing": "^6.0"
2826
},
2927
"autoload": {
3028
"psr-4": {

phpunit.xml.dist

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="true"
11-
syntaxCheck="false"
1211
verbose="true"
1312
>
1413
<testsuites>

src/Form/Field/Map.php

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class Map extends Field
88
{
9+
protected $value = [
10+
'lat' => null,
11+
'lng' => null
12+
];
13+
914
/**
1015
* Column name.
1116
*

tests/FileUploadTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class FileUploadTest extends TestCase
88
{
9-
public function setUp()
9+
protected function setUp(): void
1010
{
1111
parent::setUp();
1212

@@ -16,7 +16,7 @@ public function setUp()
1616
public function testFileUploadPage()
1717
{
1818
$this->visit('admin/files/create')
19-
->see('Upload file')
19+
->see('Files')
2020
->seeInElement('h3[class=box-title]', 'Create')
2121
->seeElement('input[name=file1]')
2222
->seeElement('input[name=file2]')

tests/ImageUploadTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class ImageUploadTest extends TestCase
99
{
10-
public function setUp()
10+
protected function setUp(): void
1111
{
1212
parent::setUp();
1313

@@ -23,7 +23,7 @@ public function testDisableFilter()
2323
public function testImageUploadPage()
2424
{
2525
$this->visit('admin/images/create')
26-
->see('Upload image')
26+
->see('Images')
2727
->seeInElement('h3[class=box-title]', 'Create')
2828
->seeElement('input[name=image1]')
2929
->seeElement('input[name=image2]')
@@ -177,7 +177,7 @@ public function testUploadMultipleImage()
177177
$path = __DIR__.'/assets/test.jpg';
178178

179179
$file = new \Illuminate\Http\UploadedFile(
180-
$path, 'test.jpg', 'image/jpeg', filesize($path), null, true
180+
$path, 'test.jpg', 'image/jpeg', null, true
181181
);
182182

183183
$size = rand(10, 20);
@@ -213,7 +213,7 @@ public function testRemoveMultipleFiles()
213213
$path = __DIR__.'/assets/test.jpg';
214214

215215
$file = new \Illuminate\Http\UploadedFile(
216-
$path, 'test.jpg', 'image/jpeg', filesize($path), null, true
216+
$path, 'test.jpg', 'image/jpeg', null, true
217217
);
218218

219219
$size = rand(10, 20);

tests/IndexTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class IndexTest extends TestCase
66
{
7-
public function setUp()
7+
protected function setUp(): void
88
{
99
parent::setUp();
1010

tests/MenuTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class MenuTest extends TestCase
77
{
8-
public function setUp()
8+
protected function setUp(): void
99
{
1010
parent::setUp();
1111

tests/ModelTreeTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class ModelTreeTest extends TestCase
66
{
7-
public function setUp()
7+
protected function setUp(): void
88
{
99
parent::setUp();
1010
}

tests/OperationLogTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class OperationLogTest extends TestCase
77
{
8-
public function setUp()
8+
protected function setUp(): void
99
{
1010
parent::setUp();
1111

tests/PermissionsTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class PermissionsTest extends TestCase
88
{
9-
public function setUp()
9+
protected function setUp(): void
1010
{
1111
parent::setUp();
1212

tests/RolesTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class RolesTest extends TestCase
77
{
8-
public function setUp()
8+
protected function setUp(): void
99
{
1010
parent::setUp();
1111

tests/TestCase.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function createApplication()
3131
return $app;
3232
}
3333

34-
public function setUp()
34+
protected function setUp(): void
3535
{
3636
parent::setUp();
3737

@@ -65,9 +65,13 @@ public function setUp()
6565
require __DIR__.'/routes.php';
6666

6767
require __DIR__.'/seeds/factory.php';
68+
69+
// \Encore\Admin\Admin::$css = [];
70+
// \Encore\Admin\Admin::$js = [];
71+
// \Encore\Admin\Admin::$script = [];
6872
}
6973

70-
public function tearDown()
74+
protected function tearDown(): void
7175
{
7276
(new CreateAdminTables())->down();
7377

tests/UserFormTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class UserFormTest extends TestCase
77
{
8-
public function setUp()
8+
protected function setUp(): void
99
{
1010
parent::setUp();
1111

tests/UserGridTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class UserGridTest extends TestCase
88
{
9-
public function setUp()
9+
protected function setUp(): void
1010
{
1111
parent::setUp();
1212

@@ -16,7 +16,7 @@ public function setUp()
1616
public function testIndexPage()
1717
{
1818
$this->visit('admin/users')
19-
->see('All users')
19+
->see('Users')
2020
->seeInElement('tr th', 'Username')
2121
->seeInElement('tr th', 'Email')
2222
->seeInElement('tr th', 'Mobile')
@@ -66,7 +66,7 @@ public function testGridWithData()
6666
$this->seedsTable();
6767

6868
$this->visit('admin/users')
69-
->see('All users');
69+
->see('Users');
7070

7171
$this->assertCount(100, UserModel::all());
7272
$this->assertCount(100, ProfileModel::all());
@@ -77,7 +77,7 @@ public function testGridPagination()
7777
$this->seedsTable(65);
7878

7979
$this->visit('admin/users')
80-
->see('All users');
80+
->see('Users');
8181

8282
$this->visit('admin/users?page=2');
8383
$this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-edit]'));
@@ -114,7 +114,7 @@ public function testEqualFilter()
114114
$this->seedsTable(50);
115115

116116
$this->visit('admin/users')
117-
->see('All users');
117+
->see('Users');
118118

119119
$this->assertCount(50, UserModel::all());
120120
$this->assertCount(50, ProfileModel::all());
@@ -142,7 +142,7 @@ public function testLikeFilter()
142142
$this->seedsTable(50);
143143

144144
$this->visit('admin/users')
145-
->see('All users');
145+
->see('Users');
146146

147147
$this->assertCount(50, UserModel::all());
148148
$this->assertCount(50, ProfileModel::all());

tests/UserSettingTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class UserSettingTest extends TestCase
77
{
8-
public function setUp()
8+
protected function setUp(): void
99
{
1010
parent::setUp();
1111

tests/UsersTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class UsersTest extends TestCase
66
{
77
protected $user;
88

9-
public function setUp()
9+
protected function setUp(): void
1010
{
1111
parent::setUp();
1212

tests/controllers/FileController.php

+23-68
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,14 @@
22

33
namespace Tests\Controllers;
44

5-
use App\Http\Controllers\Controller;
6-
use Encore\Admin\Controllers\ModelForm;
7-
use Encore\Admin\Facades\Admin;
5+
use Encore\Admin\Controllers\AdminController;
86
use Encore\Admin\Form;
97
use Encore\Admin\Grid;
10-
use Encore\Admin\Layout\Content;
118
use Tests\Models\File;
129

13-
class FileController extends Controller
10+
class FileController extends AdminController
1411
{
15-
use ModelForm;
16-
17-
/**
18-
* Index interface.
19-
*
20-
* @return Content
21-
*/
22-
public function index()
23-
{
24-
return Admin::content(function (Content $content) {
25-
$content->header('header');
26-
$content->description('description');
27-
28-
$content->body($this->grid());
29-
});
30-
}
31-
32-
/**
33-
* Edit interface.
34-
*
35-
* @param $id
36-
*
37-
* @return Content
38-
*/
39-
public function edit($id)
40-
{
41-
return Admin::content(function (Content $content) use ($id) {
42-
$content->header('header');
43-
$content->description('description');
44-
45-
$content->body($this->form()->edit($id));
46-
});
47-
}
48-
49-
/**
50-
* Create interface.
51-
*
52-
* @return Content
53-
*/
54-
public function create()
55-
{
56-
return Admin::content(function (Content $content) {
57-
$content->header('Upload file');
58-
59-
$content->body($this->form());
60-
});
61-
}
12+
protected $title = 'Files';
6213

6314
/**
6415
* Make a grid builder.
@@ -67,12 +18,14 @@ public function create()
6718
*/
6819
protected function grid()
6920
{
70-
return Admin::grid(File::class, function (Grid $grid) {
71-
$grid->id('ID')->sortable();
21+
$grid = new Grid(new File());
22+
23+
$grid->id('ID')->sortable();
7224

73-
$grid->created_at();
74-
$grid->updated_at();
75-
});
25+
$grid->created_at();
26+
$grid->updated_at();
27+
28+
return $grid;
7629
}
7730

7831
/**
@@ -82,18 +35,20 @@ protected function grid()
8235
*/
8336
protected function form()
8437
{
85-
return Admin::form(File::class, function (Form $form) {
86-
$form->display('id', 'ID');
38+
$form = new Form(new File());
39+
40+
$form->display('id', 'ID');
41+
42+
$form->file('file1');
43+
$form->file('file2');
44+
$form->file('file3');
45+
$form->file('file4');
46+
$form->file('file5');
47+
$form->file('file6');
8748

88-
$form->file('file1');
89-
$form->file('file2');
90-
$form->file('file3');
91-
$form->file('file4');
92-
$form->file('file5');
93-
$form->file('file6');
49+
$form->display('created_at', 'Created At');
50+
$form->display('updated_at', 'Updated At');
9451

95-
$form->display('created_at', 'Created At');
96-
$form->display('updated_at', 'Updated At');
97-
});
52+
return $form;
9853
}
9954
}

0 commit comments

Comments
 (0)