예제 #1
0
 public function testPushAfter()
 {
     $input = 'lorem ipsum';
     $this->assertCount(1, ArrayUtils::pushAfter($this->_getArrayPreset('empty_array'), $input, 1));
     $pushedArray = ArrayUtils::pushAfter($this->_getArrayPreset('01234567'), $input, 5);
     $this->assertCount(9, $pushedArray);
     $this->assertEquals($input, $pushedArray[6]);
     $pushedArray = ArrayUtils::pushAfter($this->_getArrayPreset('01234567'), $input, 5, 'lipsum');
     $this->assertArrayHasKey('lipsum', $pushedArray);
     for ($i = 0; $i <= 5; $i++) {
         array_shift($pushedArray);
     }
     $this->assertEquals($input, array_shift($pushedArray));
     $this->assertArrayHasKey('lipsum', ArrayUtils::pushAfter($this->_getArrayPreset('associative'), $input, 'lorem', 'lipsum'));
 }