Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[develop] Removes usage of Tests\CreatesApplication #173

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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