Skip to content

Commit

Permalink
Merge branch '1.x' into generator-presets
Browse files Browse the repository at this point in the history
  • Loading branch information
crynobone authored Oct 15, 2023
2 parents 484ffd0 + 52d5f5d commit 3ed8a7a
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/FUNDING.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: crynobone
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
Expand All @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: crynobone
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ["https://paypal.me/crynobone"]
custom: # ["https://paypal.me/crynobone"]
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"require": {
"php": "^8.0",
"composer-runtime-api": "^2.2",
"illuminate/console": "^9.52.15 || ^10.23.0",
"illuminate/support": "^9.52.15 || ^10.23.0",
"illuminate/console": "^9.52.15 || ^10.26.0",
"illuminate/support": "^9.52.15 || ^10.26.0",
"laravel/tinker": "^2.8.2",
"orchestra/canvas": "dev-generator-presets as 8.12.0",
"orchestra/testbench-core": "^7.32.0 || ^8.12.0"
Expand All @@ -44,7 +44,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "0.4.x-dev"
"dev-master": "0.5.x-dev"
}
},
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions routes/workbench.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Orchestra\Workbench\Http\Controllers\WorkbenchController;

Route::group([
'prefix' => '_workbench',
'middleware' => 'web',
], static function (Router $router) {
$router->get(
'/', [WorkbenchController::class, 'start']
)->name('workbench.start');

$router->get(
'/login/{userId}/{guard?}', [WorkbenchController::class, 'login']
)->name('workbench.login');

$router->get(
'/logout/{guard?}', [WorkbenchController::class, 'logout']
)->name('workbench.logout');

$router->get(
'/user/{guard?}', [WorkbenchController::class, 'user']
)->name('workbench.user');
});
5 changes: 5 additions & 0 deletions src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ protected function prepareWorkbenchDirectories(Filesystem $filesystem, string $w
return "{$workbenchWorkingPath}/{$directory}";
})
);

$this->callSilently('make:seeder', [
'name' => 'DatabaseSeeder',
'--preset' => 'workbench',
]);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Console/stubs/testbench.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ providers: []
migrations:
- workbench/database/migrations

seeders: []
seeders:
- Workbench\Database\Seeders\DatabaseSeeder

workbench:
start: '/'
install: true
welcome: true
discovers:
web: false
api: false
commands: false
build: []
assets: []
sync: []
34 changes: 2 additions & 32 deletions src/WorkbenchServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Illuminate\Contracts\Events\Dispatcher as EventDispatcher;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Http\Kernel as HttpKernel;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Orchestra\Testbench\Contracts\Config;
use Orchestra\Testbench\Foundation\Events\ServeCommandEnded;
Expand Down Expand Up @@ -40,7 +38,8 @@ public function register(): void
*/
public function boot(): void
{
static::authenticationRoutes();
$this->loadRoutesFrom((string) realpath(__DIR__.'/../routes/workbench.php'));
$this->loadViewsFrom(Workbench::path('resources/views'), 'workbench');

$this->app->make(HttpKernel::class)->pushMiddleware(Http\Middleware\CatchDefaultRoute::class);

Expand All @@ -63,33 +62,4 @@ public function boot(): void
Workbench::discover($app);
});
}

/**
* Provide the authentication routes for Testbench.
*
* @return void
*/
public static function authenticationRoutes()
{
Route::group(array_filter([
'prefix' => '_workbench',
'middleware' => 'web',
]), static function (Router $router) {
$router->get(
'/', [Http\Controllers\WorkbenchController::class, 'start']
)->name('workbench.start');

$router->get(
'/login/{userId}/{guard?}', [Http\Controllers\WorkbenchController::class, 'login']
)->name('workbench.login');

$router->get(
'/logout/{guard?}', [Http\Controllers\WorkbenchController::class, 'logout']
)->name('workbench.logout');

$router->get(
'/user/{guard?}', [Http\Controllers\WorkbenchController::class, 'user']
)->name('workbench.user');
});
}
}
32 changes: 8 additions & 24 deletions tests/Http/Controllers/WorkbenchControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ protected function getPackageProviders($app)
];
}

/**
* @test
*/
/** @test */
public function it_can_get_current_user_information()
{
$user = UserFactory::new()->create();
Expand All @@ -78,9 +76,7 @@ public function it_can_get_current_user_information()
]);
}

/**
* @test
*/
/** @test */
public function it_can_get_current_user_information_without_authenticated_user_return_empty_array()
{
$user = UserFactory::new()->create();
Expand All @@ -91,9 +87,7 @@ public function it_can_get_current_user_information_without_authenticated_user_r
$response->assertOk()->assertExactJson([]);
}

/**
* @test
*/
/** @test */
public function it_can_authenticate_a_user()
{
$user = UserFactory::new()->create();
Expand All @@ -107,9 +101,7 @@ public function it_can_authenticate_a_user()
->assertAuthenticatedAs($user);
}

/**
* @test
*/
/** @test */
public function it_can_authenticate_a_user_using_email()
{
$user = UserFactory::new()->create();
Expand All @@ -123,9 +115,7 @@ public function it_can_authenticate_a_user_using_email()
->assertAuthenticatedAs($user);
}

/**
* @test
*/
/** @test */
public function it_can_deauthenticate_a_user()
{
$user = UserFactory::new()->create();
Expand All @@ -139,9 +129,7 @@ public function it_can_deauthenticate_a_user()
$this->assertGuest('web');
}

/**
* @test
*/
/** @test */
public function it_can_automatically_authenticate_a_user()
{
$user = UserFactory::new()->create();
Expand All @@ -158,9 +146,7 @@ public function it_can_automatically_authenticate_a_user()
->assertAuthenticatedAs($user);
}

/**
* @test
*/
/** @test */
public function it_can_automatically_authenticate_a_user_using_email()
{
$user = UserFactory::new()->create();
Expand All @@ -177,9 +163,7 @@ public function it_can_automatically_authenticate_a_user_using_email()
->assertAuthenticatedAs($user);
}

/**
* @test
*/
/** @test */
public function it_can_automatically_deauthenticate_a_user()
{
$user = UserFactory::new()->create();
Expand Down
16 changes: 4 additions & 12 deletions tests/Http/Middleware/CatchDefaultRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ protected function getPackageProviders($app)
];
}

/**
* @test
*/
/** @test */
public function it_would_redirect_to_workbench_path()
{
$user = UserFactory::new()->create();
Expand All @@ -75,9 +73,7 @@ public function it_would_redirect_to_workbench_path()
->assertRedirect('/_workbench');
}

/**
* @test
*/
/** @test */
public function it_would_show_default_page()
{
$this->instance(ConfigContract::class, new Config([
Expand All @@ -102,9 +98,7 @@ public function it_would_show_default_page()
->assertOk();
}

/**
* @test
*/
/** @test */
public function it_would_not_redirect_to_workbench_path_if_configuration_doesnt_requires_it()
{
$this->instance(ConfigContract::class, new Config([
Expand All @@ -129,9 +123,7 @@ public function it_would_not_redirect_to_workbench_path_if_configuration_doesnt_
->assertNotFound();
}

/**
* @test
*/
/** @test */
public function it_would_not_redirect_to_workbench_path_on_path_other_than_root()
{
$user = UserFactory::new()->create();
Expand Down
Empty file.
16 changes: 16 additions & 0 deletions workbench/database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Workbench\Database\Seeders;

use Illuminate\Database\Seeder;

class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
//
}
}

0 comments on commit 3ed8a7a

Please sign in to comment.