Skip to content

Commit

Permalink
Removes CreatesApplication trait
Browse files Browse the repository at this point in the history
  • Loading branch information
nunomaduro committed Jan 3, 2024
1 parent 6d6009c commit 6fe6bb5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ use Laravel\BrowserKitTesting\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;

public $baseUrl = 'http://localhost';

// ...
Expand Down
22 changes: 18 additions & 4 deletions src/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace Laravel\BrowserKitTesting;

use Illuminate\Contracts\Console\Kernel;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\RefreshDatabase;
Expand All @@ -12,6 +14,7 @@
use Illuminate\Support\Facades\Facade;
use Mockery;
use PHPUnit\Framework\TestCase as BaseTestCase;
use RuntimeException;

abstract class TestCase extends BaseTestCase
{
Expand Down Expand Up @@ -55,11 +58,22 @@ abstract class TestCase extends BaseTestCase
/**
* Creates the application.
*
* Needs to be implemented by subclasses.
*
* @return \Symfony\Component\HttpKernel\HttpKernelInterface
* @return \Illuminate\Foundation\Application
*/
abstract public function createApplication();
public function createApplication()
{
if (method_exists(Application::class, 'inferBaseDirectory')) {
$app = require Application::inferBaseDirectory().'/bootstrap/app.php';

$app->make(Kernel::class)->bootstrap();

return $app;
}

throw new RuntimeException(
'Unable to guess application base directory. Please use the [Tests\CreatesApplication] trait.',
);
}

/**
* Setup the test environment.
Expand Down

0 comments on commit 6fe6bb5

Please sign in to comment.