Skip to content

Commit

Permalink
tests(phpunit): fix phpunit tests related to base_path changes here : 4…
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelAlphonso committed Sep 14, 2022
1 parent b928fcd commit 64b146f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
4 changes: 3 additions & 1 deletion packages/app/tests/Charcoal/App/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ class AppTest extends AbstractTestCase
*/
public function setUp(): void
{
$config = new AppConfig();
$config = new AppConfig([
'base_path' => sys_get_temp_dir(),
]);
$container = new AppContainer([
'config' => $config
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function testConfigWithoutTypeThrowsException()

private function createAppConfig($defaults = null)
{
return new AppConfig($defaults);
return new AppConfig(array_replace(['base_path' => sys_get_temp_dir()], $defaults));
}

private function getContainer($defaults = null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ private function container()
$container['database'] = new PDO('sqlite::memory:');

$container['config'] = new AppConfig([
'base_path' => sys_get_temp_dir(),
'metadata' => [
'paths' => [],
],
Expand Down
25 changes: 6 additions & 19 deletions packages/view/src/Charcoal/View/AbstractLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,22 @@
*/
abstract class AbstractLoader implements LoaderInterface
{
/**
* @var string
*/
private $basePath = '';

/**
* @var string[]
*/
private $paths = [];

/**
* @var array
*/
private $dynamicTemplates = [];
private string $basePath = '';
private array $paths = [];
private array $dynamicTemplates = [];

/**
* The cache of searched template files.
*
* @var array
*/
private $fileCache = [];
private array $fileCache = [];

/**
* Default constructor, if none is provided by the concrete class implementations.
*
*
* @param array $data The class dependencies map.
* @param ?array $data The class dependencies map.
*/
public function __construct(array $data = null)
public function __construct(?array $data = null)
{
$this->setBasePath($data['base_path']);
$this->setPaths($data['paths']);
Expand Down

0 comments on commit 64b146f

Please sign in to comment.