includesMisc.php 908 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * @group admin
  4. */
  5. class Tests_Admin_includesMisc extends WP_UnitTestCase {
  6. function test_shorten_url() {
  7. $tests = array(
  8. 'wordpress\.org/about/philosophy'
  9. => 'wordpress\.org/about/philosophy', // no longer strips slashes
  10. 'wordpress.org/about/philosophy'
  11. => 'wordpress.org/about/philosophy',
  12. 'http://wordpress.org/about/philosophy/'
  13. => 'wordpress.org/about/philosophy', // remove http, trailing slash
  14. 'http://www.wordpress.org/about/philosophy/'
  15. => 'wordpress.org/about/philosophy', // remove http, www
  16. 'http://wordpress.org/about/philosophy/#box'
  17. => 'wordpress.org/about/philosophy/#box', // don't shorten 35 characters
  18. 'http://wordpress.org/about/philosophy/#decisions'
  19. => 'wordpress.org/about/philosophy/#&hellip;', // shorten to 32 if > 35 after cleaning
  20. );
  21. foreach ( $tests as $k => $v )
  22. $this->assertEquals( $v, url_shorten( $k ) );
  23. }
  24. }