Skip to content

Commit

Permalink
tests and event dispatcher test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Nov 16, 2024
1 parent 56e475c commit c66d964
Show file tree
Hide file tree
Showing 9 changed files with 474 additions and 507 deletions.
63 changes: 63 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions app/Core/Bootstrap/SetRequestForConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,15 @@ public function bootstrap(Application $app)
], $server);
}

if(! defined('BASE_URL')) {
define('BASE_URL', $uri);
}

//IMPORTANT: We can't use the native laravel bootstrapper for this because they inject Illuminate\Http\Request
//And we need CliRequest
$app->instance('request', CliRequest::create(
$uri, 'GET', [], [], [], $server
));

}
}
4 changes: 4 additions & 0 deletions app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ public static function add_event_listener(
string|callable|object $handler,
int $priority = 10
): void {

//Some backwards compatibility rules
$eventName = str_replace("leantime.core.template.tpl", "leantime.*", $eventName);

if (! array_key_exists($eventName, self::$eventRegistry)) {
self::$eventRegistry[$eventName] = [];
}
Expand Down
6 changes: 3 additions & 3 deletions app/Core/Providers/Views.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private function discoverComposerPaths()
if ($plugin->format === 'phar') {
$pharPath = APP_ROOT.'/app/Plugins/'.$plugin->foldername.'/'.$plugin->foldername.'.phar';

if (!file_exists($pharPath)) {
if (! file_exists($pharPath)) {
return [];
}

Expand All @@ -269,7 +269,7 @@ private function discoverComposerPaths()
$p = new \Phar($composerPath, 0);
$paths = collect(new \RecursiveIteratorIterator($p));

foreach($paths as $path) {
foreach ($paths as $path) {
$something = $path;
$composers[] = 'Plugins/'.$plugin->foldername.'/Composers/'.$path->getFileName();
}
Expand All @@ -281,7 +281,7 @@ private function discoverComposerPaths()
}
}

return glob($basePath.'/Composers/*.php') ?: [];
return glob(APP_ROOT.'app/Views/Composers/*.php') ?: [];
})
->flatten();

Expand Down
27 changes: 27 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Leantime\Core\Support\FromFormat;
use Symfony\Component\HttpFoundation\RedirectResponse;


if (! function_exists('__')) {
/**
* Translate a string.
Expand Down Expand Up @@ -206,3 +207,29 @@ function get_domain_key()
}

}

if (! function_exists('mix')) {
/**
* Get the path to a versioned Mix file. Customized for Leantime.
*
* @param string $path
* @param string $manifestDirectory
* @return Mix|string
*
* @throws BindingResolutionException
*/
function mix(string $path = '', string $manifestDirectory = ''): \Leantime\Core\Support\Mix|string
{
if (! ($app = app())->bound(\Leantime\Core\Support\Mix::class)) {
$app->instance(\Leantime\Core\Support\Mix::class, new \Leantime\Core\Support\Mix());
}

$mix = $app->make(\Leantime\Core\Support\Mix::class);

if (empty($path)) {
return $mix;
}

return $mix($path, $manifestDirectory);
}
}
3 changes: 3 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

define('RESTRICTED', true);

/* Load Leantime helper functions before laravel */
require __DIR__.'/../app/helpers.php';

require __DIR__.'/../vendor/autoload.php';

//Get the application once.
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
define('DEV_ROOT', PROJECT_ROOT.'.dev/');

$app = require __DIR__.'/../../bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();
$app->make(\Leantime\Core\Console\ConsoleKernel::class)->bootstrap();

$bootstrapper = get_class(new class
{
Expand Down
Loading

0 comments on commit c66d964

Please sign in to comment.