Skip to content

Commit

Permalink
remove deprecated named constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
aaemnnosttv committed Feb 24, 2018
1 parent b4d89e1 commit 6c4d55c
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 47 deletions.
17 changes: 0 additions & 17 deletions src/Post/Model.php
Expand Up @@ -81,23 +81,6 @@ public function __construct($post = [])
$this->fill($attributes);
}

/**
* Create a new instance from the given WP_Post object
* @deprecated - use static::make()
*
* @param WP_Post $post
*
* @return static
*/
public static function fromWpPost(WP_Post $post)
{
if ($post->post_type !== static::postTypeId()) {
throw new ModelPostTypeMismatchException(static::class, $post);
}

return new static($post);
}

/**
* Create a new instance from a Post with the given ID
*
Expand Down
13 changes: 0 additions & 13 deletions src/Term/Model.php
Expand Up @@ -65,19 +65,6 @@ public function __construct($term = [])
$this->fill($attributes);
}

/**
* Create a new instance from a WP_Term object.
* @deprecated - use static::make()
*
* @param WP_Term $term [description]
*
* @return static
*/
public static function fromWpTerm(WP_Term $term)
{
return new static($term);
}

/**
* Create a new instance from a term ID.
*
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Post/PageTest.php
Expand Up @@ -12,7 +12,7 @@ function it_works()
$page = $this->factory->post->create_and_get(['post_type' => 'page']);

$model_from_id = Page::fromID($page->ID);
$model_from_obj = Page::fromWpPost($page);
$model_from_obj = Page::make($page);
$model_from_slug = Page::fromSlug($page->post_name);

$this->assertSame($page->ID, $model_from_id->id);
Expand Down
15 changes: 1 addition & 14 deletions tests/unit/Post/PostTest.php
Expand Up @@ -41,19 +41,6 @@ function it_blows_up_if_instantiated_with_a_post_of_a_different_post_type()
new Post($wp_post);
}


/** @test */
function it_can_be_instantiated_from_a_wp_post_object()
{
$post = $this->factory->post->create_and_get();
$model = Post::fromWpPost($post);

$this->assertSame($post->ID, $model->id);

$model = Post::make($post);
$this->assertSame($post, $model->object);
}

/** @test */
function it_can_be_instantiated_with_an_array_of_attributes()
{
Expand Down Expand Up @@ -282,7 +269,7 @@ function it_proxies_non_existent_static_methods_to_the_builder()
public function it_has_a_method_for_the_permalink()
{
$post = $this->factory->post->create_and_get();
$model = Post::fromWpPost($post);
$model = Post::make($post);

$this->assertSame(
get_permalink($post->ID),
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Term/TermTest.php
Expand Up @@ -41,7 +41,7 @@ function it_can_create_a_new_instance_from_a_wp_term()
wp_insert_term('Blue', 'category');
$term = get_term_by('name', 'Blue', 'category');

$model = Category::fromWpTerm($term);
$model = new Category($term);

$this->assertInstanceOf(Category::class, $model);
$this->assertSame($term->term_id, $model->id);
Expand Down Expand Up @@ -77,7 +77,7 @@ function it_blows_up_if_the_terms_taxonomy_does_not_match_the_models()
wp_insert_term('Green', 'post_tag');
$tag_term = get_term_by('name', 'Green', 'post_tag');

Category::fromWpTerm($tag_term);
new Category($tag_term);
}

/** @test */
Expand Down

0 comments on commit 6c4d55c

Please sign in to comment.