Jump to:

22977 Posts in 11732 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Unit Test Failures

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1218 Views
  • smares
    Avatar
    Community Member
    25 Posts

    Unit Test Failures Link to this post

    Hey, I just fetched a copy of the stable build off SVN, installed it and ran all unit tests. For some reason I get two failures:

    ⊗ Date Test::test Nice Date
    Date->Nice() works with timestamp integers
    Failed asserting that <string:31/03/2008> is equal to <string:01/04/2008>.
    Date->Nice() works with timestamp integers

    ⊗ Date Test::test Long Date
    Date->Long() works with numeric timestamp
    Failed asserting that <string:31 March 2008> is equal to <string:1 April 2008>.
    Date->Long() works with numeric timestamp

    Any idea what the problem is?

    Another frustrating thing is that the unit tests rely on php5-curl and php5-tidy being installed, but this is not mentioned in the system requirements.

  • smares
    Avatar
    Community Member
    25 Posts

    Re: Unit Test Failures Link to this post

    I don't get it. The timezone is set to Europe/Berlin in my PHP installation and 1206968400 is March 31st, 2008 for this timezone. However, the unit test is setting the timezone to Pacific/Auckland and for that timezone, 1206968400 is April 1st, 2008:

    Here's a small test:

    <?php
    $tz = ini_get('date.timezone');
    ini_set('date.timezone', 'Pacific/Auckland');
    echo date('r', 1206968400) . PHP_EOL;
    ini_set('date.timezone', $tz);
    ?>

    Edit: If I run the DateTest alone, the test passes, but not when I run all of them. O_o

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Unit Test Failures Link to this post

    Interesting. Are you running just the sapphire test suite or your application tests as well?

    What is the timezone at the top of the testNiceData() test?

    Another frustrating thing is that the unit tests rely on php5-curl and php5-tidy being installed, but this is not mentioned in the system requirements.

    Good point, I think these 2 should be warnings (rather than errors) for the installer. Could you raise this as a bug on open.silverstripe.org.

  • smares
    Avatar
    Community Member
    25 Posts

    Re: Unit Test Failures Link to this post

    Interesting. Are you running just the sapphire test suite or your application tests as well?

    Fresh unmodified copy either from SVN or as tar.gz, installed, then called /dev/tests/all. First it told me that I need PHPUnit which makes sense, but isn't documented AFAIK, then I had something like 11 fails because the curl and tidy extensions were missing and now I only get the two fails mentioned above when testing the date functions. If I call the DateTest (/dev/tests/DateTest) alone, I get 2 passes.

    What is the timezone at the top of the testNiceData() test?

    Something is borked...

    var_dump(ini_get('date.timezone')); --> string 'Pacific/Auckland' (length=16)
    var_dump(date('r')); --> string 'Sat, 12 Feb 2011 10:55:48 +0100' (length=31)

    When I execute DateTest alone, I get...

    var_dump(ini_get('date.timezone')); --> string 'Pacific/Auckland' (length=16)
    var_dump(date('r')); --> string 'Sat, 12 Feb 2011 23:17:47 +1300' (length=31)

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Unit Test Failures Link to this post

    Raise this as an issue on open.silverstripe.org as a bug. Include what branch / tag / revision you downloaded.

    1218 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.