File: 0-basic.t

package info (click to toggle)
libtest-mockdatetime-perl 0.02-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 120 kB
  • sloc: perl: 42; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 610 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use strict;
use warnings;
use DateTime;
use Test::More;

use ok 'Test::MockDateTime';

can_ok 'main', 'on';

# I hope nobody turns back the time :-)
isnt +DateTime->now->ymd,
    '2013-01-02', 
    'current time is later than 2013-01-02';

on '2013-01-02 12:23:45', sub {
    isa_ok +DateTime->now, 'DateTime';
    
    is +DateTime->now->ymd,
        '2013-01-02',
        'mocked now date is 2013-01-02';

    is +DateTime->now->hms,
        '12:23:45',
        'mocked now time is 12:23:45';
};

isnt +DateTime->now->ymd,
    '2013-01-02', 
    'current time is later than 2013-01-02 again';

done_testing;