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
8c95642e
Commit
8c95642e
authored
8 years ago
by
Hanne Moa
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests depending on Language->language_names
parent
766699a1
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/Locale/LanguageTest.php
+42
-20
42 additions, 20 deletions
tests/lib/SimpleSAML/Locale/LanguageTest.php
with
42 additions
and
20 deletions
tests/lib/SimpleSAML/Locale/LanguageTest.php
+
42
−
20
View file @
8c95642e
...
@@ -20,11 +20,11 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
...
@@ -20,11 +20,11 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
// test defaults coming from configuration
// test defaults coming from configuration
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'
xx
'
,
'
yy
'
,
'
zz
'
),
'language.available'
=>
array
(
'
en
'
,
'
es
'
,
'
nn
'
),
'language.default'
=>
'
yy
'
,
'language.default'
=>
'
es
'
,
));
));
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$this
->
assertEquals
(
'
yy
'
,
$l
->
getDefaultLanguage
());
$this
->
assertEquals
(
'
es
'
,
$l
->
getDefaultLanguage
());
}
}
...
@@ -44,39 +44,61 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
...
@@ -44,39 +44,61 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
// test that it works with non-defaults
// test that it works with non-defaults
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'
xx
'
,
'
yy
'
,
'
zz
'
),
'language.available'
=>
array
(
'
en
'
,
'
es
'
,
'
nn
'
),
'language.cookie.name'
=>
'xyz'
'language.cookie.name'
=>
'xyz'
),
''
,
'simplesaml'
);
),
''
,
'simplesaml'
);
$_COOKIE
[
'xyz'
]
=
'
Yy
'
;
// test values are converted to lowercase too
$_COOKIE
[
'xyz'
]
=
'
Es
'
;
// test values are converted to lowercase too
$this
->
assertEquals
(
'
yy
'
,
Language
::
getLanguageCookie
());
$this
->
assertEquals
(
'
es
'
,
Language
::
getLanguageCookie
());
}
}
/**
/**
* Test SimpleSAML\Locale\Language::getLanguageList().
* Test SimpleSAML\Locale\Language::getLanguageList().
*/
*/
public
function
testGetLanguageList
()
public
function
testGetLanguageList
NoConfig
()
{
{
// test defaults
// test defaults
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(),
''
,
'simplesaml'
);
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(),
''
,
'simplesaml'
);
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$l
->
setLanguage
(
'en'
);
$l
->
setLanguage
(
'en'
);
$this
->
assertEquals
(
array
(
'en'
=>
true
),
$l
->
getLanguageList
());
$this
->
assertEquals
(
array
(
'en'
=>
true
),
$l
->
getLanguageList
());
}
// test non-defaults
/**
* Test SimpleSAML\Locale\Language::getLanguageList().
*/
public
function
testGetLanguageListCorrectConfig
()
{
// test langs from from language_names
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'
xx
'
,
'
yy
'
,
'
zz
'
),
'language.available'
=>
array
(
'
en
'
,
'
nn
'
,
'
es
'
),
),
''
,
'simplesaml'
);
),
''
,
'simplesaml'
);
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$l
->
setLanguage
(
'
yy
'
);
$l
->
setLanguage
(
'
es
'
);
$this
->
assertEquals
(
array
(
$this
->
assertEquals
(
array
(
'
xx
'
=>
false
,
'
en
'
=>
false
,
'
yy
'
=>
true
,
'
es
'
=>
true
,
'
zz
'
=>
false
,
'
nn
'
=>
false
,
),
$l
->
getLanguageList
());
),
$l
->
getLanguageList
());
}
}
/**
* Test SimpleSAML\Locale\Language::getLanguageList().
*/
public
function
testGetLanguageListIncorrectConfig
()
{
// test non-existent langs
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'foo'
,
'bar'
),
),
''
,
'simplesaml'
);
$l
=
new
Language
(
$c
);
$l
->
setLanguage
(
'foo'
);
$this
->
assertEquals
(
array
(
'en'
=>
true
),
$l
->
getLanguageList
());
}
/**
/**
* Test SimpleSAML\Locale\Language::getLanguageParameterName().
* Test SimpleSAML\Locale\Language::getLanguageParameterName().
*/
*/
...
@@ -109,7 +131,7 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
...
@@ -109,7 +131,7 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
// test non-defaults, non-RTL
// test non-defaults, non-RTL
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.rtl'
=>
array
(
'
xx'
,
'yy
'
,
'
zz
'
),
'language.rtl'
=>
array
(
'
foo
'
,
'
bar
'
),
),
''
,
'simplesaml'
);
),
''
,
'simplesaml'
);
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$l
->
setLanguage
(
'en'
);
$l
->
setLanguage
(
'en'
);
...
@@ -117,11 +139,11 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
...
@@ -117,11 +139,11 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
// test non-defaults, RTL
// test non-defaults, RTL
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'
xx'
,
'yy
'
,
'
zz
'
,
'e
n
'
),
'language.available'
=>
array
(
'
en
'
,
'
nn
'
,
'e
s
'
),
'language.rtl'
=>
array
(
'
xx
'
,
'
yy
'
),
'language.rtl'
=>
array
(
'
nn
'
,
'
es
'
),
),
''
,
'simplesaml'
);
),
''
,
'simplesaml'
);
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$l
->
setLanguage
(
'
yy
'
);
$l
->
setLanguage
(
'
es
'
);
$this
->
assertTrue
(
$l
->
isLanguageRTL
());
$this
->
assertTrue
(
$l
->
isLanguageRTL
());
}
}
...
@@ -133,13 +155,13 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
...
@@ -133,13 +155,13 @@ class LanguageTest extends \PHPUnit_Framework_TestCase
{
{
// test with valid configuration, no cookies set
// test with valid configuration, no cookies set
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
$c
=
\SimpleSAML_Configuration
::
loadFromArray
(
array
(
'language.available'
=>
array
(
'
xx
'
,
'
yy
'
,
'
zz
'
),
'language.available'
=>
array
(
'
en
'
,
'
nn
'
,
'
es
'
),
'language.parameter.name'
=>
'xyz'
,
'language.parameter.name'
=>
'xyz'
,
'language.parameter.setcookie'
=>
false
,
'language.parameter.setcookie'
=>
false
,
),
''
,
'simplesaml'
);
),
''
,
'simplesaml'
);
$_GET
[
'xyz'
]
=
'
Zz
'
;
// test also that lang code is transformed to lower caps
$_GET
[
'xyz'
]
=
'
Es
'
;
// test also that lang code is transformed to lower caps
$l
=
new
Language
(
$c
);
$l
=
new
Language
(
$c
);
$this
->
assertEquals
(
'
zz
'
,
$l
->
getLanguage
());
$this
->
assertEquals
(
'
es
'
,
$l
->
getLanguage
());
// test with valid configuration, no cookies, language set unavailable
// test with valid configuration, no cookies, language set unavailable
$_GET
[
'xyz'
]
=
'unavailable'
;
$_GET
[
'xyz'
]
=
'unavailable'
;
...
...
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