-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
706 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Domains\Contact\DAV\Jobs; | ||
|
||
use App\Domains\Contact\Dav\Jobs\UpdateVCard; | ||
use App\Models\Contact; | ||
use App\Models\User; | ||
use App\Models\Vault; | ||
use Illuminate\Bus\DatabaseBatchRepository; | ||
use Illuminate\Bus\PendingBatch; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Illuminate\Support\Facades\Bus; | ||
use Tests\TestCase; | ||
use Tests\Unit\Domains\Contact\DAV\CardEtag; | ||
|
||
class UpdateVCardTest extends TestCase | ||
{ | ||
use DatabaseTransactions; | ||
use CardEtag; | ||
|
||
/** @test */ | ||
public function it_create_a_contact() | ||
{ | ||
$fake = Bus::fake(); | ||
|
||
$user = User::factory()->create(); | ||
$vault = $this->createVaultUser($user, Vault::PERMISSION_MANAGE); | ||
|
||
$contact = new Contact(); | ||
$contact->forceFill([ | ||
'first_name' => 'Test', | ||
'uuid' => 'affacde9-b2fe-4371-9acb-6612aaee6971', | ||
'updated_at' => now(), | ||
]); | ||
|
||
$card = $this->getCard($contact); | ||
$etag = $this->getEtag($contact, true); | ||
|
||
$pendingBatch = $fake->batch([ | ||
$job = new UpdateVCard([ | ||
'account_id' => $vault->account_id, | ||
'author_id' => $user->id, | ||
'vault_id' => $vault->id, | ||
'uri' => 'https://test/dav/uricontact1', | ||
'etag' => $etag, | ||
'card' => $card, | ||
]), | ||
]); | ||
$batch = $pendingBatch->dispatch(); | ||
|
||
$fake->assertBatched(function (PendingBatch $pendingBatch) { | ||
$this->assertCount(1, $pendingBatch->jobs); | ||
$this->assertInstanceOf(UpdateVCard::class, $pendingBatch->jobs->first()); | ||
|
||
return true; | ||
}); | ||
|
||
$batch = app(DatabaseBatchRepository::class)->store($pendingBatch); | ||
$job->withBatchId($batch->id)->handle(); | ||
|
||
$this->assertDatabaseHas('contacts', [ | ||
'first_name' => 'Test', | ||
'vcard' => $card, | ||
'distant_etag' => $etag, | ||
]); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
tests/Unit/Domains/Contact/DavClient/Jobs/DeleteMultipleVCardTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Tests\Unit\Domains\Contact\DavClient\Jobs; | ||
|
||
use App\Domains\Contact\DavClient\Jobs\DeleteMultipleVCard; | ||
use App\Domains\Contact\DavClient\Jobs\DeleteVCard; | ||
use App\Models\AddressBookSubscription; | ||
use Illuminate\Bus\DatabaseBatchRepository; | ||
use Illuminate\Bus\PendingBatch; | ||
use Illuminate\Foundation\Testing\DatabaseTransactions; | ||
use Illuminate\Support\Facades\Bus; | ||
use Tests\TestCase; | ||
|
||
class DeleteMultipleVCardTest extends TestCase | ||
{ | ||
use DatabaseTransactions; | ||
|
||
/** @test */ | ||
public function it_delete_cards() | ||
{ | ||
$fake = Bus::fake(); | ||
|
||
$addressBookSubscription = AddressBookSubscription::factory()->create(); | ||
|
||
$pendingBatch = $fake->batch([ | ||
$job = new DeleteMultipleVCard($addressBookSubscription, ['https://test/dav/uri']), | ||
]); | ||
$batch = $pendingBatch->dispatch(); | ||
|
||
$fake->assertBatched(function (PendingBatch $pendingBatch) { | ||
$this->assertCount(1, $pendingBatch->jobs); | ||
$this->assertInstanceOf(DeleteMultipleVCard::class, $pendingBatch->jobs->first()); | ||
|
||
return true; | ||
}); | ||
|
||
$batch = app(DatabaseBatchRepository::class)->store($pendingBatch); | ||
$job->withBatchId($batch->id)->handle(); | ||
|
||
$fake->assertDispatched(function (DeleteVCard $updateVCard) { | ||
$uri = $this->getPrivateValue($updateVCard, 'uri'); | ||
$this->assertEquals('https://test/dav/uri', $uri); | ||
|
||
return true; | ||
}); | ||
} | ||
} |
Oops, something went wrong.