Permalink
Browse files

BUGFIX Modulus and MultipleOf should start at index 0 to match the it…

…erator position, by default (from r94071)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95586 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent a481bc5 commit ed630229ab7ba67c87c9adf7ec704b7ec78b22bc @halkyon halkyon committed Dec 16, 2009
Showing with 8 additions and 8 deletions.
  1. +2 −2 core/ViewableData.php
  2. +6 −6 tests/DataObjectSetTest.php
@@ -623,7 +623,7 @@ public function TotalItems() {
/**
* Returns the modulus of the numerical position of the item in the data set.
- * The count starts from $startIndex, which defaults to 1.
+ * The count starts from $startIndex, which defaults to 0.
* @param int $Mod The number to perform Mod operation to.
* @param int $startIndex Number to start count from.
* @return int
@@ -632,7 +632,7 @@ public function Modulus($mod, $startIndex = 1) {
return ($this->iteratorPos + $startIndex) % $mod;
}
- public function MultipleOf($factor, $offset = 1) {
+ public function MultipleOf($factor, $offset = 0) {
return ($this->Modulus($factor, $offset) == 0);
}
@@ -84,15 +84,15 @@ public function testMultipleOf() {
}
}
- $this->assertEquals(2, $multiplesOf3);
+ $this->assertEquals(3, $multiplesOf3);
- $this->assertFalse($commArr[0]->IsMultipleOf3);
+ $this->assertTrue($commArr[0]->IsMultipleOf3);
$this->assertFalse($commArr[1]->IsMultipleOf3);
- $this->assertTrue($commArr[2]->IsMultipleOf3);
- $this->assertFalse($commArr[3]->IsMultipleOf3);
+ $this->assertFalse($commArr[2]->IsMultipleOf3);
+ $this->assertTrue($commArr[3]->IsMultipleOf3);
$this->assertFalse($commArr[4]->IsMultipleOf3);
- $this->assertTrue($commArr[5]->IsMultipleOf3);
- $this->assertFalse($commArr[6]->IsMultipleOf3);
+ $this->assertFalse($commArr[5]->IsMultipleOf3);
+ $this->assertTrue($commArr[6]->IsMultipleOf3);
}
/**

0 comments on commit ed63022

Please sign in to comment.