-
Notifications
You must be signed in to change notification settings - Fork 9
/
PageTest.php
47 lines (37 loc) · 1.19 KB
/
PageTest.php
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
<?php
use Silk\WordPress\Post\Page;
class PageTest extends WP_UnitTestCase
{
/**
* @test
**/
function it_works()
{
$page = $this->factory->post->create_and_get(['post_type' => 'page']);
$model_from_id = Page::fromID($page->ID);
$model_from_obj = Page::make($page);
$model_from_slug = Page::fromSlug($page->post_name);
$this->assertSame($page->ID, $model_from_id->id);
$this->assertSame($page->ID, $model_from_obj->id);
$this->assertSame($page->ID, $model_from_slug->id);
}
/** @test */
function it_can_create_a_page_from_a_new_instance()
{
$model = new Page;
$model->post_title = 'some title';
$model->save();
$this->assertGreaterThan(0, $model->id);
$this->assertSame('page', $model->post_type);
}
/**
* @test
* @expectedException \Silk\Post\Exception\ModelPostTypeMismatchException
*/
function it_blows_up_if_instantiated_with_a_non_page_post_type()
{
$post_id = $this->factory->post->create(['post_type' => 'post']);
// this will blow up since the post id is for a post_type of `post`
Page::fromID($post_id);
}
}