This file is indexed.

/usr/share/php/tests/nag/Nag/Unit/Driver/Base.php is in php-horde-nag 4.1.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/**
 * Driver test base.
 *
 * PHP version 5
 *
 * @category   Horde
 * @package    Nag
 * @subpackage UnitTests
 * @author     Gunnar Wrobel <wrobel@pardus.de>
 * @link       http://www.horde.org/apps/nag
 * @license    http://www.horde.org/licenses/gpl GNU General Public License, version 2
 */

/**
 * Driver test base.
 *
 * Copyright 2011-2013 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPLv2). If you did not
 * receive this file, see http://www.horde.org/licenses/gpl
 *
 * @category   Horde
 * @package    Nag
 * @subpackage UnitTests
 * @author     Gunnar Wrobel <wrobel@pardus.de>
 * @link       http://www.horde.org/apps/nag
 * @license    http://www.horde.org/licenses/gpl GNU General Public License, version 2
 */
class Nag_Unit_Driver_Base extends Nag_TestCase
{
    /**
     * The test setup.
     *
     * @var Horde_Test_Setup
     */
    static $setup;

    /**
     * @static Nag_Driver
     */
    static $driver;

    /**
     * List of tasks added during the test.
     */
    private $_added = array();

    public static function setUpBeforeClass()
    {
        self::$setup = new Horde_Test_Setup();
        self::createBasicNagSetup(self::$setup);
        parent::setUpBeforeClass();
    }

    public static function tearDownAfterClass()
    {
        self::$driver = null;
        parent::tearDownAfterClass();
    }

    public function setUp()
    {
        $error = self::$setup->getError();
        if (!empty($error)) {
            $this->markTestSkipped($error);
        }
    }

    public function tearDown()
    {
        parent::tearDown();
        foreach ($this->_added as $added) {
            try {
                self::$driver->delete($added);
            } catch (Horde_Exception_NotFound $e) {
            }
        }
    }

    private function _add($task)
    {
        $id = self::$driver->add($task);
        $this->_added[] = $id[0];
        return $id;
    }

    public function testListTasks()
    {
        $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        self::$driver->retrieve();
        $this->assertEquals(1, self::$driver->tasks->count());
    }

    public function testListSubTasks()
    {
        $id = $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        $this->_add(array('name' => 'SUB',
                          'desc' => 'Some sub task.',
                          'parent' => $id[0]));
        self::$driver->retrieve();
        $this->assertEquals(2, self::$driver->tasks->count());
    }

    public function testDueTasks()
    {
        $due = time() + 20;
        $id = $this->_add(array('name' => 'TEST',
                                'desc' => 'Some test task.',
                                'due' => $due));
        $result = self::$driver->get($id[0]);
        $this->assertEquals($due, $result->due);
    }

    public function testStartTasks()
    {
        $start = time() + 20;
        $id = $this->_add(array('name' => 'TEST',
                                'desc' => 'Some test task.',
                                'start' => $start));
        $result = self::$driver->get($id[0]);
        $this->assertEquals($start, $result->start);
    }

    public function testRecurringTasks()
    {
        $due = time() - 1;
        $recurrence = new Horde_Date_Recurrence($due);
        $recurrence->setRecurType(Horde_Date_Recurrence::RECUR_DAILY);
        $id = $this->_add(array('name' => 'TEST',
                                'desc' => 'Some test task.',
                                'due' => $due,
                                'recurrence' => $recurrence));
        $due = new Horde_Date($due);
        $result = self::$driver->get($id[0]);
        $next = $result->getNextDue();
        $this->assertInstanceOf('Horde_Date', $next);
        $this->assertEquals($due->timestamp(), $next->timestamp());
        $result->toggleComplete();
        $result->save();
        $result2 = self::$driver->get($id[0]);
        $due->mday++;
        $next = $result2->getNextDue();
        $this->assertInstanceOf('Horde_Date', $next);
        $this->assertEquals($due->timestamp(), $next->timestamp());
        $result2->toggleComplete();
        $result2->save();
        $result3 = self::$driver->get($id[0]);
        $due->mday++;
        $next = $result3->getNextDue();
        $this->assertInstanceOf('Horde_Date', $next);
        $this->assertEquals($due->timestamp(), $next->timestamp());
        $this->assertFalse($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
        $due->mday--;
        $this->assertTrue($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
        $due->mday--;
        $this->assertTrue($result3->recurrence->hasCompletion($due->year, $due->month, $due->mday));
    }

    public function testModify()
    {
        $id = $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        self::$driver->modify($id[0], array('desc' => 'Modified'));
        $result = self::$driver->get($id[0]);
        $this->assertEquals('Modified', $result->desc);
        $result->name = 'MODIFIED';
        $result->save();
        $result2 = self::$driver->get($id[0]);
        $this->assertEquals('MODIFIED', $result2->name);
    }

    public function testDelete()
    {
        $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        $id = $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        self::$driver->delete($id[0]);
        self::$driver->retrieve();
        $this->assertEquals(1, self::$driver->tasks->count());
    }

    public function testDeleteAll()
    {
        $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        $this->_add(array('name' => 'TEST', 'desc' => 'Some test task.'));
        self::$driver->retrieve();
        $this->assertEquals(2, self::$driver->tasks->count());
        self::$driver->deleteAll();
        self::$driver->retrieve();
        $this->assertEquals(0, self::$driver->tasks->count());
    }
}