Repository: laravel/framework (php)

Issue:
Dumping a schemefrom a postgresql database with a non default schema (i.e. other than public) results in a full dump including data.
<!-- DO NOT THROW THIS AWAY -->
<!-- Fill out the FULL versions with patch versions -->

- Laravel Version: 8.23.1
- PHP Version: 7.4.10
- Database Driver & Version: Postgres 9.6+

### Description:

When performing a dump as follows:

```shell
php artisan schema:dump
```

It generates a dump file containing all data from the database.

### Steps To Reproduce:

1. Create a new Postgresql database and rename it's default schema:

```shell
createdb testdb
psql -c 'ALTER SCHEMA public RENAME TO alternative' testdb
```

2. Properly setup the database connection on `.env`

3. In the project change `config/database.php` line `'schema' => 'public',` to `'schema' => 'alternative',` in the pgsql driver.

4. Execute `migrate:install`

5. Add some data to the database on any table other then `migrations` using any method.

6. Execute the command `schema:dump`

Pull request:
[8.x] Fix issue with dumping schema from a postgres database using no default schema
This PR solves the issue #35965 by adding the schema of the table to be ignored in the `--exclude-table-data` option when performing a dump.

When loading generated dump it outputs some warnings saying that it cannot create the schema because it already exists, either way the rest of the load works successfully. Looking into the [Postgresql documentation](https://www.postgresql.org/docs/9.6/app-pgrestore.html) it is possible tho suppress such warnings ugins the option `--clean` and `--if-exists` when executing a `pg_restore`. As the load will only occur when the database is empty anyway the addition of those options seems harmless.

Fixes #35965

Patch:
diff --git a/src/Illuminate/Database/Schema/PostgresSchemaState.php b/src/Illuminate/Database/Schema/PostgresSchemaState.php
index 179db6189c..bca0958c3b 100644
--- a/src/Illuminate/Database/Schema/PostgresSchemaState.php
+++ b/src/Illuminate/Database/Schema/PostgresSchemaState.php
@@ -16,12 +16,13 @@ class PostgresSchemaState extends SchemaState
      */
     public function dump(Connection $connection, $path)
     {
+        $schema = $connection->getConfig('schema');
         $excludedTables = collect($connection->getSchemaBuilder()->getAllTables())
                         ->map->tablename
                         ->reject(function ($table) {
                             return $table === $this->migrationTable;
-                        })->map(function ($table) {
-                            return '--exclude-table-data='.$table;
+                        })->map(function ($table) use ($schema) {
+                            return '--exclude-table-data='.$schema.'.'.$table;
                         })->implode(' ');
 
         $this->makeProcess(
@@ -39,7 +40,7 @@ public function dump(Connection $connection, $path)
      */
     public function load($path)
     {
-        $command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --no-owner --no-acl --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH';
+        $command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD pg_restore --no-owner --no-acl --clean --if-exists --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE $LARAVEL_LOAD_PATH';
 
         if (Str::endsWith($path, '.sql')) {
             $command = 'PGPASSWORD=$LARAVEL_LOAD_PASSWORD psql --file=$LARAVEL_LOAD_PATH --host=$LARAVEL_LOAD_HOST --port=$LARAVEL_LOAD_PORT --username=$LARAVEL_LOAD_USER --dbname=$LARAVEL_LOAD_DATABASE';
diff --git a/src/Illuminate/Queue/Events/JobQueued.php b/src/Illuminate/Queue/Events/JobQueued.php
deleted file mode 100644
index c91d140959..0000000000
--- a/src/Illuminate/Queue/Events/JobQueued.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-namespace Illuminate\Queue\Events;
-
-class JobQueued
-{
-    /**
-     * The connection name.
-     *
-     * @var string
-     */
-    public $connectionName;
-
-    /**
-     * The job ID.
-     *
-     * @var string|int|null
-     */
-    public $id;
-
-    /**
-     * The job instance.
-     *
-     * @var \Closure|string|object
-     */
-    public $job;
-
-    /**
-     * Create a new event instance.
-     *
-     * @param  string  $connectionName
-     * @param  string|int|null  $id
-     * @param  \Closure|string|object  $job
-     * @return void
-     */
-    public function __construct($connectionName, $id, $job)
-    {
-        $this->connectionName = $connectionName;
-        $this->id = $id;
-        $this->job = $job;
-    }
-}
diff --git a/src/Illuminate/Queue/Queue.php b/src/Illuminate/Queue/Queue.php
index f036f2a871..b22ed51cd4 100755
--- a/src/Illuminate/Queue/Queue.php
+++ b/src/Illuminate/Queue/Queue.php
@@ -7,7 +7,6 @@
 use Illuminate\Container\Container;
 use Illuminate\Contracts\Encryption\Encrypter;
 use Illuminate\Contracts\Queue\ShouldBeEncrypted;
-use Illuminate\Queue\Events\JobQueued;
 use Illuminate\Support\Arr;
 use Illuminate\Support\InteractsWithTime;
 use Illuminate\Support\Str;
@@ -285,17 +284,13 @@ protected function enqueueUsing($job, $payload, $queue, $delay, $callback)
         if ($this->shouldDispatchAfterCommit($job) &&
             $this->container->bound('db.transactions')) {
             return $this->container->make('db.transactions')->addCallback(
-                function () use ($payload, $queue, $delay, $callback, $job) {
-                    return tap($callback($payload, $queue, $delay), function ($jobId) use ($job) {
-                        $this->raiseJobQueuedEvent($jobId, $job);
-                    });
+                function () use ($payload, $queue, $delay, $callback) {
+                    return $callback($payload, $queue, $delay);
                 }
             );
         }
 
-        return tap($callback($payload, $queue, $delay), function ($jobId) use ($job) {
-            $this->raiseJobQueuedEvent($jobId, $job);
-        });
+        return $callback($payload, $queue, $delay);
     }
 
     /**
@@ -317,20 +312,6 @@ protected function shouldDispatchAfterCommit($job)
         return false;
     }
 
-    /**
-     * Raise the job queued event.
-     *
-     * @param  string|int|null  $jobId
-     * @param  \Closure|string|object  $job
-     * @return void
-     */
-    protected function raiseJobQueuedEvent($jobId, $job)
-    {
-        if ($this->container->bound('events')) {
-            $this->container['events']->dispatch(new JobQueued($this->connectionName, $jobId, $job));
-        }
-    }
-
     /**
      * Get the connection name for the queue.
      *


Test patch:
diff --git a/tests/Queue/QueueBeanstalkdQueueTest.php b/tests/Queue/QueueBeanstalkdQueueTest.php
index 534a161413..7134917a23 100755
--- a/tests/Queue/QueueBeanstalkdQueueTest.php
+++ b/tests/Queue/QueueBeanstalkdQueueTest.php
@@ -13,16 +13,6 @@
 
 class QueueBeanstalkdQueueTest extends TestCase
 {
-    /**
-     * @var BeanstalkdQueue
-     */
-    private $queue;
-
-    /**
-     * @var Container|m\LegacyMockInterface|m\MockInterface
-     */
-    private $container;
-
     protected function tearDown(): void
     {
         m::close();
@@ -36,16 +26,14 @@ public function testPushProperlyPushesJobOntoBeanstalkd()
             return $uuid;
         });
 
-        $this->setQueue('default', 60);
-        $pheanstalk = $this->queue->getPheanstalk();
+        $queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), 'default', 60);
+        $pheanstalk = $queue->getPheanstalk();
         $pheanstalk->shouldReceive('useTube')->once()->with('stack')->andReturn($pheanstalk);
         $pheanstalk->shouldReceive('useTube')->once()->with('default')->andReturn($pheanstalk);
         $pheanstalk->shouldReceive('put')->twice()->with(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), 1024, 0, 60);
 
-        $this->queue->push('foo', ['data'], 'stack');
-        $this->queue->push('foo', ['data']);
-
-        $this->container->shouldHaveReceived('bound')->with('events')->times(2);
+        $queue->push('foo', ['data'], 'stack');
+        $queue->push('foo', ['data']);
 
         Str::createUuidsNormally();
     }
@@ -58,68 +46,53 @@ public function testDelayedPushProperlyPushesJobOntoBeanstalkd()
             return $uuid;
         });
 
-        $this->setQueue('default', 60);
-        $pheanstalk = $this->queue->getPheanstalk();
+        $queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), 'default', 60);
+        $pheanstalk = $queue->getPheanstalk();
         $pheanstalk->shouldReceive('useTube')->once()->with('stack')->andReturn($pheanstalk);
         $pheanstalk->shouldReceive('useTube')->once()->with('default')->andReturn($pheanstalk);
         $pheanstalk->shouldReceive('put')->twice()->with(json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data']]), Pheanstalk::DEFAULT_PRIORITY, 5, Pheanstalk::DEFAULT_TTR);
 
-        $this->queue->later(5, 'foo', ['data'], 'stack');
-        $this->queue->later(5, 'foo', ['data']);
-
-        $this->container->shouldHaveReceived('bound')->with('events')->times(2);
+        $queue->later(5, 'foo', ['data'], 'stack');
+        $queue->later(5, 'foo', ['data']);
 
         Str::createUuidsNormally();
     }
 
     public function testPopProperlyPopsJobOffOfBeanstalkd()
     {
-        $this->setQueue('default', 60);
-
-        $pheanstalk = $this->queue->getPheanstalk();
+        $queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), 'default', 60);
+        $queue->setContainer(m::mock(Container::class));
+        $pheanstalk = $queue->getPheanstalk();
         $pheanstalk->shouldReceive('watchOnly')->once()->with('default')->andReturn($pheanstalk);
         $job = m::mock(Job::class);
         $pheanstalk->shouldReceive('reserveWithTimeout')->once()->with(0)->andReturn($job);
 
-        $result = $this->queue->pop();
+        $result = $queue->pop();
 
         $this->assertInstanceOf(BeanstalkdJob::class, $result);
     }
 
     public function testBlockingPopProperlyPopsJobOffOfBeanstalkd()
     {
-        $this->setQueue('default', 60, 60);
-
-        $pheanstalk = $this->queue->getPheanstalk();
+        $queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), 'default', 60, 60);
+        $queue->setContainer(m::mock(Container::class));
+        $pheanstalk = $queue->getPheanstalk();
         $pheanstalk->shouldReceive('watchOnly')->once()->with('default')->andReturn($pheanstalk);
         $job = m::mock(Job::class);
         $pheanstalk->shouldReceive('reserveWithTimeout')->once()->with(60)->andReturn($job);
 
-        $result = $this->queue->pop();
+        $result = $queue->pop();
 
         $this->assertInstanceOf(BeanstalkdJob::class, $result);
     }
 
     public function testDeleteProperlyRemoveJobsOffBeanstalkd()
     {
-        $this->setQueue('default', 60);
-
-        $pheanstalk = $this->queue->getPheanstalk();
+        $queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), 'default', 60);
+        $pheanstalk = $queue->getPheanstalk();
         $pheanstalk->shouldReceive('useTube')->once()->with('default')->andReturn($pheanstalk);
         $pheanstalk->shouldReceive('delete')->once()->with(m::type(Job::class));
 
-        $this->queue->deleteMessage('default', 1);
-    }
-
-    /**
-     * @param string $default
-     * @param int $timeToRun
-     * @param int $blockFor
-     */
-    private function setQueue($default, $timeToRun, $blockFor = 0)
-    {
-        $this->queue = new BeanstalkdQueue(m::mock(Pheanstalk::class), $default, $timeToRun, $blockFor);
-        $this->container = m::spy(Container::class);
-        $this->queue->setContainer($this->container);
+        $queue->deleteMessage('default', 1);
     }
 }
diff --git a/tests/Queue/QueueDatabaseQueueUnitTest.php b/tests/Queue/QueueDatabaseQueueUnitTest.php
index c87dc75454..6fa35eca57 100644
--- a/tests/Queue/QueueDatabaseQueueUnitTest.php
+++ b/tests/Queue/QueueDatabaseQueueUnitTest.php
@@ -2,7 +2,6 @@
 
 namespace Illuminate\Tests\Queue;
 
-use Illuminate\Container\Container;
 use Illuminate\Database\Connection;
 use Illuminate\Queue\DatabaseQueue;
 use Illuminate\Queue\Queue;
@@ -29,7 +28,6 @@ public function testPushProperlyPushesJobOntoDatabase()
 
         $queue = $this->getMockBuilder(DatabaseQueue::class)->onlyMethods(['currentTime'])->setConstructorArgs([$database = m::mock(Connection::class), 'table', 'default'])->getMock();
         $queue->expects($this->any())->method('currentTime')->willReturn('time');
-        $queue->setContainer($container = m::spy(Container::class));
         $database->shouldReceive('table')->with('table')->andReturn($query = m::mock(stdClass::class));
         $query->shouldReceive('insertGetId')->once()->andReturnUsing(function ($array) use ($uuid) {
             $this->assertSame('default', $array['queue']);
@@ -41,8 +39,6 @@ public function testPushProperlyPushesJobOntoDatabase()
 
         $queue->push('foo', ['data']);
 
-        $container->shouldHaveReceived('bound')->with('events')->once();
-
         Str::createUuidsNormally();
     }
 
@@ -60,7 +56,6 @@ public function testDelayedPushProperlyPushesJobOntoDatabase()
             [$database = m::mock(Connection::class), 'table', 'default']
         )->getMock();
         $queue->expects($this->any())->method('currentTime')->willReturn('time');
-        $queue->setContainer($container = m::spy(Container::class));
         $database->shouldReceive('table')->with('table')->andReturn($query = m::mock(stdClass::class));
         $query->shouldReceive('insertGetId')->once()->andReturnUsing(function ($array) use ($uuid) {
             $this->assertSame('default', $array['queue']);
@@ -72,8 +67,6 @@ public function testDelayedPushProperlyPushesJobOntoDatabase()
 
         $queue->later(10, 'foo', ['data']);
 
-        $container->shouldHaveReceived('bound')->with('events')->once();
-
         Str::createUuidsNormally();
     }
 
diff --git a/tests/Queue/QueueRedisQueueTest.php b/tests/Queue/QueueRedisQueueTest.php
index 952384b7f2..2060772d78 100644
--- a/tests/Queue/QueueRedisQueueTest.php
+++ b/tests/Queue/QueueRedisQueueTest.php
@@ -2,7 +2,6 @@
 
 namespace Illuminate\Tests\Queue;
 
-use Illuminate\Container\Container;
 use Illuminate\Contracts\Redis\Factory;
 use Illuminate\Queue\LuaScripts;
 use Illuminate\Queue\Queue;
@@ -29,13 +28,11 @@ public function testPushProperlyPushesJobOntoRedis()
 
         $queue = $this->getMockBuilder(RedisQueue::class)->onlyMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
         $queue->expects($this->once())->method('getRandomId')->willReturn('foo');
-        $queue->setContainer($container = m::spy(Container::class));
         $redis->shouldReceive('connection')->once()->andReturn($redis);
         $redis->shouldReceive('eval')->once()->with(LuaScripts::push(), 2, 'queues:default', 'queues:default:notify', json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data'], 'id' => 'foo', 'attempts' => 0]));
 
         $id = $queue->push('foo', ['data']);
         $this->assertSame('foo', $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
 
         Str::createUuidsNormally();
     }
@@ -50,7 +47,6 @@ public function testPushProperlyPushesJobOntoRedisWithCustomPayloadHook()
 
         $queue = $this->getMockBuilder(RedisQueue::class)->onlyMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
         $queue->expects($this->once())->method('getRandomId')->willReturn('foo');
-        $queue->setContainer($container = m::spy(Container::class));
         $redis->shouldReceive('connection')->once()->andReturn($redis);
         $redis->shouldReceive('eval')->once()->with(LuaScripts::push(), 2, 'queues:default', 'queues:default:notify', json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data'], 'custom' => 'taylor', 'id' => 'foo', 'attempts' => 0]));
 
@@ -60,7 +56,6 @@ public function testPushProperlyPushesJobOntoRedisWithCustomPayloadHook()
 
         $id = $queue->push('foo', ['data']);
         $this->assertSame('foo', $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
 
         Queue::createPayloadUsing(null);
 
@@ -77,7 +72,6 @@ public function testPushProperlyPushesJobOntoRedisWithTwoCustomPayloadHook()
 
         $queue = $this->getMockBuilder(RedisQueue::class)->onlyMethods(['getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
         $queue->expects($this->once())->method('getRandomId')->willReturn('foo');
-        $queue->setContainer($container = m::spy(Container::class));
         $redis->shouldReceive('connection')->once()->andReturn($redis);
         $redis->shouldReceive('eval')->once()->with(LuaScripts::push(), 2, 'queues:default', 'queues:default:notify', json_encode(['uuid' => $uuid, 'displayName' => 'foo', 'job' => 'foo', 'maxTries' => null, 'maxExceptions' => null, 'backoff' => null, 'timeout' => null, 'data' => ['data'], 'custom' => 'taylor', 'bar' => 'foo', 'id' => 'foo', 'attempts' => 0]));
 
@@ -91,7 +85,6 @@ public function testPushProperlyPushesJobOntoRedisWithTwoCustomPayloadHook()
 
         $id = $queue->push('foo', ['data']);
         $this->assertSame('foo', $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
 
         Queue::createPayloadUsing(null);
 
@@ -107,7 +100,6 @@ public function testDelayedPushProperlyPushesJobOntoRedis()
         });
 
         $queue = $this->getMockBuilder(RedisQueue::class)->onlyMethods(['availableAt', 'getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
-        $queue->setContainer($container = m::spy(Container::class));
         $queue->expects($this->once())->method('getRandomId')->willReturn('foo');
         $queue->expects($this->once())->method('availableAt')->with(1)->willReturn(2);
 
@@ -120,7 +112,6 @@ public function testDelayedPushProperlyPushesJobOntoRedis()
 
         $id = $queue->later(1, 'foo', ['data']);
         $this->assertSame('foo', $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
 
         Str::createUuidsNormally();
     }
@@ -135,7 +126,6 @@ public function testDelayedPushWithDateTimeProperlyPushesJobOntoRedis()
 
         $date = Carbon::now();
         $queue = $this->getMockBuilder(RedisQueue::class)->onlyMethods(['availableAt', 'getRandomId'])->setConstructorArgs([$redis = m::mock(Factory::class), 'default'])->getMock();
-        $queue->setContainer($container = m::spy(Container::class));
         $queue->expects($this->once())->method('getRandomId')->willReturn('foo');
         $queue->expects($this->once())->method('availableAt')->with($date)->willReturn(2);
 
@@ -147,7 +137,6 @@ public function testDelayedPushWithDateTimeProperlyPushesJobOntoRedis()
         );
 
         $queue->later($date, 'foo', ['data']);
-        $container->shouldHaveReceived('bound')->with('events')->once();
 
         Str::createUuidsNormally();
     }
diff --git a/tests/Queue/QueueSqsQueueTest.php b/tests/Queue/QueueSqsQueueTest.php
index 60e02b161e..789084515b 100755
--- a/tests/Queue/QueueSqsQueueTest.php
+++ b/tests/Queue/QueueSqsQueueTest.php
@@ -92,39 +92,33 @@ public function testDelayedPushWithDateTimeProperlyPushesJobOntoSqs()
     {
         $now = Carbon::now();
         $queue = $this->getMockBuilder(SqsQueue::class)->onlyMethods(['createPayload', 'secondsUntil', 'getQueue'])->setConstructorArgs([$this->sqs, $this->queueName, $this->account])->getMock();
-        $queue->setContainer($container = m::spy(Container::class));
         $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->queueName, $this->mockedData)->willReturn($this->mockedPayload);
         $queue->expects($this->once())->method('secondsUntil')->with($now)->willReturn(5);
         $queue->expects($this->once())->method('getQueue')->with($this->queueName)->willReturn($this->queueUrl);
         $this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload, 'DelaySeconds' => 5])->andReturn($this->mockedSendMessageResponseModel);
         $id = $queue->later($now->addSeconds(5), $this->mockedJob, $this->mockedData, $this->queueName);
         $this->assertEquals($this->mockedMessageId, $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
     }
 
     public function testDelayedPushProperlyPushesJobOntoSqs()
     {
         $queue = $this->getMockBuilder(SqsQueue::class)->onlyMethods(['createPayload', 'secondsUntil', 'getQueue'])->setConstructorArgs([$this->sqs, $this->queueName, $this->account])->getMock();
-        $queue->setContainer($container = m::spy(Container::class));
         $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->queueName, $this->mockedData)->willReturn($this->mockedPayload);
         $queue->expects($this->once())->method('secondsUntil')->with($this->mockedDelay)->willReturn($this->mockedDelay);
         $queue->expects($this->once())->method('getQueue')->with($this->queueName)->willReturn($this->queueUrl);
         $this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload, 'DelaySeconds' => $this->mockedDelay])->andReturn($this->mockedSendMessageResponseModel);
         $id = $queue->later($this->mockedDelay, $this->mockedJob, $this->mockedData, $this->queueName);
         $this->assertEquals($this->mockedMessageId, $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
     }
 
     public function testPushProperlyPushesJobOntoSqs()
     {
         $queue = $this->getMockBuilder(SqsQueue::class)->onlyMethods(['createPayload', 'getQueue'])->setConstructorArgs([$this->sqs, $this->queueName, $this->account])->getMock();
-        $queue->setContainer($container = m::spy(Container::class));
         $queue->expects($this->once())->method('createPayload')->with($this->mockedJob, $this->queueName, $this->mockedData)->willReturn($this->mockedPayload);
         $queue->expects($this->once())->method('getQueue')->with($this->queueName)->willReturn($this->queueUrl);
         $this->sqs->shouldReceive('sendMessage')->once()->with(['QueueUrl' => $this->queueUrl, 'MessageBody' => $this->mockedPayload])->andReturn($this->mockedSendMessageResponseModel);
         $id = $queue->push($this->mockedJob, $this->mockedData, $this->queueName);
         $this->assertEquals($this->mockedMessageId, $id);
-        $container->shouldHaveReceived('bound')->with('events')->once();
     }
 
     public function testSizeProperlyReadsSqsQueueSize()
diff --git a/tests/Queue/RedisQueueIntegrationTest.php b/tests/Queue/RedisQueueIntegrationTest.php
index 5fbad9311d..0380988bd4 100644
--- a/tests/Queue/RedisQueueIntegrationTest.php
+++ b/tests/Queue/RedisQueueIntegrationTest.php
@@ -3,9 +3,7 @@
 namespace Illuminate\Tests\Queue;
 
 use Illuminate\Container\Container;
-use Illuminate\Contracts\Events\Dispatcher;
 use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
-use Illuminate\Queue\Events\JobQueued;
 use Illuminate\Queue\Jobs\RedisJob;
 use Illuminate\Queue\RedisQueue;
 use Illuminate\Support\Carbon;
@@ -23,11 +21,6 @@ class RedisQueueIntegrationTest extends TestCase
      */
     private $queue;
 
-    /**
-     * @var \Mockery\MockInterface|\Mockery\LegacyMockInterface
-     */
-    private $container;
-
     protected function setUp(): void
     {
         Carbon::setTestNow(Carbon::now());
@@ -64,8 +57,6 @@ public function testExpiredJobsArePopped($driver)
         $this->queue->later(-300, $jobs[2]);
         $this->queue->later(-100, $jobs[3]);
 
-        $this->container->shouldHaveReceived('bound')->with('events')->times(4);
-
         $this->assertEquals($jobs[2], unserialize(json_decode($this->queue->pop()->getRawBody())->data->command));
         $this->assertEquals($jobs[1], unserialize(json_decode($this->queue->pop()->getRawBody())->data->command));
         $this->assertEquals($jobs[3], unserialize(json_decode($this->queue->pop()->getRawBody())->data->command));
@@ -192,14 +183,13 @@ public function testPopProperlyPopsDelayedJobOffOfRedis($driver)
      */
     public function testPopPopsDelayedJobOffOfRedisWhenExpireNull($driver)
     {
-        $this->setQueue($driver, 'default', null, null);
+        $this->queue = new RedisQueue($this->redis[$driver], 'default', null, null);
+        $this->queue->setContainer(m::mock(Container::class));
 
         // Push an item into queue
         $job = new RedisQueueIntegrationTestJob(10);
         $this->queue->later(-10, $job);
 
-        $this->container->shouldHaveReceived('bound')->with('events')->once();
-
         // Pop and check it is popped correctly
         $before = $this->currentTime();
         $this->assertEquals($job, unserialize(json_decode($this->queue->pop()->getRawBody())->data->command));
@@ -274,13 +264,12 @@ public function testBlockingPopProperlyPopsExpiredJobs($driver)
      */
     public function testNotExpireJobsWhenExpireNull($driver)
     {
-        $this->setQueue($driver, 'default', null, null);
+        $this->queue = new RedisQueue($this->redis[$driver], 'default', null, null);
+        $this->queue->setContainer(m::mock(Container::class));
 
         // Make an expired reserved job
         $failed = new RedisQueueIntegrationTestJob(-20);
         $this->queue->push($failed);
-        $this->container->shouldHaveReceived('bound')->with('events')->once();
-
         $beforeFailPop = $this->currentTime();
         $this->queue->pop();
         $afterFailPop = $this->currentTime();
@@ -288,7 +277,6 @@ public function testNotExpireJobsWhenExpireNull($driver)
         // Push an item into queue
         $job = new RedisQueueIntegrationTestJob(10);
         $this->queue->push($job);
-        $this->container->shouldHaveReceived('bound')->with('events')->times(2);
 
         // Pop and check it is popped correctly
         $before = $this->currentTime();
@@ -321,12 +309,12 @@ public function testNotExpireJobsWhenExpireNull($driver)
      */
     public function testExpireJobsWhenExpireSet($driver)
     {
-        $this->setQueue($driver, 'default', null, 30);
+        $this->queue = new RedisQueue($this->redis[$driver], 'default', null, 30);
+        $this->queue->setContainer(m::mock(Container::class));
 
         // Push an item into queue
         $job = new RedisQueueIntegrationTestJob(10);
         $this->queue->push($job);
-        $this->container->shouldHaveReceived('bound')->with('events')->once();
 
         // Pop and check it is popped correctly
         $before = $this->currentTime();
@@ -467,67 +455,17 @@ public function testSize($driver)
         $this->assertEquals(2, $this->queue->size());
     }
 
-    /**
-     * @dataProvider redisDriverProvider
-     *
-     * @param  string  $driver
-     */
-    public function testPushJobQueuedEvent($driver)
-    {
-        $events = m::mock(Dispatcher::class);
-        $events->shouldReceive('dispatch')->withArgs(function (JobQueued $jobQueued) {
-            $this->assertInstanceOf(RedisQueueIntegrationTestJob::class, $jobQueued->job);
-            $this->assertIsString(RedisQueueIntegrationTestJob::class, $jobQueued->id);
-
-            return true;
-        })->andReturnNull()->once();
-
-        $container = m::mock(Container::class);
-        $container->shouldReceive('bound')->with('events')->andReturn(true)->once();
-        $container->shouldReceive('offsetGet')->with('events')->andReturn($events)->once();
-
-        $queue = new RedisQueue($this->redis[$driver]);
-        $queue->setContainer($container);
-
-        $queue->push(new RedisQueueIntegrationTestJob(5));
-    }
-
-    /**
-     * @dataProvider redisDriverProvider
-     *
-     * @param  string  $driver
-     */
-    public function testBulkJobQueuedEvent($driver)
-    {
-        $events = m::mock(Dispatcher::class);
-        $events->shouldReceive('dispatch')->with(m::type(JobQueued::class))->andReturnNull()->times(3);
-
-        $container = m::mock(Container::class);
-        $container->shouldReceive('bound')->with('events')->andReturn(true)->times(3);
-        $container->shouldReceive('offsetGet')->with('events')->andReturn($events)->times(3);
-
-        $queue = new RedisQueue($this->redis[$driver]);
-        $queue->setContainer($container);
-
-        $queue->bulk([
-            new RedisQueueIntegrationTestJob(5),
-            new RedisQueueIntegrationTestJob(10),
-            new RedisQueueIntegrationTestJob(15),
-        ]);
-    }
-
     /**
      * @param  string  $driver
      * @param  string  $default
-     * @param  string|null  $connection
+     * @param  string  $connection
      * @param  int  $retryAfter
      * @param  int|null  $blockFor
      */
     private function setQueue($driver, $default = 'default', $connection = null, $retryAfter = 60, $blockFor = null)
     {
         $this->queue = new RedisQueue($this->redis[$driver], $default, $connection, $retryAfter, $blockFor);
-        $this->container = m::spy(Container::class);
-        $this->queue->setContainer($this->container);
+        $this->queue->setContainer(m::mock(Container::class));
     }
 }