コード例 #1
0
 /**
  * @dataProvider instanceProvider
  *
  * @since 1.20
  *
  * @param GenericArrayObject $list
  *
  * @covers GenericArrayObject::offsetUnset
  */
 public function testUnset(GenericArrayObject $list)
 {
     if ($list->isEmpty()) {
         $this->assertTrue(true);
         // We cannot test unset if there are no elements
     } else {
         $offset = $list->getIterator()->key();
         $count = $list->count();
         $list->offsetUnset($offset);
         $this->assertEquals($count - 1, $list->count());
     }
     if (!$list->isEmpty()) {
         $offset = $list->getIterator()->key();
         $count = $list->count();
         unset($list[$offset]);
         $this->assertEquals($count - 1, $list->count());
     }
 }
コード例 #2
0
 /**
  * @dataProvider instanceProvider
  *
  * @since 1.20
  *
  * @param GenericArrayObject $list
  */
 public function testUnset(GenericArrayObject $list)
 {
     if (!$list->isEmpty()) {
         $offset = $list->getIterator()->key();
         $count = $list->count();
         $list->offsetUnset($offset);
         $this->assertEquals($count - 1, $list->count());
     }
     if (!$list->isEmpty()) {
         $offset = $list->getIterator()->key();
         $count = $list->count();
         unset($list[$offset]);
         $this->assertEquals($count - 1, $list->count());
     }
     $exception = null;
     try {
         $list->offsetUnset('sdfsedtgsrdysftu');
     } catch (\Exception $exception) {
     }
     $this->assertInstanceOf('\\Exception', $exception);
 }
コード例 #3
0
 /**
  * @see GenericArrayObject::unserialize
  *
  * @since 1.21
  *
  * @param string $serialization
  *
  * @return array
  */
 public function unserialize($serialization)
 {
     $serializationData = parent::unserialize($serialization);
     $this->byInternalId = $serializationData['internalIds'];
     $this->byGlobalId = $serializationData['globalIds'];
     return $serializationData;
 }
コード例 #4
0
 /**
  * @see ArrayObject::offsetUnset()
  *
  * @since 1.21
  *
  * @param mixed $index
  */
 public function offsetUnset($index)
 {
     /**
      * @var Site $site
      */
     $site = $this->offsetGet($index);
     if ($site !== false) {
         unset($this->byGlobalId[$site->getGlobalId()]);
         unset($this->byInternalId[$site->getInternalId()]);
     }
     parent::offsetUnset($index);
 }