mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues. This change includes three notable additions: - Multiline function calls must now put each parameter on a new line. - Auto-formatting files is now part of the `grunt precommit` script. - Auto-fixable coding standards issues will now cause Travis failures. Fixes #44600. git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
141 lines
3.4 KiB
PHP
141 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* @group link
|
|
*/
|
|
class Tests_Link_GetPostCommentsFeedLink extends WP_UnitTestCase {
|
|
|
|
public function test_post_link() {
|
|
$post_id = self::factory()->post->create();
|
|
|
|
$link = get_post_comments_feed_link( $post_id );
|
|
$expected = add_query_arg(
|
|
array(
|
|
'feed' => get_default_feed(),
|
|
'p' => $post_id,
|
|
),
|
|
home_url( '/' )
|
|
);
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_post_pretty_link() {
|
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
|
|
$post_id = self::factory()->post->create();
|
|
|
|
$link = get_post_comments_feed_link( $post_id );
|
|
$expected = get_permalink( $post_id ) . 'feed/';
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_attachment_link() {
|
|
$post_id = self::factory()->post->create();
|
|
$attachment_id = self::factory()->attachment->create_object(
|
|
'image.jpg',
|
|
$post_id,
|
|
array(
|
|
'post_mime_type' => 'image/jpeg',
|
|
'post_type' => 'attachment',
|
|
)
|
|
);
|
|
|
|
$link = get_post_comments_feed_link( $attachment_id );
|
|
$expected = add_query_arg(
|
|
array(
|
|
'feed' => get_default_feed(),
|
|
'p' => $attachment_id,
|
|
),
|
|
home_url( '/' )
|
|
);
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_attachment_pretty_link() {
|
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
|
|
$post_id = self::factory()->post->create(
|
|
array(
|
|
'post_status' => 'publish',
|
|
)
|
|
);
|
|
$attachment_id = self::factory()->attachment->create_object(
|
|
'image.jpg',
|
|
$post_id,
|
|
array(
|
|
'post_mime_type' => 'image/jpeg',
|
|
'post_type' => 'attachment',
|
|
'post_title' => 'Burrito',
|
|
)
|
|
);
|
|
|
|
$p = get_post( $post_id );
|
|
|
|
$link = get_post_comments_feed_link( $attachment_id );
|
|
$expected = get_permalink( $post_id ) . 'burrito/feed/';
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_attachment_no_name_pretty_link() {
|
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
|
|
$post_id = self::factory()->post->create();
|
|
$attachment_id = self::factory()->attachment->create_object(
|
|
'image.jpg',
|
|
$post_id,
|
|
array(
|
|
'post_mime_type' => 'image/jpeg',
|
|
'post_type' => 'attachment',
|
|
)
|
|
);
|
|
|
|
$link = get_post_comments_feed_link( $attachment_id );
|
|
$expected = get_permalink( $post_id ) . 'attachment/' . $attachment_id . '/feed/';
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_unattached_link() {
|
|
$attachment_id = self::factory()->attachment->create_object(
|
|
'image.jpg',
|
|
0,
|
|
array(
|
|
'post_mime_type' => 'image/jpeg',
|
|
'post_type' => 'attachment',
|
|
)
|
|
);
|
|
|
|
$link = get_post_comments_feed_link( $attachment_id );
|
|
$expected = add_query_arg(
|
|
array(
|
|
'feed' => get_default_feed(),
|
|
'attachment_id' => $attachment_id,
|
|
),
|
|
home_url( '/' )
|
|
);
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
|
|
public function test_unattached_pretty_link() {
|
|
$this->set_permalink_structure( '/%year%/%monthnum%/%day%/%postname%/' );
|
|
|
|
$attachment_id = self::factory()->attachment->create_object(
|
|
'image.jpg',
|
|
0,
|
|
array(
|
|
'post_mime_type' => 'image/jpeg',
|
|
'post_type' => 'attachment',
|
|
)
|
|
);
|
|
|
|
$link = get_post_comments_feed_link( $attachment_id );
|
|
$expected = add_query_arg( 'attachment_id', $attachment_id, home_url( '/feed/' ) );
|
|
|
|
$this->assertEquals( $expected, $link );
|
|
}
|
|
}
|