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

Add phpunit tests #2

Open
alphp opened this issue Mar 17, 2022 · 2 comments
Open

Add phpunit tests #2

alphp opened this issue Mar 17, 2022 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@alphp
Copy link
Owner

alphp commented Mar 17, 2022

No description provided.

@alphp alphp added this to the 1.0.0 milestone Mar 17, 2022
@alphp alphp added enhancement New feature or request help wanted Extra attention is needed labels Mar 17, 2022
@splitbrain
Copy link
Contributor

Current master's tests fail on my local machine (PHP 8.1.4):

There were 3 failures:

1) strftimeTest::testTimeFormats
%X: Preferred time representation based on locale, without the date
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'1:02:03 PM'
+'13:02:03'

/home/andi/www/devel/strftime/tests/strftimeTest.php:132

2) strftimeTest::testStampsFormats
%c: Preferred date and time stamp based on locale
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'March 6, 2022 at 1:02 PM'
+'March 6, 2022 at 13:02'

/home/andi/www/devel/strftime/tests/strftimeTest.php:143

3) strftimeTest::testLocale
%c: Preferred date and time stamp based on locale
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'2022(e)ko martxoaren 6(a) 13:02'
+'2022(e)ko martxoakren 6(a) 13:02'

/home/andi/www/devel/strftime/tests/strftimeTest.php:177

Is that a known issue? Are the tests somehow dependent on the locale setup of my machine?

alphp added a commit that referenced this issue Apr 28, 2022
@alphp
Copy link
Owner Author

alphp commented Apr 28, 2022

Is an bug in the test setUp:

public function setUp () : void {
    setlocale(LC_TIME, 'en');
    date_default_timezone_set('Europe/Madrid');
}

In my experience there are differences in the values supported by the php setlocale function.
It was a mistake on my part to trust that setlocale(LC_TIME, 'en') would work in all environments.
I've removed the setlocale from setUp and used the locale option of the strftime function with the string 'en-EN', hopefully that's more universal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants