-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define Post Model Terms Fluently #277
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I would confirm my suspicions about the logic concern in one of the assertions before merging, but everything else seems good to go.
🎸
public function assertPostNotHasTerm( $post, $term ) { | ||
if ( $post instanceof Post ) { | ||
$post = $post->id(); | ||
} | ||
|
||
$term = $this->get_term_from_argument( $term ); | ||
|
||
if ( $term ) { | ||
PHPUnit::assertFalse( \has_term( $term->term_id, $term->taxonomy, $post ) ); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this has already been merged, but I wanted to call out that without PHPUnit::assertNotInstanceOf
we no longer have an assertion if $term
is null. That was the intent behind that line in my previous suggestion.
Extends #276
Docs https://github.com/alleyinteractive/mantle-docs/pull/21/files
Allows post models to add/set/delete/update terms using a fluent format.
The
Post
model support interacting with terms through relationships or through the model directly. The model supports multiple methods to make setting terms on a post simple:Terms can also be set when creating a post (specifying the taxonomy is optional):