jqh 5 years ago
parent
commit
2c65aade1c
83 changed files with 117 additions and 3018 deletions
  1. 41 8
      src/Console/Development/LinkCommand.php
  2. 0 0
      tests/.ide-helper.php
  3. 0 0
      tests/Browser/AuthTest.php
  4. 0 0
      tests/Browser/Components/Component.php
  5. 0 0
      tests/Browser/Components/Form/Field/MultipleSelect2.php
  6. 0 0
      tests/Browser/Components/Form/Field/Select2.php
  7. 0 0
      tests/Browser/Components/Form/Field/Tree.php
  8. 0 0
      tests/Browser/Components/Form/MenuCreationForm.php
  9. 0 0
      tests/Browser/Components/Form/MenuEditForm.php
  10. 0 0
      tests/Browser/IndexTest.php
  11. 0 0
      tests/Browser/InstallTest.php
  12. 0 0
      tests/Browser/MenuTest.php
  13. 0 0
      tests/Browser/Pages/MenuEditPage.php
  14. 0 0
      tests/Browser/Pages/MenuPage.php
  15. 0 0
      tests/Browser/Pages/Page.php
  16. 0 0
      tests/Browser/console/.gitignore
  17. 0 0
      tests/Browser/screenshots/.gitignore
  18. 0 0
      tests/BrowserExtension.php
  19. 0 0
      tests/ChromeProcess.php
  20. 1 1
      tests/Controllers/DropdownController.php
  21. 2 2
      tests/Controllers/ReportController.php
  22. 3 3
      tests/Controllers/UserController.php
  23. 9 11
      tests/CreatesApplication.php
  24. 39 9
      tests/DuskTestCase.php
  25. 0 67
      tests/Feature/AuthTest.php
  26. 0 41
      tests/Feature/CombineGridTest.php
  27. 0 51
      tests/Feature/IndexTest.php
  28. 0 38
      tests/Feature/InstallTest.php
  29. 0 67
      tests/Feature/MenuTest.php
  30. 0 82
      tests/Feature/OperationLogTest.php
  31. 0 137
      tests/Feature/PermissionsTest.php
  32. 0 104
      tests/Feature/RolesTest.php
  33. 0 107
      tests/Feature/SectionTest.php
  34. 0 65
      tests/Feature/TranslationTest.php
  35. 0 199
      tests/Feature/UserFormTest.php
  36. 0 225
      tests/Feature/UserGridTest.php
  37. 0 81
      tests/Feature/UserSettingTest.php
  38. 0 43
      tests/Feature/UserShowTest.php
  39. 0 89
      tests/Feature/UsersTest.php
  40. 0 0
      tests/InteractsWithDatabase.php
  41. 1 1
      tests/Models/File.php
  42. 1 1
      tests/Models/Image.php
  43. 1 1
      tests/Models/MultipleImage.php
  44. 1 1
      tests/Models/Profile.php
  45. 1 1
      tests/Models/Tag.php
  46. 1 1
      tests/Models/Tree.php
  47. 1 1
      tests/Models/User.php
  48. 1 1
      tests/Repositories/Report.php
  49. 2 2
      tests/Repositories/User.php
  50. 2 30
      tests/TestCase.php
  51. 0 66
      tests/artisan
  52. 0 86
      tests/browser-tests/Controllers/DropdownController.php
  53. 0 62
      tests/browser-tests/Controllers/ReportController.php
  54. 0 211
      tests/browser-tests/Controllers/UserController.php
  55. 0 113
      tests/browser-tests/CreatesApplication.php
  56. 0 106
      tests/browser-tests/DuskTestCase.php
  57. 0 10
      tests/browser-tests/Models/File.php
  58. 0 10
      tests/browser-tests/Models/Image.php
  59. 0 22
      tests/browser-tests/Models/MultipleImage.php
  60. 0 15
      tests/browser-tests/Models/Profile.php
  61. 0 15
      tests/browser-tests/Models/Tag.php
  62. 0 28
      tests/browser-tests/Models/Tree.php
  63. 0 40
      tests/browser-tests/Models/User.php
  64. 0 61
      tests/browser-tests/Repositories/Report.php
  65. 0 11
      tests/browser-tests/Repositories/User.php
  66. 0 7
      tests/browser-tests/TestCase.php
  67. BIN
      tests/browser-tests/resources/assets/test.jpg
  68. 0 381
      tests/browser-tests/resources/config/admin.php
  69. 0 95
      tests/browser-tests/resources/config/filesystems.php
  70. BIN
      tests/browser-tests/resources/drivers/chromedriver-linux
  71. BIN
      tests/browser-tests/resources/drivers/chromedriver-mac
  72. BIN
      tests/browser-tests/resources/drivers/chromedriver-win.exe
  73. 0 15
      tests/browser-tests/resources/lang/en/global.php
  74. 0 16
      tests/browser-tests/resources/lang/en/user.php
  75. 0 98
      tests/browser-tests/resources/migrations/2016_11_22_093148_create_test_tables.php
  76. 0 21
      tests/browser-tests/resources/seeds/UserTableSeeder.php
  77. 0 36
      tests/browser-tests/resources/seeds/factory.php
  78. 0 1
      tests/browser-tests/resources/views/test.blade.php
  79. 0 10
      tests/browser-tests/routes.php
  80. 0 0
      tests/helpers.php
  81. 3 3
      tests/resources/seeds/UserTableSeeder.php
  82. 3 3
      tests/resources/seeds/factory.php
  83. 4 6
      tests/routes.php

+ 41 - 8
src/Console/Development/LinkCommand.php

@@ -3,6 +3,7 @@
 namespace Dcat\Admin\Console\Development;
 
 use Dcat\Admin\Admin;
+use Illuminate\Filesystem\Filesystem;
 use Illuminate\Console\Command;
 
 class LinkCommand extends Command
@@ -21,30 +22,62 @@ class LinkCommand extends Command
      */
     public function handle()
     {
-        $this->linkAssets();
-        $this->linkTests();
+        $files = $this->laravel->make('files');
+
+        $this->linkAssets($files);
+        $this->linkTests($files);
     }
 
-    protected function linkTests()
+    /**
+     * @param Filesystem $files
+     *
+     * @return void
+     */
+    protected function linkTests($files)
     {
+        $target = base_path('tests');
+        $testsPath = realpath(__DIR__.'/../../../tests');
+
+        if (is_dir($testsPath)) {
+            $result = $this->ask("The [{$testsPath}] directory already exists, are you sure to delete it? [yes/no]");
+
+            if (strtolower($testsPath) !== 'yes') {
+                return;
+            }
+
+            $files->deleteDirectory($testsPath);
+        }
+
+        $files->link(
+            $testsPath, $target
+        );
+
+        $this->info("The [$testsPath] directory has been linked.");
     }
 
-    protected function linkAssets()
+    /**
+     * @param Filesystem $files
+     *
+     * @return void
+     */
+    protected function linkAssets($files)
     {
         $basePath = Admin::asset()->getRealPath('@admin');
         $publicPath = public_path($basePath);
 
         if (! is_dir($publicPath.'/..')) {
-            app('files')->makeDirectory($publicPath.'/..', 0755, true, true);
+            $files->makeDirectory($publicPath.'/..', 0755, true, true);
         }
 
-        if (file_exists(public_path($publicPath))) {
-            return $this->error("The \"{$basePath}\" directory already exists.");
+        if (file_exists($publicPath)) {
+            $this->warn("The [public/{$basePath}] directory already exists.");
+
+            return;
         }
 
         $distPath = realpath(__DIR__ . '/../../../resources/dist');
 
-        $this->laravel->make('files')->link(
+        $files->link(
             $distPath, $publicPath
         );
 

+ 0 - 0
tests/browser-tests/.ide-helper.php → tests/.ide-helper.php


+ 0 - 0
tests/browser-tests/Browser/AuthTest.php → tests/Browser/AuthTest.php


+ 0 - 0
tests/browser-tests/Browser/Components/Component.php → tests/Browser/Components/Component.php


+ 0 - 0
tests/browser-tests/Browser/Components/Form/Field/MultipleSelect2.php → tests/Browser/Components/Form/Field/MultipleSelect2.php


+ 0 - 0
tests/browser-tests/Browser/Components/Form/Field/Select2.php → tests/Browser/Components/Form/Field/Select2.php


+ 0 - 0
tests/browser-tests/Browser/Components/Form/Field/Tree.php → tests/Browser/Components/Form/Field/Tree.php


+ 0 - 0
tests/browser-tests/Browser/Components/Form/MenuCreationForm.php → tests/Browser/Components/Form/MenuCreationForm.php


+ 0 - 0
tests/browser-tests/Browser/Components/Form/MenuEditForm.php → tests/Browser/Components/Form/MenuEditForm.php


+ 0 - 0
tests/browser-tests/Browser/IndexTest.php → tests/Browser/IndexTest.php


+ 0 - 0
tests/browser-tests/Browser/InstallTest.php → tests/Browser/InstallTest.php


+ 0 - 0
tests/browser-tests/Browser/MenuTest.php → tests/Browser/MenuTest.php


+ 0 - 0
tests/browser-tests/Browser/Pages/MenuEditPage.php → tests/Browser/Pages/MenuEditPage.php


+ 0 - 0
tests/browser-tests/Browser/Pages/MenuPage.php → tests/Browser/Pages/MenuPage.php


+ 0 - 0
tests/browser-tests/Browser/Pages/Page.php → tests/Browser/Pages/Page.php


+ 0 - 0
tests/browser-tests/Browser/console/.gitignore → tests/Browser/console/.gitignore


+ 0 - 0
tests/browser-tests/Browser/screenshots/.gitignore → tests/Browser/screenshots/.gitignore


+ 0 - 0
tests/browser-tests/BrowserExtension.php → tests/BrowserExtension.php


+ 0 - 0
tests/browser-tests/ChromeProcess.php → tests/ChromeProcess.php


+ 1 - 1
tests/Controllers/DropdownController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Controllers;
+namespace Tests\Controllers;
 
 use Dcat\Admin\Admin;
 use Dcat\Admin\Layout\Content;

+ 2 - 2
tests/Controllers/ReportController.php

@@ -1,11 +1,11 @@
 <?php
 
-namespace Dcat\Admin\Tests\Controllers;
+namespace Tests\Controllers;
 
 use App\Http\Controllers\Controller;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Layout\Content;
-use Dcat\Admin\Tests\Repositories\Report;
+use Tests\Repositories\Report;
 
 class ReportController extends Controller
 {

+ 3 - 3
tests/Controllers/UserController.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Controllers;
+namespace Tests\Controllers;
 
 use App\Http\Controllers\Controller;
 use Dcat\Admin\Controllers\HasResourceActions;
@@ -8,8 +8,8 @@ use Dcat\Admin\Form;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Layout\Content;
 use Dcat\Admin\Show;
-use Dcat\Admin\Tests\Models\Tag;
-use Dcat\Admin\Tests\Repositories\User;
+use Tests\Models\Tag;
+use Tests\Repositories\User;
 
 class UserController extends Controller
 {

+ 9 - 11
tests/CreatesApplication.php

@@ -1,11 +1,12 @@
 <?php
 
-namespace Dcat\Admin\Tests;
+namespace Tests;
 
 use Dcat\Admin\Models\Administrator;
-use Illuminate\Filesystem\Filesystem;
 use Illuminate\Contracts\Console\Kernel;
+use Illuminate\Filesystem\Filesystem;
 use Illuminate\Support\Arr;
+use Illuminate\Support\Facades\Artisan;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Schema;
 
@@ -18,17 +19,14 @@ trait CreatesApplication
      */
     public function createApplication()
     {
-        $app = require __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
+        $app = require __DIR__.'/../bootstrap/app.php';
 
         $app->make(Kernel::class)->bootstrap();
 
-        $app->register('Dcat\Admin\AdminServiceProvider');
-
-        $app->make('config')->set('app.locale', 'en');
-
         return $app;
     }
 
+
     protected function boot()
     {
         $this->config();
@@ -45,15 +43,13 @@ trait CreatesApplication
             require $routes;
         }
 
+        require __DIR__.'/helpers.php';
+
         require __DIR__.'/routes.php';
 
         require __DIR__.'/resources/seeds/factory.php';
 
         view()->addNamespace('admin-tests', __DIR__.'/resources/views');
-
-        if ($this->login) {
-            $this->be($this->getUser(), 'admin');
-        }
     }
 
     protected function destory()
@@ -64,6 +60,8 @@ trait CreatesApplication
 
         DB::select("delete from `migrations` where `migration` = '2016_01_04_173148_create_admin_tables'");
         DB::select("delete from `migrations` where `migration` = '2016_11_22_093148_create_test_tables'");
+
+        Artisan::call('migrate:rollback');
     }
 
     /**

+ 39 - 9
tests/DuskTestCase.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests;
+namespace Tests;
 
 use Dcat\Admin\Models\Administrator;
 use Facebook\WebDriver\Chrome\ChromeOptions;
@@ -11,13 +11,16 @@ use Laravel\Dusk\TestCase as BaseTestCase;
 
 abstract class DuskTestCase extends BaseTestCase
 {
-    use CreatesApplication;
+    use CreatesApplication, BrowserExtension, InteractsWithDatabase;
 
     /**
      * @var Administrator
      */
     protected $user;
 
+    /**
+     * @var bool
+     */
     protected $login = true;
 
     public function login(Browser $browser)
@@ -29,10 +32,11 @@ abstract class DuskTestCase extends BaseTestCase
     {
         parent::setUp();
 
+        $this->extendBrowser();
+
         $this->boot();
     }
 
-
     public function tearDown(): void
     {
         $this->destory();
@@ -44,7 +48,6 @@ abstract class DuskTestCase extends BaseTestCase
      * Prepare for Dusk test execution.
      *
      * @beforeClass
-     *
      * @return void
      */
     public static function prepare()
@@ -52,6 +55,22 @@ abstract class DuskTestCase extends BaseTestCase
         static::startChromeDriver();
     }
 
+    /**
+     * @param \Facebook\WebDriver\Remote\RemoteWebDriver $driver
+     *
+     * @return \Laravel\Dusk\Browser
+     */
+    protected function newBrowser($driver)
+    {
+        $browser = parent::newBrowser($driver)->resize(1566, 1080);
+
+        if ($this->login) {
+            $this->login($browser);
+        }
+
+        return $browser;
+    }
+
     /**
      * Create the RemoteWebDriver instance.
      *
@@ -59,18 +78,29 @@ abstract class DuskTestCase extends BaseTestCase
      */
     protected function driver()
     {
-        $options = (new ChromeOptions())->addArguments([
+        $options = (new ChromeOptions)->addArguments([
             '--disable-gpu',
             '--headless',
             '--window-size=1920,1080',
         ]);
 
         return RemoteWebDriver::create(
-            'http://localhost:9515',
-            DesiredCapabilities::chrome()->setCapability(
-                ChromeOptions::CAPABILITY,
-                $options
+            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
+                ChromeOptions::CAPABILITY_W3C, $options
             )
         );
     }
+
+    /**
+     * Build the process to run the Chromedriver.
+     *
+     * @param  array  $arguments
+     * @return \Symfony\Component\Process\Process
+     *
+     * @throws \RuntimeException
+     */
+    protected static function buildChromeProcess(array $arguments = [])
+    {
+        return (new ChromeProcess(static::$chromeDriver))->toProcess($arguments);
+    }
 }

+ 0 - 67
tests/Feature/AuthTest.php

@@ -1,67 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group auth
- */
-class AuthTest extends TestCase
-{
-    protected $login = false;
-
-    public function testLoginPage()
-    {
-        $this->visit('admin/auth/login')
-            ->see('Login');
-    }
-
-    public function testVisitWithoutLogin()
-    {
-        $this->visit('admin')
-            ->dontSeeIsAuthenticated('admin')
-            ->seePageIs('admin/auth/login');
-    }
-
-    public function testLogin()
-    {
-        $credentials = ['username' => 'admin', 'password' => 'admin'];
-
-        $this->visit('admin/auth/login')
-            ->seePageIs('admin/auth/login')
-            ->see('Login')
-            ->submitForm('Login', $credentials)
-            ->see('dashboard')
-            ->seeCredentials($credentials, 'admin')
-            ->seeIsAuthenticated('admin')
-            ->seePageIs('admin')
-            ->see('Dashboard')
-            ->see('Description...')
-
-            ->see('Environment')
-            ->see('PHP version')
-            ->see('Laravel version')
-
-            ->see('Extensions')
-
-            ->see('Dependencies')
-            ->see('php')
-            ->see('laravel/framework');
-
-        $this
-            ->see('<span>Admin</span>')
-            ->see('<span>Users</span>')
-            ->see('<span>Roles</span>')
-            ->see('<span>Permission</span>')
-            ->see('<span>Operation log</span>')
-            ->see('<span>Menu</span>');
-    }
-
-    public function testLogout()
-    {
-        $this->visit('admin/auth/logout')
-            ->seePageIs('admin/auth/login')
-            ->dontSeeIsAuthenticated('admin');
-    }
-}

+ 0 - 41
tests/Feature/CombineGridTest.php

@@ -1,41 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group combine-grid
- */
-class CombineGridTest extends TestCase
-{
-    public function test()
-    {
-        $this->visit('admin/tests/report')
-            ->assertResponseStatus(200)
-            ->see('报表')
-            ->see('avgMonthCost')
-            ->see('avgVist')
-            ->see('avgCost')
-            ->see('top');
-
-        // Column::help
-        $this->assertCount(1, $this->crawler()->filter('th a[class*=fa-question-circle]'));
-
-        $this->assertCount(2, $this->crawler()->filter('thead tr'));
-
-        $firstTr = $this->crawler()->filter('thead tr')->first()->filter('th');
-
-        // cost
-        $this->assertSame('2', (string) $firstTr->eq(2)->attr('rowspan'));
-
-        // avgCost
-        $this->assertSame('3', (string) $firstTr->eq(3)->attr('colspan'));
-
-        // avgVist
-        $this->assertSame('3', (string) $firstTr->eq(4)->attr('colspan'));
-
-        // top
-        $this->assertSame('3', (string) $firstTr->eq(5)->attr('colspan'));
-    }
-}

+ 0 - 51
tests/Feature/IndexTest.php

@@ -1,51 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group index
- */
-class IndexTest extends TestCase
-{
-    public function testIndex()
-    {
-        $this->visit('admin/')
-            ->see('Dashboard')
-            ->see('Description...')
-
-            ->see('Environment')
-            ->see('PHP version')
-            ->see('Laravel version')
-
-            ->see('Extensions')
-
-            ->see('Dependencies')
-            ->see('php')
-            ->see('laravel/framework');
-    }
-
-    public function testClickMenu()
-    {
-        $this->visit('admin/')
-            ->click('Users')
-            ->seePageis('admin/auth/users')
-            ->click('Roles')
-            ->seePageis('admin/auth/roles')
-            ->click('Permission')
-            ->seePageis('admin/auth/permissions')
-            ->click('Menu')
-            ->seePageis('admin/auth/menu')
-            ->click('Operation log')
-            ->seePageis('admin/auth/logs')
-            ->click('Extensions')
-            ->seePageis('admin/helpers/extensions')
-            ->click('Scaffold')
-            ->seePageis('admin/helpers/scaffold')
-            ->click('Routes')
-            ->seePageis('admin/helpers/routes')
-            ->click('Icons')
-            ->seePageis('admin/helpers/icons');
-    }
-}

+ 0 - 38
tests/Feature/InstallTest.php

@@ -1,38 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group install
- */
-class InstallTest extends TestCase
-{
-    public function testInstalledDirectories()
-    {
-        $this->assertFileExists(admin_path());
-
-        $this->assertFileExists(admin_path('Controllers'));
-
-        $this->assertFileExists(admin_path('routes.php'));
-
-        $this->assertFileExists(admin_path('bootstrap.php'));
-
-        $this->assertFileExists(admin_path('Controllers/HomeController.php'));
-
-        $this->assertFileExists(admin_path('Controllers/AuthController.php'));
-
-        $this->assertFileExists(config_path('admin.php'));
-
-        $this->assertFileExists(public_path('vendor/dcat-admin'));
-
-        $this->assertFileExists(database_path('migrations/2016_01_04_173148_create_admin_tables.php'));
-
-        $this->assertFileExists(resource_path('lang/en/admin.php'));
-
-        $this->assertFileExists(resource_path('lang/zh-CN/admin.php'));
-
-        $this->assertFileExists(resource_path('lang/zh-CN/global.php'));
-    }
-}

+ 0 - 67
tests/Feature/MenuTest.php

@@ -1,67 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Models\Menu;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group menu
- */
-class MenuTest extends TestCase
-{
-    public function testMenuIndex()
-    {
-        $this->visit('admin/auth/menu')
-            ->see('Menu')
-            ->see('Index')
-            ->see('Auth')
-            ->see('Users')
-            ->see('Roles')
-            ->see('Permission')
-            ->see('Menu')
-            ->see('Operation log')
-            ->see('Helpers')
-            ->see('Extensions')
-            ->see('Scaffold')
-            ->see('Routes');
-    }
-
-    public function testAddMenu()
-    {
-        $item = ['parent_id' => '0', 'title' => 'Test', 'uri' => 'test', 'icon' => 'fa-user'];
-
-        $this->visit('admin/auth/menu')
-            ->seePageIs('admin/auth/menu')
-            ->see('Menu')
-            ->submitForm('Submit', $item)
-            ->seePageIs('admin/auth/menu')
-            ->seeInDatabase(config('admin.database.menu_table'), $item)
-            ->assertEquals(8, Menu::count());
-    }
-
-    public function testDeleteMenu()
-    {
-        $this->delete('admin/auth/menu/8')
-            ->assertEquals(7, Menu::count());
-    }
-
-    public function testEditMenu()
-    {
-        $this->visit('admin/auth/menu/1/edit')
-            ->see('Menu')
-            ->submitForm('Submit', ['title' => 'blablabla'])
-            ->seePageIs('admin/auth/menu')
-            ->seeInDatabase(config('admin.database.menu_table'), ['title' => 'blablabla'])
-            ->assertEquals(7, Menu::count());
-    }
-
-    public function testEditMenuParent()
-    {
-        $this->expectException(\Laravel\BrowserKitTesting\HttpException::class);
-
-        $this->visit('admin/auth/menu/5/edit')
-            ->see('Menu')
-            ->submitForm('Submit', ['parent_id' => 5]);
-    }
-}

+ 0 - 82
tests/Feature/OperationLogTest.php

@@ -1,82 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Models\OperationLog;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group log
- */
-class OperationLogTest extends TestCase
-{
-    public function testOperationLogIndex()
-    {
-        $this->visit('admin/auth/logs')
-            ->see('Operation log')
-            ->see('List')
-            ->see('GET')
-            ->see('admin/auth/logs');
-    }
-
-    public function testGenerateLogs()
-    {
-        $table = config('admin.database.operation_log_table');
-
-        $this->visit('admin/auth/menu')
-            ->seePageIs('admin/auth/menu')
-            ->visit('admin/auth/users')
-            ->seePageIs('admin/auth/users')
-            ->visit('admin/auth/permissions')
-            ->seePageIs('admin/auth/permissions')
-            ->visit('admin/auth/roles')
-            ->seePageIs('admin/auth/roles')
-            ->visit('admin/auth/logs')
-            ->seePageIs('admin/auth/logs')
-            ->seeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET']);
-
-        $this->assertSame(4, OperationLog::count());
-    }
-
-    public function testDeleteLogs()
-    {
-        $table = config('admin.database.operation_log_table');
-
-        $this->visit('admin/auth/logs')
-            ->seePageIs('admin/auth/logs')
-            ->assertEquals(0, OperationLog::count());
-
-        $this->visit('admin/auth/users');
-
-        $this->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET']);
-
-        $this->delete('admin/auth/logs/1')
-            ->assertEquals(0, OperationLog::count());
-    }
-
-    public function testDeleteMultipleLogs()
-    {
-        $table = config('admin.database.operation_log_table');
-
-        $this->visit('admin/auth/menu')
-            ->visit('admin/auth/users')
-            ->visit('admin/auth/permissions')
-            ->visit('admin/auth/roles')
-            ->seeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
-            ->seeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET'])
-            ->assertEquals(4, OperationLog::count());
-
-        $this->delete('admin/auth/logs/1,2,3,4')
-            ->notSeeInDatabase($table, ['path' => 'admin/auth/menu', 'method' => 'GET'])
-            ->notSeeInDatabase($table, ['path' => 'admin/auth/users', 'method' => 'GET'])
-            ->notSeeInDatabase($table, ['path' => 'admin/auth/permissions', 'method' => 'GET'])
-            ->notSeeInDatabase($table, ['path' => 'admin/auth/roles', 'method' => 'GET'])
-
-            ->assertEquals(0, OperationLog::count());
-    }
-}

+ 0 - 137
tests/Feature/PermissionsTest.php

@@ -1,137 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Models\Administrator;
-use Dcat\Admin\Models\Permission;
-use Dcat\Admin\Models\Role;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group permissions
- */
-class PermissionsTest extends TestCase
-{
-    public function testPermissionsIndex()
-    {
-        $this->assertTrue(Administrator::first()->isAdministrator());
-
-        $this->visit('admin/auth/permissions')
-            ->see('Permissions');
-    }
-
-    public function testAddAndDeletePermissions()
-    {
-        $this->visit('admin/auth/permissions/create')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => ['users/1/edit'], 'http_method' => ['GET']])
-            ->seePageIs('admin/auth/permissions')
-            ->visit('admin/auth/permissions/create')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => ['users/1'], 'http_method' => ['DELETE']])
-            ->seePageIs('admin/auth/permissions')
-            ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => 'users/1/edit', 'http_method' => 'GET'])
-            ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-delete', 'name' => 'Can delete', 'http_path' => 'users/1', 'http_method' => 'DELETE'])
-            ->assertEquals(8, Permission::count());
-
-        $this->assertTrue(Administrator::first()->can('can-edit'));
-        $this->assertTrue(Administrator::first()->can('can-delete'));
-
-        $this->delete('admin/auth/permissions/7')
-            ->assertEquals(7, Permission::count());
-
-        $this->delete('admin/auth/permissions/8')
-            ->assertEquals(6, Permission::count());
-    }
-
-    public function testAddPermissionToRole()
-    {
-        $this->visit('admin/auth/permissions/create')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-create', 'name' => 'Can Create', 'http_path' => ['users/create'], 'http_method' => ['GET']])
-            ->seePageIs('admin/auth/permissions');
-
-        $this->assertSame(7, Permission::count());
-
-        $this->visit('admin/auth/roles/1/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['permissions' => 1])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.role_permissions_table'), ['role_id' => 1, 'permission_id' => 1]);
-    }
-
-    public function testPermissionThroughRole()
-    {
-        $user = [
-            'username'              => 'Test',
-            'name'                  => 'Name',
-            'password'              => '123456',
-            'password_confirmation' => '123456',
-        ];
-
-        // 1.add a user
-        $this->visit('admin/auth/users/create')
-            ->see('Create')
-            ->submitForm('Submit', $user)
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
-
-        $this->assertFalse(Administrator::find(2)->isAdministrator());
-
-        // 2.add a role
-        $this->visit('admin/auth/roles/create')
-            ->see('Roles')
-            ->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
-            ->assertEquals(2, Role::count());
-
-        $this->assertFalse(Administrator::find(2)->isRole('developer'));
-
-        // 3.assign role to user
-        $this->visit('admin/auth/users/2/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['roles' => [2]])
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 2]);
-
-        $this->assertTrue(Administrator::find(2)->isRole('developer'));
-
-        //  4.add a permission
-        $this->visit('admin/auth/permissions/create')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-remove', 'name' => 'Can Remove', 'http_path' => ['users/*'], 'http_method' => ['DELETE']])
-            ->seePageIs('admin/auth/permissions');
-
-        $this->assertSame(7, Permission::count());
-
-        $this->assertTrue(Administrator::find(2)->cannot('can-remove'));
-
-        // 5.assign permission to role
-        $this->visit('admin/auth/roles/2/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['permissions' => 7])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.role_permissions_table'), ['role_id' => 2, 'permission_id' => 7]);
-
-        $this->assertTrue(Administrator::find(2)->can('can-remove'));
-    }
-
-    public function testEditPermission()
-    {
-        $this->visit('admin/auth/permissions/create')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-edit', 'name' => 'Can edit', 'http_path' => ['users/1/edit'], 'http_method' => ['GET']])
-            ->seePageIs('admin/auth/permissions')
-            ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-edit'])
-            ->seeInDatabase(config('admin.database.permissions_table'), ['name' => 'Can edit'])
-            ->assertEquals(7, Permission::count());
-
-        $this->visit('admin/auth/permissions/1/edit')
-            ->see('Permissions')
-            ->submitForm('Submit', ['slug' => 'can-delete'])
-            ->seePageIs('admin/auth/permissions')
-            ->seeInDatabase(config('admin.database.permissions_table'), ['slug' => 'can-delete'])
-            ->assertEquals(7, Permission::count());
-    }
-}

+ 0 - 104
tests/Feature/RolesTest.php

@@ -1,104 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Models\Administrator;
-use Dcat\Admin\Models\Role;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group role
- */
-class RolesTest extends TestCase
-{
-    public function testRolesIndex()
-    {
-        $this->visit('admin/auth/roles')
-            ->see('Roles')
-            ->see('administrator');
-    }
-
-    public function testAddRole()
-    {
-        $this->visit('admin/auth/roles/create')
-            ->see('Roles')
-            ->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
-            ->assertEquals(2, Role::count());
-    }
-
-    public function testAddRoleToUser()
-    {
-        $user = [
-            'username'              => 'Test',
-            'name'                  => 'Name',
-            'password'              => '123456',
-            'password_confirmation' => '123456',
-
-        ];
-
-        $this->visit('admin/auth/users/create')
-            ->see('Create')
-            ->submitForm('Submit', $user)
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.users_table'), ['username' => 'Test']);
-
-        $this->assertSame(1, Role::count());
-
-        $this->visit('admin/auth/roles/create')
-            ->see('Roles')
-            ->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
-            ->assertEquals(2, Role::count());
-
-        $this->assertFalse(Administrator::find(2)->isRole('developer'));
-
-        $this->visit('admin/auth/users/2/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['roles' => [2]])
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 2]);
-
-        $this->assertTrue(Administrator::find(2)->isRole('developer'));
-
-        $this->assertFalse(Administrator::find(2)->inRoles(['editor', 'operator']));
-        $this->assertTrue(Administrator::find(2)->inRoles(['developer', 'operator', 'editor']));
-    }
-
-    public function testDeleteRole()
-    {
-        $this->assertSame(1, Role::count());
-
-        $this->visit('admin/auth/roles/create')
-            ->see('Roles')
-            ->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...']);
-//            ->assertEquals(2, Role::count());
-
-        $this->delete('admin/auth/roles/2');
-        $this->assertSame(1, Role::count());
-
-//        $this->delete('admin/auth/roles/1');
-//        $this->assertEquals(0, Role::count());
-    }
-
-    public function testEditRole()
-    {
-        $this->visit('admin/auth/roles/create')
-            ->see('Roles')
-            ->submitForm('Submit', ['slug' => 'developer', 'name' => 'Developer...'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['slug' => 'developer', 'name' => 'Developer...'])
-            ->assertEquals(2, Role::count());
-
-        $this->visit('admin/auth/roles/2/edit')
-            ->see('Roles')
-            ->submitForm('Submit', ['name' => 'blablabla'])
-            ->seePageIs('admin/auth/roles')
-            ->seeInDatabase(config('admin.database.roles_table'), ['name' => 'blablabla'])
-            ->assertEquals(2, Role::count());
-    }
-}

+ 0 - 107
tests/Feature/SectionTest.php

@@ -1,107 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-class SectionTest extends TestCase
-{
-    protected $login = false;
-
-    public function testInjectValues()
-    {
-        // view
-        admin_inject_section('key1', view('admin-tests::test'));
-
-        $this->assertSame(admin_section('key1'), '<h1>Hello world</h1>');
-
-        // string
-        admin_inject_section('key2', 'test');
-
-        $this->assertSame(admin_section('key2'), 'test');
-
-        // callable
-        admin_inject_section('key3', function () {
-            return view('admin-tests::test');
-        });
-
-        $this->assertSame(admin_section('key3'), '<h1>Hello world</h1>');
-    }
-
-    public function testOptions()
-    {
-        admin_inject_section('key1', 'value1');
-
-        admin_inject_section('key1', function ($options) {
-            return "previous:{$options->previous},name:{$options->name},age:{$options->age}";
-        }, false);
-
-        $this->assertSame(
-            admin_section('key1', null, ['name' => 'Mike', 'age' => 18]),
-            'previous:value1,name:Mike,age:18'
-        );
-    }
-
-    public function testAppend()
-    {
-        // 1 append
-        admin_inject_section('key1', 'test1,');
-        admin_inject_section('key1', 'test2,');
-        admin_inject_section('key1', 'test3,');
-
-        $this->assertSame(admin_section('key1'), 'test1,test2,test3,');
-
-        // 2 overwrite
-        admin_inject_section('key2', 'test1,');
-        admin_inject_section('key2', 'test2,', false);
-
-        $this->assertSame(admin_section('key2'), 'test2,');
-
-        admin_inject_section('key2', 'test3,', false);
-
-        $this->assertSame(admin_section('key2'), 'test3,');
-
-        // 3 overwrite
-        admin_inject_section('key3', 'test1,');
-        admin_inject_section('key3', 'test2,', false);
-        admin_inject_section('key3', function ($options) {
-            return $options->previous.'test3,';
-        }, false);
-        admin_inject_section('key3', function ($options) {
-            return $options->previous.'test4,';
-        }, false);
-
-        $this->assertSame(admin_section('key3'), 'test2,test3,test4,');
-    }
-
-    public function testSort()
-    {
-        // 值越大排序越靠前
-        admin_inject_section('key1', '4,', true, -100);
-        admin_inject_section('key1', '2,', true, 2);
-        admin_inject_section('key1', '1,', true, 3);
-        admin_inject_section('key1', '3,', true, 1);
-
-        $this->assertSame(admin_section('key1'), '1,2,3,4,');
-    }
-
-    public function testInjectDefaultSection()
-    {
-        // step1
-        admin_inject_default_section('key', 'Hello');
-
-        $this->assertSame(admin_section('key'), 'Hello');
-
-        // step2
-        admin_inject_default_section('key', function ($options) {
-            return 'Hello '.$options->var1;
-        });
-
-        $this->assertSame(admin_section('key', null, ['var1' => 'world']), 'Hello world');
-
-        // step3
-        admin_inject_section('key', '');
-
-        $this->assertSame(admin_section('key'), '');
-    }
-}

+ 0 - 65
tests/Feature/TranslationTest.php

@@ -1,65 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-use Illuminate\Translation\FileLoader;
-use Illuminate\Translation\Translator;
-
-/**
- * @group trans
- */
-class TranslationTest extends TestCase
-{
-    public function testTransField()
-    {
-        $this->visit('admin/tests/users')
-            ->see('Post code');
-
-        $this->registerTranslator();
-
-        $this->assertSame('user', admin_controller_slug());
-
-        $this->assertSame(admin_trans_field('username'), '用户名');
-        $this->assertSame(admin_trans_field('profile.postcode'), '邮政编码');
-
-        $this->assertSame(admin_trans_field('value'), 'value');
-        $this->assertSame(admin_trans_field('profile.value'), 'value');
-    }
-
-    public function testTransLabel()
-    {
-        $this->visit('admin/tests/users');
-
-        $this->registerTranslator();
-
-        $this->assertSame('user', admin_controller_slug());
-
-        $this->assertSame(admin_trans_label('user'), '用户');
-    }
-
-    public function testTransGlobal()
-    {
-        $this->visit('admin/tests/users');
-
-        $this->registerTranslator();
-
-        $this->assertSame('user', admin_controller_slug());
-
-        $this->assertSame(admin_trans_field('id'), 'ID');
-        $this->assertSame(admin_trans_field('profile.address'), '地址');
-
-        $this->assertSame(admin_trans_label('List'), '列表');
-
-        $this->assertSame(admin_trans_label('Create'), 'Create');
-    }
-
-    protected function registerTranslator()
-    {
-        $loader = new FileLoader(app('files'), __DIR__.'/../resources/lang');
-
-        $translator = new Translator($loader, 'en');
-
-        app()->instance('translator', $translator);
-    }
-}

+ 0 - 199
tests/Feature/UserFormTest.php

@@ -1,199 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\Models\Profile;
-use Dcat\Admin\Tests\Models\Tag;
-use Dcat\Admin\Tests\Models\User as UserModel;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group user-form
- */
-class UserFormTest extends TestCase
-{
-    public function testCreatePage()
-    {
-        $this->visit('admin/tests/users/create')
-            ->seeElement('input[type=text][name=username]')
-            ->seeElement('input[type=email][name=email]')
-            ->seeElement('input[type=text][name=mobile]')
-//            ->seeElement('input[type=file][name=avatar]')
-            ->seeElement('hr')
-            ->seeElement("input[type=text][name='profile[first_name]']")
-            ->seeElement("input[type=text][name='profile[last_name]']")
-            ->seeElement("input[type=text][name='profile[postcode]']")
-            ->seeElement("textarea[name='profile[address]'][rows=15]")
-            ->seeElement("input[type=hidden][name='profile[latitude]']")
-            ->seeElement("input[type=hidden][name='profile[longitude]']")
-            ->seeElement("input[type=text][name='profile[color]']")
-            ->seeElement("input[type=text][name='profile[start_at]']")
-            ->seeElement("input[type=text][name='profile[end_at]']")
-            ->seeElement('span[class=help-block] i[class*=fa-info-circle]')
-            ->seeInElement('span[class=help-block]', 'Please input your postcode')
-            ->seeElement('span[class=help-block] i[class*=fa-image]')
-            ->seeInElement('span[class=help-block]', '上传头像')
-            ->seeElement("select[name='tags[]'][multiple=multiple]")
-            ->seeInElement('a[html-field]', 'html...');
-    }
-
-    public function testSubmitForm()
-    {
-        $data = [
-            'username'              => 'John Doe',
-            'email'                 => 'hello@world.com',
-            'mobile'                => '13421234123',
-            'password'              => '123456',
-            'password_confirmation' => '123456',
-            //"avatar"   => "test.jpg",
-            'profile' => [
-                'first_name' => 'John',
-                'last_name'  => 'Doe',
-                'postcode'   => '123456',
-                'address'    => 'Jinshajiang RD',
-                'latitude'   => '131.2123123456',
-                'longitude'  => '21.342123456',
-                'color'      => '#ffffff',
-                'start_at'   => date('Y-m-d H:i:s', time()),
-                'end_at'     => date('Y-m-d H:i:s', time()),
-            ],
-        ];
-
-        $this->visit('admin/tests/users/create')
-//            ->attach(__DIR__.'/assets/test.jpg', 'avatar')
-            ->submitForm('Submit', $data);
-
-        $this->seePageIs('admin/tests/users')
-            ->seeInElement('td', 1)
-            ->seeInElement('td', $data['username'])
-            ->seeInElement('td', $data['email'])
-            ->seeInElement('td', $data['mobile'])
-            ->seeInElement('td', "{$data['profile']['first_name']} {$data['profile']['last_name']}")
-            ->seeElement('td img')
-            ->seeInElement('td', $data['profile']['postcode'])
-            ->seeInElement('td', $data['profile']['address'])
-//            ->seeInElement('td', "{$data['profile']['latitude']} {$data['profile']['longitude']}")
-            ->seeInElement('td', $data['profile']['color'])
-            ->seeInElement('td', $data['profile']['start_at'])
-            ->seeInElement('td', $data['profile']['end_at']);
-
-        $this->assertCount(1, UserModel::all());
-
-        $this->seeInDatabase('test_users', ['username' => $data['username']]);
-        $this->seeInDatabase('test_users', ['email' => $data['email']]);
-        $this->seeInDatabase('test_users', ['mobile' => $data['mobile']]);
-        $this->seeInDatabase('test_users', ['password' => $data['password']]);
-
-        $this->seeInDatabase('test_user_profiles', ['first_name' => $data['profile']['first_name']]);
-        $this->seeInDatabase('test_user_profiles', ['last_name' => $data['profile']['last_name']]);
-        $this->seeInDatabase('test_user_profiles', ['postcode' => $data['profile']['postcode']]);
-        $this->seeInDatabase('test_user_profiles', ['address' => $data['profile']['address']]);
-        $this->seeInDatabase('test_user_profiles', ['latitude' => $data['profile']['latitude']]);
-        $this->seeInDatabase('test_user_profiles', ['longitude' => $data['profile']['longitude']]);
-        $this->seeInDatabase('test_user_profiles', ['color' => $data['profile']['color']]);
-        $this->seeInDatabase('test_user_profiles', ['start_at' => $data['profile']['start_at']]);
-        $this->seeInDatabase('test_user_profiles', ['end_at' => $data['profile']['end_at']]);
-
-//        $avatar = UserModel::first()->avatar;
-
-//        $this->assertFileExists(public_path('uploads/'.$avatar));
-    }
-
-    protected function seedsTable($count = 100)
-    {
-        factory(UserModel::class, $count)
-            ->create()
-            ->each(function ($u) {
-                $u->profile()->save(factory(Profile::class)->make());
-                $u->tags()->saveMany(factory(Tag::class, 5)->make());
-            });
-    }
-
-    public function testEditForm()
-    {
-        $this->seedsTable(10);
-
-        $id = mt_rand(1, 10);
-
-        $user = UserModel::with('profile')->find($id);
-
-        $this->visit("admin/tests/users/$id/edit")
-            ->seeElement("input[type=text][name=username][value='{$user->username}']")
-            ->seeElement("input[type=email][name=email][value='{$user->email}']")
-            ->seeElement("input[type=text][name=mobile][value='{$user->mobile}']")
-            ->seeElement('hr')
-            ->seeElement("input[type=text][name='profile[first_name]'][value='{$user->profile->first_name}']")
-            ->seeElement("input[type=text][name='profile[last_name]'][value='{$user->profile->last_name}']")
-            ->seeElement("input[type=text][name='profile[postcode]'][value='{$user->profile->postcode}']")
-            ->seeInElement("textarea[name='profile[address]']", $user->profile->address)
-//            ->seeElement("input[type=hidden][name='profile[latitude]'][value='{$user->profile->latitude}']")
-//            ->seeElement("input[type=hidden][name='profile[longitude]'][value='{$user->profile->longitude}']")
-            ->seeElement("input[type=text][name='profile[color]'][value='{$user->profile->color}']")
-            ->seeElement("input[type=text][name='profile[start_at]'][value='{$user->profile->start_at}']")
-            ->seeElement("input[type=text][name='profile[end_at]'][value='{$user->profile->end_at}']")
-            ->seeElement("select[name='tags[]'][multiple=multiple]");
-
-        $this->assertCount(50, $this->crawler()->filter("select[name='tags[]'] option"));
-        $this->assertCount(5, $this->crawler()->filter("select[name='tags[]'] option[selected]"));
-    }
-
-    public function testUpdateForm()
-    {
-        $this->seedsTable(10);
-
-        $id = mt_rand(1, 10);
-
-        $this->visit("admin/tests/users/$id/edit")
-            ->type('hello world', 'username')
-            ->type('123', 'password')
-            ->type('123', 'password_confirmation')
-            ->press('Submit')
-            ->seePageIs('admin/tests/users')
-            ->seeInDatabase('test_users', ['username' => 'hello world']);
-
-        $user = UserModel::with('profile')->find($id);
-
-        $this->assertSame($user->username, 'hello world');
-    }
-
-    public function testUpdateFormWithRule()
-    {
-        $this->seedsTable(10);
-
-        $id = mt_rand(1, 10);
-
-        $this->visit("admin/tests/users/$id/edit")
-            ->type('', 'email')
-            ->press('Submit')
-            ->seePageIs("admin/tests/users/$id/edit")
-            ->see('The email field is required');
-
-        $this->type('xxaxx', 'email')
-            ->press('Submit')
-            ->seePageIs("admin/tests/users/$id/edit")
-            ->see('The email must be a valid email address.');
-
-        $this->visit("admin/tests/users/$id/edit")
-            ->type('123', 'password')
-            ->type('1234', 'password_confirmation')
-            ->press('Submit')
-            ->seePageIs("admin/tests/users/$id/edit")
-            ->see('The Password confirmation does not match.');
-
-        $this->type('xx@xx.xx', 'email')
-            ->type('123', 'password')
-            ->type('123', 'password_confirmation')
-            ->press('Submit')
-            ->seePageIs('admin/tests/users')
-            ->seeInDatabase('test_users', ['email' => 'xx@xx.xx']);
-    }
-
-    public function testFormFooter()
-    {
-        $this->seedsTable(1);
-
-        $this->visit('admin/tests/users/1/edit')
-            ->seeElement('input[type=checkbox][value=1]')
-            ->seeElement('input[type=checkbox][value=3]');
-    }
-}

+ 0 - 225
tests/Feature/UserGridTest.php

@@ -1,225 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\Models\Profile as ProfileModel;
-use Dcat\Admin\Tests\Models\User as UserModel;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group user-grid
- */
-class UserGridTest extends TestCase
-{
-    public function testIndexPage()
-    {
-        $this->visit('admin/tests/users')
-            ->see('All users')
-            ->seeInElement('tr th', 'Username')
-            ->seeInElement('tr th', 'Email')
-            ->seeInElement('tr th', 'Mobile')
-            ->seeInElement('tr th', 'Full name')
-            ->seeInElement('tr th', 'Avatar')
-            ->seeInElement('tr th', 'Post code')
-            ->seeInElement('tr th', 'Address')
-//            ->seeInElement('tr th', 'Position')
-            ->seeInElement('tr th', 'Color')
-            ->seeInElement('tr th', '开始时间')
-            ->seeInElement('tr th', '结束时间')
-            ->seeInElement('tr th', 'Color')
-            ->seeInElement('tr th', 'Created at')
-            ->seeInElement('tr th', 'Updated at');
-
-        $action = url('/admin/tests/users');
-
-        //$this->seeInElement('a[href="http://localhost:8000/admin/tests/users?_export_=all"]', 'All')
-        //    ->seeInElement('a[href="http://localhost:8000/admin/tests/users/create"]', 'New');
-
-        $this->seeElement("form[action='$action'][method=get]")
-//            ->seeElement("form[action='$action'][method=get] input[name=id]")
-            ->seeElement("form[action='$action'][method=get] input[name=username]")
-            ->seeElement("form[action='$action'][method=get] input[name=email]")
-            ->seeElement("form[action='$action'][method=get] input[name='profile[start_at][start]']")
-            ->seeElement("form[action='$action'][method=get] input[name='profile[start_at][end]']")
-            ->seeElement("form[action='$action'][method=get] input[name='profile[end_at][start]']")
-            ->seeElement("form[action='$action'][method=get] input[name='profile[end_at][end]']");
-    }
-
-    protected function seedsTable($count = 100)
-    {
-        factory(\Dcat\Admin\Tests\Models\User::class, $count)
-            ->create()
-            ->each(function ($u) {
-                $u->profile()->save(factory(\Dcat\Admin\Tests\Models\Profile::class)->make());
-                $u->tags()->saveMany(factory(\Dcat\Admin\Tests\Models\Tag::class, 5)->make());
-            });
-    }
-
-    public function testGridWithData()
-    {
-        $this->seedsTable();
-
-        $this->visit('admin/tests/users')
-            ->see('All users');
-
-        $this->assertCount(100, UserModel::all());
-        $this->assertCount(100, ProfileModel::all());
-    }
-
-    public function testGridPagination()
-    {
-        $this->seedsTable(65);
-
-        $this->visit('admin/tests/users')
-            ->see('All users');
-
-        $this->visit('admin/tests/users?page=2');
-        $this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-ellipsis-v]'));
-
-        $this->visit('admin/tests/users?page=3');
-        $this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-ellipsis-v]'));
-
-        $this->visit('admin/tests/users?page=4');
-        $this->assertCount(5, $this->crawler()->filter('td a i[class*=fa-ellipsis-v]'));
-
-        $this->click(1)->seePageIs('admin/tests/users?page=1');
-        $this->assertCount(20, $this->crawler()->filter('td a i[class*=fa-ellipsis-v]'));
-    }
-
-    public function testEqualFilter()
-    {
-        $this->seedsTable(50);
-
-        $this->visit('admin/tests/users')
-            ->see('All users');
-
-        $this->assertCount(50, UserModel::all());
-        $this->assertCount(50, ProfileModel::all());
-
-        $id = mt_rand(1, 50);
-
-        $user = UserModel::find($id);
-
-        $this->visit('admin/tests/users?id='.$id)
-            ->seeInElement('td', $user->username)
-            ->seeInElement('td', $user->email)
-            ->seeInElement('td', $user->mobile)
-//            ->seeElement("img[src='{$user->avatar}']")
-            ->seeInElement('td', "{$user->profile->first_name} {$user->profile->last_name}")
-            ->seeInElement('td', $user->postcode)
-            ->seeInElement('td', $user->address)
-//            ->seeInElement('td', "{$user->profile->latitude} {$user->profile->longitude}")
-            ->seeInElement('td', $user->color)
-            ->seeInElement('td', $user->start_at)
-            ->seeInElement('td', $user->end_at);
-    }
-
-    public function testLikeFilter()
-    {
-        $this->seedsTable(50);
-
-        $this->visit('admin/tests/users')
-            ->see('All users');
-
-        $this->assertCount(50, UserModel::all());
-        $this->assertCount(50, ProfileModel::all());
-
-        $users = UserModel::where('username', 'like', '%mi%')->get();
-
-        $this->visit('admin/tests/users?username=mi');
-
-        $this->assertSame($this->crawler()->filter('td a i[class*=fa-ellipsis-v]')->count(), count($users->toArray()));
-
-        foreach ($users as $user) {
-            $this->seeInElement('td', $user->username);
-        }
-    }
-
-    public function testFilterRelation()
-    {
-        $this->seedsTable(20);
-
-        $user = UserModel::with('profile')->find(mt_rand(1, 20));
-
-        $this->visit('admin/tests/users?email='.$user->email)
-            ->seeInElement('td', $user->username)
-            ->seeInElement('td', $user->email)
-            ->seeInElement('td', $user->mobile)
-//            ->seeElement("img[src='{$user->avatar}']")
-            ->seeInElement('td', "{$user->profile->first_name} {$user->profile->last_name}")
-            ->seeInElement('td', $user->postcode)
-            ->seeInElement('td', $user->address)
-//            ->seeInElement('td', "{$user->profile->latitude} {$user->profile->longitude}")
-            ->seeInElement('td', $user->color)
-            ->seeInElement('td', $user->start_at)
-            ->seeInElement('td', $user->end_at);
-    }
-
-    public function testDisplayCallback()
-    {
-        $this->seedsTable(1);
-
-        $user = UserModel::with('profile')->find(1);
-
-        $this->visit('admin/tests/users')
-            ->seeInElement('th', 'Column1 not in table')
-            ->seeInElement('th', 'Column2 not in table')
-            ->seeInElement('td', "full name:{$user->profile->first_name} {$user->profile->last_name}")
-            ->seeInElement('td', "{$user->email}#{$user->profile->color}");
-    }
-
-    public function testHasManyRelation()
-    {
-        factory(\Dcat\Admin\Tests\Models\User::class, 10)
-            ->create()
-            ->each(function ($u) {
-                $u->profile()->save(factory(\Dcat\Admin\Tests\Models\Profile::class)->make());
-                $u->tags()->saveMany(factory(\Dcat\Admin\Tests\Models\Tag::class, 5)->make());
-            });
-
-        $this->visit('admin/tests/users')
-            ->seeElement('td code');
-
-        $this->assertCount(50, $this->crawler()->filter('td code'));
-    }
-
-    public function testGridActions()
-    {
-        $this->seedsTable(15);
-
-        $this->visit('admin/tests/users');
-
-        $this->assertCount(15, $this->crawler()->filter('td a i[class*=fa-ellipsis-v]'));
-    }
-
-    public function testGridRows()
-    {
-        $this->seedsTable(10);
-
-        $this->visit('admin/tests/users')
-            ->seeInElement('td a[class*=btn]', 'detail');
-
-        $this->assertCount(5, $this->crawler()->filter('td a[class*=btn]'));
-    }
-
-    public function testGridPerPage()
-    {
-        $this->seedsTable(98);
-
-        $this->visit('admin/tests/users')
-            ->seeElement('select[class*=per-page][name=per-page]')
-            ->seeInElement('select option', 10)
-            ->seeInElement('select option[selected]', 20)
-            ->seeInElement('select option', 30)
-            ->seeInElement('select option', 50)
-            ->seeInElement('select option', 100);
-
-        $this->assertSame('http://localhost:8000/admin/tests/users?per_page=20', $this->crawler()->filter('select option[selected]')->attr('value'));
-
-        $perPage = mt_rand(1, 98);
-
-        $this->visit('admin/tests/users?per_page='.$perPage)
-            ->seeInElement('select option[selected]', $perPage)
-            ->assertCount($perPage + 1, $this->crawler()->filter('tr'));
-    }
-}

+ 0 - 81
tests/Feature/UserSettingTest.php

@@ -1,81 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Models\Administrator;
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group user-setting
- */
-class UserSettingTest extends TestCase
-{
-    public function testVisitSettingPage()
-    {
-        $this->visit('admin/auth/setting')
-            ->see('User setting')
-            ->see('Username')
-            ->see('Name')
-            ->see('Avatar')
-            ->see('Password')
-            ->see('Password confirmation');
-
-        $this->seeElement('input[value=Administrator]')
-            ->seeInElement('.box-body', 'administrator');
-    }
-
-    public function testUpdateName()
-    {
-        $data = [
-            'name' => 'tester',
-        ];
-
-        $this->visit('admin/auth/setting')
-            ->submitForm('Submit', $data)
-            ->seePageIs('admin/auth/setting');
-
-        $this->seeInDatabase('admin_users', ['name' => $data['name']]);
-    }
-
-    public function testUpdatePasswordConfirmation()
-    {
-        $data = [
-            'password'              => '123456',
-            'password_confirmation' => '123',
-        ];
-
-        $this->visit('admin/auth/setting')
-            ->submitForm('Submit', $data)
-            ->seePageIs('admin/auth/setting')
-            ->see('The Password confirmation does not match.');
-    }
-
-    public function testUpdatePassword()
-    {
-        $data = [
-            'old_password'          => 'admin',
-            'password'              => '123456',
-            'password_confirmation' => '123456',
-        ];
-
-        $this->visit('admin/auth/setting')
-            ->submitForm('Submit', $data)
-            ->seePageIs('admin/auth/setting');
-
-        $this->assertTrue(app('hash')->check($data['password'], Administrator::first()->makeVisible('password')->password));
-
-        $this->visit('admin/auth/logout')
-            ->seePageIs('admin/auth/login')
-            ->dontSeeIsAuthenticated('admin');
-
-        $credentials = ['username' => 'admin', 'password' => '123456'];
-
-        $this->visit('admin/auth/login')
-            ->see('login')
-            ->submitForm('Login', $credentials)
-            ->see('dashboard')
-            ->seeCredentials($credentials, 'admin')
-            ->seeIsAuthenticated('admin')
-            ->seePageIs('admin');
-    }
-}

+ 0 - 43
tests/Feature/UserShowTest.php

@@ -1,43 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group user-show
- */
-class UserShowTest extends TestCase
-{
-    public function test()
-    {
-        $this->seedsTable(10);
-
-        $this->visit('admin/tests/users/1');
-
-        $this->assertResponseStatus(200);
-
-        $this->see('Detail')
-            ->see('ID')
-            ->see('username')
-            ->see('email')
-            ->see('full name')
-            ->see('postcode')
-            ->see('tags');
-
-        $this->seeInElement('a[href="http://localhost:8000/admin/tests/users"]', 'List')
-            ->seeInElement('a[href="http://localhost:8000/admin/tests/users/1/edit"]', 'Edit');
-
-        $this->assertCount(1, $this->crawler()->filter('hr'));
-    }
-
-    protected function seedsTable($count = 100)
-    {
-        factory(\Dcat\Admin\Tests\Models\User::class, $count)
-            ->create()
-            ->each(function ($u) {
-                $u->profile()->save(factory(\Dcat\Admin\Tests\Models\Profile::class)->make());
-                $u->tags()->saveMany(factory(\Dcat\Admin\Tests\Models\Tag::class, 5)->make());
-            });
-    }
-}

+ 0 - 89
tests/Feature/UsersTest.php

@@ -1,89 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Feature;
-
-use Dcat\Admin\Tests\TestCase;
-
-/**
- * @group user
- */
-class UsersTest extends TestCase
-{
-    public function testUsersIndexPage()
-    {
-        $this->visit('admin/auth/users')
-            ->see('Administrator');
-    }
-
-    public function testCreateUser()
-    {
-        $user = [
-            'username'              => 'Test',
-            'name'                  => 'Name',
-            'password'              => '123456',
-            'password_confirmation' => '123456',
-        ];
-
-        // create user
-        $this->visit('admin/auth/users/create')
-            ->see('Create')
-            ->submitForm('Submit', $user)
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.users_table'), ['username' => $user['username'], 'name' => $user['name']]);
-
-        // assign role to user
-        $this->visit('admin/auth/users/2/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['roles' => [1]])
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.role_users_table'), ['user_id' => 2, 'role_id' => 1]);
-
-        $this->visit('admin/auth/logout')
-            ->dontSeeIsAuthenticated('admin')
-            ->seePageIs('admin/auth/login')
-            ->submitForm('Login', ['username' => $user['username'], 'password' => $user['password']])
-            ->see('dashboard')
-            ->seeIsAuthenticated('admin')
-            ->seePageIs('admin');
-
-        $this->assertTrue($this->app['auth']->guard('admin')->getUser()->isAdministrator());
-
-        $this->see('<span>Users</span>')
-            ->see('<span>Roles</span>')
-            ->see('<span>Permission</span>')
-            ->see('<span>Operation log</span>')
-            ->see('<span>Menu</span>');
-    }
-
-    public function testUpdateUser()
-    {
-        $this->visit('admin/auth/users/'.$this->user->id.'/edit')
-            ->see('Edit')
-            ->submitForm('Submit', ['name' => 'test', 'roles' => [1]])
-            ->seePageIs('admin/auth/users')
-            ->seeInDatabase(config('admin.database.users_table'), ['name' => 'test']);
-    }
-
-    public function testResetPassword()
-    {
-        $password = 'odjwyufkglte';
-
-        $data = [
-            'password'              => $password,
-            'password_confirmation' => $password,
-            'roles'                 => [1],
-        ];
-
-        $this->visit('admin/auth/users/'.$this->user->id.'/edit')
-            ->see('Edit')
-            ->submitForm('Submit', $data)
-            ->seePageIs('admin/auth/users')
-            ->visit('admin/auth/logout')
-            ->dontSeeIsAuthenticated('admin')
-            ->seePageIs('admin/auth/login')
-            ->submitForm('Login', ['username' => $this->user->username, 'password' => $password])
-            ->see('dashboard')
-            ->seeIsAuthenticated('admin')
-            ->seePageIs('admin');
-    }
-}

+ 0 - 0
tests/browser-tests/InteractsWithDatabase.php → tests/InteractsWithDatabase.php


+ 1 - 1
tests/Models/File.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Models/Image.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Models/MultipleImage.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Models/Profile.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Models/Tag.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Models/Tree.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Encore\Admin\Traits\AdminBuilder;
 use Encore\Admin\Traits\ModelTree;

+ 1 - 1
tests/Models/User.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Models;
+namespace Tests\Models;
 
 use Illuminate\Database\Eloquent\Model;
 

+ 1 - 1
tests/Repositories/Report.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace Dcat\Admin\Tests\Repositories;
+namespace Tests\Repositories;
 
 use Dcat\Admin\Grid;
 use Dcat\Admin\Repositories\Repository;

+ 2 - 2
tests/Repositories/User.php

@@ -1,9 +1,9 @@
 <?php
 
-namespace Dcat\Admin\Tests\Repositories;
+namespace Tests\Repositories;
 
 use Dcat\Admin\Repositories\EloquentRepository;
-use Dcat\Admin\Tests\Models\User as Model;
+use Tests\Models\User as Model;
 
 class User extends EloquentRepository
 {

+ 2 - 30
tests/TestCase.php

@@ -1,35 +1,7 @@
 <?php
 
-namespace Dcat\Admin\Tests;
+namespace Tests;
 
-use Dcat\Admin\Models\Administrator;
-use Laravel\BrowserKitTesting\TestCase as BaseTestCase;
-
-class TestCase extends BaseTestCase
+abstract class TestCase extends DuskTestCase
 {
-    use CreatesApplication;
-
-    protected $baseUrl = 'http://localhost:8000';
-
-    /**
-     * @var Administrator
-     */
-    protected $user;
-
-    protected $login = true;
-
-    public function setUp(): void
-    {
-        parent::setUp();
-
-        $this->boot();
-    }
-
-
-    public function tearDown(): void
-    {
-        $this->destory();
-
-        parent::tearDown();
-    }
 }

+ 0 - 66
tests/artisan

@@ -1,66 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-define('LARAVEL_START', microtime(true));
-
-/*
-|--------------------------------------------------------------------------
-| Register The Auto Loader
-|--------------------------------------------------------------------------
-|
-| Composer provides a convenient, automatically generated class loader
-| for our application. We just need to utilize it! We'll require it
-| into the script here so that we do not have to worry about the
-| loading of any our classes "manually". Feels great to relax.
-|
-*/
-
-require __DIR__.'/../vendor/autoload.php';
-
-$app = require_once __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
-
-/*
-|--------------------------------------------------------------------------
-| Run The Artisan Application
-|--------------------------------------------------------------------------
-|
-| When we run the console application, the current CLI command will be
-| executed in this console and the response sent back to a terminal
-| or another output device for the developers. Here goes nothing!
-|
-*/
-
-$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
-
-Illuminate\Console\Application::starting(function ($artisan) {
-    $artisan->resolveCommands([
-        \Dcat\Admin\Tests\Console\InstallCommand::class,
-    ]);
-});
-
-$app->booting(function () use ($app) {
-    $app['env'] = 'local';
-
-    $app->register(\Laravel\Dusk\DuskServiceProvider::class);
-    $app->register(\BeyondCode\DuskDashboard\DuskDashboardServiceProvider::class);
-});
-
-$status = $kernel->handle(
-    $input = new Symfony\Component\Console\Input\ArgvInput,
-    new Symfony\Component\Console\Output\ConsoleOutput
-);
-
-/*
-|--------------------------------------------------------------------------
-| Shutdown The Application
-|--------------------------------------------------------------------------
-|
-| Once Artisan has finished running, we will fire off the shutdown events
-| so that any final work may be done by the application before we shut
-| down the process. This is the last thing to happen to the request.
-|
-*/
-
-$kernel->terminate($input, $status);
-
-exit($status);

+ 0 - 86
tests/browser-tests/Controllers/DropdownController.php

@@ -1,86 +0,0 @@
-<?php
-
-namespace Tests\Controllers;
-
-use Dcat\Admin\Admin;
-use Dcat\Admin\Layout\Content;
-use Dcat\Admin\Layout\Row;
-use Dcat\Admin\Widgets\Box;
-use Dcat\Admin\Widgets\Dropdown;
-use Illuminate\Routing\Controller;
-
-class DropdownController extends Controller
-{
-    protected $tian = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];
-    protected $di = ['寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥', '子', '丑'];
-
-    public function index(Content $content)
-    {
-        return $content->header('Dropdown Menu')
-            ->row(function (Row $row) {
-                $row->column(3, $this->example1());
-                $row->column(3, $this->example2());
-                $row->column(3, $this->example3());
-            });
-    }
-
-    protected function example1()
-    {
-        $menu1 = Dropdown::make($this->tian)->button('天干');
-
-        $menu2 = Dropdown::make()
-            ->button('使用标题')
-            ->buttonClass('btn btn-sm btn-inverse')
-            ->options($this->tian, '天干')
-            ->options($this->di, '地支');
-
-        $menu3 = Dropdown::make([1, 2, 3, Dropdown::DIVIDER, 4, 5])->button('中间加分隔线');
-
-        return Box::make(
-            'Example1',
-            $menu1->render().' &nbsp; '.$menu2->render().' &nbsp; '.$menu3->render()
-        );
-    }
-
-    protected function example2()
-    {
-        $menu = Dropdown::make($this->tian);
-
-        $menu->map(function ($v, $k) {
-            if ($k === 7) {
-                $this->divider();
-            }
-            $k++;
-
-            return "{$k}. $v";
-        });
-
-        return Box::make('Example2', function () use ($menu) {
-            return "<div class='dropdown'><a class='btn no-shadow text-muted' data-toggle='dropdown' href='javascript:void(0)'><i class='ti-email'></i> 自定义按钮 </a>{$menu->render()}</div>";
-        });
-    }
-
-    protected function example3()
-    {
-        $menu1 = Dropdown::make()
-            ->options($this->tian, '天干')
-            ->options($this->di, '地支')
-            ->click()
-            ->buttonClass('btn btn-sm btn-light')
-            ->map(function ($v, $k) {
-                $k++;
-
-                return "<a class='test_item' data-id='$k', data-value='{$v}' data-test='Hello world.' href='javascript:void(0)'>{$k}. $v</a>";
-            });
-
-        Admin::script(
-            <<<'JS'
-$('.test_item').click(function () {
-    LA.info("Selected: " + JSON.stringify($(this).data()));
-});
-JS
-        );
-
-        return Box::make('Example3', $menu1);
-    }
-}

+ 0 - 62
tests/browser-tests/Controllers/ReportController.php

@@ -1,62 +0,0 @@
-<?php
-
-namespace Tests\Controllers;
-
-use App\Http\Controllers\Controller;
-use Dcat\Admin\Grid;
-use Dcat\Admin\Layout\Content;
-use Tests\Repositories\Report;
-
-class ReportController extends Controller
-{
-    public function index(Content $content)
-    {
-        return $content
-            ->header('报表')
-            ->body($this->grid());
-    }
-
-    protected function grid()
-    {
-        $grid = new Grid(new Report());
-
-        // 开启responsive插件
-        $grid->responsive();
-
-        $grid->disableActions();
-        $grid->disableBatchDelete();
-        $grid->disableCreateButton();
-
-        $grid->rowSelector()->style('success')->click();
-
-        $grid->combine('avgCost', ['avgMonthCost', 'avgQuarterCost', 'avgYearCost'])->responsive()->help('test');
-        $grid->combine('avgVist', ['avgMonthVist', 'avgQuarterVist', 'avgYearVist'])->responsive();
-        $grid->combine('top', ['topCost', 'topVist', 'topIncr'])->responsive()->style('color:#1867c0');
-
-        $grid->content->limit(50)->responsive();
-        $grid->cost->sortable()->responsive();
-        $grid->avgMonthCost->responsive();
-        $grid->avgQuarterCost->responsive()->setHeaderAttributes(['style' => 'color:#5b69bc']);
-        $grid->avgYearCost->responsive();
-        $grid->avgMonthVist->responsive();
-        $grid->avgQuarterVist->responsive();
-        $grid->avgYearVist->responsive();
-        $grid->incrs->hide();
-        $grid->avgVists->hide();
-        $grid->topCost->responsive();
-        $grid->topVist->responsive();
-        $grid->topIncr->responsive();
-        $grid->date->sortable()->responsive();
-
-        $grid->filter(function (Grid\Filter $filter) {
-            $filter->scope(1, admin_trans_field('month'))->where('date', 2019, '<=');
-            $filter->scope(2, admin_trans_label('quarter'))->where('date', 2019, '<=');
-            $filter->scope(3, admin_trans_label('year'))->where('date', 2019, '<=');
-
-            $filter->equal('content');
-            $filter->equal('cost');
-        });
-
-        return $grid;
-    }
-}

+ 0 - 211
tests/browser-tests/Controllers/UserController.php

@@ -1,211 +0,0 @@
-<?php
-
-namespace Tests\Controllers;
-
-use App\Http\Controllers\Controller;
-use Dcat\Admin\Controllers\HasResourceActions;
-use Dcat\Admin\Form;
-use Dcat\Admin\Grid;
-use Dcat\Admin\Layout\Content;
-use Dcat\Admin\Show;
-use Tests\Models\Tag;
-use Tests\Repositories\User;
-
-class UserController extends Controller
-{
-    use HasResourceActions;
-
-    /**
-     * Index interface.
-     *
-     * @return Content
-     */
-    public function index(Content $content)
-    {
-        $content->header('All users');
-        $content->description('description');
-
-        return $content->body($this->grid());
-    }
-
-    /**
-     * Edit interface.
-     *
-     * @param $id
-     *
-     * @return Content
-     */
-    public function edit(Content $content, $id)
-    {
-        $content->header('Edit user');
-        $content->description('description');
-
-        $content->body($this->form()->edit($id));
-
-        return $content;
-    }
-
-    /**
-     * Create interface.
-     *
-     * @return Content
-     */
-    public function create(Content $content)
-    {
-        $content->header('Create user');
-
-        return $content->body($this->form());
-    }
-
-    /**
-     * Show interface.
-     *
-     * @param mixed   $id
-     * @param Content $content
-     *
-     * @return Content
-     */
-    public function show($id, Content $content)
-    {
-        return $content
-            ->header('User')
-            ->description('Detail')
-            ->body($this->detail($id));
-    }
-
-    /**
-     * Make a grid builder.
-     *
-     * @return Grid
-     */
-    protected function grid()
-    {
-        $grid = new Grid(new User());
-
-        $grid->model()->with(['tags', 'profile']);
-
-        $grid->id('ID')->sortable();
-
-        $grid->username();
-        $grid->email();
-        $grid->mobile();
-        $grid->full_name();
-        $grid->avatar()->display(function ($avatar) {
-            return "<img src='{$avatar}' />";
-        });
-        $grid->column('profile.postcode', 'Post code');
-        $grid->column('profile.address');
-        $grid->column('profile.color');
-        $grid->column('profile.start_at', '开始时间');
-        $grid->column('profile.end_at', '结束时间');
-
-        $grid->column('column1_not_in_table')->display(function () {
-            return 'full name:'.$this->full_name;
-        });
-
-        $grid->column('column2_not_in_table')->display(function () {
-            return $this->email.'#'.$this->profile['color'];
-        });
-
-        $grid->tags()->display(function ($tags) {
-            $tags = collect($tags)->map(function ($tag) {
-                return "<code>{$tag['name']}</code>";
-            })->toArray();
-
-            return implode('', $tags);
-        });
-
-        $grid->created_at();
-        $grid->updated_at();
-
-        $grid->filter(function (Grid\Filter $filter) {
-            $filter->equal('id');
-            $filter->like('username');
-            $filter->like('email');
-            $filter->like('profile.postcode');
-            $filter->between('profile.start_at')->datetime();
-            $filter->between('profile.end_at')->datetime();
-        });
-
-        $grid->actions(function (Grid\Displayers\Actions $actions) {
-            if ($actions->getKey() % 2 == 0) {
-                $actions->append('<a href="/" class="btn btn-xs btn-danger">detail</a>');
-            }
-        });
-
-        return $grid;
-    }
-
-    /**
-     * Make a show builder.
-     *
-     * @param mixed $id
-     *
-     * @return Show
-     */
-    protected function detail($id)
-    {
-        return Show::make($id, new User(), function (Show $show) {
-            $show->id('ID');
-            $show->username();
-            $show->email;
-
-            $show->divider();
-
-            $show->full_name();
-            $show->field('profile.postcode');
-
-            $show->tags->json();
-        });
-    }
-
-    /**
-     * Make a form builder.
-     *
-     * @return Form
-     */
-    protected function form()
-    {
-        Form::extend('map', Form\Field\Map::class);
-        Form::extend('editor', Form\Field\Editor::class);
-
-        $form = new Form(new User());
-
-        $form->disableDeleteButton();
-
-        $form->display('id', 'ID');
-        $form->text('username');
-        $form->email('email')->rules('required');
-        $form->mobile('mobile');
-        $form->image('avatar')->help('上传头像', 'fa-image');
-        $form->ignore(['password_confirmation']);
-        $form->password('password')->rules('confirmed');
-        $form->password('password_confirmation');
-
-        $form->divider();
-
-        $form->text('profile.first_name');
-        $form->text('profile.last_name');
-        $form->text('profile.postcode')->help('Please input your postcode');
-        $form->textarea('profile.address')->rows(15);
-        $form->map('profile.latitude', 'profile.longitude', 'Position');
-        $form->color('profile.color');
-        $form->datetime('profile.start_at');
-        $form->datetime('profile.end_at');
-
-        $form->multipleSelect('tags', 'Tags')->options(Tag::all()->pluck('name', 'id'))->customFormat(function ($value) {
-            if (! $value) {
-                return [];
-            }
-
-            return array_column($value, 'id');
-        });
-
-        $form->display('created_at', 'Created At');
-        $form->display('updated_at', 'Updated At');
-
-        $form->html('<a html-field>html...</a>');
-
-        return $form;
-    }
-}

+ 0 - 113
tests/browser-tests/CreatesApplication.php

@@ -1,113 +0,0 @@
-<?php
-
-namespace Tests;
-
-use Dcat\Admin\Models\Administrator;
-use Illuminate\Contracts\Console\Kernel;
-use Illuminate\Filesystem\Filesystem;
-use Illuminate\Support\Arr;
-use Illuminate\Support\Facades\Artisan;
-use Illuminate\Support\Facades\DB;
-use Illuminate\Support\Facades\Schema;
-
-trait CreatesApplication
-{
-    /**
-     * Creates the application.
-     *
-     * @return \Illuminate\Foundation\Application
-     */
-    public function createApplication()
-    {
-        $app = require __DIR__.'/../bootstrap/app.php';
-
-        $app->make(Kernel::class)->bootstrap();
-
-        return $app;
-    }
-
-
-    protected function boot()
-    {
-        $this->config();
-
-        $this->artisan('admin:publish');
-
-        Schema::defaultStringLength(191);
-
-        $this->artisan('admin:install');
-
-        $this->migrateTestTables();
-
-        if (file_exists($routes = admin_path('routes.php'))) {
-            require $routes;
-        }
-
-        require __DIR__.'/helpers.php';
-
-        require __DIR__.'/routes.php';
-
-        require __DIR__.'/resources/seeds/factory.php';
-
-        view()->addNamespace('admin-tests', __DIR__.'/resources/views');
-    }
-
-    protected function destory()
-    {
-        (new \CreateAdminTables())->down();
-
-        (new \CreateTestTables())->down();
-
-        DB::select("delete from `migrations` where `migration` = '2016_01_04_173148_create_admin_tables'");
-        DB::select("delete from `migrations` where `migration` = '2016_11_22_093148_create_test_tables'");
-
-        Artisan::call('migrate:rollback');
-    }
-
-    /**
-     * run package database migrations.
-     *
-     * @return void
-     */
-    public function migrateTestTables()
-    {
-        $fileSystem = new Filesystem();
-
-        $fileSystem->requireOnce(__DIR__.'/resources/migrations/2016_11_22_093148_create_test_tables.php');
-
-        (new \CreateTestTables())->up();
-    }
-
-    protected function config()
-    {
-        $adminConfig = require __DIR__.'/resources/config/admin.php';
-
-        $config = $this->app['config'];
-
-        $config->set('database.default', 'mysql');
-        $config->set('database.connections.mysql.host', env('MYSQL_HOST', 'localhost'));
-        $config->set('database.connections.mysql.database', 'laravel_dcat_admin_test');
-        $config->set('database.connections.mysql.username', env('MYSQL_USER', 'root'));
-        $config->set('database.connections.mysql.password', env('MYSQL_PASSWORD', ''));
-        $config->set('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF');
-        $config->set('filesystems', require __DIR__.'/resources/config/filesystems.php');
-        $config->set('admin', $adminConfig);
-        $config->set('app.debug', true);
-
-        foreach (Arr::dot(Arr::get($adminConfig, 'auth'), 'auth.') as $key => $value) {
-            $this->app['config']->set($key, $value);
-        }
-    }
-
-    /**
-     * @return Administrator
-     */
-    protected function getUser()
-    {
-        if ($this->user) {
-            return $this->user;
-        }
-
-        return $this->user = Administrator::first();
-    }
-}

+ 0 - 106
tests/browser-tests/DuskTestCase.php

@@ -1,106 +0,0 @@
-<?php
-
-namespace Tests;
-
-use Dcat\Admin\Models\Administrator;
-use Facebook\WebDriver\Chrome\ChromeOptions;
-use Facebook\WebDriver\Remote\DesiredCapabilities;
-use Facebook\WebDriver\Remote\RemoteWebDriver;
-use Laravel\Dusk\Browser;
-use Laravel\Dusk\TestCase as BaseTestCase;
-
-abstract class DuskTestCase extends BaseTestCase
-{
-    use CreatesApplication, BrowserExtension, InteractsWithDatabase;
-
-    /**
-     * @var Administrator
-     */
-    protected $user;
-
-    /**
-     * @var bool
-     */
-    protected $login = true;
-
-    public function login(Browser $browser)
-    {
-        $browser->loginAs($this->getUser(), 'admin');
-    }
-
-    public function setUp(): void
-    {
-        parent::setUp();
-
-        $this->extendBrowser();
-
-        $this->boot();
-    }
-
-    public function tearDown(): void
-    {
-        $this->destory();
-
-        parent::tearDown();
-    }
-
-    /**
-     * Prepare for Dusk test execution.
-     *
-     * @beforeClass
-     * @return void
-     */
-    public static function prepare()
-    {
-        static::startChromeDriver();
-    }
-
-    /**
-     * @param \Facebook\WebDriver\Remote\RemoteWebDriver $driver
-     *
-     * @return \Laravel\Dusk\Browser
-     */
-    protected function newBrowser($driver)
-    {
-        $browser = parent::newBrowser($driver)->resize(1566, 1080);
-
-        if ($this->login) {
-            $this->login($browser);
-        }
-
-        return $browser;
-    }
-
-    /**
-     * Create the RemoteWebDriver instance.
-     *
-     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
-     */
-    protected function driver()
-    {
-        $options = (new ChromeOptions)->addArguments([
-            '--disable-gpu',
-            '--headless',
-            '--window-size=1920,1080',
-        ]);
-
-        return RemoteWebDriver::create(
-            'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
-                ChromeOptions::CAPABILITY_W3C, $options
-            )
-        );
-    }
-
-    /**
-     * Build the process to run the Chromedriver.
-     *
-     * @param  array  $arguments
-     * @return \Symfony\Component\Process\Process
-     *
-     * @throws \RuntimeException
-     */
-    protected static function buildChromeProcess(array $arguments = [])
-    {
-        return (new ChromeProcess(static::$chromeDriver))->toProcess($arguments);
-    }
-}

+ 0 - 10
tests/browser-tests/Models/File.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class File extends Model
-{
-    protected $table = 'test_files';
-}

+ 0 - 10
tests/browser-tests/Models/Image.php

@@ -1,10 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Image extends Model
-{
-    protected $table = 'test_images';
-}

+ 0 - 22
tests/browser-tests/Models/MultipleImage.php

@@ -1,22 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class MultipleImage extends Model
-{
-    protected $table = 'test_multiple_images';
-
-    public function setPicturesAttribute($pictures)
-    {
-        if (is_array($pictures)) {
-            $this->attributes['pictures'] = json_encode($pictures);
-        }
-    }
-
-    public function getPicturesAttribute($pictures)
-    {
-        return json_decode($pictures, true) ?: [];
-    }
-}

+ 0 - 15
tests/browser-tests/Models/Profile.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Profile extends Model
-{
-    protected $table = 'test_user_profiles';
-
-    public function user()
-    {
-        return $this->belongsTo(User::class, 'user_id');
-    }
-}

+ 0 - 15
tests/browser-tests/Models/Tag.php

@@ -1,15 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class Tag extends Model
-{
-    protected $table = 'test_tags';
-
-    public function users()
-    {
-        return $this->belongsToMany(User::class, 'test_user_tags', 'tag_id', 'user_id');
-    }
-}

+ 0 - 28
tests/browser-tests/Models/Tree.php

@@ -1,28 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Encore\Admin\Traits\AdminBuilder;
-use Encore\Admin\Traits\ModelTree;
-use Illuminate\Database\Eloquent\Model;
-
-class Tree extends Model
-{
-    use AdminBuilder, ModelTree;
-
-    /**
-     * Create a new Eloquent model instance.
-     *
-     * @param array $attributes
-     */
-    public function __construct(array $attributes = [])
-    {
-        $connection = config('admin.database.connection') ?: config('database.default');
-
-        $this->setConnection($connection);
-
-        $this->setTable(config('admin.database.menu_table'));
-
-        parent::__construct($attributes);
-    }
-}

+ 0 - 40
tests/browser-tests/Models/User.php

@@ -1,40 +0,0 @@
-<?php
-
-namespace Tests\Models;
-
-use Illuminate\Database\Eloquent\Model;
-
-class User extends Model
-{
-    protected $table = 'test_users';
-
-    protected $appends = ['full_name', 'position'];
-
-    public function profile()
-    {
-        return $this->hasOne(Profile::class, 'user_id');
-    }
-
-    public function getFullNameAttribute()
-    {
-        if (! $this->profile) {
-            return;
-        }
-
-        return "{$this->profile['first_name']} {$this->profile['last_name']}";
-    }
-
-    public function getPositionAttribute()
-    {
-        if (! $this->profile) {
-            return;
-        }
-
-        return "{$this->profile->latitude} {$this->profile->longitude}";
-    }
-
-    public function tags()
-    {
-        return $this->belongsToMany(Tag::class, 'test_user_tags', 'user_id', 'tag_id');
-    }
-}

+ 0 - 61
tests/browser-tests/Repositories/Report.php

@@ -1,61 +0,0 @@
-<?php
-
-namespace Tests\Repositories;
-
-use Dcat\Admin\Grid;
-use Dcat\Admin\Repositories\Repository;
-use Faker\Factory;
-use Illuminate\Pagination\LengthAwarePaginator;
-
-class Report extends Repository
-{
-    public function get(Grid\Model $model)
-    {
-        $items = $this->fetch();
-
-        $paginator = new LengthAwarePaginator(
-            $items,
-            1000,
-            $model->getPerPage(), // 传入每页显示行数
-            $model->getCurrentPage() // 传入当前页码
-        );
-
-        // 必须设置链接
-        $paginator->setPath(\url()->current());
-
-        return $paginator;
-    }
-
-    /**
-     * 这里生成假数据演示报表功能.
-     *
-     * @return array
-     */
-    public function fetch()
-    {
-        $faker = Factory::create();
-
-        $data = [];
-
-        for ($i = 0; $i < 20; $i++) {
-            $data[] = [
-                'content'        => $faker->text,
-                'cost'           => $faker->randomFloat(),
-                'avgMonthCost'   => $faker->randomFloat(),
-                'avgQuarterCost' => $faker->randomFloat(),
-                'avgYearCost'    => $faker->randomFloat(),
-                'incrs'          => $faker->numberBetween(1, 999999999),
-                'avgMonthVist'   => $faker->numberBetween(1, 999999),
-                'avgQuarterVist' => $faker->numberBetween(1, 999999),
-                'avgYearVist'    => $faker->numberBetween(1, 999999),
-                'avgVists'       => $faker->numberBetween(1, 999999),
-                'topCost'        => $faker->numberBetween(1, 999999999),
-                'topVist'        => $faker->numberBetween(1, 9999990009),
-                'topIncr'        => $faker->numberBetween(1, 99999999),
-                'date'           => $faker->date(),
-            ];
-        }
-
-        return $data;
-    }
-}

+ 0 - 11
tests/browser-tests/Repositories/User.php

@@ -1,11 +0,0 @@
-<?php
-
-namespace Tests\Repositories;
-
-use Dcat\Admin\Repositories\EloquentRepository;
-use Tests\Models\User as Model;
-
-class User extends EloquentRepository
-{
-    protected $eloquentClass = Model::class;
-}

+ 0 - 7
tests/browser-tests/TestCase.php

@@ -1,7 +0,0 @@
-<?php
-
-namespace Tests;
-
-abstract class TestCase extends DuskTestCase
-{
-}

BIN
tests/browser-tests/resources/assets/test.jpg


+ 0 - 381
tests/browser-tests/resources/config/admin.php

@@ -1,381 +0,0 @@
-<?php
-
-return [
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin name
-    |--------------------------------------------------------------------------
-    |
-    | This value is the name of dcat-admin, This setting is displayed on the
-    | login page.
-    |
-    */
-    'name' => 'Dcat Admin',
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin logo
-    |--------------------------------------------------------------------------
-    |
-    | The logo of all admin pages. You can also set it as an image by using a
-    | `img` tag, eg '<img src="http://logo-url" alt="Admin logo">'.
-    |
-    */
-    'logo' => '<span>Dcat</span> Admin',
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin mini logo
-    |--------------------------------------------------------------------------
-    |
-    | The logo of all admin pages when the sidebar menu is collapsed. You can
-    | also set it as an image by using a `img` tag, eg
-    | '<img src="http://logo-url" alt="Admin logo">'.
-    |
-    */
-    'logo-mini' => 'Da',
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin route settings
-    |--------------------------------------------------------------------------
-    |
-    | The routing configuration of the admin page, including the path prefix,
-    | the controller namespace, and the default middleware. If you want to
-    | access through the root path, just set the prefix to empty string.
-    |
-    */
-    'route' => [
-
-        'prefix' => env('ADMIN_ROUTE_PREFIX', 'admin'),
-
-        'namespace' => 'App\\Admin\\Controllers',
-
-        'middleware' => ['web', 'admin'],
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin install directory
-    |--------------------------------------------------------------------------
-    |
-    | The installation directory of the controller and routing configuration
-    | files of the administration page. The default is `app/Admin`, which must
-    | be set before running `artisan admin::install` to take effect.
-    |
-    */
-    'directory' => app_path('Admin'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin html title
-    |--------------------------------------------------------------------------
-    |
-    | Html title for all pages.
-    |
-    */
-    'title' => 'Admin',
-
-    /*
-    |--------------------------------------------------------------------------
-    | Assets hostname
-    |--------------------------------------------------------------------------
-    |
-   */
-    'assets_server' => env('ADMIN_ASSETS_SERVER'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Cdn setting
-    |--------------------------------------------------------------------------
-    |
-   */
-    'cdn' => env('ADMIN_CDN', false),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Access via `https`
-    |--------------------------------------------------------------------------
-    |
-    | If your page is going to be accessed via https, set it to `true`.
-    |
-    */
-    'https' => env('ADMIN_HTTPS', false),
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin auth setting
-    |--------------------------------------------------------------------------
-    |
-    | Authentication settings for all admin pages. Include an authentication
-    | guard and a user provider setting of authentication driver.
-    |
-    | You can specify a controller for `login` `logout` and other auth routes.
-    |
-    */
-    'auth' => [
-        'enable' => true,
-
-        'controller' => Dcat\Admin\Controllers\AuthController::class,
-
-        'login_view' => 'admin::login',
-
-        'guard' => 'admin',
-
-        'guards' => [
-            'admin' => [
-                'driver'   => 'session',
-                'provider' => 'admin',
-            ],
-        ],
-
-        'providers' => [
-            'admin' => [
-                'driver' => 'eloquent',
-                'model'  => Dcat\Admin\Models\Administrator::class,
-            ],
-        ],
-
-        // Add "remember me" to login form
-        'remember' => true,
-
-        // All method to path like: auth/users/*/edit
-        // or specific method to path like: get:auth/users.
-        'except' => [
-            'auth/login',
-            'auth/logout',
-        ],
-
-    ],
-
-    'grid' => [
-
-        /*
-        |--------------------------------------------------------------------------
-        | The global Grid action display class.
-        |--------------------------------------------------------------------------
-        */
-        'grid_action_class' => Dcat\Admin\Grid\Displayers\DropdownActions::class,
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin helpers setting.
-    |--------------------------------------------------------------------------
-    */
-    'helpers' => [
-        'enable' => true,
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin permission setting
-    |--------------------------------------------------------------------------
-    |
-    | Permission settings for all admin pages.
-    |
-    */
-    'permission' => [
-        // Whether enable permission.
-        'enable' => true,
-
-        // All method to path like: auth/users/*/edit
-        // or specific method to path like: get:auth/users.
-        'except' => [
-            '/',
-            'auth/login',
-            'auth/logout',
-            'auth/setting',
-        ],
-
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin menu setting
-    |--------------------------------------------------------------------------
-    |
-    */
-    'menu' => [
-        'cache' => [
-            // enable cache or not
-            'enable' => true,
-            'store'  => 'file',
-        ],
-
-        // Whether enable menu bind to a permission.
-        'bind_permission' => true,
-
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin upload setting
-    |--------------------------------------------------------------------------
-    |
-    | File system configuration for form upload files and images, including
-    | disk and upload path.
-    |
-    */
-    'upload' => [
-
-        // Disk in `config/filesystem.php`.
-        'disk' => 'admin',
-
-        // Image and file upload path under the disk above.
-        'directory' => [
-            'image' => 'images',
-            'file'  => 'files',
-        ],
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | dcat-admin database settings
-    |--------------------------------------------------------------------------
-    |
-    | Here are database settings for dcat-admin builtin model & tables.
-    |
-    */
-    'database' => [
-
-        // Database connection for following tables.
-        'connection' => '',
-
-        // User tables and model.
-        'users_table' => 'admin_users',
-        'users_model' => Dcat\Admin\Models\Administrator::class,
-
-        // Role table and model.
-        'roles_table' => 'admin_roles',
-        'roles_model' => Dcat\Admin\Models\Role::class,
-
-        // Permission table and model.
-        'permissions_table' => 'admin_permissions',
-        'permissions_model' => Dcat\Admin\Models\Permission::class,
-
-        // Menu table and model.
-        'menu_table' => 'admin_menu',
-        'menu_model' => Dcat\Admin\Models\Menu::class,
-
-        // Pivot table for table above.
-        'operation_log_table'    => 'admin_operation_log',
-        'user_permissions_table' => 'admin_user_permissions',
-        'role_users_table'       => 'admin_role_users',
-        'role_permissions_table' => 'admin_role_permissions',
-        'role_menu_table'        => 'admin_role_menu',
-        'permission_menu_table'  => 'admin_permission_menu',
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | User operation log setting
-    |--------------------------------------------------------------------------
-    |
-    | By setting this option to open or close operation log in dcat-admin.
-    |
-    */
-    'operation_log' => [
-
-        'enable' => true,
-
-        // Only logging allowed methods in the list
-        'allowed_methods' => ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH'],
-
-        // Routes that will not log to database.
-        // All method to path like: auth/logs/*/edit
-        // or specific method to path like: get:auth/logs.
-        'except' => [
-            'auth/logs*',
-        ],
-    ],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Admin map field provider
-    |--------------------------------------------------------------------------
-    |
-    | Supported: "tencent", "google", "yandex".
-    |
-    */
-    'map_provider' => 'google',
-
-    /*
-    |--------------------------------------------------------------------------
-    | Application Skin
-    |--------------------------------------------------------------------------
-    |
-    | This value is the skin of admin pages.
-    | @see https://adminlte.io/docs/2.4/layout
-    |
-    | Supported:
-    |    "skin-blue-light", "skin-black", "skin-black-light".
-    |
-    */
-    'skin' => 'skin-black',
-
-    /*
-    |--------------------------------------------------------------------------
-    | Application layout
-    |--------------------------------------------------------------------------
-    |
-    | This value is the layout of admin pages.
-    | @see https://adminlte.io/docs/2.4/layout
-    |
-    | Supported: "fixed", "layout-boxed", "layout-top-nav", "sidebar-collapse",
-    | "sidebar-mini".
-    |
-    */
-    'layout' => ['sidebar-mini', 'fixed'],
-
-    /*
-    |--------------------------------------------------------------------------
-    | Login page background image
-    |--------------------------------------------------------------------------
-    |
-    | This value is used to set the background image of login page.
-    |
-    */
-    'login_background_image' => '',
-
-    /*
-    |--------------------------------------------------------------------------
-    | The exception handler class
-    |--------------------------------------------------------------------------
-    |
-    */
-    'exception_handler' => \Dcat\Admin\Exception\Handler::class,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Enable default breadcrumb
-    |--------------------------------------------------------------------------
-    |
-    | Whether enable default breadcrumb for every page content.
-    */
-    'enable_default_breadcrumb' => true,
-
-    /*
-    |--------------------------------------------------------------------------
-    | Extension Directory
-    |--------------------------------------------------------------------------
-    |
-    | When you use command `php artisan admin:extend` to generate extensions,
-    | the extension files will be generated in this directory.
-    */
-    'extension_dir' => app_path('Admin/Extensions'),
-
-    /*
-    |--------------------------------------------------------------------------
-    | Settings for extensions.
-    |--------------------------------------------------------------------------
-    |
-    | You can find all available extensions here
-    | https://github.com/dcat-admin-extensions.
-    |
-    */
-    'extensions' => [
-
-    ],
-];

+ 0 - 95
tests/browser-tests/resources/config/filesystems.php

@@ -1,95 +0,0 @@
-<?php
-
-return [
-
-    /*
-    |--------------------------------------------------------------------------
-    | Default Filesystem Disk
-    |--------------------------------------------------------------------------
-    |
-    | Here you may specify the default filesystem disk that should be used
-    | by the framework. A "local" driver, as well as a variety of cloud
-    | based drivers are available for your choosing. Just store away!
-    |
-    | Supported: "local", "ftp", "s3", "rackspace"
-    |
-    */
-
-    'default' => 'public',
-
-    /*
-    |--------------------------------------------------------------------------
-    | Default Cloud Filesystem Disk
-    |--------------------------------------------------------------------------
-    |
-    | Many applications store files both locally and in the cloud. For this
-    | reason, you may specify a default "cloud" driver here. This driver
-    | will be bound as the Cloud disk implementation in the container.
-    |
-    */
-
-    'cloud' => 's3',
-
-    /*
-    |--------------------------------------------------------------------------
-    | Filesystem Disks
-    |--------------------------------------------------------------------------
-    |
-    | Here you may configure as many filesystem "disks" as you wish, and you
-    | may even configure multiple disks of the same driver. Defaults have
-    | been setup for each driver as an example of the required options.
-    |
-    */
-
-    'disks' => [
-
-        'local' => [
-            'driver' => 'local',
-            'root'   => storage_path('app'),
-        ],
-
-        'public' => [
-            'driver'     => 'local',
-            'root'       => storage_path('app/public'),
-            'visibility' => 'public',
-        ],
-
-        's3' => [
-            'driver' => 's3',
-            'key'    => 'your-key',
-            'secret' => 'your-secret',
-            'region' => 'your-region',
-            'bucket' => 'your-bucket',
-        ],
-
-        'admin' => [
-            'driver'     => 'local',
-            'root'       => public_path('uploads'),
-            'visibility' => 'public',
-            'url'        => 'http://localhost:8000/uploads/',
-        ],
-
-        'qiniu' => [
-            'driver'  => 'qiniu',
-            'domains' => [
-                'default' => 'of8kfibjo.bkt.clouddn.com', //你的七牛域名
-                'https'   => 'dn-yourdomain.qbox.me',         //你的HTTPS域名
-                'custom'  => 'static.abc.com',                //你的自定义域名
-            ],
-            'access_key' => 'tIyz5h5IDT1-PQS22iRrI4dCBEktWj76O-ls856K',  //AccessKey
-            'secret_key' => 'TCU2GuSlbzxKgnixYO_-pdo4odbXttm1RNNvEwSD',  //SecretKey
-            'bucket'     => 'laravel',  //Bucket名字
-            'notify_url' => '',  //持久化处理回调地址
-        ],
-
-        'aliyun' => [
-            'driver'     => 'oss',
-            'access_id'  => 'LTAIsOQNIDQN78Jr',
-            'access_key' => 'ChsYewaCxm1mi7AIBPRniuncEbFHNO',
-            'bucket'     => 'laravel-admin',
-            'endpoint'   => 'oss-cn-shanghai.aliyuncs.com',
-        ],
-
-    ],
-
-];

BIN
tests/browser-tests/resources/drivers/chromedriver-linux


BIN
tests/browser-tests/resources/drivers/chromedriver-mac


BIN
tests/browser-tests/resources/drivers/chromedriver-win.exe


+ 0 - 15
tests/browser-tests/resources/lang/en/global.php

@@ -1,15 +0,0 @@
-<?php
-
-return [
-    'fields' => [
-        'id' => 'ID',
-
-        'profile' => [
-            'address' => '地址',
-        ],
-
-    ],
-    'labels' => [
-        'List' => '列表',
-    ],
-];

+ 0 - 16
tests/browser-tests/resources/lang/en/user.php

@@ -1,16 +0,0 @@
-<?php
-
-return [
-    'fields' => [
-        'username' => '用户名',
-        'email'    => '邮箱',
-
-        'profile' => [
-            'postcode' => '邮政编码',
-        ],
-
-    ],
-    'labels' => [
-        'user' => '用户',
-    ],
-];

+ 0 - 98
tests/browser-tests/resources/migrations/2016_11_22_093148_create_test_tables.php

@@ -1,98 +0,0 @@
-<?php
-
-use Illuminate\Database\Migrations\Migration;
-use Illuminate\Database\Schema\Blueprint;
-
-class CreateTestTables extends Migration
-{
-    /**
-     * Run the migrations.
-     *
-     * @return void
-     */
-    public function up()
-    {
-        Schema::create('test_images', function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('image1');
-            $table->string('image2');
-            $table->string('image3');
-            $table->string('image4');
-            $table->string('image5');
-            $table->string('image6');
-            $table->timestamps();
-        });
-
-        Schema::create('test_multiple_images', function (Blueprint $table) {
-            $table->increments('id');
-            $table->text('pictures');
-            $table->timestamps();
-        });
-
-        Schema::create('test_files', function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('file1');
-            $table->string('file2');
-            $table->string('file3');
-            $table->string('file4');
-            $table->string('file5');
-            $table->string('file6');
-            $table->timestamps();
-        });
-
-        Schema::create('test_users', function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('username');
-            $table->string('email');
-            $table->string('mobile')->nullable();
-            $table->string('avatar')->nullable();
-            $table->string('password');
-            $table->timestamps();
-        });
-
-        Schema::create('test_user_profiles', function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('user_id');
-            $table->string('first_name')->nullable();
-            $table->string('last_name')->nullable();
-            $table->string('postcode')->nullable();
-            $table->string('address')->nullable();
-            $table->string('latitude')->nullable();
-            $table->string('longitude')->nullable();
-            $table->string('color')->nullable();
-            $table->timestamp('start_at')->nullable();
-            $table->timestamp('end_at')->nullable();
-
-            $table->timestamps();
-        });
-
-        Schema::create('test_tags', function (Blueprint $table) {
-            $table->increments('id');
-            $table->string('name');
-            $table->timestamps();
-        });
-
-        Schema::create('test_user_tags', function (Blueprint $table) {
-            $table->integer('user_id');
-            $table->integer('tag_id');
-            $table->index(['user_id', 'tag_id']);
-            $table->timestamps();
-        });
-    }
-
-    /**
-     * Reverse the migrations.
-     *
-     * @return void
-     */
-    public function down()
-    {
-        Schema::dropIfExists('test_images');
-        Schema::dropIfExists('test_multiple_images');
-        Schema::dropIfExists('test_files');
-        Schema::dropIfExists('test_users');
-        Schema::dropIfExists('test_user_profiles');
-        Schema::dropIfExists('test_tags');
-        Schema::dropIfExists('test_user_tags');
-    }
-}

+ 0 - 21
tests/browser-tests/resources/seeds/UserTableSeeder.php

@@ -1,21 +0,0 @@
-<?php
-
-namespace Tests\Seeds;
-
-use Tests\Models\Profile;
-use Tests\Models\Tag;
-use Tests\Models\User;
-use Illuminate\Database\Seeder;
-
-class UserTableSeeder extends Seeder
-{
-    public function run()
-    {
-        factory(User::class, 50)
-            ->create()
-            ->each(function ($u) {
-                $u->profile()->save(factory(Profile::class)->make());
-                $u->tags()->saveMany(factory(Tag::class, 5)->make());
-            });
-    }
-}

+ 0 - 36
tests/browser-tests/resources/seeds/factory.php

@@ -1,36 +0,0 @@
-<?php
-
-use Faker\Generator as Faker;
-use Illuminate\Database\Eloquent\Factory;
-
-$factory = app(Factory::class);
-
-$factory->define(\Tests\Models\User::class, function (Faker $faker) {
-    return [
-        'username' => $faker->userName,
-        'email'    => $faker->email,
-        'mobile'   => $faker->phoneNumber,
-        'avatar'   => $faker->imageUrl(),
-        'password' => bcrypt('123456'),
-    ];
-});
-
-$factory->define(\Tests\Models\Profile::class, function (Faker $faker) {
-    return [
-        'first_name' => $faker->firstName,
-        'last_name'  => $faker->lastName,
-        'postcode'   => $faker->postcode,
-        'address'    => $faker->address,
-        'latitude'   => $faker->latitude,
-        'longitude'  => $faker->longitude,
-        'color'      => $faker->hexColor,
-        'start_at'   => $faker->dateTime,
-        'end_at'     => $faker->dateTime,
-    ];
-});
-
-$factory->define(\Tests\Models\Tag::class, function (Faker $faker) {
-    return [
-        'name' => $faker->word,
-    ];
-});

+ 0 - 1
tests/browser-tests/resources/views/test.blade.php

@@ -1 +0,0 @@
-<h1>Hello world</h1>

+ 0 - 10
tests/browser-tests/routes.php

@@ -1,10 +0,0 @@
-<?php
-
-Route::group([
-    'prefix'     => config('admin.route.prefix'),
-    'namespace'  => 'Tests\Controllers',
-    'middleware' => ['web', 'admin'],
-], function ($router) {
-    $router->resource('tests/users', UserController::class);
-    $router->resource('tests/report', ReportController::class);
-});

+ 0 - 0
tests/browser-tests/helpers.php → tests/helpers.php


+ 3 - 3
tests/resources/seeds/UserTableSeeder.php

@@ -2,9 +2,9 @@
 
 namespace Tests\Seeds;
 
-use Dcat\Admin\Tests\Models\Profile;
-use Dcat\Admin\Tests\Models\Tag;
-use Dcat\Admin\Tests\Models\User;
+use Tests\Models\Profile;
+use Tests\Models\Tag;
+use Tests\Models\User;
 use Illuminate\Database\Seeder;
 
 class UserTableSeeder extends Seeder

+ 3 - 3
tests/resources/seeds/factory.php

@@ -5,7 +5,7 @@ use Illuminate\Database\Eloquent\Factory;
 
 $factory = app(Factory::class);
 
-$factory->define(\Dcat\Admin\Tests\Models\User::class, function (Faker $faker) {
+$factory->define(\Tests\Models\User::class, function (Faker $faker) {
     return [
         'username' => $faker->userName,
         'email'    => $faker->email,
@@ -15,7 +15,7 @@ $factory->define(\Dcat\Admin\Tests\Models\User::class, function (Faker $faker) {
     ];
 });
 
-$factory->define(\Dcat\Admin\Tests\Models\Profile::class, function (Faker $faker) {
+$factory->define(\Tests\Models\Profile::class, function (Faker $faker) {
     return [
         'first_name' => $faker->firstName,
         'last_name'  => $faker->lastName,
@@ -29,7 +29,7 @@ $factory->define(\Dcat\Admin\Tests\Models\Profile::class, function (Faker $faker
     ];
 });
 
-$factory->define(\Dcat\Admin\Tests\Models\Tag::class, function (Faker $faker) {
+$factory->define(\Tests\Models\Tag::class, function (Faker $faker) {
     return [
         'name' => $faker->word,
     ];

+ 4 - 6
tests/routes.php

@@ -1,12 +1,10 @@
 <?php
 
-use Illuminate\Routing\Router;
-
 Route::group([
     'prefix'     => config('admin.route.prefix'),
-    'namespace'  => 'Dcat\Admin\Tests\Controllers',
+    'namespace'  => 'Tests\Controllers',
     'middleware' => ['web', 'admin'],
-], function (Router $router) {
-    $router->resource('tests/users', 'UserController');
-    $router->resource('tests/report', 'ReportController');
+], function ($router) {
+    $router->resource('tests/users', UserController::class);
+    $router->resource('tests/report', ReportController::class);
 });