wordpress-develop/tests/phpunit/tests/post/bodyClass.php
Sergey Biryukov 97b2f07d2e Coding Standards: Replace alias PHP functions with the canonical names.
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning.

This replaces all uses of the following:
* `join()` with `implode()`
* `sizeof()` with `count()`
* `is_writeable()` with `is_writable()`
* `doubleval()` with a `(float)` cast

In part, this is a follow-up to #47746.

Props jrf.
See #50767.

git-svn-id: https://develop.svn.wordpress.org/trunk@49193 602fd350-edb4-49c9-b593-d223f7449a82
2020-10-18 17:25:10 +00:00

30 lines
797 B
PHP

<?php
/**
* @group post
* @covers ::body_class
*/
class Tests_Post_BodyClass extends WP_UnitTestCase {
protected $post_id;
public function setUp() {
parent::setUp();
$this->post_id = self::factory()->post->create();
}
public function test_body_class() {
$expected = 'class="' . implode( ' ', get_body_class( '', $this->post_id ) ) . '"';
$this->expectOutputString( $expected );
body_class( '', $this->post_id );
}
public function test_body_class_extra_esc_attr() {
$classes = get_body_class( '', $this->post_id );
$escaped_again = array_map( 'esc_attr', $classes );
$escaped_another_time = 'class="' . esc_attr( implode( ' ', $escaped_again ) ) . '"';
$this->expectOutputString( $escaped_another_time );
body_class( '', $this->post_id );
}
}