mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Returning 'first last' in ViewableData->FirstLast() if item is both at the same time
This commit is contained in:
parent
075cb5d7b9
commit
1d92172931
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
|
@ -545,6 +545,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
* @return string|null
|
* @return string|null
|
||||||
*/
|
*/
|
||||||
public function FirstLast() {
|
public function FirstLast() {
|
||||||
|
if($this->First() && $this->Last()) return 'first last';
|
||||||
if($this->First()) return 'first';
|
if($this->First()) return 'first';
|
||||||
if($this->Last()) return 'last';
|
if($this->Last()) return 'last';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user