<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2171] 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php: Add complete assertions for using the `valid-wxr-1.1.xml` small test file.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2171">2171</a></dd>
<dt>Author</dt> <dd>frederick.ding</dd>
<dt>Date</dt> <dd>2013-07-29 06:02:06 +0000 (Mon, 29 Jul 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add complete assertions for using the `valid-wxr-1.1.xml` small test file.

- Now registers a custom taxonomy first
- Checks all user additions, posts and pages, categories, tags, and other
  taxonomy terms
- See <a href="http://gsoc.trac.wordpress.org/ticket/332">#332</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013frederickdingimportertrunkteststestclasswordpressimporterphp">2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013frederickdingimportertrunkteststestclasswordpressimporterphp"></a>
<div class="modfile"><h4>Modified: 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php (2170 => 2171)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php        2013-07-29 06:01:55 UTC (rev 2170)
+++ 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php   2013-07-29 06:02:06 UTC (rev 2171)
</span><span class="lines">@@ -277,7 +277,7 @@
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Tiny test case of a valid WXR file, not utilizing cron scheduler.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @depends test_save_vars
</span><span class="cx">   * @depends test_advance
</span><span class="cx">   * @depends test_get_error
</span><span class="lines">@@ -289,25 +289,82 @@
</span><span class="cx">          
</span><span class="cx">          // use the WordPress core test case
</span><span class="cx">          $authors = array(
</span><del>-                               'admin' => false,
-                               'editor' => false,
-                               'author' => false
</del><ins>+                                'john',
</ins><span class="cx">           );
</span><span class="cx">          $wxr_file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml';
</span><span class="cx">          $this->assertNotInstanceOf( 'WP_Error', 
</span><span class="cx">                          $parse = $instance->do_parse( $wxr_file ) );
</span><span class="cx">          
</span><span class="cx">          // set the parameters necessary for the process to run
</span><ins>+               $this->assertTrue( $instance->set_param( 'imported_authors', $authors ) );
</ins><span class="cx">           $this->assertTrue( $instance->set_param( 'user_new', $authors ) );
</span><del>-               $this->assertEquals('start', $instance->advance( 'start' ));
</del><ins>+                $this->assertEquals( 'start', $instance->advance( 'start' ) );
</ins><span class="cx">           $this->assertTrue( $instance->is_allowed_user_creation() );
</span><span class="cx">          
</span><ins>+               // this import file has a custom taxonomy
+               register_taxonomy('post_tax', 'post');
+               $this->assertTrue(taxonomy_exists('post_tax'));
+               
</ins><span class="cx">           // should be done in one cron run
</span><del>-               $this->assertTrue($instance->do_import());
-               $this->assertNull($instance->get_error());
</del><ins>+                $this->assertTrue( $instance->do_import() );
+               $this->assertNull( $instance->get_error() );
</ins><span class="cx">           
</span><ins>+               // this specific import file was only meant for testing the parser, 
+               // so we DO expect an invalid taxonomy warning
+               
</ins><span class="cx">           $instance->do_cleanup();
</span><span class="cx">          
</span><ins>+               // check author was imported correctly
+               $user_count = count_users();
+               $this->assertEquals( 1, $user_count['total_users'] );
+                       
+               // check that terms were imported correctly
+               $this->assertEquals( 1, wp_count_terms( 'category' ) );
+               $this->assertEquals( 1, wp_count_terms( 'post_tag' ) );
+               $this->assertEquals( 1, wp_count_terms( 'post_tax' ) );
+               $alpha = get_term_by( 'slug', 'alpha', 'category' );
+               $this->assertEquals( 0, $alpha->parent );
+               $clippable = get_term_by( 'slug', 'clippable', 'post_tag' );
+               $this->assertEquals( 0, $clippable->parent );
+               $bieup = get_term_by( 'slug', 'bieup', 'post_tax' );
+               $this->assertEquals( 0, $bieup->parent );
+               
+               // check posts
+               $posts = get_posts( 
+                               array(
+                                               'numberposts' => 10,
+                                               'post_type' => 'any',
+                                               'post_status' => 'any',
+                                               'orderby' => 'ID'
+                               ) );
+               $this->assertCount( 2, $posts );
+               
+               $author = get_user_by( 'login', 'john' );
+                       
+               // check posts and pages
+               $post = $posts[0];
+               $this->assertEquals( 'About', $post->post_title );
+               $this->assertEquals( 'about', $post->post_name );
+               $this->assertEquals( $author->ID, $post->post_author );
+               $this->assertEquals( 'page', $post->post_type );
+               $this->assertEquals( 'publish', $post->post_status );
+               $this->assertEquals( 0, $post->post_parent );
+               $this->assertEquals( 'default', 
+                               get_post_meta( $post->ID, '_wp_page_template', true ) );
+               
+               $post = $posts[1];
+               $this->assertEquals( 'Hello world!', $post->post_title );
+               $this->assertEquals( 'hello-world', $post->post_name );
+               $this->assertEquals( $author->ID, $post->post_author );
+               $this->assertEquals( 'post', $post->post_type );
+               $this->assertEquals( 'publish', $post->post_status );
+               $this->assertEquals( 0, $post->post_parent );
+               $cats = wp_get_post_categories( $post->ID, array( 'fields' => 'all' ) );
+               $this->assertEquals( 1, count( $cats ) );
+               $this->assertEquals('alpha', $cats[0]->slug );
+               $tags = wp_get_post_tags( $post->ID );
+               $this->assertEquals( 1, count($tags) );
+               $this->assertEquals( 'clippable', $tags[0]->slug );
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  /**
</span></span></pre>
</div>
</div>

</body>
</html>