Jeroen De Dauw has submitted this change and it was merged.

Change subject: Add tests for Mutating Indexes
......................................................................


Add tests for Mutating Indexes

Change-Id: I4018cbf4583838077b8ce9f25b44a3f073216fba
---
M tests/phpunit/Schema/Definition/TableDefinitionTest.php
1 file changed, 51 insertions(+), 4 deletions(-)

Approvals:
  Jeroen De Dauw: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/phpunit/Schema/Definition/TableDefinitionTest.php 
b/tests/phpunit/Schema/Definition/TableDefinitionTest.php
index 9c80a18..7e66c2c 100644
--- a/tests/phpunit/Schema/Definition/TableDefinitionTest.php
+++ b/tests/phpunit/Schema/Definition/TableDefinitionTest.php
@@ -273,12 +273,59 @@
                return $args;
        }
 
-       public function testMutateIndexes(){
-               $this->markTestIncomplete( 'Test Me!' );
+       /**
+        * @dataProvider mutateIndexAwayProvider
+        */
+       public function testMutateIndexes( $toRemove, TableDefinition 
$definition, TableDefinition $expected ){
+               $newIndexes = array();
+               foreach( $definition->getIndexes() as $index ){
+                       if( $index->getName() !== $toRemove ){
+                               $newIndexes[] = $index;
+                       }
+               }
+               $newDefinition = $definition->mutateIndexes( $newIndexes );
+               $this->assertEquals( $expected, $newDefinition );
        }
 
-       public function testMutateIndexAway(){
-               $this->markTestIncomplete( 'Test Me!' );
+       /**
+        * @dataProvider mutateIndexAwayProvider
+        */
+       public function testMutateIndexAway( $toRemove, TableDefinition 
$definition, TableDefinition $expected ){
+               $newDefinition = $definition->mutateIndexAway( $toRemove );
+               $this->assertEquals( $expected, $newDefinition );
+       }
+
+       public function mutateIndexAwayProvider() {
+               $args = array(
+                       array( 'o',
+                               new TableDefinition(
+                                       'spam',
+                                       array( new FieldDefinition( 'foo', 
FieldDefinition::TYPE_BOOLEAN ) ),
+                                       array(
+                                               new IndexDefinition( 'o', 
array( 'a' => 1 ), IndexDefinition::TYPE_INDEX ),
+                                               new IndexDefinition( 'h', 
array( 'b' => 2 ), IndexDefinition::TYPE_PRIMARY ),
+                                       )
+                               ),
+                               new TableDefinition(
+                                       'spam',
+                                       array( new FieldDefinition( 'foo', 
FieldDefinition::TYPE_BOOLEAN ) ),
+                                       array( new IndexDefinition( 'h', array( 
'b' => 2 ), IndexDefinition::TYPE_PRIMARY ) )
+                               ),
+                       ),
+                       array( 'o',
+                               new TableDefinition(
+                                       'spam',
+                                       array( new FieldDefinition( 'foo', 
FieldDefinition::TYPE_BOOLEAN ) ),
+                                       array( new IndexDefinition( 'h', array( 
'b' => 2 ), IndexDefinition::TYPE_PRIMARY ) )
+                               ),
+                               new TableDefinition(
+                                       'spam',
+                                       array( new FieldDefinition( 'foo', 
FieldDefinition::TYPE_BOOLEAN ) ),
+                                       array( new IndexDefinition( 'h', array( 
'b' => 2 ), IndexDefinition::TYPE_PRIMARY ) )
+                               ),
+                       ),
+               );
+               return $args;
        }
 
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/89531
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4018cbf4583838077b8ce9f25b44a3f073216fba
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikibaseDatabase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to