Skip to content

Commit

Permalink
[PLA-1693] Improved local testing. (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
v16Studios authored and leonardocustodio committed Jul 11, 2024
1 parent 2ec0a4d commit 6a391d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/BeamServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Enjin\Platform\Events\Substrate\MultiTokens\TokenBurned;
use Enjin\Platform\Events\Substrate\MultiTokens\TokenDestroyed;
use Enjin\Platform\Events\Substrate\MultiTokens\TokenTransferred;
use Enjin\Platform\Beam\Package as BeamPackage;
use Illuminate\Support\Facades\Event;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand Down Expand Up @@ -49,6 +50,10 @@ public function configurePackage(Package $package): void
*/
public function register()
{
if (app()->runningUnitTests()) {
BeamPackage::setPath(__DIR__ . '/..');
}

parent::register();

Event::listen(TransactionUpdated::class, UpdateClaimStatus::class);
Expand Down
15 changes: 2 additions & 13 deletions src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@
namespace Enjin\Platform\Beam;

use Enjin\Platform\Beam\Enums\BeamRoute;
use Enjin\Platform\Package as CorePackage;

class Package
class Package extends CorePackage
{
/**
* Get the composer autoloader for auto-bootstrapping services.
*/
public static function getAutoloader(): string
{
// TODO: It doesn't work on a real laravel env if using the below
// $loader = require realpath(__DIR__ . 'vendor/autoload.php');
// TODO: If using the below it doesn't work on testbench, neither composer will install
// $loader = require app()->basePath('../../../autoload.php')
return app()->runningUnitTests() ? require app()->basePath('../../../autoload.php') : require app()->basePath('vendor/autoload.php');
}

/**
* Get any routes that have been set up for this package.
*/
Expand Down

0 comments on commit 6a391d9

Please sign in to comment.