Skip to content
Snippets Groups Projects
Commit 1ef7d624 authored by Jaime Perez Crespo's avatar Jaime Perez Crespo
Browse files

Complete the test coverage for \SimpleSAML\Utils\Config\Metadata::getContact().

parent 489fc1c3
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,13 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase ...@@ -12,6 +12,13 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
*/ */
public function testGetContact() public function testGetContact()
{ {
// test invalid argument
try {
$parsed = \SimpleSAML\Utils\Config\Metadata::getContact('string');
} catch (InvalidArgumentException $e) {
$this->assertEquals('Invalid input parameters', $e->getMessage());
}
// test missing type // test missing type
$contact = array( $contact = array(
'name' => 'John Doe' 'name' => 'John Doe'
...@@ -159,6 +166,12 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase ...@@ -159,6 +166,12 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
); );
} }
} }
$valid_types = array('email@example.com', array('email1@example.com', 'email2@example.com'));
foreach ($valid_types as $type) {
$contact['emailAddress'] = $type;
$parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
$this->assertEquals($type, $parsed['emailAddress']);
}
// test telephoneNumber // test telephoneNumber
$contact = array( $contact = array(
...@@ -185,6 +198,12 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase ...@@ -185,6 +198,12 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase
$this->assertEquals('Telephone numbers must be a string and cannot be empty.', $e->getMessage()); $this->assertEquals('Telephone numbers must be a string and cannot be empty.', $e->getMessage());
} }
} }
$valid_types = array('1234', array('1234', '5678'));
foreach ($valid_types as $type) {
$contact['telephoneNumber'] = $type;
$parsed = \SimpleSAML\Utils\Config\Metadata::getContact($contact);
$this->assertEquals($type, $parsed['telephoneNumber']);
}
// test completeness // test completeness
$contact = array(); $contact = array();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment