wordpress-develop/tests/phpunit/tests/formatting/urlShorten.php
Tonya Mork 40ac5de838 Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-04 15:22:47 +00:00

24 lines
1.1 KiB
PHP

<?php
/**
* @group formatting
*/
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 );
}
}