? ? Pending

User tests: Successful: Unsuccessful:

avatar andrepereiradasilva
andrepereiradasilva
2 Sep 2016

Summary of Changes

Reduce unit tests time a little further, but removing to 1 seconds sleep in JFactoryTest::testGetDateNow (one line changed).

Testing Instructions

Unit tested passed.
Code review

Documentation Changes Required

None.

avatar andrepereiradasilva andrepereiradasilva - open - 2 Sep 2016
avatar andrepereiradasilva andrepereiradasilva - change - 2 Sep 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 2 Sep 2016
Category Unit Tests
avatar joomla-cms-bot joomla-cms-bot - change - 2 Sep 2016
Labels Added: ? ?
avatar csthomas
csthomas - comment - 2 Sep 2016

Code review failed.

Datetime precision is 1 second.

test at console:
$a = new Datetime();usleep(1);$b = new Datetime();
var_dump($a == $b); // bool(true)

and:
$a = new Datetime();sleep(1);$b = new Datetime();
var_dump($a == $b); // bool(false)

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

how do you test this at console? what's the command? i only tested on online travis.

Also i think DateTime supports microseconds since php 5.2.2 ->format('u')

avatar csthomas
csthomas - comment - 2 Sep 2016

On local computer type command:
php -a

You should see:

$ php -a
Interactive mode enabled

php >

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

I tought JDate was extended to have microseconds too
So 'now' for Joomla can be 0.99 seconds ago ?

We could do something like this here https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/date/date.php#L107 for joomla to have the correct 'now' up to microsecond but i really don't know the impacts of this.

if ($date === 'now')
{
    $now   = microtime(true);
    $micro = sprintf("%06d", ($now - floor($now)) * 1000000);
    $date  = date('Y-m-d H:i:s.' . $micro, $now);
}

But, for now the 'now' is in seconds.

i will change this PR to 1 second them.

avatar mbabker
mbabker - comment - 2 Sep 2016

Since JDate is extending PHP's native DateTime, I wouldn't do too much with its internal data structure, especially if it causes weird side effects or breakage of features using the native class.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

Does adding microseconds when constructing a DateTime causes weird side effects or breakage of features using the native class ?

avatar mbabker
mbabker - comment - 2 Sep 2016

I don't know, I don't generally work with microseconds when using time based data (at least I haven't had a use case for it in 5+ years).

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

i actually use microseconds a lot for performance tests.

avatar mbabker
mbabker - comment - 2 Sep 2016

Quick glance through the PHP docs says yes it is supported (use u in your format strings when formatting DateTime objects). So I guess it's fine.

avatar andrepereiradasilva
andrepereiradasilva - comment - 2 Sep 2016

Patched microseconds here #11890

avatar andrepereiradasilva andrepereiradasilva - change - 2 Sep 2016
Title
[unit tests] 2 seconds less
[unit tests] 1 second less
avatar andrepereiradasilva andrepereiradasilva - change - 2 Sep 2016
The description was changed
avatar csthomas csthomas - test_item - 2 Sep 2016 - Tested successfully
avatar csthomas
csthomas - comment - 2 Sep 2016

I have tested this item successfully on

Code review.
1 second less is OK.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/11888.

avatar wilsonge wilsonge - change - 3 Sep 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-09-03 11:36:28
Closed_By wilsonge

Add a Comment

Login with GitHub to post a comment