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
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
ae1387f0
Unverified
Commit
ae1387f0
authored
7 years ago
by
Tim van Dijen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PSR-2
parent
474506f5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/lib/SimpleSAML/ConfigurationTest.php
+146
-108
146 additions, 108 deletions
tests/lib/SimpleSAML/ConfigurationTest.php
with
146 additions
and
108 deletions
tests/lib/SimpleSAML/ConfigurationTest.php
+
146
−
108
View file @
ae1387f0
...
@@ -5,11 +5,11 @@
...
@@ -5,11 +5,11 @@
*/
*/
class
Test_SimpleSAML_Configuration
extends
SimpleSAML\Test\Utils\ClearStateTestCase
class
Test_SimpleSAML_Configuration
extends
SimpleSAML\Test\Utils\ClearStateTestCase
{
{
/**
/**
* Test SimpleSAML_Configuration::getVersion()
* Test SimpleSAML_Configuration::getVersion()
*/
*/
public
function
testGetVersion
()
{
public
function
testGetVersion
()
{
$c
=
SimpleSAML_Configuration
::
getOptionalConfig
();
$c
=
SimpleSAML_Configuration
::
getOptionalConfig
();
$this
->
assertTrue
(
is_string
(
$c
->
getVersion
()));
$this
->
assertTrue
(
is_string
(
$c
->
getVersion
()));
}
}
...
@@ -48,11 +48,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -48,11 +48,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getValue()
* Test SimpleSAML_Configuration::getValue()
*/
*/
public
function
testGetValue
()
{
public
function
testGetValue
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'exists_true'
=>
true
,
'exists_true'
=>
true
,
'exists_null'
=>
null
,
'exists_null'
=>
null
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
),
null
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
),
null
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
,
true
),
true
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
,
true
),
true
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
,
true
),
true
);
$this
->
assertEquals
(
$c
->
getValue
(
'missing'
,
true
),
true
);
...
@@ -67,7 +68,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -67,7 +68,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getValue(), REQUIRED_OPTION flag.
* Test SimpleSAML_Configuration::getValue(), REQUIRED_OPTION flag.
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetValueRequired
()
{
public
function
testGetValueRequired
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
$c
->
getValue
(
'missing'
,
SimpleSAML_Configuration
::
REQUIRED_OPTION
);
$c
->
getValue
(
'missing'
,
SimpleSAML_Configuration
::
REQUIRED_OPTION
);
}
}
...
@@ -75,7 +77,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -75,7 +77,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::hasValue()
* Test SimpleSAML_Configuration::hasValue()
*/
*/
public
function
testHasValue
()
{
public
function
testHasValue
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
'exists_true'
=>
true
,
'exists_true'
=>
true
,
'exists_null'
=>
null
,
'exists_null'
=>
null
,
...
@@ -88,7 +91,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -88,7 +91,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::hasValue()
* Test SimpleSAML_Configuration::hasValue()
*/
*/
public
function
testHasValueOneOf
()
{
public
function
testHasValueOneOf
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
'exists_true'
=>
true
,
'exists_true'
=>
true
,
'exists_null'
=>
null
,
'exists_null'
=>
null
,
...
@@ -106,8 +110,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -106,8 +110,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getBaseURL()
* Test SimpleSAML_Configuration::getBaseURL()
*/
*/
public
function
testGetBaseURL
()
{
public
function
testGetBaseURL
()
{
// Need to set a default configuration because the SSP Logger attempts to use it.
// Need to set a default configuration because the SSP Logger attempts to use it.
SimpleSAML_Configuration
::
loadFromArray
(
array
(),
'[ARRAY]'
,
'simplesaml'
);
SimpleSAML_Configuration
::
loadFromArray
(
array
(),
'[ARRAY]'
,
'simplesaml'
);
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
...
@@ -147,7 +151,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -147,7 +151,8 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getBasePath()
* Test SimpleSAML_Configuration::getBasePath()
*/
*/
public
function
testGetBasePath
()
{
public
function
testGetBasePath
()
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
$this
->
assertEquals
(
$c
->
getBasePath
(),
'/simplesaml/'
);
$this
->
assertEquals
(
$c
->
getBasePath
(),
'/simplesaml/'
);
...
@@ -203,10 +208,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -203,10 +208,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::resolvePath()
* Test SimpleSAML_Configuration::resolvePath()
*/
*/
public
function
testResolvePath
()
{
public
function
testResolvePath
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'basedir'
=>
'/basedir/'
,
'basedir'
=>
'/basedir/'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
resolvePath
(
null
),
null
);
$this
->
assertEquals
(
$c
->
resolvePath
(
null
),
null
);
$this
->
assertEquals
(
$c
->
resolvePath
(
'/otherdir'
),
'/otherdir'
);
$this
->
assertEquals
(
$c
->
resolvePath
(
'/otherdir'
),
'/otherdir'
);
...
@@ -219,12 +225,13 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -219,12 +225,13 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getPathValue()
* Test SimpleSAML_Configuration::getPathValue()
*/
*/
public
function
testGetPathValue
()
{
public
function
testGetPathValue
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'basedir'
=>
'/basedir/'
,
'basedir'
=>
'/basedir/'
,
'path_opt'
=>
'path'
,
'path_opt'
=>
'path'
,
'slashes_opt'
=>
'slashes//'
,
'slashes_opt'
=>
'slashes//'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getPathValue
(
'missing'
),
null
);
$this
->
assertEquals
(
$c
->
getPathValue
(
'missing'
),
null
);
$this
->
assertEquals
(
$c
->
getPathValue
(
'path_opt'
),
'/basedir/path/'
);
$this
->
assertEquals
(
$c
->
getPathValue
(
'path_opt'
),
'/basedir/path/'
);
...
@@ -234,13 +241,14 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -234,13 +241,14 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getBaseDir()
* Test SimpleSAML_Configuration::getBaseDir()
*/
*/
public
function
testGetBaseDir
()
{
public
function
testGetBaseDir
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([]);
$this
->
assertEquals
(
$c
->
getBaseDir
(),
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
'/'
);
$this
->
assertEquals
(
$c
->
getBaseDir
(),
dirname
(
dirname
(
dirname
(
dirname
(
__FILE__
))))
.
'/'
);
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
[
'basedir'
=>
'/basedir'
,
'basedir'
=>
'/basedir'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getBaseDir
(),
'/basedir/'
);
$this
->
assertEquals
(
$c
->
getBaseDir
(),
'/basedir/'
);
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
...
@@ -252,11 +260,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -252,11 +260,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getBoolean()
* Test SimpleSAML_Configuration::getBoolean()
*/
*/
public
function
testGetBoolean
()
{
public
function
testGetBoolean
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'true_opt'
=>
true
,
'true_opt'
=>
true
,
'false_opt'
=>
false
,
'false_opt'
=>
false
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'true_opt'
,
'--missing--'
),
true
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'true_opt'
,
'--missing--'
),
true
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'false_opt'
,
'--missing--'
),
false
);
$this
->
assertEquals
(
$c
->
getBoolean
(
'false_opt'
,
'--missing--'
),
false
);
...
@@ -266,8 +275,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -266,8 +275,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getBoolean() missing option
* Test SimpleSAML_Configuration::getBoolean() missing option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetBooleanMissing
()
{
public
function
testGetBooleanMissing
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([]);
$c
->
getBoolean
(
'missing_opt'
);
$c
->
getBoolean
(
'missing_opt'
);
}
}
...
@@ -275,20 +285,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -275,20 +285,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getBoolean() wrong option
* Test SimpleSAML_Configuration::getBoolean() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetBooleanWrong
()
{
public
function
testGetBooleanWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'wrong'
=>
'true'
,
'wrong'
=>
'true'
,
)
);
]
);
$c
->
getBoolean
(
'wrong'
);
$c
->
getBoolean
(
'wrong'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getString()
* Test SimpleSAML_Configuration::getString()
*/
*/
public
function
testGetString
()
{
public
function
testGetString
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'str_opt'
=>
'Hello World!'
,
'str_opt'
=>
'Hello World!'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getString
(
'str_opt'
,
'--missing--'
),
'Hello World!'
);
$this
->
assertEquals
(
$c
->
getString
(
'str_opt'
,
'--missing--'
),
'Hello World!'
);
}
}
...
@@ -297,8 +309,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -297,8 +309,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getString() missing option
* Test SimpleSAML_Configuration::getString() missing option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetStringMissing
()
{
public
function
testGetStringMissing
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([]);
$c
->
getString
(
'missing_opt'
);
$c
->
getString
(
'missing_opt'
);
}
}
...
@@ -306,20 +319,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -306,20 +319,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getString() wrong option
* Test SimpleSAML_Configuration::getString() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetStringWrong
()
{
public
function
testGetStringWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'wrong'
=>
false
,
'wrong'
=>
false
,
)
);
]
);
$c
->
getString
(
'wrong'
);
$c
->
getString
(
'wrong'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getInteger()
* Test SimpleSAML_Configuration::getInteger()
*/
*/
public
function
testGetInteger
()
{
public
function
testGetInteger
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'int_opt'
=>
42
,
'int_opt'
=>
42
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getInteger
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getInteger
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getInteger
(
'int_opt'
,
'--missing--'
),
42
);
$this
->
assertEquals
(
$c
->
getInteger
(
'int_opt'
,
'--missing--'
),
42
);
}
}
...
@@ -328,8 +343,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -328,8 +343,9 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getInteger() missing option
* Test SimpleSAML_Configuration::getInteger() missing option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetIntegerMissing
()
{
public
function
testGetIntegerMissing
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
());
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([]);
$c
->
getInteger
(
'missing_opt'
);
$c
->
getInteger
(
'missing_opt'
);
}
}
...
@@ -337,20 +353,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -337,20 +353,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getInteger() wrong option
* Test SimpleSAML_Configuration::getInteger() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetIntegerWrong
()
{
public
function
testGetIntegerWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'wrong'
=>
'42'
,
'wrong'
=>
'42'
,
)
);
]
);
$c
->
getInteger
(
'wrong'
);
$c
->
getInteger
(
'wrong'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getIntegerRange()
* Test SimpleSAML_Configuration::getIntegerRange()
*/
*/
public
function
testGetIntegerRange
()
{
public
function
testGetIntegerRange
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'int_opt'
=>
42
,
'int_opt'
=>
42
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'missing_opt'
,
0
,
100
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'missing_opt'
,
0
,
100
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
0
,
100
),
42
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
0
,
100
),
42
);
}
}
...
@@ -359,10 +377,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -359,10 +377,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getIntegerRange() below limit
* Test SimpleSAML_Configuration::getIntegerRange() below limit
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetIntegerRangeBelow
()
{
public
function
testGetIntegerRangeBelow
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'int_opt'
=>
9
,
'int_opt'
=>
9
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
10
,
100
),
42
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
10
,
100
),
42
);
}
}
...
@@ -370,10 +389,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -370,10 +389,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getIntegerRange() above limit
* Test SimpleSAML_Configuration::getIntegerRange() above limit
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetIntegerRangeAbove
()
{
public
function
testGetIntegerRangeAbove
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'int_opt'
=>
101
,
'int_opt'
=>
101
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
10
,
100
),
42
);
$this
->
assertEquals
(
$c
->
getIntegerRange
(
'int_opt'
,
10
,
100
),
42
);
}
}
...
@@ -392,20 +412,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -392,20 +412,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getValueValidate() wrong option
* Test SimpleSAML_Configuration::getValueValidate() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetValueValidateWrong
()
{
public
function
testGetValueValidateWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
'd'
,
'opt'
=>
'd'
,
)
);
]
);
$c
->
getValueValidate
(
'opt'
,
array
(
'a'
,
'b'
,
'c'
));
$c
->
getValueValidate
(
'opt'
,
array
(
'a'
,
'b'
,
'c'
));
}
}
/**
/**
* Test SimpleSAML_Configuration::getArray()
* Test SimpleSAML_Configuration::getArray()
*/
*/
public
function
testGetArray
()
{
public
function
testGetArray
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
)
);
]
);
$this
->
assertEquals
(
$c
->
getArray
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArray
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArray
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
$this
->
assertEquals
(
$c
->
getArray
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
}
}
...
@@ -414,22 +436,24 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -414,22 +436,24 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getArray() wrong option
* Test SimpleSAML_Configuration::getArray() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetArrayWrong
()
{
public
function
testGetArrayWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
'not_an_array'
,
'opt'
=>
'not_an_array'
,
)
);
]
);
$c
->
getArray
(
'opt'
);
$c
->
getArray
(
'opt'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getArrayize()
* Test SimpleSAML_Configuration::getArrayize()
*/
*/
public
function
testGetArrayize
()
{
public
function
testGetArrayize
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
'opt_int'
=>
42
,
'opt_int'
=>
42
,
'opt_str'
=>
'string'
,
'opt_str'
=>
'string'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getArrayize
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArrayize
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArrayize
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
$this
->
assertEquals
(
$c
->
getArrayize
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
$this
->
assertEquals
(
$c
->
getArrayize
(
'opt_int'
),
array
(
42
));
$this
->
assertEquals
(
$c
->
getArrayize
(
'opt_int'
),
array
(
42
));
...
@@ -439,11 +463,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -439,11 +463,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getArrayizeString()
* Test SimpleSAML_Configuration::getArrayizeString()
*/
*/
public
function
testGetArrayizeString
()
{
public
function
testGetArrayizeString
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
'opt'
=>
array
(
'a'
,
'b'
,
'c'
),
'opt_str'
=>
'string'
,
'opt_str'
=>
'string'
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'opt'
),
array
(
'a'
,
'b'
,
'c'
));
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'opt_str'
),
array
(
'string'
));
$this
->
assertEquals
(
$c
->
getArrayizeString
(
'opt_str'
),
array
(
'string'
));
...
@@ -453,20 +478,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -453,20 +478,22 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getArrayizeString() option with an array that contains something that isn't a string.
* Test SimpleSAML_Configuration::getArrayizeString() option with an array that contains something that isn't a string.
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetArrayizeStringWrongValue
()
{
public
function
testGetArrayizeStringWrongValue
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'a'
,
'b'
,
42
),
'opt'
=>
array
(
'a'
,
'b'
,
42
),
)
);
]
);
$c
->
getArrayizeString
(
'opt'
);
$c
->
getArrayizeString
(
'opt'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getConfigItem()
* Test SimpleSAML_Configuration::getConfigItem()
*/
*/
public
function
testGetConfigItem
()
{
public
function
testGetConfigItem
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'a'
=>
42
),
'opt'
=>
array
(
'a'
=>
42
),
)
);
]
);
$this
->
assertEquals
(
$c
->
getConfigItem
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getConfigItem
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$opt
=
$c
->
getConfigItem
(
'opt'
);
$opt
=
$c
->
getConfigItem
(
'opt'
);
$this
->
assertInstanceOf
(
'SimpleSAML_Configuration'
,
$opt
);
$this
->
assertInstanceOf
(
'SimpleSAML_Configuration'
,
$opt
);
...
@@ -477,23 +504,25 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -477,23 +504,25 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getConfigItem() wrong option
* Test SimpleSAML_Configuration::getConfigItem() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetConfigItemWrong
()
{
public
function
testGetConfigItemWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
'not_an_array'
,
'opt'
=>
'not_an_array'
,
)
);
]
);
$c
->
getConfigItem
(
'opt'
);
$c
->
getConfigItem
(
'opt'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getConfigList()
* Test SimpleSAML_Configuration::getConfigList()
*/
*/
public
function
testGetConfigList
()
{
public
function
testGetConfigList
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opts'
=>
array
(
'opts'
=>
array
(
'a'
=>
array
(
'opt1'
=>
'value1'
),
'a'
=>
array
(
'opt1'
=>
'value1'
),
'b'
=>
array
(
'opt2'
=>
'value2'
),
'b'
=>
array
(
'opt2'
=>
'value2'
),
),
),
)
);
]
);
$this
->
assertEquals
(
$c
->
getConfigList
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getConfigList
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$opts
=
$c
->
getConfigList
(
'opts'
);
$opts
=
$c
->
getConfigList
(
'opts'
);
$this
->
assertInternalType
(
'array'
,
$opts
);
$this
->
assertInternalType
(
'array'
,
$opts
);
...
@@ -508,10 +537,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -508,10 +537,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getConfigList() wrong option
* Test SimpleSAML_Configuration::getConfigList() wrong option
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetConfigListWrong
()
{
public
function
testGetConfigListWrong
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
'not_an_array'
,
'opt'
=>
'not_an_array'
,
)
);
]
);
$c
->
getConfigList
(
'opt'
);
$c
->
getConfigList
(
'opt'
);
}
}
...
@@ -522,12 +552,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -522,12 +552,12 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
*/
*/
public
function
testGetConfigListWrongArrayValues
()
public
function
testGetConfigListWrongArrayValues
()
{
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
[
'opts'
=>
array
(
'opts'
=>
array
(
'a'
,
'a'
,
'b'
,
'b'
,
),
),
)
);
]
);
$c
->
getConfigList
(
'opts'
);
$c
->
getConfigList
(
'opts'
);
}
}
...
@@ -535,22 +565,24 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -535,22 +565,24 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getOptions()
* Test SimpleSAML_Configuration::getOptions()
*/
*/
public
function
testGetOptions
()
{
public
function
testGetOptions
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'a'
=>
true
,
'a'
=>
true
,
'b'
=>
null
,
'b'
=>
null
,
)
);
]
);
$this
->
assertEquals
(
$c
->
getOptions
(),
array
(
'a'
,
'b'
));
$this
->
assertEquals
(
$c
->
getOptions
(),
array
(
'a'
,
'b'
));
}
}
/**
/**
* Test SimpleSAML_Configuration::toArray()
* Test SimpleSAML_Configuration::toArray()
*/
*/
public
function
testToArray
()
{
public
function
testToArray
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'a'
=>
true
,
'a'
=>
true
,
'b'
=>
null
,
'b'
=>
null
,
)
);
]
);
$this
->
assertEquals
(
$c
->
toArray
(),
array
(
'a'
=>
true
,
'b'
=>
null
));
$this
->
assertEquals
(
$c
->
toArray
(),
array
(
'a'
=>
true
,
'b'
=>
null
));
}
}
...
@@ -879,14 +911,15 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -879,14 +911,15 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
/**
/**
* Test SimpleSAML_Configuration::getLocalizedString()
* Test SimpleSAML_Configuration::getLocalizedString()
*/
*/
public
function
testGetLocalizedString
()
{
public
function
testGetLocalizedString
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'str_opt'
=>
'Hello World!'
,
'str_opt'
=>
'Hello World!'
,
'str_array'
=>
array
(
'str_array'
=>
array
(
'en'
=>
'Hello World!'
,
'en'
=>
'Hello World!'
,
'no'
=>
'Hei Verden!'
,
'no'
=>
'Hei Verden!'
,
),
),
)
);
]
);
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'missing_opt'
,
'--missing--'
),
'--missing--'
);
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'str_opt'
),
array
(
'en'
=>
'Hello World!'
));
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'str_opt'
),
array
(
'en'
=>
'Hello World!'
));
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'str_array'
),
array
(
'en'
=>
'Hello World!'
,
'no'
=>
'Hei Verden!'
));
$this
->
assertEquals
(
$c
->
getLocalizedString
(
'str_array'
),
array
(
'en'
=>
'Hello World!'
,
'no'
=>
'Hei Verden!'
));
...
@@ -896,10 +929,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -896,10 +929,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getLocalizedString() not array nor simple string
* Test SimpleSAML_Configuration::getLocalizedString() not array nor simple string
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetLocalizedStringNotArray
()
{
public
function
testGetLocalizedStringNotArray
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
42
,
'opt'
=>
42
,
)
);
]
);
$c
->
getLocalizedString
(
'opt'
);
$c
->
getLocalizedString
(
'opt'
);
}
}
...
@@ -907,10 +941,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -907,10 +941,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getLocalizedString() not string key
* Test SimpleSAML_Configuration::getLocalizedString() not string key
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetLocalizedStringNotStringKey
()
{
public
function
testGetLocalizedStringNotStringKey
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
42
=>
'text'
),
'opt'
=>
array
(
42
=>
'text'
),
)
);
]
);
$c
->
getLocalizedString
(
'opt'
);
$c
->
getLocalizedString
(
'opt'
);
}
}
...
@@ -918,10 +953,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -918,10 +953,11 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getLocalizedString() not string value
* Test SimpleSAML_Configuration::getLocalizedString() not string value
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetLocalizedStringNotStringValue
()
{
public
function
testGetLocalizedStringNotStringValue
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'opt'
=>
array
(
'en'
=>
42
),
'opt'
=>
array
(
'en'
=>
42
),
)
);
]
);
$c
->
getLocalizedString
(
'opt'
);
$c
->
getLocalizedString
(
'opt'
);
}
}
...
@@ -929,17 +965,19 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
...
@@ -929,17 +965,19 @@ class Test_SimpleSAML_Configuration extends SimpleSAML\Test\Utils\ClearStateTest
* Test SimpleSAML_Configuration::getConfig() nonexistent file
* Test SimpleSAML_Configuration::getConfig() nonexistent file
* @expectedException Exception
* @expectedException Exception
*/
*/
public
function
testGetConfigNonexistentFile
()
{
public
function
testGetConfigNonexistentFile
()
{
SimpleSAML_Configuration
::
getConfig
(
'nonexistent-nopreload.php'
);
SimpleSAML_Configuration
::
getConfig
(
'nonexistent-nopreload.php'
);
}
}
/**
/**
* Test SimpleSAML_Configuration::getConfig() preloaded nonexistent file
* Test SimpleSAML_Configuration::getConfig() preloaded nonexistent file
*/
*/
public
function
testGetConfigNonexistentFilePreload
()
{
public
function
testGetConfigNonexistentFilePreload
()
$c
=
SimpleSAML_Configuration
::
loadFromArray
(
array
(
{
$c
=
SimpleSAML_Configuration
::
loadFromArray
([
'key'
=>
'value'
'key'
=>
'value'
)
);
]
);
$virtualFile
=
'nonexistent-preload.php'
;
$virtualFile
=
'nonexistent-preload.php'
;
SimpleSAML_Configuration
::
setPreLoadedConfig
(
$c
,
$virtualFile
);
SimpleSAML_Configuration
::
setPreLoadedConfig
(
$c
,
$virtualFile
);
$nc
=
SimpleSAML_Configuration
::
getConfig
(
$virtualFile
);
$nc
=
SimpleSAML_Configuration
::
getConfig
(
$virtualFile
);
...
...
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