本文整理汇总了PHP中lithium\util\Inflector::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP Inflector::reset方法的具体用法?PHP Inflector::reset怎么用?PHP Inflector::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lithium\util\Inflector
的用法示例。
在下文中一共展示了Inflector::reset方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->_backups['catalogConfig'] = Catalog::config();
Catalog::reset();
Catalog::config(array('runtime' => array('adapter' => new Memory())));
Inflector::reset();
}
示例2: tearDown
public function tearDown()
{
Inflector::reset();
Catalog::reset();
Catalog::config($this->_backup['catalogConfig']);
}
示例3: testAddTransliterations
/**
* Tests adding transliterated characters to the map used in `Inflector::slug()`.
*
* @return void
*/
public function testAddTransliterations()
{
$this->assertEqual(Inflector::slug('Montréal'), 'Montreal');
$this->assertNotEqual(Inflector::slug('Écaussines'), 'Ecaussines');
Inflector::rules('transliteration', array('/É|Ê/' => 'E'));
$this->assertEqual(Inflector::slug('Écaussines-d\'Enghien'), 'Ecaussines-d-Enghien');
$this->assertNotEqual(Inflector::slug('JØRGEN'), 'JORGEN');
Inflector::rules('transliteration', array('/Ø/' => 'O'));
$this->assertEqual(Inflector::slug('JØRGEN'), 'JORGEN');
$this->assertNotEqual(Inflector::slug('ÎÍ'), 'II');
Inflector::rules('transliteration', array('/Î|Í/' => 'I'));
$this->assertEqual(Inflector::slug('ÎÍ'), 'II');
$this->assertEqual(Inflector::slug('ABc'), 'ABc');
Inflector::rules('transliteration', array('AB' => 'a'));
Inflector::reset();
$this->assertEqual(Inflector::slug('ABc'), 'aac');
}
示例4: testStorageMechanism
/**
* Tests the storage mechanism for `$_underscored`, `$_camelized`,
* `$_humanized` and `$_pluralized`.
*
* @return void
*/
public function testStorageMechanism()
{
Inflector::reset();
$expected = array('TestField' => 'test_field');
$this->assertFalse($this->getProtectedValue('$_underscored'));
$this->assertEqual(Inflector::underscore('TestField'), 'test_field');
$this->assertEqual($expected, $this->getProtectedValue('$_underscored'));
$this->assertEqual(Inflector::underscore('TestField'), 'test_field');
$expected = array('test_field' => 'TestField');
$this->assertFalse($this->getProtectedValue('$_camelized'));
$this->assertEqual(Inflector::camelize('test_field', true), 'TestField');
$this->assertEqual($expected, $this->getProtectedValue('$_camelized'));
$this->assertEqual(Inflector::camelize('test_field', true), 'TestField');
$expected = array('test_field:_' => 'Test Field');
$this->assertFalse($this->getProtectedValue('$_humanized'));
$this->assertEqual(Inflector::humanize('test_field'), 'Test Field');
$this->assertEqual($expected, $this->getProtectedValue('$_humanized'));
$this->assertEqual(Inflector::humanize('test_field'), 'Test Field');
$expected = array('field' => 'fields');
$this->assertFalse($this->getProtectedValue('$_pluralized'));
$this->assertEqual(Inflector::pluralize('field'), 'fields');
$this->assertEqual($expected, $this->getProtectedValue('$_pluralized'));
$this->assertEqual(Inflector::pluralize('field'), 'fields');
}
示例5: testAddingSingularizationRules
public function testAddingSingularizationRules()
{
$before = Inflector::rules('singular');
$result = Inflector::singularize('errata');
$this->assertNull(Inflector::rules('singular', array('/rata/' => '\\1ratus')));
$this->assertEqual(Inflector::singularize('errata'), $result);
Inflector::reset();
$this->assertNotEqual(Inflector::singularize('errata'), $result);
$after = Inflector::rules('singular');
$expected = array('rules', 'irregular', 'uninflected', 'regexUninflected', 'regexIrregular');
$this->assertEqual(array_keys($before), $expected);
$this->assertEqual(array_keys($after), $expected);
$result = array_diff($after['rules'], $before['rules']);
$this->assertEqual($result, array('/rata/' => '\\1ratus'));
foreach (array('irregular', 'uninflected', 'regexUninflected', 'regexIrregular') as $key) {
$this->assertIdentical($before[$key], $after[$key]);
}
$this->assertNull(Inflector::rules('singular', array('rules' => array('/rata/' => '\\1ratus'))));
$this->assertIdentical(Inflector::rules('singular'), $after);
}