GithubHelp home page GithubHelp logo

Add phpunit tests about strftime HOT 2 OPEN

alphp avatar alphp commented on August 26, 2024
Add phpunit tests

from strftime.

Comments (2)

splitbrain avatar splitbrain commented on August 26, 2024

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?

from strftime.

alphp avatar alphp commented on August 26, 2024

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.

from strftime.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.