mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
ae6c6d0a36
git-svn-id: https://svn.cakephp.org/repo/trunk/cake@129 3807eeeb-6ff5-0310-8944-8be069107fe0
70 lines
No EOL
1.8 KiB
PHP
70 lines
No EOL
1.8 KiB
PHP
<?PHP
|
|
|
|
uses ('test', 'inflector');
|
|
|
|
class InflectorTest extends TestCase {
|
|
var $abc;
|
|
|
|
function ControllerTest($name) {
|
|
$this->TestCase($name);
|
|
}
|
|
|
|
function setUp() {
|
|
$this->abc = new Inflector ();
|
|
}
|
|
|
|
function tearDown() {
|
|
unset($this->abc);
|
|
}
|
|
|
|
function testPluralizeSingularize () {
|
|
$singulars = array(
|
|
'search', 'switch', 'fix', 'box', 'process', 'address', 'query', 'ability',
|
|
'agency', 'half', 'safe', 'wife', 'basis', 'diagnosis', 'datum', 'medium',
|
|
'person', 'salesperson', 'man', 'woman', 'spokesman', 'child', 'page', 'robot');
|
|
$plurals = array(
|
|
'searches', 'switches', 'fixes', 'boxes', 'processes', 'addresses', 'queries', 'abilities',
|
|
'agencies', 'halves', 'saves', 'wives', 'bases', 'diagnoses', 'data', 'media',
|
|
'people', 'salespeople', 'men', 'women', 'spokesmen', 'children', 'pages', 'robots');
|
|
|
|
foreach (array_combine($singulars, $plurals) as $singular => $plural) {
|
|
$this->assertEquals($this->abc->pluralize($singular), $plural);
|
|
$this->assertEquals($this->abc->singularize($plural), $singular);
|
|
}
|
|
}
|
|
|
|
function testCamelize() {
|
|
$this->asEq($this->abc->camelize('foo_bar_baz'), 'FooBarBaz');
|
|
}
|
|
|
|
function testUnderscore () {
|
|
$this->asEq($this->abc->underscore('FooBarBaz'), 'foo_bar_baz');
|
|
}
|
|
|
|
function testHumanize () {
|
|
$this->asEq($this->abc->humanize('foo_bar_baz'), 'Foo Bar Baz');
|
|
}
|
|
|
|
function testTableize () {
|
|
$this->asEq($this->abc->tableize('Bar'), 'bars');
|
|
}
|
|
|
|
function testClassify () {
|
|
$this->asEq($this->abc->classify('bars'), 'Bar');
|
|
}
|
|
|
|
function testForeignKey () {
|
|
$this->asEq($this->abc->foreignKey('Bar'), 'bar_id');
|
|
}
|
|
|
|
|
|
/*
|
|
function test () {
|
|
$result = $this->abc->();
|
|
$expected = '';
|
|
$this->assertEquals($result, $expected);
|
|
}
|
|
*/
|
|
}
|
|
|
|
?>
|