Remove the \ before the class name.
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / GenericArrayObjectTest.php
index 8a2fb55..40a3965 100644 (file)
@@ -39,22 +39,30 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
        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
@@ -102,7 +110,10 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
         * @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 );
@@ -115,10 +126,6 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
                        unset( $list[$offset] );
                        $this->assertEquals( $count - 1, $list->count() );
                }
-
-               $exception = null;
-               try { $list->offsetUnset( 'sdfsedtgsrdysftu' ); } catch ( \Exception $exception ){}
-               $this->assertInstanceOf( '\Exception', $exception );
        }
 
        /**
@@ -163,7 +170,7 @@ abstract class GenericArrayObjectTest extends MediaWikiTestCase {
 
                $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{