summaryrefslogtreecommitdiffstats
path: root/tests/lib/SimpleSAML
diff options
context:
space:
mode:
authorJaime Perez Crespo <jaime.perez@uninett.no>2015-09-01 13:38:52 +0200
committerJaime Perez Crespo <jaime.perez@uninett.no>2015-09-01 13:38:52 +0200
commit33aa4f30faaeeeebdc599ba10e2ffd759d828256 (patch)
tree52f0dd275b6f616c9a2ab1d33fb4103efb5c4cd8 /tests/lib/SimpleSAML
parent60641a82c00244766d189f8ab3f16f5ba7b0ce02 (diff)
downloadsimplesamlphp-33aa4f30faaeeeebdc599ba10e2ffd759d828256.zip
simplesamlphp-33aa4f30faaeeeebdc599ba10e2ffd759d828256.tar.gz
simplesamlphp-33aa4f30faaeeeebdc599ba10e2ffd759d828256.tar.bz2
Refactor SimpleSAML\Utils\Arrays::normalizeAttributesArray() to SimpleSAML\Utils\Attributes::normalizeAttributesArray().
Diffstat (limited to 'tests/lib/SimpleSAML')
-rw-r--r--tests/lib/SimpleSAML/Utils/ArraysTest.php49
-rw-r--r--tests/lib/SimpleSAML/Utils/AttributesTest.php53
2 files changed, 53 insertions, 49 deletions
diff --git a/tests/lib/SimpleSAML/Utils/ArraysTest.php b/tests/lib/SimpleSAML/Utils/ArraysTest.php
index 5cc00de..014dd24 100644
--- a/tests/lib/SimpleSAML/Utils/ArraysTest.php
+++ b/tests/lib/SimpleSAML/Utils/ArraysTest.php
@@ -33,55 +33,6 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase
$this->assertEquals($expected, SimpleSAML\Utils\Arrays::arrayize($expected[$index], $index));
}
- /**
- * Test the normalizeAttributesArray() function with input not being an array
- *
- * @expectedException InvalidArgumentException
- */
- public function testNormalizeAttributesArrayBadInput()
- {
- SimpleSAML\Utils\Arrays::normalizeAttributesArray('string');
- }
-
- /**
- * Test the normalizeAttributesArray() function with an array with non-string attribute names.
- *
- * @expectedException InvalidArgumentException
- */
- public function testNormalizeAttributesArrayBadKeys()
- {
- SimpleSAML\Utils\Arrays::normalizeAttributesArray(array('attr1' => 'value1', 1 => 'value2'));
- }
-
- /**
- * Test the normalizeAttributesArray() function with an array with non-string attribute values.
- *
- * @expectedException InvalidArgumentException
- */
- public function testNormalizeAttributesArrayBadValues()
- {
- SimpleSAML\Utils\Arrays::normalizeAttributesArray(array('attr1' => 'value1', 'attr2' => 0));
- }
-
- /**
- * Test the normalizeAttributesArray() function.
- */
- public function testNormalizeAttributesArray()
- {
- $attributes = array(
- 'key1' => 'value1',
- 'key2' => array('value2', 'value3'),
- 'key3' => 'value1'
- );
- $expected = array(
- 'key1' => array('value1'),
- 'key2' => array('value2', 'value3'),
- 'key3' => array('value1')
- );
- $this->assertEquals($expected, SimpleSAML\Utils\Arrays::normalizeAttributesArray($attributes),
- 'Attribute array normalization failed');
- }
-
/**
* Test the transpose() function.
diff --git a/tests/lib/SimpleSAML/Utils/AttributesTest.php b/tests/lib/SimpleSAML/Utils/AttributesTest.php
index 1960de0..72daf19 100644
--- a/tests/lib/SimpleSAML/Utils/AttributesTest.php
+++ b/tests/lib/SimpleSAML/Utils/AttributesTest.php
@@ -98,4 +98,57 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
$expected = 'attribute';
$this->assertEquals($value, \SimpleSAML\Utils\Attributes::getExpectedAttribute($attributes, $expected, true));
}
+
+
+ /**
+ * Test the normalizeAttributesArray() function with input not being an array
+ *
+ * @expectedException InvalidArgumentException
+ */
+ public function testNormalizeAttributesArrayBadInput()
+ {
+ SimpleSAML\Utils\Attributes::normalizeAttributesArray('string');
+ }
+
+ /**
+ * Test the normalizeAttributesArray() function with an array with non-string attribute names.
+ *
+ * @expectedException InvalidArgumentException
+ */
+ public function testNormalizeAttributesArrayBadKeys()
+ {
+ SimpleSAML\Utils\Attributes::normalizeAttributesArray(array('attr1' => 'value1', 1 => 'value2'));
+ }
+
+ /**
+ * Test the normalizeAttributesArray() function with an array with non-string attribute values.
+ *
+ * @expectedException InvalidArgumentException
+ */
+ public function testNormalizeAttributesArrayBadValues()
+ {
+ SimpleSAML\Utils\Attributes::normalizeAttributesArray(array('attr1' => 'value1', 'attr2' => 0));
+ }
+
+ /**
+ * Test the normalizeAttributesArray() function.
+ */
+ public function testNormalizeAttributesArray()
+ {
+ $attributes = array(
+ 'key1' => 'value1',
+ 'key2' => array('value2', 'value3'),
+ 'key3' => 'value1'
+ );
+ $expected = array(
+ 'key1' => array('value1'),
+ 'key2' => array('value2', 'value3'),
+ 'key3' => array('value1')
+ );
+ $this->assertEquals(
+ $expected,
+ SimpleSAML\Utils\Attributes::normalizeAttributesArray($attributes),
+ 'Attribute array normalization failed'
+ );
+ }
}