You are here

public function InflectorTest::testCustomSingularRule in Plug 7

testCustomSingularRule method

Return value

void

File

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

Class

InflectorTest

Namespace

Doctrine\Tests\Common\Inflector

Code

public function testCustomSingularRule() {
  Inflector::reset();
  Inflector::rules('singular', array(
    '/(eple)r$/i' => '\\1',
    '/(jente)r$/i' => '\\1',
  ));
  $this
    ->assertEquals(Inflector::singularize('epler'), 'eple');
  $this
    ->assertEquals(Inflector::singularize('jenter'), 'jente');
  Inflector::rules('singular', array(
    'rules' => array(
      '/^(bil)er$/i' => '\\1',
      '/^(inflec|contribu)tors$/i' => '\\1ta',
    ),
    'uninflected' => array(
      'singulars',
    ),
    'irregular' => array(
      'spins' => 'spinor',
    ),
  ));
  $this
    ->assertEquals(Inflector::singularize('inflectors'), 'inflecta');
  $this
    ->assertEquals(Inflector::singularize('contributors'), 'contributa');
  $this
    ->assertEquals(Inflector::singularize('spins'), 'spinor');
  $this
    ->assertEquals(Inflector::singularize('singulars'), 'singulars');
}