-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathPost.php
More file actions
executable file
·81 lines (66 loc) · 2.08 KB
/
Copy pathPost.php
File metadata and controls
executable file
·81 lines (66 loc) · 2.08 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
class WPAPI_Test_Server_Post extends WPAPI_Test_Server {
public function setUp() {
parent::setUp();
$this->post = $this->api->posts->create(array(
'title' => 'API Test Post',
'content_raw' => 'This is a test to check that creating posts from the API works correctly.',
'excerpt_raw' => 'Test post from the API',
'date' => date('c', time())
));
$this->assertInstanceOf('WPAPI_Post', $this->post);
}
public function testAgainstSchema() {
$this->checkEntityAgainstSchema($this->post->getRawData(), 'post');
}
public function testProperties() {
$this->assertNotEmpty($this->post->title);
$this->assertEquals('API Test Post', $this->post->title);
$this->assertNotEmpty($this->post->date);
$this->assertNotEmpty($this->post->date_gmt);
$this->assertNotEmpty($this->post->date_tz);
}
public function testUpdateTitle() {
$success = $this->post->update(array(
'title' => 'API Test Post Updated'
));
$this->assertTrue($success);
$this->assertEquals('API Test Post Updated', $this->post->title);
}
public function testUpdateContent() {
$success = $this->post->update(array(
'content_raw' => 'This is a test of updating the post.',
));
$this->assertTrue($success);
$this->assertEquals('This is a test of updating the post.', $this->post->content_raw);
}
/**
* @depends testProperties
*/
public function testTimezoneFormat() {
$timezones = DateTimeZone::listIdentifiers();
$this->assertContains($this->post->date_tz, $timezones);
}
public function testIgnoreTimezoneForGMT() {
$date = gmdate('c', strtotime('-1 day'));
$success = $this->post->update(array(
'date_gmt' => str_replace('+00:00', '+9:00', $date)
));
$this->assertTrue($success);
$this->assertEquals($date, $this->post->date_gmt);
}
public function tearDown() {
$id = $this->post->ID;
$result = $this->post->delete();
$this->assertTrue($result);
// Check that the post is gone
try {
$post = $this->api->posts->get($id);
}
catch (Requests_Exception $e) {
if ($e->getCode() === 404)
return;
}
$this->fail("Post still appears to exist");
}
}