From 68cba56c7f276c6f1f5ce434804bbcd0fd8129b2 Mon Sep 17 00:00:00 2001 From: Jaime Perez Crespo <jaime.perez@uninett.no> Date: Wed, 3 Feb 2016 13:22:50 +0100 Subject: [PATCH] Add full test coverage to SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(). --- .../SimpleSAML/Utils/Config/MetadataTest.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php index f01d9b819..8a771354c 100644 --- a/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php +++ b/tests/lib/SimpleSAML/Utils/Config/MetadataTest.php @@ -218,4 +218,40 @@ class Utils_MetadataTest extends PHPUnit_Framework_TestCase } $this->assertArrayNotHasKey('name', $parsed); } + + + /** + * Test \SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(). + */ + public function testIsHiddenFromDiscovery() + { + // test for success + $metadata = array( + 'EntityAttributes' => array( + \SimpleSAML\Utils\Config\Metadata::$ENTITY_CATEGORY => array( + \SimpleSAML\Utils\Config\Metadata::$HIDE_FROM_DISCOVERY, + ), + ), + ); + $this->assertTrue(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery($metadata)); + + // test for failures + $this->assertFalse(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(array('foo'))); + $this->assertFalse(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(array( + 'EntityAttributes' => 'bar', + ))); + $this->assertFalse(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(array( + 'EntityAttributes' => array(), + ))); + $this->assertFalse(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(array( + 'EntityAttributes' => array( + \SimpleSAML\Utils\Config\Metadata::$ENTITY_CATEGORY => '', + ), + ))); + $this->assertFalse(\SimpleSAML\Utils\Config\Metadata::isHiddenFromDiscovery(array( + 'EntityAttributes' => array( + \SimpleSAML\Utils\Config\Metadata::$ENTITY_CATEGORY => array(), + ), + ))); + } } -- GitLab