/usr/share/php/kohana3.1/system/tests/kohana/UTF8Test.php is in libkohana3.1-core-php 3.1.5-1.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 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 | <?php defined('SYSPATH') OR die('Kohana bootstrap needs to be included before tests run');
/**
* Tests Kohana_UTF8 class
*
* @group kohana
* @group kohana.core
* @group kohana.core.utf8
*
* @package Kohana
* @category Tests
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_UTF8Test extends Unittest_TestCase
{
/**
* Provides test data for test_clean()
*/
public function provider_clean()
{
return array(
array("\0", ''),
array("→foo\021", '→foo'),
array("\x7Fbar", 'bar'),
array("\xFF", ''),
array("\x41", 'A'),
array(array("→foo\021", "\x41"), array('→foo', 'A')),
);
}
/**
* Tests UTF8::clean
*
* @test
* @dataProvider provider_clean
*/
public function test_clean($input, $expected)
{
$this->assertSame($expected, UTF8::clean($input));
}
/**
* Provides test data for test_is_ascii()
*/
public function provider_is_ascii()
{
return array(
array("\0", TRUE),
array("\$eno\r", TRUE),
array('Señor', FALSE),
array(array('Se', 'nor'), TRUE),
array(array('Se', 'ñor'), FALSE),
);
}
/**
* Tests UTF8::is_ascii
*
* @test
* @dataProvider provider_is_ascii
*/
public function test_is_ascii($input, $expected)
{
$this->assertSame($expected, UTF8::is_ascii($input));
}
/**
* Provides test data for test_strip_ascii_ctrl()
*/
public function provider_strip_ascii_ctrl()
{
return array(
array("\0", ''),
array("→foo\021", '→foo'),
array("\x7Fbar", 'bar'),
array("\xFF", "\xFF"),
array("\x41", 'A'),
);
}
/**
* Tests UTF8::strip_ascii_ctrl
*
* @test
* @dataProvider provider_strip_ascii_ctrl
*/
public function test_strip_ascii_ctrl($input, $expected)
{
$this->assertSame($expected, UTF8::strip_ascii_ctrl($input));
}
/**
* Provides test data for test_strip_non_ascii()
*/
public function provider_strip_non_ascii()
{
return array(
array("\0\021\x7F", "\0\021\x7F"),
array('I ♥ cocoñùт', 'I coco'),
);
}
/**
* Tests UTF8::strip_non_ascii
*
* @test
* @dataProvider provider_strip_non_ascii
*/
public function test_strip_non_ascii($input, $expected)
{
$this->assertSame($expected, UTF8::strip_non_ascii($input));
}
/**
* Provides test data for test_transliterate_to_ascii()
*/
public function provider_transliterate_to_ascii()
{
return array(
array('Cocoñùт', -1, 'Coconuт'),
array('COCOÑÙТ', -1, 'COCOÑÙТ'),
array('Cocoñùт', 0, 'Coconuт'),
array('COCOÑÙТ', 0, 'COCONUТ'),
array('Cocoñùт', 1, 'Cocoñùт'),
array('COCOÑÙТ', 1, 'COCONUТ'),
);
}
/**
* Tests UTF8::transliterate_to_ascii
*
* @test
* @dataProvider provider_transliterate_to_ascii
*/
public function test_transliterate_to_ascii($input, $case, $expected)
{
$this->assertSame($expected, UTF8::transliterate_to_ascii($input, $case));
}
/**
* Provides test data for test_strlen()
*/
public function provider_strlen()
{
return array(
array('Cocoñùт', 7),
array('Coconut', 7),
);
}
/**
* Tests UTF8::strlen
*
* @test
* @dataProvider provider_strlen
*/
public function test_strlen($input, $expected)
{
$this->assertSame($expected, UTF8::strlen($input));
}
/**
* Provides test data for test_strpos()
*/
public function provider_strpos()
{
return array(
array('Cocoñùт', 'o', 0, 1),
array('Cocoñùт', 'ñ', 1, 4),
);
}
/**
* Tests UTF8::strpos
*
* @test
* @dataProvider provider_strpos
*/
public function test_strpos($input, $str, $offset, $expected)
{
$this->assertSame($expected, UTF8::strpos($input, $str, $offset));
}
/**
* Provides test data for test_strrpos()
*/
public function provider_strrpos()
{
return array(
array('Cocoñùт', 'o', 0, 3),
array('Cocoñùт', 'ñ', 2, 4),
);
}
/**
* Tests UTF8::strrpos
*
* @test
* @dataProvider provider_strrpos
*/
public function test_strrpos($input, $str, $offset, $expected)
{
$this->assertSame($expected, UTF8::strrpos($input, $str, $offset));
}
/**
* Provides test data for test_substr()
*/
public function provider_substr()
{
return array(
array('Cocoñùт', 3, 2, 'oñ'),
array('Cocoñùт', 3, 9, 'oñùт'),
array('Cocoñùт', 3, NULL, 'oñùт'),
array('Cocoñùт', 3, -2, 'oñ'),
);
}
/**
* Tests UTF8::substr
*
* @test
* @dataProvider provider_substr
*/
public function test_substr($input, $offset, $length, $expected)
{
$this->assertSame($expected, UTF8::substr($input, $offset, $length));
}
/**
* Provides test data for test_substr_replace()
*/
public function provider_substr_replace()
{
return array(
array('Cocoñùт', 'šš', 3, 2, 'Cocššùт'),
array('Cocoñùт', 'šš', 3, 9, 'Cocšš'),
);
}
/**
* Tests UTF8::substr_replace
*
* @test
* @dataProvider provider_substr_replace
*/
public function test_substr_replace($input, $replacement, $offset, $length, $expected)
{
$this->assertSame($expected, UTF8::substr_replace($input, $replacement, $offset, $length));
}
/**
* Provides test data for test_strtolower()
*/
public function provider_strtolower()
{
return array(
array('COCOÑÙТ', 'cocoñùт'),
array('JÄGER', 'jäger'),
);
}
/**
* Tests UTF8::strtolower
*
* @test
* @dataProvider provider_strtolower
*/
public function test_strtolower($input, $expected)
{
$this->assertSame($expected, UTF8::strtolower($input));
}
/**
* Provides test data for test_strtoupper()
*/
public function provider_strtoupper()
{
return array(
array('Cocoñùт', 'COCOÑÙТ'),
array('jäger', 'JÄGER'),
);
}
/**
* Tests UTF8::strtoupper
*
* @test
* @dataProvider provider_strtoupper
*/
public function test_strtoupper($input, $expected)
{
$this->assertSame($expected, UTF8::strtoupper($input));
}
/**
* Provides test data for test_ucfirst()
*/
public function provider_ucfirst()
{
return array(
array('ñùт', 'Ñùт'),
);
}
/**
* Tests UTF8::ucfirst
*
* @test
* @dataProvider provider_ucfirst
*/
public function test_ucfirst($input, $expected)
{
$this->assertSame($expected, UTF8::ucfirst($input));
}
/**
* Provides test data for test_strip_non_ascii()
*/
public function provider_ucwords()
{
return array(
array('ExAmple', 'ExAmple'),
array('i ♥ Cocoñùт', 'I ♥ Cocoñùт'),
);
}
/**
* Tests UTF8::ucwords
*
* @test
* @dataProvider provider_ucwords
*/
public function test_ucwords($input, $expected)
{
$this->assertSame($expected, UTF8::ucwords($input));
}
/**
* Provides test data for test_strcasecmp()
*/
public function provider_strcasecmp()
{
return array(
array('Cocoñùт', 'Cocoñùт', 0),
array('Čau', 'Čauo', -1),
array('Čau', 'Ča', 1),
array('Cocoñùт', 'Cocoñ', 4),
array('Cocoñùт', 'Coco', 6),
);
}
/**
* Tests UTF8::strcasecmp
*
* @test
* @dataProvider provider_strcasecmp
*/
public function test_strcasecmp($input, $input2, $expected)
{
$this->assertSame($expected, UTF8::strcasecmp($input, $input2));
}
/**
* Provides test data for test_str_ireplace()
*/
public function provider_str_ireplace()
{
return array(
array('т', 't', 'cocoñuт', 'cocoñut'),
array('Ñ', 'N', 'cocoñuт', 'cocoNuт'),
array(array('т', 'Ñ', 'k' => 'k'), array('t', 'N', 'K'), array('cocoñuт'), array('cocoNut')),
array(array('ñ'), 'n', 'cocoñuт', 'coconuт'),
);
}
/**
* Tests UTF8::str_ireplace
*
* @test
* @dataProvider provider_str_ireplace
*/
public function test_str_ireplace($search, $replace, $subject, $expected)
{
$this->assertSame($expected, UTF8::str_ireplace($search, $replace, $subject));
}
/**
* Provides test data for test_stristr()
*/
public function provider_stristr()
{
return array(
array('Cocoñùт', 'oñ', 'oñùт'),
array('Cocoñùт', 'o', 'ocoñùт'),
array('Cocoñùт', 'k', FALSE),
);
}
/**
* Tests UTF8::stristr
*
* @test
* @dataProvider provider_stristr
*/
public function test_stristr($input, $input2, $expected)
{
$this->assertSame($expected, UTF8::stristr($input, $input2));
}
/**
* Provides test data for test_strspn()
*/
public function provider_strspn()
{
return array(
array("foo", "o", 1, 2, 2),
array('Cocoñùт', 'oñ', NULL, NULL, 1),
array('Cocoñùт', 'oñ', 2, 4, 1),
array('Cocoñùт', 'šš', 3, 9, 4),
);
}
/**
* Tests UTF8::strspn
*
* @test
* @dataProvider provider_strspn
*/
public function test_strspn($input, $mask, $offset, $length, $expected)
{
$this->assertSame($expected, UTF8::strspn($input, $mask, $offset, $length));
}
/**
* Provides test data for test_strcspn()
*/
public function provider_strcspn()
{
return array(
array('Cocoñùт', 'oñ', NULL, NULL, 1),
array('Cocoñùт', 'oñ', 2, 4, 1),
array('Cocoñùт', 'šš', 3, 9, 4),
);
}
/**
* Tests UTF8::strcspn
*
* @test
* @dataProvider provider_strcspn
*/
public function test_strcspn($input, $mask, $offset, $length, $expected)
{
$this->assertSame($expected, UTF8::strcspn($input, $mask, $offset, $length));
}
/**
* Provides test data for test_str_pad()
*/
public function provider_str_pad()
{
return array(
array('Cocoñùт', 10, 'š', STR_PAD_RIGHT, 'Cocoñùтššš'),
array('Cocoñùт', 10, 'š', STR_PAD_LEFT, 'šššCocoñùт'),
array('Cocoñùт', 10, 'š', STR_PAD_BOTH, 'šCocoñùтšš'),
);
}
/**
* Tests UTF8::str_pad
*
* @test
* @dataProvider provider_str_pad
*/
public function test_str_pad($input, $length, $pad, $type, $expected)
{
$this->assertSame($expected, UTF8::str_pad($input, $length, $pad, $type));
}
/**
* Tests UTF8::str_pad error
*
* @test
* @expectedException Exception
*/
public function test_str_pad_error()
{
UTF8::str_pad('Cocoñùт', 10, 'š', 15, 'šCocoñùтšš');
}
/**
* Provides test data for test_str_split()
*/
public function provider_str_split()
{
return array(
array('Bár', 1, array('B', 'á', 'r')),
array('Cocoñùт', 2, array('Co', 'co', 'ñù', 'т')),
array('Cocoñùт', 3, array('Coc', 'oñù', 'т')),
);
}
/**
* Tests UTF8::str_split
*
* @test
* @dataProvider provider_str_split
*/
public function test_str_split($input, $split_length, $expected)
{
$this->assertSame($expected, UTF8::str_split($input, $split_length));
}
/**
* Provides test data for test_strrev()
*/
public function provider_strrev()
{
return array(
array('Cocoñùт', 'тùñocoC'),
);
}
/**
* Tests UTF8::strrev
*
* @test
* @dataProvider provider_strrev
*/
public function test_strrev($input, $expected)
{
$this->assertSame($expected, UTF8::strrev($input));
}
/**
* Provides test data for test_trim()
*/
public function provider_trim()
{
return array(
array(' bar ', NULL, 'bar'),
array('bar', 'b', 'ar'),
array('barb', 'b', 'ar'),
);
}
/**
* Tests UTF8::trim
*
* @test
* @dataProvider provider_trim
*/
public function test_trim($input, $input2, $expected)
{
$this->assertSame($expected, UTF8::trim($input, $input2));
}
/**
* Provides test data for test_ltrim()
*/
public function provider_ltrim()
{
return array(
array(' bar ', NULL, 'bar '),
array('bar', 'b', 'ar'),
array('barb', 'b', 'arb'),
array('ñùт', 'ñ', 'ùт'),
);
}
/**
* Tests UTF8::ltrim
*
* @test
* @dataProvider provider_ltrim
*/
public function test_ltrim($input, $charlist, $expected)
{
$this->assertSame($expected, UTF8::ltrim($input, $charlist));
}
/**
* Provides test data for test_rtrim()
*/
public function provider_rtrim()
{
return array(
array(' bar ', NULL, ' bar'),
array('bar', 'b', 'bar'),
array('barb', 'b', 'bar'),
array('Cocoñùт', 'т', 'Cocoñù'),
);
}
/**
* Tests UTF8::rtrim
*
* @test
* @dataProvider provider_rtrim
*/
public function test_rtrim($input, $input2, $expected)
{
$this->assertSame($expected, UTF8::rtrim($input, $input2));
}
/**
* Provides test data for test_ord()
*/
public function provider_ord()
{
return array(
array('f', 102),
array('ñ', 241),
array('Ñ', 209),
);
}
/**
* Tests UTF8::ord
*
* @test
* @dataProvider provider_ord
*/
public function test_ord($input, $expected)
{
$this->assertSame($expected, UTF8::ord($input));
}
}
|