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

[10.x] Test Improvements #49338

Merged
merged 59 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
fa8e075
wip
crynobone Dec 12, 2023
c14880b
wip
crynobone Dec 12, 2023
c6b61de
Apply fixes from StyleCI
StyleCIBot Dec 12, 2023
e349edc
wip
crynobone Dec 12, 2023
f1baf91
wip
crynobone Dec 12, 2023
a99f32d
wip
crynobone Dec 12, 2023
f498e40
wip
crynobone Dec 12, 2023
30e9efb
wip
crynobone Dec 12, 2023
081ee36
wip
crynobone Dec 12, 2023
aff3815
Apply fixes from StyleCI
StyleCIBot Dec 12, 2023
d50ed3e
wip
crynobone Dec 12, 2023
a8920d9
wip
crynobone Dec 12, 2023
dacd534
wip
crynobone Dec 12, 2023
aafb5d5
wip
crynobone Dec 12, 2023
36e648c
wip
crynobone Dec 12, 2023
13f5237
wip
crynobone Dec 12, 2023
651b776
wip
crynobone Dec 12, 2023
90dabb7
wip
crynobone Dec 12, 2023
8f7050c
wip
crynobone Dec 12, 2023
a898cec
wip
crynobone Dec 12, 2023
bd54d8f
wip
crynobone Dec 12, 2023
446386c
Merge remote-tracking branch 'upstream/10.x' into queue-tests-ci
crynobone Dec 12, 2023
d2a5822
wip
crynobone Dec 12, 2023
c11e51b
wip
crynobone Dec 12, 2023
e4d6d1c
wip
crynobone Dec 12, 2023
f63892f
wip
crynobone Dec 12, 2023
56027b2
wip
crynobone Dec 12, 2023
a2a13cb
wip
crynobone Dec 12, 2023
3f2065a
wip
crynobone Dec 12, 2023
8b128e0
wip
crynobone Dec 12, 2023
65ad2b8
wip
crynobone Dec 12, 2023
aaba355
wip
crynobone Dec 12, 2023
c6310b7
wip
crynobone Dec 12, 2023
b6a6e84
wip
crynobone Dec 12, 2023
7b47bbc
wip
crynobone Dec 12, 2023
bc917ab
wip
crynobone Dec 12, 2023
70cdbd4
wip
crynobone Dec 12, 2023
235aeb0
wip
crynobone Dec 12, 2023
49a8ff6
Apply fixes from StyleCI
StyleCIBot Dec 12, 2023
43588f8
wip
crynobone Dec 12, 2023
b653969
Merge remote-tracking branch 'upstream/queue-tests-ci' into queue-tes…
crynobone Dec 12, 2023
3d9e779
wip
crynobone Dec 12, 2023
5e19026
wip
crynobone Dec 12, 2023
d3e9d2d
wip
crynobone Dec 12, 2023
862954a
wip
crynobone Dec 12, 2023
a4f3b3f
wip
crynobone Dec 12, 2023
4abfc6f
wip
crynobone Dec 12, 2023
37a2dca
wip
crynobone Dec 12, 2023
04a66bd
wip
crynobone Dec 12, 2023
51ac0a6
wip
crynobone Dec 12, 2023
9e989a5
wip
crynobone Dec 12, 2023
a188e9f
wip
crynobone Dec 12, 2023
2aa17e7
Merge remote-tracking branch 'upstream/10.x' into queue-tests-ci
crynobone Dec 12, 2023
07e1a14
wip
crynobone Dec 12, 2023
c2facc6
wip
crynobone Dec 12, 2023
89312b9
wip
crynobone Dec 12, 2023
9c75dfe
Merge remote-tracking branch 'upstream/10.x' into queue-tests-ci
crynobone Dec 13, 2023
179d85a
wip
crynobone Dec 13, 2023
2aafb76
wip
crynobone Dec 13, 2023
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
160 changes: 160 additions & 0 deletions .github/workflows/queues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
name: queues

on:
push:
branches:
- master
- '*.x'
pull_request:

jobs:
sync:
runs-on: ubuntu-22.04

strategy:
fail-fast: true

name: Sync Driver

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Queue
env:
QUEUE_CONNECTION: sync

database:
runs-on: ubuntu-22.04

strategy:
fail-fast: true

name: Database Driver

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Queue
env:
DB_CONNECTION: testing
QUEUE_CONNECTION: database

redis:
runs-on: ubuntu-22.04

services:
redis:
image: redis:7.0
ports:
- 6379:6379
options: --entrypoint redis-server

strategy:
fail-fast: true

name: Redis Driver

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Queue
env:
QUEUE_CONNECTION: redis

beanstalkd:
runs-on: ubuntu-22.04

name: Beanstalkd Driver

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/checkout@v3
- name: Download & Extract beanstalkd
run: curl -L https://github.com/beanstalkd/beanstalkd/archive/refs/tags/v1.13.tar.gz | tar xz
- name: Make beanstalkd
run: make
working-directory: beanstalkd-1.13

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_mysql, :php-psr
tools: composer:v2
coverage: none

- name: Install dependencies
uses: nick-fields/retry@v2
with:
timeout_minutes: 5
max_attempts: 5
command: composer update --prefer-stable --prefer-dist --no-interaction --no-progress

- name: Daemonize beanstalkd
run: ./beanstalkd-1.13/beanstalkd &

- name: Execute tests
run: vendor/bin/phpunit tests/Integration/Queue
env:
QUEUE_CONNECTION: beanstalkd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait InteractsWithRedis
/**
* Redis manager instance.
*
* @var \Illuminate\Redis\RedisManager[]
* @var array<string, \Illuminate\Redis\RedisManager>
*/
private $redis;

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

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

m::close();
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orchestra\Testbench\TestCase::tearDown() already calls Mockery::close()


public function testJobCanBeDispatched()
{
CallQueuedHandlerTestJob::$handled = false;
Expand Down
5 changes: 2 additions & 3 deletions tests/Integration/Queue/CustomPayloadTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Queue\Queue;
use Illuminate\Support\ServiceProvider;
use Orchestra\Testbench\Concerns\CreatesApplication;
use PHPUnit\Framework\Attributes\DataProvider;

class CustomPayloadTest extends TestCase
{
Expand All @@ -25,9 +26,7 @@ public static function websites()
yield ['blog.laravel.com'];
}

/**
* @dataProvider websites
*/
#[DataProvider('websites')]
public function test_custom_payload_gets_cleared_for_each_data_provider(string $websites)
{
$dispatcher = $this->app->make(QueueingDispatcher::class);
Expand Down
38 changes: 20 additions & 18 deletions tests/Integration/Queue/DynamoBatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Env;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase;
Expand All @@ -17,34 +18,35 @@
*/
class DynamoBatchTest extends TestCase
{
const DYNAMODB_ENDPOINT = 'http://localhost:8888';
public function setUp(): void
{
$this->afterApplicationCreated(function () {
BatchRunRecorder::reset();
app(DynamoBatchRepository::class)->createAwsDynamoTable();
});

$this->beforeApplicationDestroyed(function () {
app(DynamoBatchRepository::class)->deleteAwsDynamoTable();
});

protected function getEnvironmentSetUp($app)
parent::setUp();
}

protected function defineEnvironment($app)
{
if (is_null($endpoint = Env::get('DYNAMODB_ENDPOINT'))) {
$this->markTestSkipped('Require `dynamodb` to be configured');
}

$app['config']->set('queue.batching', [
'driver' => 'dynamodb',
'region' => 'us-west-2',
'endpoint' => static::DYNAMODB_ENDPOINT,
'endpoint' => $endpoint,
'key' => 'key',
'secret' => 'secret',
]);
}

public function setUp(): void
{
parent::setUp();

BatchRunRecorder::reset();
app(DynamoBatchRepository::class)->createAwsDynamoTable();
}

public function tearDown(): void
{
app(DynamoBatchRepository::class)->deleteAwsDynamoTable();

parent::tearDown();
}

public function test_running_a_batch()
{
Bus::batch([
Expand Down
10 changes: 8 additions & 2 deletions tests/Integration/Queue/DynamoBatchTestWithTTL.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

namespace Illuminate\Tests\Integration\Queue;

use Illuminate\Support\Env;

class DynamoBatchTestWithTTL extends DynamoBatchTest
{
protected function getEnvironmentSetUp($app)
protected function defineEnvironment($app)
{
if (is_null($endpoint = Env::get('DYNAMODB_ENDPOINT'))) {
$this->markTestSkipped('Require `dynamodb` to be configured');
}

$app['config']->set('queue.batching', [
'driver' => 'dynamodb',
'region' => 'us-west-2',
'endpoint' => static::DYNAMODB_ENDPOINT,
'endpoint' => $endpoint,
'key' => 'key',
'secret' => 'secret',
'ttl' => 1,
Expand Down
Loading