jqh 5 år sedan
förälder
incheckning
ff7c95deb3

+ 1 - 0
src/AdminServiceProvider.php

@@ -30,6 +30,7 @@ class AdminServiceProvider extends ServiceProvider
         Console\FormCommand::class,
         Console\ActionCommand::class,
         Console\MenuCacheCommand::class,
+        Console\Tests\InstallCommand::class,
     ];
 
     /**

+ 46 - 0
src/Console/Tests/InstallCommand.php

@@ -0,0 +1,46 @@
+<?php
+
+namespace Dcat\Admin\Console\Tests;
+
+use Illuminate\Console\Command;
+use Illuminate\Filesystem\Filesystem;
+
+class InstallCommand extends Command
+{
+    protected $signature = 'admin:tests:install';
+
+    protected $description = 'Install the admin tests package';
+
+    /**
+     * @var Filesystem
+     */
+    protected $files;
+
+    protected $directory;
+
+    public function handle()
+    {
+        $this->files = app('files');
+
+        $this->initTestsDirectory();
+
+        $this->files->link(realpath(__DIR__.'/../../../tests'), $this->directory);
+
+        $this->info('The [tests/] directory has been linked.');
+    }
+
+    protected function initTestsDirectory()
+    {
+        $dir = realpath(__DIR__.'/../../../vendor/laravel/laravel/tests');
+        if ($this->files->isDirectory($dir)) {
+            $this->directory = $dir;
+
+            $this->files->deleteDirectory($this->directory);
+            $this->files->makeDirectory($this->directory);
+
+            return;
+        }
+
+        $this->directory = base_path();
+    }
+}

+ 0 - 25
tests/Browser/LoginTest.php

@@ -1,25 +0,0 @@
-<?php
-
-namespace Dcat\Admin\Tests\Browser;
-
-use Laravel\Dusk\Browser;
-use Dcat\Admin\Tests\DuskTestCase;
-
-/**
- * @group login
- */
-class LoginTest extends DuskTestCase
-{
-    /**
-     * A Dusk test example.
-     *
-     * @return void
-     */
-    public function testExample()
-    {
-        $this->browse(function (Browser $browser) {
-            $browser->visit('/admin')
-                ->assertSee('Dcat Admin');
-        });
-    }
-}

+ 13 - 5
tests/artisan

@@ -32,16 +32,24 @@ $app = require_once __DIR__.'/../vendor/laravel/laravel/bootstrap/app.php';
 
 $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
 );
 
-$app['env'] = false;
-
-$app->register(\Laravel\Dusk\DuskServiceProvider::class);
-$app->register(\BeyondCode\DuskDashboard\DuskDashboardServiceProvider::class);
-
 /*
 |--------------------------------------------------------------------------
 | Shutdown The Application

BIN
tests/resources/drivers/chromedriver-linux


BIN
tests/resources/drivers/chromedriver-mac


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