You are here

public function InflectorTest::testCustomPluralRule in Plug 7

testCustomPluralRule method

Return value

void

File

lib/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php, line 103

Class

InflectorTest

Namespace

Doctrine\Tests\Common\Inflector

Code

public function testCustomPluralRule() {
  Inflector::reset();
  Inflector::rules('plural', array(
    '/^(custom)$/i' => '\\1izables',
  ));
  $this
    ->assertEquals(Inflector::pluralize('custom'), 'customizables');
  Inflector::rules('plural', array(
    'uninflected' => array(
      'uninflectable',
    ),
  ));
  $this
    ->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable');
  Inflector::rules('plural', array(
    'rules' => array(
      '/^(alert)$/i' => '\\1ables',
    ),
    'uninflected' => array(
      'noflect',
      'abtuse',
    ),
    'irregular' => array(
      'amaze' => 'amazable',
      'phone' => 'phonezes',
    ),
  ));
  $this
    ->assertEquals(Inflector::pluralize('noflect'), 'noflect');
  $this
    ->assertEquals(Inflector::pluralize('abtuse'), 'abtuse');
  $this
    ->assertEquals(Inflector::pluralize('alert'), 'alertables');
  $this
    ->assertEquals(Inflector::pluralize('amaze'), 'amazable');
  $this
    ->assertEquals(Inflector::pluralize('phone'), 'phonezes');
}