This file is indexed.

/usr/share/php/tests/Horde_View/Horde/View/Helper/DateTest.php is in php-horde-view 2.0.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
/**
 * Copyright 2007-2008 Maintainable Software, LLC
 * Copyright 2006-2013 Horde LLC (http://www.horde.org/)
 *
 * @author     Mike Naberezny <mike@maintainable.com>
 * @author     Derek DeVries <derek@maintainable.com>
 * @author     Chuck Hagenbuch <chuck@horde.org>
 * @license    http://www.horde.org/licenses/bsd
 * @category   Horde
 * @package    View
 * @subpackage UnitTests
 */

/**
 * @group      view
 * @author     Mike Naberezny <mike@maintainable.com>
 * @author     Derek DeVries <derek@maintainable.com>
 * @author     Chuck Hagenbuch <chuck@horde.org>
 * @license    http://www.horde.org/licenses/bsd
 * @category   Horde
 * @package    View
 * @subpackage UnitTests
 */
class Horde_View_Helper_DateTest extends Horde_Test_Case
{
    public function setUp()
    {
        $this->helper = new Horde_View_Helper_Date(new Horde_View());
    }

    public function testDistanceInWords()
    {
        $from = mktime(21, 45, 0, 6, 6, 2004);

        // 0..1 with $includeSeconds
        $this->assertEquals('less than 5 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 0, true));
        $this->assertEquals('less than 5 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 4, true));
        $this->assertEquals('less than 10 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 5, true));
        $this->assertEquals('less than 10 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 9, true));
        $this->assertEquals('less than 20 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 10, true));
        $this->assertEquals('less than 20 seconds',
                            $this->helper->distanceOfTimeInWords($from, $from + 19, true));
        $this->assertEquals('half a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 20, true));
        $this->assertEquals('half a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 39, true));
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 40, true));
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 59, true));
        $this->assertEquals('1 minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 60, true));
        $this->assertEquals('1 minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 89, true));

        // First case 0..1
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 0));
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 29));
        $this->assertEquals('1 minute',
                            $this->helper->distanceOfTimeInWords($from, $from + 30));
        $this->assertEquals('1 minute',
                            $this->helper->distanceOfTimeInWords($from, $from + (1*60) + 29));

        // 2..44
        $this->assertEquals('2 minutes',
                            $this->helper->distanceOfTimeInWords($from, $from + (1*60) + 30));
        $this->assertEquals('44 minutes',
                            $this->helper->distanceOfTimeInWords($from, $from + (44*60) + 29));

        // 45..89
        $this->assertEquals('about 1 hour',
                            $this->helper->distanceOfTimeInWords($from, $from + (44*60) + 30));
        $this->assertEquals('about 1 hour',
                            $this->helper->distanceOfTimeInWords($from, $from + (89*60) + 29));

        // 90..1439
        $this->assertEquals('about 2 hours',
                            $this->helper->distanceOfTimeInWords($from, $from + (89*60) + 30));
        $this->assertEquals('about 24 hours',
                            $this->helper->distanceOfTimeInWords($from, $from + (23*3600) + (59*60) + 29));

        // 2880..43199
        $this->assertEquals('2 days',
                            $this->helper->distanceOfTimeInWords($from, $from + (47*3600) + (59*60) + 30));
        $this->assertEquals('29 days',
                            $this->helper->distanceOfTimeInWords($from, $from + (29*86400) + (23*3600) + (59*60) + 29));

        // 43200..86399
        $this->assertEquals('about 1 month',
                            $this->helper->distanceOfTimeInWords($from, $from + (29*86400) + (23*3600) + (59*60) + 30));
        $this->assertEquals('about 1 month',
                            $this->helper->distanceOfTimeInWords($from, $from + (59*86400) + (23*3600) + (59*60) + 29));

        // 86400..525599
        $this->assertEquals('2 months',
                            $this->helper->distanceOfTimeInWords($from, $from + (59*86400) + (23*3600) + (59*60) + 30));

        $this->assertEquals('12 months',
                            $this->helper->distanceOfTimeInWords($from, $from + (1*31557600) - 31));

        // 525960..1051919
        $this->assertEquals('about 1 year',
                            $this->helper->distanceOfTimeInWords($from, $from + (1*31557600) - 30));
        $this->assertEquals('about 1 year',
                            $this->helper->distanceOfTimeInWords($from, $from + (2*31557600) - 31));

        // > 1051920
        $this->assertEquals('over 2 years',
                            $this->helper->distanceOfTimeInWords($from, $from + (2*31557600) - 30));
        $this->assertEquals('over 10 years',
                            $this->helper->distanceOfTimeInWords($from, $from + (10*31557600)));

        // test to < from
        $this->assertEquals('about 4 hours',
                            $this->helper->distanceOfTimeInWords($from + (4*3600), $from));
        $this->assertEquals('less than 20 seconds',
                            $this->helper->distanceOfTimeInWords($from + 19, $from, true));
    }

    public function testDistanceInWordsWithIntegers()
    {
        $this->markTestIncomplete('not yet passing');

        $from = mktime(21, 45, 0, 6, 6, 2004);

        // test with integers (not yet passing)
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords(59));
        $this->assertEquals('about 1 hour',
                            $this->helper->distanceOfTimeInWords(60*60));
        $this->assertEquals('less than a minute',
                            $this->helper->distanceOfTimeInWords(0, 59));
        $this->assertEquals('about 1 hour',
                            $this->helper->distanceOfTimeInWords(60*60, 0));
    }
}