/** * Update the post/group association when saving posts * * @since 1.1.0 * * @param int $id * @param \WP_Post $post */ public function track_groups($id, $post) { posts::update_groups_in_post($post); }
/** * Test that we can find the IDs from the shortcodes in post content * * @since 1.1.0 * * @group group * @group objects * @group posts_object * * @covers ingot\testing\utility\posts::update_groups_in_post() */ public function testUpdatePost() { $id = $this->factory->post->create(['post_title' => 'good', 'post_content' => 'sfdjlakjsdf [ingot id="9"] sfdj fsdkdfs SDF657R542 ingot id="7" fsd [ingot id="42"][ingot id="11"]']); $post = get_post($id); \ingot\testing\utility\posts::update_groups_in_post($post); $obj = new \ingot\testing\object\posts(get_post($id)); $expected = [9, 42, 11]; $this->assertSame($expected, $obj->get_groups()); $post->post_content = 'sfdjlakjsdf [ingot id="9"]'; \ingot\testing\utility\posts::update_groups_in_post($post); $obj = new \ingot\testing\object\posts(get_post($id)); $this->assertSame([9], $obj->get_groups()); }