Skip to content

Commit

Permalink
Merge pull request #1377 from brefphp/fix-local-invoke
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli authored Jan 8, 2023
2 parents a32ce26 + ad59000 commit e15a1b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Runtime/FileHandlerLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ class FileHandlerLocator implements ContainerInterface

public function __construct(?string $directory = null)
{
$this->directory = $directory ?: ($_SERVER['LAMBDA_TASK_ROOT'] ?? null);
$directory = $directory ?: ($_SERVER['LAMBDA_TASK_ROOT'] ?? null);

// When running locally (`serverless bref:local` CLI command) `LAMBDA_TASK_ROOT` is undefined
if (! $this->directory) {
$this->directory = getcwd();
}
$this->directory = $directory ?: getcwd();
}

/**
Expand Down
7 changes: 7 additions & 0 deletions tests/Runtime/FileHandlerLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ public function test expects file to return handler()

$locator->get('broken.php');
}

public function test accepts empty directory()
{
$locator = new FileHandlerLocator;

$this->assertTrue($locator->has('tests/BrefTest.php'));
}
}

0 comments on commit e15a1b1

Please sign in to comment.