Skip to content

Missing tests for ByPropertyIdArray #705

@JeroenDeDauw

Description

@JeroenDeDauw

ByPropertyIdArray::moveObjectInPropertyGroup

if ( $toIndex > $lastIndex + 1 || $toIndex < $numericIndices[0] ) {

This predicate can be removed with false and the tests still pass


Full mutation testing report:

36) \Humbug\Mutator\ConditionalBoundary\GreaterThan
Diff on \Wikibase\DataModel\ByPropertyIdArray::moveObjectInPropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 
-		if ( $toIndex > $lastIndex + 1 || $toIndex < $numericIndices[0] ) {
+		if ( $toIndex >= $lastIndex + 1 || $toIndex < $numericIndices[0] ) {
 			throw new OutOfBoundsException( 'Object cannot be moved to ' . $toIndex );
 		}
 
 		if ( $toIndex >= $lastIndex ) {
 			$this->moveObjectToEndOfPropertyGroup( $object );
 		} else {


37) \Humbug\Mutator\Number\IntegerValue
Diff on \Wikibase\DataModel\ByPropertyIdArray::moveObjectInPropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 
-		if ( $toIndex > $lastIndex + 1 || $toIndex < $numericIndices[0] ) {
+		if ( $toIndex > $lastIndex + 0 || $toIndex < $numericIndices[0] ) {
 			throw new OutOfBoundsException( 'Object cannot be moved to ' . $toIndex );
 		}
 
 		if ( $toIndex >= $lastIndex ) {
 			$this->moveObjectToEndOfPropertyGroup( $object );
 		} else {


38) \Humbug\Mutator\Boolean\LogicalOr
Diff on \Wikibase\DataModel\ByPropertyIdArray::moveObjectInPropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 
-		if ( $toIndex > $lastIndex + 1 || $toIndex < $numericIndices[0] ) {
+		if ( $toIndex > $lastIndex + 1 && $toIndex < $numericIndices[0] ) {
 			throw new OutOfBoundsException( 'Object cannot be moved to ' . $toIndex );
 		}
 
 		if ( $toIndex >= $lastIndex ) {
 			$this->moveObjectToEndOfPropertyGroup( $object );
 		} else {


39) \Humbug\Mutator\ConditionalBoundary\GreaterThan
Diff on \Wikibase\DataModel\ByPropertyIdArray::movePropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 
-		if ( $toIndex > $oldIndex ) {
+		if ( $toIndex >= $oldIndex ) {
 			// If the group shall be moved towards the bottom, the number of objects within the
 			// group needs to be subtracted from the absolute toIndex:
 			$toIndex -= count( $byIdClone[$propertyId->getSerialization()] );
 		}
 
 		foreach ( $this->getPropertyIds() as $pId ) {


40) \Humbug\Mutator\ConditionalBoundary\LessThanOrEqualTo
Diff on \Wikibase\DataModel\ByPropertyIdArray::moveObjectToIndex() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 		} else {
-			$edgeIndex = ( $toIndex <= $propertyIndices[0] )
+			$edgeIndex = ( $toIndex < $propertyIndices[0] )
 				? $propertyIndices[0]
 				: $propertyIndices[count( $propertyIndices ) - 1];
 
 			$this->moveObjectInPropertyGroup( $object, $edgeIndex );
 			$this->movePropertyGroup( $object->getPropertyId(), $toIndex );
 		}


41) \Humbug\Mutator\ConditionalBoundary\LessThan
Diff on \Wikibase\DataModel\ByPropertyIdArray::addObjectToPropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 			// index:
-			if ( $index < $validIndices[0] ) {
+			if ( $index <= $validIndices[0] ) {
 				array_unshift( $this->byId[$propertyId->getSerialization()], $object );
 			} else {
 				$this->byId[$propertyId->getSerialization()][] = $object;
 			}
 		}
 


42) \Humbug\Mutator\Number\IntegerValue
Diff on \Wikibase\DataModel\ByPropertyIdArray::addObjectToPropertyGroup() in /home/j/workspace/WikibaseDataModel/src/ByPropertyIdArray.php:
--- Original
+++ New
@@ @@
 			// index:
-			if ( $index < $validIndices[0] ) {
+			if ( $index < $validIndices[1] ) {
 				array_unshift( $this->byId[$propertyId->getSerialization()], $object );
 			} else {
 				$this->byId[$propertyId->getSerialization()][] = $object;
 			}
 		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions