BUGFIX Returning 'first last' in ViewableData->FirstLast() if item is both at the same time

This commit is contained in:
Ingo Schommer 2011-12-17 02:32:10 +01:00
parent 075cb5d7b9
commit 1d92172931
2 changed files with 17 additions and 0 deletions

View File

@ -112,6 +112,22 @@ class ViewableDataTest extends SapphireTest {
}
}
function testFirstLast() {
$vd = new ViewableData();
$vd->iteratorProperties(0, 3);
$this->assertEquals('first', $vd->FirstLast());
$vd->iteratorProperties(1, 3);
$this->assertEquals(null, $vd->FirstLast());
$vd->iteratorProperties(2, 3);
$this->assertEquals('last', $vd->FirstLast());
$vd->iteratorProperties(0, 1);
$this->assertEquals('first last', $vd->FirstLast());
}
}
/**#@+

View File

@ -545,6 +545,7 @@ class ViewableData extends Object implements IteratorAggregate {
* @return string|null
*/
public function FirstLast() {
if($this->First() && $this->Last()) return 'first last';
if($this->First()) return 'first';
if($this->Last()) return 'last';
}