TextLibTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. App::uses('TextLib', 'Tools.Utility');
  3. /**
  4. * 2010-07-14 ms
  5. */
  6. class TextLibTest extends CakeTestCase {
  7. public $TextLib;
  8. public function setUp() {
  9. parent::setUp();
  10. $this->TextLib = new TextLib();
  11. }
  12. public function testConvertToOrd() {
  13. $this->TextLib = new TextLib('h H');
  14. $is = $this->TextLib->convertToOrd();
  15. //pr($is);
  16. $this->assertEquals($is, '0-104-32-72-0');
  17. $is = $this->TextLib->convertToOrd('x'.NL.'x'.LF.'x'.PHP_EOL.'x'.CR.'x'.TB.'x');
  18. //pr($is);
  19. }
  20. public function testConvertToOrdTable() {
  21. $is = $this->TextLib->convertToOrdTable('x'.NL.'x'.LF.'x'.PHP_EOL.'x'.CR.'x'.TB.'x');
  22. //pr($is);
  23. }
  24. public function testMaxWords() {
  25. $this->assertEquals('Taylor...', TextLib::maxWords('Taylor Otwell', 1));
  26. $this->assertEquals('Taylor___', TextLib::maxWords('Taylor Otwell', 1, array('ellipsis'=>'___')));
  27. $this->assertEquals('Taylor Otwell', TextLib::maxWords('Taylor Otwell', 3));
  28. }
  29. public function testWords() {
  30. $this->TextLib = new TextLib('Hochhaus, Unter dem Bau von ae Äußeren Einflüssen - und von Autos.');
  31. $is = $this->TextLib->words(array('min_char'=>3));
  32. //pr($is);
  33. $this->assertTrue(!empty($is) && is_array($is) && count($is) === 9);
  34. }
  35. }