wordpress-develop/tests/phpunit/tests/admin/includesMisc.php
Gary Pendergast 8f95800d52 Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.



git-svn-id: https://develop.svn.wordpress.org/trunk@42343 602fd350-edb4-49c9-b593-d223f7449a82
2017-11-30 23:09:33 +00:00

27 lines
914 B
PHP

<?php
/**
* @group admin
*/
class Tests_Admin_includesMisc extends WP_UnitTestCase {
function test_shorten_url() {
$tests = array(
'wordpress\.org/about/philosophy'
=> 'wordpress\.org/about/philosophy', // no longer strips slashes
'wordpress.org/about/philosophy'
=> 'wordpress.org/about/philosophy',
'http://wordpress.org/about/philosophy/'
=> 'wordpress.org/about/philosophy', // remove http, trailing slash
'http://www.wordpress.org/about/philosophy/'
=> 'wordpress.org/about/philosophy', // remove http, www
'http://wordpress.org/about/philosophy/#box'
=> 'wordpress.org/about/philosophy/#box', // don't shorten 35 characters
'http://wordpress.org/about/philosophy/#decisions'
=> 'wordpress.org/about/philosophy/#&hellip;', // shorten to 32 if > 35 after cleaning
);
foreach ( $tests as $k => $v ) {
$this->assertEquals( $v, url_shorten( $k ) );
}
}
}