2007-02-06 17:18:23 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
2007-07-09 17:02:55 +00:00
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
|
|
|
* Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
2007-02-06 17:18:23 +00:00
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2007-07-09 17:02:55 +00:00
|
|
|
* @copyright Copyright 2005-2007, Cake Software Foundation, Inc.
|
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
|
|
|
* @since CakePHP(tm) v 1.2.0.4206
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
2007-02-06 17:18:23 +00:00
|
|
|
*/
|
2007-07-08 01:17:57 +00:00
|
|
|
uses('inflector');
|
2007-02-06 17:18:23 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
2007-07-09 17:02:55 +00:00
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs
|
2007-02-06 17:18:23 +00:00
|
|
|
*/
|
|
|
|
class InflectorTest extends UnitTestCase {
|
2007-07-09 17:02:55 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
var $Inflector = null;
|
2007-02-06 17:18:23 +00:00
|
|
|
|
|
|
|
function setUp() {
|
2007-07-08 01:17:57 +00:00
|
|
|
$this->Inflector = new Inflector();
|
2007-02-06 17:18:23 +00:00
|
|
|
}
|
|
|
|
|
2007-02-07 00:01:04 +00:00
|
|
|
function testInflectingSingulars() {
|
2007-10-15 16:55:14 +00:00
|
|
|
$result = $this->Inflector->singularize('categorias');
|
|
|
|
$expected = 'categoria';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('menus');
|
2007-02-07 00:01:04 +00:00
|
|
|
$expected = 'menu';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-07 00:01:04 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('food_menus');
|
2007-07-06 07:06:06 +00:00
|
|
|
$expected = 'food_menu';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('Menus');
|
2007-05-13 00:28:03 +00:00
|
|
|
$expected = 'Menu';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('FoodMenus');
|
2007-07-06 07:06:06 +00:00
|
|
|
$expected = 'FoodMenu';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('houses');
|
2007-04-04 07:25:48 +00:00
|
|
|
$expected = 'house';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('powerhouses');
|
2007-04-04 08:01:38 +00:00
|
|
|
$expected = 'powerhouse';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('quizzes');
|
2007-02-07 00:01:04 +00:00
|
|
|
$expected = 'quiz';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-04-03 03:03:42 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('Buses');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'Bus';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('buses');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'bus';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('matrix_rows');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'matrix_row';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('matrices');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'matrix';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('vertices');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'vertex';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('indices');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'index';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-05-12 08:13:45 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('Aliases');
|
2007-05-12 08:13:45 +00:00
|
|
|
$expected = 'Alias';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('Alias');
|
2007-05-12 08:13:45 +00:00
|
|
|
$expected = 'Alias';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-07-06 07:06:06 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->singularize('Media');
|
2007-05-23 17:11:00 +00:00
|
|
|
$expected = 'Media';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-07 00:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function testInflectingPlurals() {
|
2007-10-15 16:55:14 +00:00
|
|
|
$result = $this->Inflector->pluralize('categoria');
|
|
|
|
$expected = 'categorias';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('house');
|
2007-04-04 07:25:48 +00:00
|
|
|
$expected = 'houses';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-04-04 08:01:38 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('powerhouse');
|
2007-04-04 08:01:38 +00:00
|
|
|
$expected = 'powerhouses';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-04-04 07:25:48 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('Bus');
|
2007-02-06 23:57:45 +00:00
|
|
|
$expected = 'Buses';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-06 23:57:45 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('bus');
|
2007-02-06 23:57:45 +00:00
|
|
|
$expected = 'buses';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-06 23:57:45 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('menu');
|
2007-02-07 00:01:04 +00:00
|
|
|
$expected = 'menus';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-07 00:01:04 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('food_menu');
|
2007-07-06 07:06:06 +00:00
|
|
|
$expected = 'food_menus';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('Menu');
|
2007-05-13 00:28:03 +00:00
|
|
|
$expected = 'Menus';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('FoodMenu');
|
2007-07-06 07:06:06 +00:00
|
|
|
$expected = 'FoodMenus';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('quiz');
|
2007-02-07 00:01:04 +00:00
|
|
|
$expected = 'quizzes';
|
2007-02-18 13:10:11 +00:00
|
|
|
$this->assertEqual($result, $expected);
|
2007-04-03 03:03:42 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('matrix_row');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'matrix_rows';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('matrix');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'matrices';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('vertex');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'vertices';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('index');
|
2007-04-03 03:03:42 +00:00
|
|
|
$expected = 'indices';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-05-12 08:13:45 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('Alias');
|
2007-05-12 08:13:45 +00:00
|
|
|
$expected = 'Aliases';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('Aliases');
|
2007-05-12 08:13:45 +00:00
|
|
|
$expected = 'Aliases';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-07-06 07:06:06 +00:00
|
|
|
|
2007-07-08 01:17:57 +00:00
|
|
|
$result = $this->Inflector->pluralize('Media');
|
2007-05-23 17:11:00 +00:00
|
|
|
$expected = 'Media';
|
|
|
|
$this->assertEqual($result, $expected);
|
2007-02-06 17:18:23 +00:00
|
|
|
}
|
|
|
|
|
2007-10-04 02:17:40 +00:00
|
|
|
function testInflectorSlug() {
|
|
|
|
$result = $this->Inflector->slug('Foo Bar: Not just for breakfast any-more');
|
|
|
|
$expected = 'Foo_Bar_Not_just_for_breakfast_any_more';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $this->Inflector->slug('Foo Bar: Not just for breakfast any-more', "-");
|
|
|
|
$expected = 'Foo-Bar-Not-just-for-breakfast-any-more';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
|
|
|
|
$result = $this->Inflector->slug('Foo Bar: Not just for breakfast any-more', "+");
|
|
|
|
$expected = 'Foo+Bar+Not+just+for+breakfast+any+more';
|
|
|
|
$this->assertEqual($result, $expected);
|
|
|
|
}
|
|
|
|
|
2007-02-06 17:18:23 +00:00
|
|
|
function tearDown() {
|
2007-07-08 01:17:57 +00:00
|
|
|
unset($this->Inflector);
|
2007-02-06 17:18:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|