Find the best Rector rule to solve your problem. Searching through 671 rules.
Found 7 rules:
Convert DB Expression __toString() calls to getValue() method calls.
use Illuminate\Support\Facades\DB;
-$string = DB::raw('select 1')->__toString();
+$string = DB::raw('select 1')->getValue(DB::connection()->getQueryGrammar());
Replace withoutJobs
, withoutEvents
and withoutNotifications
with Facade fake
-$this->withoutJobs();
-$this->withoutEvents();
-$this->withoutNotifications();
+\Illuminate\Support\Facades\Bus::fake();
+\Illuminate\Support\Facades\Event::fake();
+\Illuminate\Support\Facades\Notification::fake();
Dispatch non ShouldQueue jobs to dispatchSync
-dispatch(new SomeJob());
-Bus::dispatch(new SomeJob());
-$this->dispatch(new SomeJob());
+dispatch_sync(new SomeJob());
+Bus::dispatchSync(new SomeJob());
+$this->dispatchSync(new SomeJob());
Convert DB Expression string casts to getValue() method calls.
use Illuminate\Support\Facades\DB;
-$string = (string) DB::raw('select 1');
+$string = DB::raw('select 1')->getValue(DB::connection()->getQueryGrammar());
Replace assertTimesSent with assertSentTimes
-Notification::assertTimesSent(1, SomeNotification::class);
+Notification::assertSentTimes(SomeNotification::class, 1);
Unify Model $dates property with $casts
use Illuminate\Database\Eloquent\Model;
class Person extends Model
{
protected $casts = [
- 'age' => 'integer',
+ 'age' => 'integer', 'birthday' => 'datetime',
];
-
- protected $dates = ['birthday'];
}
Replace expectJobs and expectEvents methods in tests
use Illuminate\Foundation\Testing\TestCase;
class SomethingTest extends TestCase
{
public function testSomething()
{
- $this->expectsJobs([\App\Jobs\SomeJob::class, \App\Jobs\SomeOtherJob::class]);
- $this->expectsEvents(\App\Events\SomeEvent::class);
- $this->doesntExpectEvents(\App\Events\SomeOtherEvent::class);
+ \Illuminate\Support\Facades\Bus::fake([\App\Jobs\SomeJob::class, \App\Jobs\SomeOtherJob::class]);
+ \Illuminate\Support\Facades\Event::fake([\App\Events\SomeEvent::class, \App\Events\SomeOtherEvent::class]);
$this->get('/');
+
+ \Illuminate\Support\Facades\Bus::assertDispatched(\App\Jobs\SomeJob::class);
+ \Illuminate\Support\Facades\Bus::assertDispatched(\App\Jobs\SomeOtherJob::class);
+ \Illuminate\Support\Facades\Event::assertDispatched(\App\Events\SomeEvent::class);
+ \Illuminate\Support\Facades\Event::assertNotDispatched(\App\Events\SomeOtherEvent::class);
}
}