Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LDEV-4278 fixed lsweek unit tests to check java version #2189

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions test/functions/lsWeek.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {
describe( title="Testcase for lsWeek()", body=function() {
it(title="checking lsWeek() with locale argument", body = function( currentSpec ) {
var date = createDateTime(2022,01,17,12,0,0,0,"UTC");
// in Arabic (Yemen) Saturday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(3);
// in Catalan Monday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(3);

if(getJavaVersion()<=8){
// in Arabic (Yemen) Saturday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(3);
// in Catalan Monday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(3);
}else{
// after Java 8 in Arabic (Yemen) Sunday is the first day of the week
expect(lsWeek(date=date, locale="Arabic (Yemen)")).tobe(4);
// after Java 8 in Catalan Sunday is the first day of the week
expect(lsWeek(date=date, locale="Catalan")).tobe(4);
// Testing Iraq because it still has Saturday as the first day of the week after Java 8
expect(lsWeek(date =date, locale="ar_IQ")).toBe(3);
}
// in English (Canada) Sunday is the first day of the week
expect(lsWeek(date=date, locale="English (Canada)")).tobe(4);
});
Expand All @@ -21,4 +31,13 @@ component extends="org.lucee.cfml.test.LuceeTestCase" {
});
});
}

private function getJavaVersion() {
var raw=server.java.version;
var arr=listToArray(raw,'.');
if(arr[1]==1) // version 1-9
return arr[2];
return arr[1];
}

}