public abstract function elementInstancesProvider();
/**
- * Provides instances of the concrete class being tested.
+ * Returns the name of the concrete class being tested.
*
* @since 1.20
*
- * @return array
+ * @return string
*/
- public abstract function instanceProvider();
+ public abstract function getInstanceClass();
/**
- * Returns the name of the concrete class being tested.
+ * Provides instances of the concrete class being tested.
*
* @since 1.20
*
- * @return string
+ * @return array
*/
- public abstract function getInstanceClass();
+ public function instanceProvider() {
+ $instances = array();
+
+ foreach ( $this->elementInstancesProvider() as $elementInstances ) {
+ $instances[] = $this->getNew( $elementInstances[0] );
+ }
+
+ return $this->arrayWrap( $instances );
+ }
/**
* @since 1.20
* @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{