Skip to content

[12.x] Test Improvements #54782

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

Merged
merged 3 commits into from
Feb 25, 2025
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: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"league/flysystem-read-only": "^3.25.1",
"league/flysystem-sftp-v3": "^3.25.1",
"mockery/mockery": "^1.6.10",
"orchestra/testbench-core": "^10.0",
"orchestra/testbench-core": "^10.0.0",
"pda/pheanstalk": "^5.0.6",
"php-http/discovery": "^1.15",
"phpstan/phpstan": "^2.0",
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Cache/Psr6RedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ protected function setUp(): void

protected function tearDown(): void
{
parent::tearDown();

$this->tearDownRedis();

parent::tearDown();
}

#[DataProvider('redisClientDataProvider')]
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Cache/RedisStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ protected function setUp(): void

protected function tearDown(): void
{
parent::tearDown();

$this->tearDownRedis();
m::close();

parent::tearDown();
}

public function testCacheTtl(): void
Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Console/CallbackSchedulingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ public function store($name = null)
$container->instance(SchedulingMutex::class, new CacheSchedulingMutex($cache));
}

protected function tearDown(): void
{
Container::setInstance(null);

parent::tearDown();
}

public function testExecutionOrder()
{
$event = $this->app->make(Schedule::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,9 @@ public function testClosureCommandsMayBeScheduled()

protected function tearDown(): void
{
parent::tearDown();

putenv('SHELL_VERBOSITY');

ScheduleListCommand::resolveTerminalWidthUsing(null);
parent::tearDown();
}
}

Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Database/EloquentBelongsToManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@

class EloquentBelongsToManyTest extends DatabaseTestCase
{
protected function tearDown(): void
{
parent::tearDown();

Carbon::setTestNow(null);
}

protected function afterRefreshingDatabase()
{
Schema::create('users', function (Blueprint $table) {
Expand Down
16 changes: 2 additions & 14 deletions tests/Integration/Database/EloquentMassPrunableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Illuminate\Tests\Integration\Database;

use Illuminate\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Database\Eloquent\MassPrunable;
use Illuminate\Database\Eloquent\Model;
Expand All @@ -19,13 +18,11 @@ protected function setUp(): void
{
parent::setUp();

Container::setInstance($container = new Container);

$container->singleton(Dispatcher::class, function () {
$this->app->singleton(Dispatcher::class, function () {
return m::mock(Dispatcher::class);
});

$container->alias(Dispatcher::class, 'events');
$this->app->alias(Dispatcher::class, 'events');
}

protected function afterRefreshingDatabase()
Expand Down Expand Up @@ -93,15 +90,6 @@ public function testPrunesSoftDeletedRecords()
$this->assertEquals(0, MassPrunableSoftDeleteTestModel::count());
$this->assertEquals(2000, MassPrunableSoftDeleteTestModel::withTrashed()->count());
}

protected function tearDown(): void
{
parent::tearDown();

Container::setInstance(null);

m::close();
}
}

class MassPrunableTestModel extends Model
Expand Down
2 changes: 0 additions & 2 deletions tests/Integration/Events/ListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class ListenerTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();

ListenerTestListener::$ran = false;
ListenerTestListenerAfterCommit::$ran = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class OptimizeCommandTest extends TestCase
protected $files = [
'bootstrap/cache/config.php',
'bootstrap/cache/events.php',
'bootstrap/cache/routes-v7.php',
];

protected function getPackageProviders($app): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

use Illuminate\Foundation\Application;
use Illuminate\Support\Str;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

#[WithConfig('filesystems.disks.local.serve', false)]
class RouteServiceProviderHealthTest extends TestCase
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
use Illuminate\Foundation\Support\Providers\RouteServiceProvider;
use Illuminate\Support\Facades\Route;
use Illuminate\Testing\Assert;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

#[WithConfig('filesystems.disks.local.serve', false)]
class RouteServiceProviderTest extends TestCase
{
/**
Expand Down
3 changes: 2 additions & 1 deletion tests/Integration/Migration/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ protected function setUp(): void

protected function tearDown(): void
{
parent::tearDown();
Migrator::withoutMigrations([]);

parent::tearDown();
}

public function testMigrate()
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Queue/DeleteModelWhenMissingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ protected function destroyDatabaseMigrations()
#[\Override]
protected function tearDown(): void
{
parent::tearDown();

DeleteMissingModelJob::$handled = false;

parent::tearDown();
}

public function test_deleteModelWhenMissing_and_display_name(): void
Expand Down
8 changes: 0 additions & 8 deletions tests/Integration/Queue/WorkCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Database\UniqueConstraintViolationException;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Queue\Console\WorkCommand;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Exceptions;
Expand All @@ -34,13 +33,6 @@ protected function setUp(): void
$this->markTestSkippedWhenUsingSyncQueueDriver();
}

protected function tearDown(): void
{
WorkCommand::flushState();

parent::tearDown();
}

public function testRunningOneJob()
{
Queue::push(new FirstJob);
Expand Down
14 changes: 2 additions & 12 deletions tests/Integration/Routing/ImplicitModelRouteBindingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles;
use Orchestra\Testbench\TestCase;

#[WithConfig('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF')]
class ImplicitModelRouteBindingTest extends TestCase
{
use InteractsWithPublishedFiles;
Expand All @@ -20,18 +22,6 @@ class ImplicitModelRouteBindingTest extends TestCase
'routes/testbench.php',
];

protected function tearDown(): void
{
$this->tearDownInteractsWithPublishedFiles();

parent::tearDown();
}

protected function defineEnvironment($app): void
{
$app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']);
}

protected function defineDatabaseMigrations(): void
{
Schema::create('users', function (Blueprint $table) {
Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Routing/UrlSigningTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@

class UrlSigningTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();

Carbon::setTestNow(null);
}

protected function defineEnvironment($app): void
{
$app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']);
Expand Down
2 changes: 2 additions & 0 deletions tests/Testing/Console/RouteListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

#[WithConfig('filesystems.disks.local.serve', false)]
class RouteListCommandTest extends TestCase
{
use InteractsWithDeprecationHandling;
Expand Down
Loading