Skip to content

Commit

Permalink
[10.x] Test Improvements (#49338)
Browse files Browse the repository at this point in the history
* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

* wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

---------

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Co-authored-by: StyleCI Bot <bot@styleci.io>
  • Loading branch information
crynobone and StyleCIBot authored Dec 13, 2023
1 parent 00c9c7f commit 9fe14c8
Show file tree
Hide file tree
Showing 19 changed files with 496 additions and 223 deletions.
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();
}

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

0 comments on commit 9fe14c8

Please sign in to comment.