mirror of
https://github.com/roundcube/roundcubemail.git
synced 2026-03-07 00:26:48 +01:00
* fix Tests\Browser\TestCase imports * fix remaining imports * fix PHPUnit\Framework\TestCase imports * import GuzzleHttp\Client * fix remaining * "php_unit_method_casing" is not todo * fix "single_line_comment_spacing" * fix 2nd commit done using older fixer
61 lines
1.6 KiB
PHP
61 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Browser\Contacts;
|
|
|
|
use Tests\Browser\TestCase;
|
|
|
|
class ExportTest extends TestCase
|
|
{
|
|
public static function setUpBeforeClass(): void
|
|
{
|
|
\bootstrap::init_db();
|
|
}
|
|
|
|
/**
|
|
* Test exporting all contacts
|
|
*/
|
|
public function testExportAll()
|
|
{
|
|
$this->browse(function ($browser) {
|
|
$browser->go('addressbook');
|
|
|
|
$browser->clickToolbarMenuItem('export');
|
|
|
|
// Parse the downloaded vCard file
|
|
$vcard_content = $browser->readDownloadedFile('contacts.vcf');
|
|
$vcard = new \rcube_vcard();
|
|
$contacts = $vcard->import($vcard_content);
|
|
|
|
$this->assertCount(2, $contacts);
|
|
$this->assertSame('John Doe', $contacts[0]->displayname);
|
|
$this->assertSame('Jane Stalone', $contacts[1]->displayname);
|
|
|
|
$browser->removeDownloadedFile('contacts.vcf');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Test exporting selected contacts
|
|
*
|
|
* @depends testExportAll
|
|
*/
|
|
public function testExportSelected()
|
|
{
|
|
$this->browse(function ($browser) {
|
|
$browser->ctrlClick('#contacts-table tbody tr:first-child');
|
|
|
|
$browser->clickToolbarMenuItem('export', 'export.select');
|
|
|
|
$vcard_content = $browser->readDownloadedFile('contacts.vcf');
|
|
$vcard = new \rcube_vcard();
|
|
$contacts = $vcard->import($vcard_content);
|
|
|
|
// Parse the downloaded vCard file
|
|
$this->assertCount(1, $contacts);
|
|
$this->assertSame('John Doe', $contacts[0]->displayname);
|
|
|
|
$browser->removeDownloadedFile('contacts.vcf');
|
|
});
|
|
}
|
|
}
|