Skip to content
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
1 change: 1 addition & 0 deletions src/Illuminate/Bus/DatabaseBatchRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function get($limit = 50, $before = null)
public function find(string $batchId)
{
$batch = $this->connection->table($this->table)
->useWritePdo()
->where('id', $batchId)
->first();

Expand Down
13 changes: 9 additions & 4 deletions tests/Bus/BusBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\PostgresConnection;
use Illuminate\Database\Query\Builder;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\CallQueuedClosure;
use Mockery as m;
Expand Down Expand Up @@ -393,20 +394,24 @@ public function test_options_serialization_on_postgres()
->onQueue('test-queue');

$connection = m::spy(PostgresConnection::class);
$builder = m::spy(Builder::class);

$connection->shouldReceive('table')->andReturnSelf()
->shouldReceive('where')->andReturnSelf();
$connection->shouldReceive('table')->andReturn($builder);
$builder->shouldReceive('useWritePdo')->andReturnSelf();
$builder->shouldReceive('where')->andReturnSelf();

$repository = new DatabaseBatchRepository(
new BatchFactory(m::mock(Factory::class)), $connection, 'job_batches'
);

$repository->store($pendingBatch);

$connection->shouldHaveReceived('insert')
$builder->shouldHaveReceived('insert')
->withArgs(function ($argument) use ($pendingBatch) {
return unserialize(base64_decode($argument['options'])) === $pendingBatch->options;
});

$builder->shouldHaveReceived('first');
}

/**
Expand All @@ -418,7 +423,7 @@ public function test_options_unserialize_on_postgres($serialize, $options)

$connection = m::spy(PostgresConnection::class);

$connection->shouldReceive('table->where->first')
$connection->shouldReceive('table->useWritePdo->where->first')
->andReturn($m = (object) [
'id' => '',
'name' => '',
Expand Down
8 changes: 4 additions & 4 deletions tests/Support/SupportHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ public function testRetry()
$this->assertEquals(2, $attempts);

// Make sure we waited 100ms for the first attempt
$this->assertEqualsWithDelta(0.1, microtime(true) - $startTime, 0.02);
$this->assertEqualsWithDelta(0.1, microtime(true) - $startTime, 0.05);
}

public function testRetryWithPassingSleepCallback()
Expand All @@ -608,7 +608,7 @@ public function testRetryWithPassingSleepCallback()
$this->assertEquals(3, $attempts);

// Make sure we waited 300ms for the first two attempts
$this->assertEqualsWithDelta(0.3, microtime(true) - $startTime, 0.02);
$this->assertEqualsWithDelta(0.3, microtime(true) - $startTime, 0.05);
}

public function testRetryWithPassingWhenCallback()
Expand All @@ -629,7 +629,7 @@ public function testRetryWithPassingWhenCallback()
$this->assertEquals(2, $attempts);

// Make sure we waited 100ms for the first attempt
$this->assertEqualsWithDelta(0.1, microtime(true) - $startTime, 0.02);
$this->assertEqualsWithDelta(0.1, microtime(true) - $startTime, 0.05);
}

public function testRetryWithFailingWhenCallback()
Expand Down Expand Up @@ -661,7 +661,7 @@ public function testRetryWithBackoff()
// Make sure we made four attempts
$this->assertEquals(4, $attempts);

$this->assertEqualsWithDelta(0.05 + 0.1 + 0.2, microtime(true) - $startTime, 0.02);
$this->assertEqualsWithDelta(0.05 + 0.1 + 0.2, microtime(true) - $startTime, 0.05);
}

public function testTransform()
Expand Down