wordpress-develop/tests/phpunit/tests/formatting/urlShorten.php
Andrew Ozz 5a3f8484d6 Build/Test Tools, Formatting group:
- Add and update @covers tags.
- Add and improve docs and inline comments.

Props pbeane, hellofromTonya, antonvlasenko, ironprogrammer, SergeyBiryukov, costdev.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@53562 602fd350-edb4-49c9-b593-d223f7449a82
2022-06-23 20:27:34 +00:00

26 lines
1.1 KiB
PHP

<?php
/**
* @group formatting
*
* @covers ::url_shorten
*/
class Tests_Formatting_UrlShorten extends WP_UnitTestCase {
public function test_url_shorten() {
$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->assertSame( $v, url_shorten( $k ) );
}
// Shorten to 31 if > 34 after cleaning.
$this->assertSame( 'wordpress.org/about/philosophy/#&hellip;', url_shorten( 'http://wordpress.org/about/philosophy/#decisions' ), 31 );
}
}