Skip to content

Commit

Permalink
Make autoloader service optional
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Jan 29, 2022
1 parent 1e9b93a commit e53face
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ protected function prepareToRun(array $options = []) : ?Router
throw new LogicException('App is already running');
}
static::$isRunning = true;
$options['autoloader'] ??= 'default';
if ( ! isset($options['autoloader'])) {
$configs = static::config()->getInstances('autoloader');
$options['autoloader'] = isset($configs['default']) ? 'default' : false;
}
if ($options['autoloader'] !== false) {
static::autoloader($options['autoloader']);
}
Expand Down
13 changes: 13 additions & 0 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@ public function testRunHttp() : void
self::assertTrue(App::response()->isSent());
}

public function testRunHttpWithOptions() : void
{
App::setIsCli(false);
\ob_start();
$this->app->runHttp([
'autoloader' => 'default',
'exceptions' => 'default',
'router' => 'default',
]);
\ob_end_clean();
self::assertTrue(App::response()->isSent());
}

public function testRunHttpWithInvalidRouterFile() : void
{
$file = __DIR__ . '/foobar.php';
Expand Down

0 comments on commit e53face

Please sign in to comment.