Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
b5c12019
Commit
b5c12019
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Move Utils_AttributesTest to SimpleSAML\Test\Utils\AttributesTest.
parent
4f6b1c14
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/SimpleSAML/Utils/AttributesTest.php
+19
-16
19 additions, 16 deletions
tests/lib/SimpleSAML/Utils/AttributesTest.php
with
19 additions
and
16 deletions
tests/lib/SimpleSAML/Utils/AttributesTest.php
+
19
−
16
View file @
b5c12019
<?php
namespace
SimpleSAML\Test\Utils
;
use
SimpleSAML\Utils\Attributes
;
/**
* Tests for SimpleSAML\Utils\Attributes.
*
* @author Jaime Perez, UNINETT AS <jaime.perez@uninett.no>
*/
class
Utils_
AttributesTest
extends
PHPUnit_Framework_TestCase
class
AttributesTest
extends
\
PHPUnit_Framework_TestCase
{
/**
...
...
@@ -21,7 +24,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'InvalidArgumentException'
,
'The attributes array is not an array, it is: '
.
print_r
(
$attributes
,
true
)
.
'.'
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -37,7 +40,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'InvalidArgumentException'
,
'The expected attribute is not a string, it is: '
.
print_r
(
$expected
,
true
)
.
'.'
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -55,7 +58,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'InvalidArgumentException'
,
'The attributes array is not normalized, values should be arrays.'
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -73,7 +76,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'SimpleSAML_Error_Exception'
,
"No such attribute '"
.
$expected
.
"' found."
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -91,7 +94,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'SimpleSAML_Error_Exception'
,
"Empty attribute '"
.
$expected
.
"'.'"
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -112,7 +115,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'SimpleSAML_Error_Exception'
,
'More than one value found for the attribute, multiple values not allowed.'
);
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
);
}
...
...
@@ -127,7 +130,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'attribute'
=>
array
(
$value
),
);
$expected
=
'attribute'
;
$this
->
assertEquals
(
$value
,
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
));
$this
->
assertEquals
(
$value
,
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
));
// check multiple (allowed) values
$value
=
'value'
;
...
...
@@ -135,38 +138,38 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
'attribute'
=>
array
(
$value
,
'value2'
,
'value3'
),
);
$expected
=
'attribute'
;
$this
->
assertEquals
(
$value
,
\SimpleSAML\Utils\
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
,
true
));
$this
->
assertEquals
(
$value
,
Attributes
::
getExpectedAttribute
(
$attributes
,
$expected
,
true
));
}
/**
* Test the normalizeAttributesArray() function with input not being an array
*
* @expectedException InvalidArgumentException
* @expectedException
\
InvalidArgumentException
*/
public
function
testNormalizeAttributesArrayBadInput
()
{
SimpleSAML\Utils\
Attributes
::
normalizeAttributesArray
(
'string'
);
Attributes
::
normalizeAttributesArray
(
'string'
);
}
/**
* Test the normalizeAttributesArray() function with an array with non-string attribute names.
*
* @expectedException InvalidArgumentException
* @expectedException
\
InvalidArgumentException
*/
public
function
testNormalizeAttributesArrayBadKeys
()
{
SimpleSAML\Utils\
Attributes
::
normalizeAttributesArray
(
array
(
'attr1'
=>
'value1'
,
1
=>
'value2'
));
Attributes
::
normalizeAttributesArray
(
array
(
'attr1'
=>
'value1'
,
1
=>
'value2'
));
}
/**
* Test the normalizeAttributesArray() function with an array with non-string attribute values.
*
* @expectedException InvalidArgumentException
* @expectedException
\
InvalidArgumentException
*/
public
function
testNormalizeAttributesArrayBadValues
()
{
SimpleSAML\Utils\
Attributes
::
normalizeAttributesArray
(
array
(
'attr1'
=>
'value1'
,
'attr2'
=>
0
));
Attributes
::
normalizeAttributesArray
(
array
(
'attr1'
=>
'value1'
,
'attr2'
=>
0
));
}
/**
...
...
@@ -186,7 +189,7 @@ class Utils_AttributesTest extends PHPUnit_Framework_TestCase
);
$this
->
assertEquals
(
$expected
,
SimpleSAML\Utils\
Attributes
::
normalizeAttributesArray
(
$attributes
),
Attributes
::
normalizeAttributesArray
(
$attributes
),
'Attribute array normalization failed'
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment