forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwpPost.php
More file actions
61 lines (49 loc) · 1.19 KB
/
wpPost.php
File metadata and controls
61 lines (49 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* @group post
*/
class Tests_Post_WpPost extends WP_UnitTestCase {
protected static $post_id;
public static function wpSetUpBeforeClass( $factory ) {
global $wpdb;
// Ensure that there is a post with ID 1.
if ( ! get_post( 1 ) ) {
$wpdb->insert(
$wpdb->posts,
array(
'ID' => 1,
'post_title' => 'Post 1',
)
);
}
self::$post_id = self::factory()->post->create();
}
/**
* @ticket 37738
*/
public function test_get_instance_should_work_for_numeric_string() {
$found = WP_Post::get_instance( (string) self::$post_id );
$this->assertSame( self::$post_id, $found->ID );
}
/**
* @ticket 37738
*/
public function test_get_instance_should_fail_for_negative_number() {
$found = WP_Post::get_instance( -self::$post_id );
$this->assertFalse( $found );
}
/**
* @ticket 37738
*/
public function test_get_instance_should_fail_for_non_numeric_string() {
$found = WP_Post::get_instance( 'abc' );
$this->assertFalse( $found );
}
/**
* @ticket 37738
*/
public function test_get_instance_should_succeed_for_float_that_is_equal_to_post_id() {
$found = WP_Post::get_instance( 1.0 );
$this->assertSame( 1, $found->ID );
}
}