* @param GenericArrayObject $list
*/
public function testUnset( GenericArrayObject $list ) {
- if ( !$list->isEmpty() ) {
+ 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 );
unset( $list[$offset] );
$this->assertEquals( $count - 1, $list->count() );
}
-
- $exception = null;
- try { $list->offsetUnset( 'sdfsedtgsrdysftu' ); } catch ( \Exception $exception ){}
- $this->assertInstanceOf( '\Exception', $exception );
}
/**
$elementClass = $list->getObjectType();
- foreach ( array( 42, 'foo', array(), new \stdClass(), 4.2 ) as $element ) {
+ foreach ( array( 42, 'foo', array(), new stdClass(), 4.2 ) as $element ) {
$validValid = $element instanceof $elementClass;
try{