This file is indexed.

/usr/share/php/tests/Horde_Support/Horde/Support/ArrayTest.php is in php-horde-support 2.1.1-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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<?php
/**
 * Copyright 2007-2013 Horde LLC (http://www.horde.org/)
 *
 * @category   Horde
 * @package    Support
 * @subpackage UnitTests
 * @license    http://www.horde.org/licenses/bsd
 */

/**
 * @category   Horde
 * @package    Support
 * @subpackage UnitTests
 * @license    http://www.horde.org/licenses/bsd
 */
class Horde_Support_ArrayTest extends PHPUnit_Framework_TestCase
{
    public function testImplementsArrayAccess()
    {
        $o = new Horde_Support_Array();
        $this->assertInstanceOf('ArrayAccess', $o);
    }

    public function testImplementsTraversable()
    {
        $o = new Horde_Support_Array();
        $this->assertInstanceOf('Traversable', $o);
    }

    public function testImplementsCountable()
    {
        $o = new Horde_Support_Array();
        $this->assertInstanceOf('Countable', $o);
    }

    // offsetGet()

    public function testOffsetGetReturnsValueAtOffset()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $this->assertEquals('bar', $o->offsetGet('foo'));
    }

    public function testOffsetGetReturnsNullWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertNull($o->offsetGet('foo'));
    }

    // get()

    public function testGetReturnsValueAtOffset()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $this->assertEquals('bar', $o->get('foo'));
    }

    public function testGetReturnsNullByDefaultWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertNull($o->get('foo'));
    }

    public function testGetReturnsDefaultSpecifiedWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertEquals('bar', $o->get('foo', 'bar'));
    }

    public function testGetReturnsDefaultSpecifiedWhenValueAtOffsetIsNull()
    {
        $o = new Horde_Support_Array(array('foo' => null));
        $this->assertEquals('bar', $o->get('foo', 'bar'));
    }

    // getOrSet()

    public function testGetOrSetReturnsValueAtOffset()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $this->assertEquals('bar', $o->getOrSet('foo'));
    }

    public function testGetOrSetReturnsAndSetsNullWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertNull($o->getOrSet('foo'));
        $this->assertTrue($o->offsetExists('foo'));
        $this->assertNull($o->offsetGet('foo'));
    }

    public function testGetOrSetReturnsAndSetsDefaultSpecifiedWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertEquals('bar', $o->getOrSet('foo', 'bar'));
        $this->assertTrue($o->offsetExists('foo'));
        $this->assertEquals('bar', $o->offsetGet('foo'));
    }

    public function testGetOrSetReturnsAndSetsDefaultSpecifiedValueAtOffsetIsNull()
    {
        $o = new Horde_Support_Array(array('foo' => null));
        $this->assertEquals('bar', $o->getOrSet('foo', 'bar'));
        $this->assertTrue($o->offsetExists('foo'));
        $this->assertEquals('bar', $o->offsetGet('foo'));
    }

    // pop()

    public function testPopReturnsValueAtOffsetAndUnsetsIt()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $this->assertEquals('bar', $o->pop('foo'));
        $this->assertFalse($o->offsetExists('foo'));
    }

    public function testPopReturnsNullByDefaultWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertNull($o->pop('foo'));
    }

    public function testPopReturnsDefaultSpecifiedWhenOffsetDoesNotExist()
    {
        $o = new Horde_Support_Array();
        $this->assertEquals('bar', $o->pop('foo', 'bar'));
    }

    public function testPopReturnsDefaultSpecifiedWhenValueAtOffsetIsNull()
    {
        $o = new Horde_Support_Array(array('foo' => null));
        $this->assertEquals('bar', $o->pop('foo', 'bar'));
    }

    // update()

    public function testUpdateDoesNotThrowWhenArgumentIsAnArray()
    {
        $o = new Horde_Support_Array();
        $o->update(array());
    }

    public function testUpdateDoesNotThrowWhenArgumentIsTraversable()
    {
        $o = new Horde_Support_Array();
        $o->update(new ArrayObject());
    }

    public function testUpdateMergesNewValuesFromArayInArgument()
    {
        $o = new Horde_Support_Array();
        $o->update(array('foo' => 'bar'));
        $this->assertEquals('bar', $o->offsetGet('foo'));
    }

    public function testUpdateMergesAndOverwritesExistingOffsets()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $o->update(array('foo' => 'baz'));
        $this->assertEquals('baz', $o->offsetGet('foo'));
    }

    public function testUpdateMergeDoesNotAffectUnrelatedKeys()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $o->update(array('baz' => 'qux'));
        $this->assertEquals('qux', $o->offsetGet('baz'));
    }

    // clear()

    public function testClearErasesTheArray()
    {
        $o = new Horde_Support_Array(array('foo' => 'bar'));
        $o->clear();
        $this->assertEquals(0, $o->count());
    }

    // getKeys()

    public function testGetKeysReturnsEmptyArrayWhenArrayIsEmpty()
    {
        $o = new Horde_Support_Array();
        $this->assertSame(array(), $o->getKeys());
    }

    public function testGetKeysReturnsArrayOfKeysInTheArray()
    {
        $o = new Horde_Support_Array(array('foo'=> 1, 'bar' => 2));
        $this->assertSame(array('foo', 'bar'), $o->getKeys());
    }

    // getValues()

    public function testGetValuesReturnsEmptyArrayWhenArrayIsEmpty()
    {
        $o = new Horde_Support_Array();
        $this->assertSame(array(), $o->getValues());
    }

    public function testGetValuesReturnsArrayOfValuesInTheArray()
    {
        $o = new Horde_Support_Array(array('foo' => 1, 'bar' => 2));
        $this->assertSame(array(1, 2), $o->getValues());
    }

}