Server IP : 192.64.118.117 / Your IP : 18.216.207.192 Web Server : LiteSpeed System : Linux premium56.web-hosting.com 4.18.0-513.24.1.lve.1.el8.x86_64 #1 SMP Thu May 9 15:10:09 UTC 2024 x86_64 User : thecgapy ( 1160) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/thecgapy/mobilecreationz.com/wp-content/themes/TESSERACT/importer/tests/ |
Upload File : |
<?php class ImporterTest extends WP_UnitTestCase { function testCleanPackageInstall() { $prev_packages = tesseract_get_previously_imported_packages(); $this->assertEmpty( $prev_packages ); $packages = tesseract_get_packages(); tesseract_import_packages( $packages ); $prev_packages = tesseract_get_previously_imported_packages(); $this->assertNotEmpty( $prev_packages ); } function testPackageDeletion() { // Run importer with 2 packages $packages = tesseract_get_packages( dirname( __FILE__ ) . '/data/test-delete-package.json' ); tesseract_import_packages( $packages ); // Assert the number of imported packages is 2 $prev_packages = tesseract_get_previously_imported_packages(); $this->assertEquals( 2, count( $prev_packages ) ); // Grab the slug for the second package for later use $second_package_slug = $packages[1]['details']['slug']; // Assert a post from the 2nd package is present $posts = tesseract_get_tracked_posts_from_package_slug( $second_package_slug ); $this->assertNotEmpty( $posts ); // Run importer with 1 package only unset( $packages[1] ); tesseract_import_packages( $packages ); // Assert number of imported packages is 1 $prev_packages = tesseract_get_previously_imported_packages(); $this->assertEquals( 1, count( $prev_packages ) ); // Assert that same post has been deleted $posts = tesseract_get_tracked_posts_from_package_slug( $second_package_slug ); $this->assertEmpty( $posts ); } 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 ); } }