diff --git a/model/DataObject.php b/model/DataObject.php index 3f10f4a63..4c0a5f076 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -713,9 +713,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity return $name; } else { $name = $this->singular_name(); - if(substr($name,-1) == 'e') $name = substr($name,0,-1); - else if(substr($name,-1) == 'y') $name = substr($name,0,-1) . 'ie'; - + if(substr($name,-1) == 'y') $name = substr($name,0,-1) . 'ie'; return ucfirst($name . 's'); } } diff --git a/tests/model/DataObjectTest.php b/tests/model/DataObjectTest.php index 6f235ea75..ae6761038 100644 --- a/tests/model/DataObjectTest.php +++ b/tests/model/DataObjectTest.php @@ -949,21 +949,40 @@ class DataObjectTest extends SapphireTest { * Tests that singular_name() generates sensible defaults. */ public function testSingularName() { - $assertions = array ( + $assertions = array( 'DataObjectTest_Player' => 'Data Object Test Player', 'DataObjectTest_Team' => 'Data Object Test Team', 'DataObjectTest_Fixture' => 'Data Object Test Fixture' ); foreach($assertions as $class => $expectedSingularName) { - $this->assertEquals ( + $this->assertEquals( $expectedSingularName, singleton($class)->singular_name(), "Assert that the singular_name for '$class' is correct." ); } } - + + /** + * Tests that plural_name() generates sensible defaults. + */ + public function testPluralName() { + $assertions = array( + 'DataObjectTest_Player' => 'Data Object Test Players', + 'DataObjectTest_Team' => 'Data Object Test Teams', + 'DataObjectTest_Fixture' => 'Data Object Test Fixtures' + ); + + foreach($assertions as $class => $expectedPluralName) { + $this->assertEquals( + $expectedPluralName, + singleton($class)->plural_name(), + "Assert that the plural_name for '$class' is correct." + ); + } + } + public function testHasDatabaseField() { $team = singleton('DataObjectTest_Team'); $subteam = singleton('DataObjectTest_SubTeam');