Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3311060
Csv2vcard.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
Csv2vcard.php
View Options
<?php
/**
* Test class to test rcube_csv2vcard class
*
* @package Tests
*/
class
Framework_Csv2vcard
extends
PHPUnit_Framework_TestCase
{
function
test_import_generic
()
{
$csv
=
new
rcube_csv2vcard
;
// empty input
$csv
->
import
(
''
);
$this
->
assertSame
(
array
(),
$csv
->
export
());
}
function
test_import_tb_plain
()
{
$csv_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/tb_plain.csv'
);
$vcf_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/tb_plain.vcf'
);
$csv
=
new
rcube_csv2vcard
;
$csv
->
import
(
$csv_text
);
$result
=
$csv
->
export
();
$vcard
=
$result
[
0
]->
export
(
false
);
$this
->
assertCount
(
1
,
$result
);
$vcf_text
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcf_text
));
$vcard
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcard
));
$this
->
assertEquals
(
$vcf_text
,
$vcard
);
}
function
test_import_email
()
{
$csv_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/email.csv'
);
$vcf_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/email.vcf'
);
$csv
=
new
rcube_csv2vcard
;
$csv
->
import
(
$csv_text
);
$result
=
$csv
->
export
();
$this
->
assertCount
(
4
,
$result
);
$vcard
=
''
;
foreach
(
$result
as
$vcf
)
{
$vcard
.=
$vcf
->
export
(
false
)
.
"
\n
"
;
}
$vcf_text
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcf_text
));
$vcard
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcard
));
$this
->
assertEquals
(
$vcf_text
,
$vcard
);
}
function
test_import_gmail
()
{
$csv_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/gmail.csv'
);
$vcf_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/gmail.vcf'
);
$csv
=
new
rcube_csv2vcard
;
$csv
->
import
(
$csv_text
);
$result
=
$csv
->
export
();
$vcard
=
$result
[
0
]->
export
(
false
);
$this
->
assertCount
(
1
,
$result
);
$vcf_text
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcf_text
));
$vcard
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcard
));
$this
->
assertEquals
(
$vcf_text
,
$vcard
);
}
function
test_import_outlook
()
{
$csv_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/outlook.csv'
);
$vcf_text
=
file_get_contents
(
TESTS_DIR
.
'/src/Csv2vcard/outlook.vcf'
);
$csv
=
new
rcube_csv2vcard
;
$csv
->
import
(
$csv_text
);
$result
=
$csv
->
export
();
$vcard
=
$result
[
0
]->
export
(
false
);
$this
->
assertCount
(
1
,
$result
);
$vcf_text
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcf_text
));
$vcard
=
trim
(
str_replace
(
"
\r\n
"
,
"
\n
"
,
$vcard
));
$this
->
assertEquals
(
$vcf_text
,
$vcard
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, Apr 9, 12:52 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
462928
Default Alt Text
Csv2vcard.php (2 KB)
Attached To
Mode
R3 roundcubemail
Attached
Detach File
Event Timeline
Log In to Comment