Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WP unit test for export redux plugin
<?php
require_once dirname( __FILE__ ) . '/base.php';
// the path on this to the main export code in the export redux plugin
// if/when testing the export in core, modify this path
require_once __DIR__ . '/../includes/export.php';
/**
* @group export
*/
class WXR_Tests_Well_Formed extends WXR_Export_UnitTestCase {
function setUp() {
parent::setUp();
global $wpdb;
// crude but effective: make sure there's no residual data in the main tables
foreach ( array('posts', 'postmeta', 'comments', 'terms', 'term_taxonomy', 'term_relationships', 'users', 'usermeta') as $table)
$wpdb->query("DELETE FROM {$wpdb->$table}");
}
function tearDown() {
parent::tearDown();
}
function test_all_content_well_formed() {
self::factory()->post->create_many( 3, array( 'post_type' => 'post' ) );
self::factory()->post->create_many( 2, array( 'post_type' => 'page' ) );
$wxr = $this->_export_wp( array( 'contents' => 'all' ) );
libxml_use_internal_errors( true );
$dom = new DOMDocument();
$ret = $dom->loadXML( $wxr );
$this->assertEquals( $ret, true );
$errs = libxml_get_errors();
$this->assertEquals ( count( $errs ), 0 );
libxml_clear_errors();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment