You are here

public function InflectorTest::testCustomSingularRule in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/doctrine/inflector/tests/Doctrine/Tests/Common/Inflector/InflectorTest.php \Doctrine\Tests\Common\Inflector\InflectorTest::testCustomSingularRule()

testCustomSingularRule method

Return value

void

File

vendor/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');
}