Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions tests/phpunit/tests/general/bloginfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/**
* Tests for the `bloginfo()` function.
*
* @group general
* @group template
*
* @covers ::bloginfo
*/
class Tests_General_Bloginfo extends WP_UnitTestCase {

/**
* Tests that bloginfo() displays the site name by default.
*
* @ticket 65819
*/
public function test_bloginfo_default_displays_name() {
update_option( 'blogname', 'Test Blog' );

$this->expectOutputString( 'Test Blog' );
bloginfo();
}

/**
* Tests that bloginfo( 'url' ) displays the home URL.
*
* @ticket 65819
*/
public function test_bloginfo_url() {
update_option( 'home', 'http://example.org' );

$this->expectOutputString( 'http://example.org' );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot flagged this too, and it is what fails in the two example.org:8889 jobs, where the output is http://example.org:8889. Setting the option in the test keeps the literal value and works on both:

Suggested change
$this->expectOutputString( 'http://example.org' );
update_option( 'home', 'http://example.org' );
$this->expectOutputString( 'http://example.org' );

bloginfo( 'url' );
}

/**
* Tests that bloginfo() displays filtered value when the bloginfo filter is used.
*
* @ticket 65819
*/
public function test_bloginfo_filter() {
add_filter(
'bloginfo',
static function ( $output, $show ) {
if ( 'name' === $show ) {
return 'Filtered Site Title';
}
return $output;
},
10,
2
);

$this->expectOutputString( 'Filtered Site Title' );
bloginfo( 'name' );
}
}
Loading