jqh 5 years ago
parent
commit
43e800436e

+ 1 - 1
composer.json

@@ -19,7 +19,7 @@
         "spatie/eloquent-sortable": "3.*"
     },
     "require-dev": {
-        "laravel/browser-kit-testing": "~5.1",
+        "laravel/dusk": "~5.9",
         "friendsofphp/php-cs-fixer": "^2.15",
         "laravel/laravel": "~5.5|~6",
         "phpstan/phpstan": "^0.12.0",

+ 1 - 1
src/AdminServiceProvider.php

@@ -90,7 +90,7 @@ class AdminServiceProvider extends ServiceProvider
 
         $this->commands($this->commands);
 
-        if (config('app.debug') && config('app.env') === 'local') {
+        if (config('app.debug')) {
             $this->commands($this->devCommands);
         }
     }

+ 1 - 1
src/Console/Development/LinkCommand.php

@@ -41,7 +41,7 @@ class LinkCommand extends Command
         if (is_dir($testsPath)) {
             $result = $this->ask("The [{$testsPath}] directory already exists, are you sure to delete it? [yes/no]");
 
-            if (strtolower($testsPath) !== 'yes') {
+            if (strtolower($result) !== 'yes') {
                 return;
             }
 

+ 9 - 10
tests/Browser/AuthTest.php

@@ -40,21 +40,20 @@ class AuthTest extends TestCase
                 ->type('username', $credentials['username'])
                 ->type('password', $credentials['password'])
                 ->press('Login')
+                ->waitForText(__('admin.login_successful'), 3)
                 ->assertPathIs(test_admin_path('/'))
                 ->assertSee('Administrator')
                 ->assertSee('Dashboard')
                 ->assertSee('Description...')
-                ->assertSee('Environment')
-                ->assertSee('PHP version')
-                ->assertSee('Laravel version')
-                ->assertSee('Extensions')
-                ->assertSee('Dependencies')
-                ->assertSee('php')
-                ->assertSee('laravel/framework');
+                ->assertSee('New Users')
+                ->assertSee('New Devices')
+                ->assertSee('Tickets')
+                ->assertSee(__('admin.documentation'))
+                ->assertSee(__('admin.extensions'))
+                ->assertSee(__('admin.demo'))
+                ->assertSee('GITHUB');
 
-                //->assertAuthenticated('admin');
-
-            $browser->within('.main-sidebar', function (Browser $browser) {
+            $browser->within('.main-menu', function (Browser $browser) {
                 $browser->assertSee('Admin')
                     ->clickLink('Admin')
                     ->waitForText('Users', 1)

+ 1 - 1
tests/Browser/IndexTest.php

@@ -30,7 +30,7 @@ class IndexTest extends TestCase
     {
         $this->browse(function (Browser $browser) {
             $browser->visit(test_admin_path('/'))
-                ->within('.main-sidebar', function (Browser $browser) {
+                ->within('.main-menu', function (Browser $browser) {
                     $browser
                         ->clickLink('Admin')
                         ->whenTextAvailable('Users', 2)

+ 33 - 33
tests/CreatesApplication.php

@@ -12,21 +12,15 @@ use Illuminate\Support\Facades\Schema;
 
 trait CreatesApplication
 {
-    /**
-     * Creates the application.
-     *
-     * @return \Illuminate\Foundation\Application
-     */
     public function createApplication()
     {
-        $app = require __DIR__.'/../bootstrap/app.php';
+        $app = require $this->getAppPath();
 
         $app->make(Kernel::class)->bootstrap();
 
         return $app;
     }
 
-
     protected function boot()
     {
         $this->config();
@@ -52,32 +46,6 @@ trait CreatesApplication
         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';
@@ -99,6 +67,38 @@ trait CreatesApplication
         }
     }
 
+    protected function getAppPath()
+    {
+        $path = __DIR__.'/../bootstrap/app.php';
+
+        if (! is_file($path)) {
+            $path = __DIR__.'/../../bootstrap/app.php';
+        }
+
+        return $path;
+    }
+
+    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');
+    }
+
+    public function migrateTestTables()
+    {
+        $fileSystem = new Filesystem();
+
+        $fileSystem->requireOnce(__DIR__.'/resources/migrations/2016_11_22_093148_create_test_tables.php');
+
+        (new \CreateTestTables())->up();
+    }
+
     /**
      * @return Administrator
      */