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

feat: add more vcard exports #6997

Merged
merged 9 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Next Next commit
add tests
  • Loading branch information
asbiin committed Nov 4, 2023
commit 1878197d95956a35d146ad5f7814bdb4890c7e60
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ public function execute(array $data): AddressType

$type = AddressType::create([
'account_id' => $data['account_id'],
'name' => $data['name'] ?? null,
'name_translation_key' => $data['name_translation_key'] ?? null,
'name' => $this->valueOrNull($data, 'name'),
'name_translation_key' => $this->valueOrNull($data, 'name_translation_key'),
]);

return $type;
Expand Down
43 changes: 43 additions & 0 deletions tests/Unit/Domains/Contact/ManageContact/Dav/ImportAddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,49 @@ public function it_imports_address_type()
$this->assertEquals('home', $address->addressType->name);
}

#[Group('dav')]
#[Test]
public function it_imports_new_address_type()
{
$user = $this->createAdministrator();
$vault = $this->createVaultUser($user, Vault::PERMISSION_MANAGE);
$importVCard = new ImportVCard();
$importVCard->author = $user;
$importVCard->vault = $vault;
$importer = new ImportAddress();
$importer->setContext($importVCard);

$contact = Contact::factory()->create([
'vault_id' => $vault->id,
]);

$vcard = new VCard();
$vcard->add('ADR', [
'',
'line 1',
'line 2',
'city',
'province',
'postal code',
'country',
], [
'TYPE' => 'home',
]);

$contact = $importer->import($vcard, $contact);

$this->assertCount(1, $contact->addresses);
$address = $contact->addresses->first();

$this->assertDatabaseHas('address_types', [
'account_id' => $user->account_id,
'name' => 'home',
]);

$this->assertNotNull($address->addressType);
$this->assertEquals('home', $address->addressType->name);
}

#[Group('dav')]
#[Test]
public function it_imports_new_address_and_remove_old()
Expand Down