/usr/share/php/kohana3.2/system/tests/kohana/InflectorTest.php is in libkohana3.2-core-php 3.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
/**
* Tests Kohana inflector class
*
* @group kohana
* @group kohana.core
* @group kohana.core.inflector
*
* @package Kohana
* @category Tests
* @author Kohana Team
* @author Jeremy Bush <contractfrombelow@gmail.com>
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_InflectorTest extends Unittest_TestCase
{
/**
* Provides test data for test_lang()
*
* @return array
*/
public function provider_uncountable()
{
return array(
// $value, $result
array('fish', TRUE),
array('cat', FALSE),
array('deer', TRUE),
array('bison', TRUE),
array('friend', FALSE),
);
}
/**
* Tests Inflector::uncountable
*
* @test
* @dataProvider provider_uncountable
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_uncountable($input, $expected)
{
$this->assertSame($expected, Inflector::uncountable($input));
}
/**
* Provides test data for test_lang()
*
* @return array
*/
public function provider_singular()
{
return array(
// $value, $result
array('fish', NULL, 'fish'),
array('cats', NULL, 'cat'),
array('cats', 2, 'cats'),
array('cats', '2', 'cats'),
array('children', NULL, 'child'),
array('meters', 0.6, 'meters'),
array('meters', 1.6, 'meters'),
array('meters', 1.0, 'meter'),
array('status', NULL, 'status'),
array('statuses', NULL, 'status'),
array('heroes', NULL, 'hero'),
);
}
/**
* Tests Inflector::singular
*
* @test
* @dataProvider provider_singular
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_singular($input, $count, $expected)
{
$this->assertSame($expected, Inflector::singular($input, $count));
}
/**
* Provides test data for test_lang()
*
* @return array
*/
public function provider_plural()
{
return array(
// $value, $result
array('fish', NULL, 'fish'),
array('cat', NULL, 'cats'),
array('cats', 1, 'cats'),
array('cats', '1', 'cats'),
array('movie', NULL, 'movies'),
array('meter', 0.6, 'meters'),
array('meter', 1.6, 'meters'),
array('meter', 1.0, 'meter'),
array('hero', NULL, 'heroes'),
array('Dog', NULL, 'Dogs'), // Titlecase
array('DOG', NULL, 'DOGS'), // Uppercase
);
}
/**
* Tests Inflector::plural
*
* @test
* @dataProvider provider_plural
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_plural($input, $count, $expected)
{
$this->assertSame($expected, Inflector::plural($input, $count));
}
/**
* Provides test data for test_camelize()
*
* @return array
*/
public function provider_camelize()
{
return array(
// $value, $result
array('mother cat', 'camelize', 'motherCat'),
array('kittens in bed', 'camelize', 'kittensInBed'),
array('mother cat', 'underscore', 'mother_cat'),
array('kittens in bed', 'underscore', 'kittens_in_bed'),
array('kittens-are-cats', 'humanize', 'kittens are cats'),
array('dogs_as_well', 'humanize', 'dogs as well'),
);
}
/**
* Tests Inflector::camelize
*
* @test
* @dataProvider provider_camelize
* @param boolean $input Input for File::mime
* @param boolean $expected Output for File::mime
*/
public function test_camelize($input, $method, $expected)
{
$this->assertSame($expected, Inflector::$method($input));
}
/**
* Provides data for test_decamelize()
*
* @return array
*/
public function provider_decamelize()
{
return array(
array('getText', '_', 'get_text'),
array('getJSON', '_', 'get_json'),
array('getLongText', '_', 'get_long_text'),
array('getI18N', '_', 'get_i18n'),
array('getL10n', '_', 'get_l10n'),
array('getTe5t1ng', '_', 'get_te5t1ng'),
array('OpenFile', '_', 'open_file'),
array('CloseIoSocket', '_', 'close_io_socket'),
array('fooBar', ' ', 'foo bar'),
array('camelCase', '+', 'camel+case'),
);
}
/**
* Tests Inflector::decamelize()
*
* @test
* @dataProvider provider_decamelize
* @param string Camelized string
* @param string Glue
* @param string Expected string
*/
public function test_decamelize($input, $glue, $expected)
{
$this->assertSame($expected, Inflector::decamelize($input, $glue));
}
}
|