Skip to content

Commit

Permalink
PHPORM-231 Remove MongoFailedJobProvider (#3122)
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN authored Sep 2, 2024
1 parent d7da552 commit a0b6134
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 213 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.

* **BREAKING CHANGE** Use `id` as an alias for `_id` in commands and queries for compatibility with Eloquent packages by @GromNaN in [#3040](https://github.com/mongodb/laravel-mongodb/pull/3040)
* **BREAKING CHANGE** Make Query\Builder return objects instead of array to match Laravel behavior by @GromNaN in [#3107](https://github.com/mongodb/laravel-mongodb/pull/3107)
* Remove `MongoFailedJobProvider`, replaced by Laravel `DatabaseFailedJobProvider` by @GromNaN in [#3122](https://github.com/mongodb/laravel-mongodb/pull/3122)

## [4.8.0] - 2024-08-27

Expand Down
68 changes: 0 additions & 68 deletions src/MongoDBQueueServiceProvider.php

This file was deleted.

10 changes: 5 additions & 5 deletions src/Query/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,11 @@ public function delete($id = null)
$wheres = $this->aliasIdForQuery($wheres);
$options = $this->inheritConnectionOptions();

if (is_int($this->limit)) {
if ($this->limit !== 1) {
throw new LogicException(sprintf('Delete limit can be 1 or null (unlimited). Got %d', $this->limit));
}

/**
* Ignore the limit if it is set to more than 1, as it is not supported by the deleteMany method.
* Required for {@see DatabaseFailedJobProvider::prune()}
*/
if ($this->limit === 1) {
$result = $this->collection->deleteOne($wheres, $options);
} else {
$result = $this->collection->deleteMany($wheres, $options);
Expand Down
119 changes: 0 additions & 119 deletions src/Queue/Failed/MongoFailedJobProvider.php

This file was deleted.

11 changes: 0 additions & 11 deletions tests/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@

use BadMethodCallException;
use DateTimeImmutable;
use LogicException;
use MongoDB\BSON\Regex;
use MongoDB\Laravel\Eloquent\Builder;
use MongoDB\Laravel\Tests\Models\Birthday;
use MongoDB\Laravel\Tests\Models\Scoped;
use MongoDB\Laravel\Tests\Models\User;
use PHPUnit\Framework\Attributes\TestWith;

use function str;

Expand Down Expand Up @@ -662,13 +660,4 @@ public function testDelete(): void
User::limit(null)->delete();
$this->assertEquals(0, User::count());
}

#[TestWith([0])]
#[TestWith([2])]
public function testDeleteException(int $limit): void
{
$this->expectException(LogicException::class);
$this->expectExceptionMessage('Delete limit can be 1 or null (unlimited).');
User::limit($limit)->delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

namespace MongoDB\Laravel\Tests\Queue\Failed;

use Illuminate\Queue\Failed\DatabaseFailedJobProvider;
use Illuminate\Support\Facades\Date;
use Illuminate\Support\Facades\DB;
use MongoDB\BSON\ObjectId;
use MongoDB\BSON\UTCDateTime;
use MongoDB\Laravel\Queue\Failed\MongoFailedJobProvider;
use MongoDB\Laravel\Tests\TestCase;
use OutOfBoundsException;

use function array_map;
use function range;
use function sprintf;

class MongoFailedJobProviderTest extends TestCase
/**
* Ensure the Laravel class {@see DatabaseFailedJobProvider} works with a MongoDB connection.
*/
class DatabaseFailedJobProviderTest extends TestCase
{
public function setUp(): void
{
Expand Down Expand Up @@ -57,8 +60,7 @@ public function testLog(): void
$this->assertSame('default', $inserted->queue);
$this->assertSame('{"foo":"bar"}', $inserted->payload);
$this->assertStringContainsString('OutOfBoundsException: This is the error', $inserted->exception);
$this->assertInstanceOf(ObjectId::class, $inserted->_id);
$this->assertSame((string) $inserted->_id, $inserted->id);
$this->assertInstanceOf(ObjectId::class, $inserted->id);
}

public function testCount(): void
Expand Down Expand Up @@ -143,8 +145,8 @@ public function testPrune(): void
$this->assertEquals(3, $provider->count());
}

private function getProvider(): MongoFailedJobProvider
private function getProvider(): DatabaseFailedJobProvider
{
return new MongoFailedJobProvider(DB::getFacadeRoot(), '', 'failed_jobs');
return new DatabaseFailedJobProvider(DB::getFacadeRoot(), '', 'failed_jobs');
}
}
4 changes: 2 additions & 2 deletions tests/QueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

use Carbon\Carbon;
use Exception;
use Illuminate\Queue\Failed\DatabaseFailedJobProvider;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Str;
use Mockery;
use MongoDB\BSON\UTCDateTime;
use MongoDB\Laravel\Queue\Failed\MongoFailedJobProvider;
use MongoDB\Laravel\Queue\MongoJob;
use MongoDB\Laravel\Queue\MongoQueue;

Expand Down Expand Up @@ -87,7 +87,7 @@ public function testFailQueueJob(): void
{
$provider = app('queue.failer');

$this->assertInstanceOf(MongoFailedJobProvider::class, $provider);
$this->assertInstanceOf(DatabaseFailedJobProvider::class, $provider);
}

public function testFindFailJobNull(): void
Expand Down
2 changes: 0 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Illuminate\Auth\Passwords\PasswordResetServiceProvider as BasePasswordResetServiceProviderAlias;
use Illuminate\Foundation\Application;
use MongoDB\Laravel\Auth\PasswordResetServiceProvider;
use MongoDB\Laravel\MongoDBQueueServiceProvider;
use MongoDB\Laravel\MongoDBServiceProvider;
use MongoDB\Laravel\Tests\Models\User;
use MongoDB\Laravel\Validation\ValidationServiceProvider;
Expand Down Expand Up @@ -40,7 +39,6 @@ protected function getPackageProviders($app): array
{
return [
MongoDBServiceProvider::class,
MongoDBQueueServiceProvider::class,
PasswordResetServiceProvider::class,
ValidationServiceProvider::class,
];
Expand Down

0 comments on commit a0b6134

Please sign in to comment.