<!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>[845] trunk/wp-testcase/test_post_output.php: Port test_post_output.php.</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, #logmsg > ol { margin-left: 0; 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://unit-tests.trac.wordpress.org/changeset/845">845</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2012-07-01 23:21:43 +0000 (Sun, 01 Jul 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>Port test_post_output.php. fixes <a href="http://unit-tests.trac.wordpress.org/ticket/95">#95</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwptestcasetest_post_outputphp">trunk/wp-testcase/test_post_output.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwptestcasetest_post_outputphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-testcase/test_post_output.php (844 => 845)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-testcase/test_post_output.php        2012-07-01 22:49:55 UTC (rev 844)
+++ trunk/wp-testcase/test_post_output.php        2012-07-01 23:21:43 UTC (rev 845)
</span><span class="lines">@@ -2,67 +2,63 @@
</span><span class="cx"> 
</span><span class="cx"> // test the output of post template tags etc
</span><span class="cx"> 
</span><del>-class _WPTestSinglePost extends _WPEmptyBlog {
</del><ins>+/**
+ * @group post
+ * @group formatting
+ */
+class WP_Test_Post_Output extends WP_UnitTestCase {
</ins><span class="cx"> 
</span><del>-        var $post_title = NULL;
-        var $post_content = NULL;
</del><ins>+        function setUp() {
+                parent::setUp();
+                add_shortcode( 'dumptag', array( $this, '_shortcode_dumptag' ) );
+                add_shortcode( 'paragraph', array( $this, '_shortcode_paragraph' ) );
+        }
</ins><span class="cx"> 
</span><del>-        var $the_title = NULL;
-        var $the_content = NULL;
</del><ins>+        function tearDown() {
+                global $shortcode_tags;
+                unset( $shortcode_tags['dumptag'], $shortcode_tags['paragraph'] );
+                parent::tearDown();
+        }
</ins><span class="cx"> 
</span><del>-        function _do_post() {
-                $post = array(
-                        'post_author' =&gt; $this-&gt;author-&gt;ID,
-                        'post_status' =&gt; 'publish',
-                        'post_content' =&gt; $this-&gt;post_content,
-                        'post_title' =&gt; $this-&gt;post_title,
-                );
</del><ins>+        function _shortcode_dumptag( $atts ) {
+                $out = '';
+                foreach ($atts as $k=&gt;$v)
+                        $out .= &quot;$k = $v\n&quot;;
+                return $out;
+        }
</ins><span class="cx"> 
</span><del>-                // insert a post
-                $this-&gt;post_id = $this-&gt;post_ids[] = wp_insert_post($post);
-
-                // pretend we're on the single permlink page for that post
-                $out = wp_get_single_post($this-&gt;post_id);
-                $this-&gt;http(get_permalink($this-&gt;post_id));
-
-                $this-&gt;assertTrue(is_single());
-                $this-&gt;assertTrue(have_posts());
-                $this-&gt;assertNull(the_post());
</del><ins>+        function _shortcode_paragraph( $atts, $content ) {
+                extract(shortcode_atts(array(
+                        'class' =&gt; 'graf',
+                ), $atts));
+                return &quot;&lt;p class='$class'&gt;$content&lt;/p&gt;\n&quot;;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-
-}
-
-class WPTestPostMoreVB extends _WPTestSinglePost {
-
-        function setUp() {
-
-                $this-&gt;post_content =&lt;&lt;&lt;EOF
</del><ins>+        function test_the_content() {
+                $post_content = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;i&gt;This is the excerpt.&lt;/i&gt;
</span><span class="cx"> &lt;!--more--&gt;
</span><span class="cx"> This is the &lt;b&gt;body&lt;/b&gt;.
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                parent::setUp();
-        }
</del><ins>+                $post_id = $this-&gt;factory-&gt;post-&gt;create( compact( 'post_content' ) );
</ins><span class="cx"> 
</span><del>-        function test_the_content() {
-                $this-&gt;_do_post();
-                $the_content =&lt;&lt;&lt;EOF
</del><ins>+                $expected = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;p&gt;&lt;i&gt;This is the excerpt.&lt;/i&gt;&lt;br /&gt;
</span><del>-&lt;span id=&quot;more-{$this-&gt;post_id}&quot;&gt;&lt;/span&gt;&lt;br /&gt;
</del><ins>+&lt;span id=&quot;more-{$post_id}&quot;&gt;&lt;/span&gt;&lt;br /&gt;
</ins><span class="cx"> This is the &lt;b&gt;body&lt;/b&gt;.&lt;/p&gt;
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals(strip_ws($the_content), strip_ws(get_echo('the_content')));
</del><ins>+                $this-&gt;go_to( get_permalink( $post_id ) );
+                $this-&gt;assertTrue( is_single() );
+                $this-&gt;assertTrue( have_posts() );
+                $this-&gt;assertNull( the_post() );
+
+                $this-&gt;assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><del>-}
-
-class WPTestShortcodeOutput1 extends _WPTestSinglePost {
-        function setUp() {
-
-                $this-&gt;post_content =&lt;&lt;&lt;EOF
</del><ins>+        function test_the_content_shortcode() {
+                $post_content = &lt;&lt;&lt;EOF
</ins><span class="cx"> [dumptag foo=&quot;bar&quot; baz=&quot;123&quot;]
</span><span class="cx"> 
</span><span class="cx"> [dumptag foo=123 baz=bar]
</span><span class="lines">@@ -71,11 +67,6 @@
</span><span class="cx"> 
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                parent::setUp();
-        }
-
-        function test_the_content() {
-                $this-&gt;_do_post();
</del><span class="cx">                 $expected =&lt;&lt;&lt;EOF
</span><span class="cx"> foo = bar
</span><span class="cx"> baz = 123
</span><span class="lines">@@ -85,14 +76,17 @@
</span><span class="cx"> 
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
</del><ins>+                $post_id = $this-&gt;factory-&gt;post-&gt;create( compact( 'post_content' ) );
+                $this-&gt;go_to( get_permalink( $post_id ) );
+                $this-&gt;assertTrue( is_single() );
+                $this-&gt;assertTrue( have_posts() );
+                $this-&gt;assertNull( the_post() );
+
+                $this-&gt;assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
</ins><span class="cx">         }
</span><del>-}
</del><span class="cx"> 
</span><del>-class WPTestShortcodeOutputParagraph extends _WPTestSinglePost {
-        function setUp() {
-
-                $this-&gt;post_content =&lt;&lt;&lt;EOF
</del><ins>+        function test_the_content_shortcode_paragraph() {
+                $post_content = &lt;&lt;&lt;EOF
</ins><span class="cx"> Graf by itself:
</span><span class="cx"> 
</span><span class="cx"> [paragraph]my graf[/paragraph]
</span><span class="lines">@@ -106,12 +100,7 @@
</span><span class="cx"> 
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                parent::setUp();
-        }
-
-        function test_the_content() {
-                $this-&gt;_do_post();
-                $expected =&lt;&lt;&lt;EOF
</del><ins>+                $expected = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;p&gt;Graf by itself:&lt;/p&gt;
</span><span class="cx"> &lt;p class='graf'&gt;my graf&lt;/p&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -125,11 +114,21 @@
</span><span class="cx"> 
</span><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
</del><ins>+                $post_id = $this-&gt;factory-&gt;post-&gt;create( compact( 'post_content' ) );
+                $this-&gt;go_to( get_permalink( $post_id ) );
+                $this-&gt;assertTrue( is_single() );
+                $this-&gt;assertTrue( have_posts() );
+                $this-&gt;assertNull( the_post() );
+
+                $this-&gt;assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-class WPTestGalleryPost extends _WPDataset1 {
</del><ins>+/**
+ * @group media
+ * @group gallery
+ */
+class WPTestGalleryPost extends WP_UnitTestCase { // _WPDataset1
</ins><span class="cx">         function setUp() {
</span><span class="cx">                 $this-&gt;knownUTBug(30);
</span><span class="cx">                 parent::setUp();
</span><span class="lines">@@ -280,54 +279,58 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+/**
+ * @group post
+ * @group formatting
+ */
+class WPTestAttributeFiltering extends WP_UnitTestCase {
+        function setUp() {
+                parent::setUp();
+                kses_init_filters();
+        }
</ins><span class="cx"> 
</span><ins>+        function tearDown() {
+                kses_remove_filters();
+                parent::tearDown();
+        }
</ins><span class="cx"> 
</span><del>-class WPTestAttributeFiltering extends _WPTestSinglePost {
-        function setUp() {
-                kses_init_filters();
</del><ins>+        function test_the_content_attribute_filtering() {
</ins><span class="cx">                 // http://bpr3.org/?p=87
</span><span class="cx">                 // the title attribute should make it through unfiltered
</span><del>-                $this-&gt;post_content =&lt;&lt;&lt;EOF
</del><ins>+                $post_content = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;span class=&quot;Z3988&quot; title=&quot;ctx_ver=Z39.88-2004&amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;rft.aulast=Mariat&amp;rft.aufirst=Denis&amp;rft. au=Denis+Mariat&amp;rft.au=Sead+Taourit&amp;rft.au=G%C3%A9rard+Gu%C3%A9rin&amp; rft.title=Genetics+Selection+Evolution&amp;rft.atitle=&amp;rft.date=2003&amp;rft. volume=35&amp;rft.issue=1&amp;rft.spage=119&amp;rft.epage=133&amp;rft.genre=article&amp; rft.id=info:DOI/10.1051%2Fgse%3A2002039&quot;&gt;&lt;/span&gt;Mariat, D., Taourit, S., Guérin, G. (2003). . &lt;span style=&quot;font-style: italic;&quot;&gt;Genetics Selection Evolution, 35&lt;/span&gt;(1), 119-133. DOI: &lt;a rev=&quot;review&quot; href= &quot;http://dx.doi.org/10.1051/gse:2002039&quot;&gt;10.1051/gse:2002039&lt;/a&gt;
</span><del>-
</del><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                parent::setUp();
-        }
-
-        function test_the_content() {
-                $this-&gt;_do_post();
-                $expected =&lt;&lt;&lt;EOF
</del><ins>+                $expected = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;p&gt;&lt;span class=&quot;Z3988&quot; title=&quot;ctx_ver=Z39.88-2004&amp;amp;rft_val_fmt=info%3Aofi%2Ffmt%3Akev%3Amtx%3Ajournal&amp;amp;rft.aulast=Mariat&amp;amp;rft.aufirst=Denis&amp;amp;rft. au=Denis+Mariat&amp;amp;rft.au=Sead+Taourit&amp;amp;rft.au=G%C3%A9rard+Gu%C3%A9rin&amp;amp; rft.title=Genetics+Selection+Evolution&amp;amp;rft.atitle=&amp;amp;rft.date=2003&amp;amp;rft. volume=35&amp;amp;rft.issue=1&amp;amp;rft.spage=119&amp;amp;rft.epage=133&amp;amp;rft.genre=article&amp;amp; rft.id=info:DOI/10.1051%2Fgse%3A2002039&quot;&gt;&lt;/span&gt;Mariat, D., Taourit, S., Guérin, G. (2003). . &lt;span style=&quot;font-style: italic&quot;&gt;Genetics Selection Evolution, 35&lt;/span&gt;(1), 119-133. DOI: &lt;a rev=&quot;review&quot; href=&quot;http://dx.doi.org/10.1051/gse:2002039&quot;&gt;10.1051/gse:2002039&lt;/a&gt;&lt;/p&gt;
</span><del>-
</del><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
</del><ins>+                $post_id = $this-&gt;factory-&gt;post-&gt;create( compact( 'post_content' ) );
+                $this-&gt;go_to( get_permalink( $post_id ) );
+                $this-&gt;assertTrue( is_single() );
+                $this-&gt;assertTrue( have_posts() );
+                $this-&gt;assertNull( the_post() );
+
+                $this-&gt;assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
</ins><span class="cx">         }
</span><del>-}
</del><span class="cx"> 
</span><del>-class WPTestAttributeColon extends _WPTestSinglePost {
-        function setUp() {
-
</del><ins>+        function test_the_content_attribute_value_with_colon() {
</ins><span class="cx">                 // http://bpr3.org/?p=87
</span><span class="cx">                 // the title attribute should make it through unfiltered
</span><del>-                $this-&gt;post_content =&lt;&lt;&lt;EOF
</del><ins>+                $post_content = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;span title=&quot;My friends: Alice, Bob and Carol&quot;&gt;foo&lt;/span&gt;
</span><del>-
</del><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                parent::setUp();
-        }
-
-        function test_the_content() {
-                $this-&gt;_do_post();
-                $expected =&lt;&lt;&lt;EOF
</del><ins>+                $expected = &lt;&lt;&lt;EOF
</ins><span class="cx"> &lt;p&gt;&lt;span title=&quot;My friends: Alice, Bob and Carol&quot;&gt;foo&lt;/span&gt;&lt;/p&gt;
</span><del>-
</del><span class="cx"> EOF;
</span><span class="cx"> 
</span><del>-                $this-&gt;assertEquals(strip_ws($expected), strip_ws(get_echo('the_content')));
</del><ins>+                $post_id = $this-&gt;factory-&gt;post-&gt;create( compact( 'post_content' ) );
+                $this-&gt;go_to( get_permalink( $post_id ) );
+                $this-&gt;assertTrue( is_single() );
+                $this-&gt;assertTrue( have_posts() );
+                $this-&gt;assertNull( the_post() );
+
+                $this-&gt;assertEquals( strip_ws( $expected ), strip_ws( get_echo( 'the_content' ) ) );
</ins><span class="cx">         }
</span><span class="cx"> }
</span><del>-
-?&gt;
</del></span></pre>
</div>
</div>

</body>
</html>