Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Dec 9, 2023
1 parent 1ae5090 commit 7f04bb3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 27 deletions.
10 changes: 2 additions & 8 deletions src/Concerns/CreatesApplication.php
Expand Up @@ -389,14 +389,8 @@ protected function resolveApplicationBootstrappers($app)
/** @phpstan-ignore-next-line */
$this->parseTestMethodAnnotations($app, 'define-env');
},
attribute: function () use ($app) {
/** @phpstan-ignore-next-line */
$this->parseTestMethodAttributes($app, DefineEnvironment::class);
},
pest: function () use ($app) {
/** @phpstan-ignore-next-line */
$this->defineEnvironmentUsingPest($app);
}
attribute: fn () => $this->parseTestMethodAttributes($app, DefineEnvironment::class), /** @phpstan-ignore-line */
pest: fn () => $this->defineEnvironmentUsingPest($app), /** @phpstan-ignore-line */
);

$this->resolveApplicationRateLimiting($app);
Expand Down
26 changes: 15 additions & 11 deletions src/Concerns/HandlesDatabases.php
Expand Up @@ -48,16 +48,21 @@ protected function setUpDatabaseRequirements(Closure $callback): void
$attributeCallbacks = $this->resolveTestbenchTestingFeature(
default: function () {
$this->defineDatabaseMigrations();

$this->beforeApplicationDestroyed(function () {
$this->destroyDatabaseMigrations();
});
},
annotation: function () use ($app) {
$this->parseTestMethodAnnotations($app, 'define-db');
},
attribute: function () use ($app) {
return $this->parseTestMethodAttributes($app, DefineDatabase::class);
},
annotation: fn () => $this->parseTestMethodAnnotations($app, 'define-db'),
attribute: fn () => $this->parseTestMethodAttributes($app, DefineDatabase::class),
pest: function () {
/** @phpstan-ignore-next-line */
$this->defineDatabaseMigrationsUsingPest();

$this->beforeApplicationDestroyed(function () {
/** @phpstan-ignore-next-line */
$this->destroyDatabaseMigrationsUsingPest();
});
}
)->get('attribute');

Expand All @@ -69,11 +74,10 @@ protected function setUpDatabaseRequirements(Closure $callback): void
});
}

$this->defineDatabaseSeeders();

$this->beforeApplicationDestroyed(function () {
$this->destroyDatabaseMigrations();
});
$this->resolveTestbenchTestingFeature(
default: fn () => $this->defineDatabaseSeeders(),
pest: fn () => $this->defineDatabaseSeedersUsingPest() /** @phpstan-ignore-line */
);
}

/**
Expand Down
12 changes: 4 additions & 8 deletions src/Concerns/HandlesRoutes.php
Expand Up @@ -34,14 +34,10 @@ protected function setUpApplicationRoutes($app): void
$router->middleware('web')
->group(fn ($router) => $this->defineWebRoutes($router));
},
annotation: function () use ($app, $router) {
$this->parseTestMethodAnnotations($app, 'define-route', function ($method) use ($router) {
$this->{$method}($router);
});
},
attribute: function () use ($app) {
$this->parseTestMethodAttributes($app, DefineRoute::class);
},
annotation: fn () => $this->parseTestMethodAnnotations($app, 'define-route', function ($method) use ($router) {
$this->{$method}($router);
}),
attribute: fn () => $this->parseTestMethodAttributes($app, DefineRoute::class),
pest: function () use ($router) {
/** @phpstan-ignore-next-line */
$this->defineRoutesUsingPest($router);
Expand Down

0 comments on commit 7f04bb3

Please sign in to comment.