Example #1
0
function tesseract_delete_package_with_slug($slug)
{
    $imported_posts = tesseract_get_tracked_posts_from_package_slug($slug);
    foreach ($imported_posts as $post) {
        wp_delete_post($post->ID);
    }
    $imported_packages = get_option(Tesseract_Importer_Constants::$IMPORTED_PACKAGES_OPTION_NAME, array());
    unset($imported_packages[$slug]);
    update_option(Tesseract_Importer_Constants::$IMPORTED_PACKAGES_OPTION_NAME, $imported_packages);
}
Example #2
0
 function testPackageUpdate()
 {
     // Run importer with a package, version 1.0
     $packages = tesseract_get_packages(dirname(__FILE__) . '/data/test-update-package.json');
     tesseract_import_packages($packages);
     $slug = $packages["1"]['details']['slug'];
     // Assert that a post from that package is present with a certain title
     $posts = tesseract_get_tracked_posts_from_package_slug($slug);
     $this->assertEquals('Post 1.0', $posts[0]->post_title);
     // Run importer with same package slug, version 1.1, with an updated post title
     $packages = tesseract_get_packages(dirname(__FILE__) . '/data/test-update-package-updated.json');
     tesseract_import_packages($packages);
     // Assert that the post title has changed, and the old post doesn't exist
     $posts = tesseract_get_tracked_posts_from_package_slug($slug);
     $this->assertEquals(1, count($posts));
     $this->assertEquals('Post 1.1', $posts[0]->post_title);
 }