<!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>[371] wp-testcase/test_shortcode.php: shortcode_unautop() tests</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>371</dd>
<dt>Author</dt> <dd>aaroncampbell</dd>
<dt>Date</dt> <dd>2011-06-06 22:27:53 +0000 (Mon, 06 Jun 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>shortcode_unautop() tests</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#wptestcasetest_shortcodephp">wp-testcase/test_shortcode.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="wptestcasetest_shortcodephp"></a>
<div class="modfile"><h4>Modified: wp-testcase/test_shortcode.php (370 => 371)</h4>
<pre class="diff"><span>
<span class="info">--- wp-testcase/test_shortcode.php        2011-06-05 07:37:01 UTC (rev 370)
+++ wp-testcase/test_shortcode.php        2011-06-06 22:27:53 UTC (rev 371)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx">                 'foo' =&gt; 'no foo',
</span><span class="cx">                 'baz' =&gt; 'default baz',
</span><span class="cx">         ), $atts));
</span><del>-        
</del><ins>+
</ins><span class="cx">         return &quot;foo = {$foo}&quot;;
</span><span class="cx"> }
</span><span class="cx"> add_shortcode('bartag', 'bartag_func');
</span><span class="lines">@@ -50,52 +50,52 @@
</span><span class="cx">                 $this-&gt;atts = null;
</span><span class="cx">                 $this-&gt;content = null;
</span><span class="cx">                 $this-&gt;tagname = null;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function _shortcode_tag($atts, $content=NULL, $tagname=NULL) {
</span><span class="cx">                 $this-&gt;atts = $atts;
</span><span class="cx">                 $this-&gt;content = $content;
</span><span class="cx">                 $this-&gt;tagname = $tagname;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_noatts() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag /]');
</span><span class="cx">                 $this-&gt;assertEquals( '', $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( 'test-shortcode-tag', $this-&gt;tagname );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_one_att() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag foo=&quot;asdf&quot; /]');
</span><span class="cx">                 $this-&gt;assertEquals( array('foo' =&gt; 'asdf'), $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( 'test-shortcode-tag', $this-&gt;tagname );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_not_a_tag() {
</span><span class="cx">                 $out = do_shortcode('[not-a-shortcode-tag]');
</span><span class="cx">                 $this-&gt;assertEquals( '[not-a-shortcode-tag]', $out );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_two_atts() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag foo=&quot;asdf&quot; bar=&quot;bing&quot; /]');
</span><span class="cx">                 $this-&gt;assertEquals( array('foo' =&gt; 'asdf', 'bar' =&gt; 'bing'), $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( 'test-shortcode-tag', $this-&gt;tagname );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_noatts_enclosing() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag]content[/test-shortcode-tag]');
</span><span class="cx">                 $this-&gt;assertEquals( '', $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( 'content', $this-&gt;content );
</span><span class="cx">                 $this-&gt;assertEquals( 'test-shortcode-tag', $this-&gt;tagname );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_one_att_enclosing() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag foo=&quot;bar&quot;]content[/test-shortcode-tag]');
</span><span class="cx">                 $this-&gt;assertEquals( array('foo' =&gt; 'bar'), $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( 'content', $this-&gt;content );
</span><span class="cx">                 $this-&gt;assertEquals( 'test-shortcode-tag', $this-&gt;tagname );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_two_atts_enclosing() {
</span><span class="cx">                 do_shortcode('[test-shortcode-tag foo=&quot;bar&quot; baz=&quot;bing&quot;]content[/test-shortcode-tag]');
</span><span class="cx">                 $this-&gt;assertEquals( array('foo' =&gt; 'bar', 'baz' =&gt; 'bing'), $this-&gt;atts );
</span><span class="lines">@@ -149,13 +149,13 @@
</span><span class="cx">                 $out = do_shortcode('[footag]');
</span><span class="cx">                 $this-&gt;assertEquals('foo = ', $out);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_footag_val() {
</span><span class="cx">                 $val = rand_str();
</span><span class="cx">                 $out = do_shortcode('[footag foo=&quot;'.$val.'&quot;]');
</span><span class="cx">                 $this-&gt;assertEquals('foo = '.$val, $out);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_nested_tags() {
</span><span class="cx">                 $out = do_shortcode('[baztag][dumptag abc=&quot;foo&quot; def=123 http://wordpress.com/][/baztag]');
</span><span class="cx">                 $expected = &lt;&lt;&lt;EOF
</span><span class="lines">@@ -166,24 +166,24 @@
</span><span class="cx"> EOF;
</span><span class="cx">                 $this-&gt;assertEquals($expected, $out);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_tag_escaped() {
</span><span class="cx">                 $this-&gt;knownWPBug(6518);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 $out = do_shortcode('[[footag]] [[bartag foo=&quot;bar&quot;]]');
</span><span class="cx">                 $this-&gt;assertEquals('[footag] [bartag foo=&quot;bar&quot;]', $out);
</span><span class="cx"> 
</span><span class="cx">                 $out = do_shortcode('[[footag /]] [[bartag foo=&quot;bar&quot; /]]');
</span><span class="cx">                 $this-&gt;assertEquals('[footag /] [bartag foo=&quot;bar&quot; /]', $out);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 $out = do_shortcode('[[baztag foo=&quot;bar&quot;]the content[/baztag]]');
</span><span class="cx">                 $this-&gt;assertEquals('[baztag foo=&quot;bar&quot;]the content[/baztag]', $out);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 // double escaped
</span><span class="cx">                 $out = do_shortcode('[[[footag]]] [[[bartag foo=&quot;bar&quot;]]]');
</span><span class="cx">                 $this-&gt;assertEquals('[[footag]] [[bartag foo=&quot;bar&quot;]]', $out);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_tag_not_escaped() {
</span><span class="cx">                 // these have square brackets on either end but aren't actually escaped
</span><span class="cx">                 $out = do_shortcode('[[footag] [bartag foo=&quot;bar&quot;]]');
</span><span class="lines">@@ -194,14 +194,14 @@
</span><span class="cx"> 
</span><span class="cx">                 $out = do_shortcode('[[baztag foo=&quot;bar&quot;]the content[/baztag]');
</span><span class="cx">                 $this-&gt;assertEquals('[content = the content', $out);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 $out = do_shortcode('[[not-a-tag]]');
</span><span class="cx">                 $this-&gt;assertEquals('[[not-a-tag]]', $out);
</span><span class="cx"> 
</span><span class="cx">                 $out = do_shortcode('[[[footag] [bartag foo=&quot;bar&quot;]]]');
</span><span class="cx">                 $this-&gt;assertEquals('[[foo =  foo = bar]]', $out);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_mixed_tags() {
</span><span class="cx">                 $in = &lt;&lt;&lt;EOF
</span><span class="cx"> So this is a post with [footag foo=&quot;some stuff&quot;] and a bunch of tags.
</span><span class="lines">@@ -225,7 +225,7 @@
</span><span class="cx"> 
</span><span class="cx"> foo = no foo
</span><span class="cx"> 
</span><del>-content = 
</del><ins>+content =
</ins><span class="cx"> Here's some content
</span><span class="cx"> on more than one line
</span><span class="cx"> 
</span><span class="lines">@@ -238,7 +238,7 @@
</span><span class="cx">                 $out = do_shortcode($in);
</span><span class="cx">                 $this-&gt;assertEquals(strip_ws($expected), strip_ws($out));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         //TODO Review this test as it may be incorrect
</span><span class="cx">         function test_utf8_whitespace_1() {
</span><span class="cx">                 // see http://trac.wordpress.org/ticket/6562
</span><span class="lines">@@ -256,7 +256,7 @@
</span><span class="cx">                 $this-&gt;assertEquals( array('foo' =&gt; 'bar', 'abc' =&gt; 'def'), $this-&gt;atts );
</span><span class="cx">                 $this-&gt;assertEquals( '', $this-&gt;content );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> /*
</span><span class="cx"> enabled = the shortcode works as normal (default)
</span><span class="cx"> strip = the shortcode will be parsed and removed.  e.g. '[shortcode foo=&quot;bar&quot;]' produces ''.  '[shortcode]foo[/shortcode]' produces 'foo'.
</span><span class="lines">@@ -272,7 +272,7 @@
</span><span class="cx">                 $expected = 'content = foo is foo = bar';
</span><span class="cx">                 $this-&gt;assertEquals( $expected, $out );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_shortcodes_disabled() {
</span><span class="cx">                 if ( !is_callable('set_all_shortcode_status') )
</span><span class="cx">                         $this-&gt;markTestSkipped();
</span><span class="lines">@@ -281,7 +281,7 @@
</span><span class="cx">                 $expected = $out;
</span><span class="cx">                 $this-&gt;assertEquals( $expected, $out );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_shortcodes_strip() {
</span><span class="cx">                 if ( !is_callable('set_all_shortcode_status') )
</span><span class="cx">                         $this-&gt;markTestSkipped();
</span><span class="lines">@@ -290,7 +290,7 @@
</span><span class="cx">                 $expected = 'foo is ';
</span><span class="cx">                 $this-&gt;assertEquals( $expected, $out );
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         function test_shortcodes_faux() {
</span><span class="cx">                 if ( !is_callable('set_all_shortcode_status') )
</span><span class="cx">                         $this-&gt;markTestSkipped();
</span><span class="lines">@@ -300,6 +300,28 @@
</span><span class="cx">                 $this-&gt;assertEquals( $expected, $out );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        function test_shortcode_unautop() {
+                // a blank line is added at the end, so test with it already there
+                $test_string = &lt;&lt;&lt;EOF
+[footag]
+
+EOF;
+
+                $this-&gt;assertEquals( $test_string, shortcode_unautop( wpautop( $test_string ) ) );
+        }
+
+        function test_multiple_shortcode_unautop() {
+                // a blank line is added at the end, so test with it already there
+                $test_string = &lt;&lt;&lt;EOF
+[footag]
+[footag]
+
+EOF;
+
+                $actual = shortcode_unautop( wpautop( $test_string ) );
+                $this-&gt;assertEquals( $test_string, $actual );
+        }
+
</ins><span class="cx"> }
</span><span class="cx"> //http://core.trac.wordpress.org/ticket/10326
</span><span class="cx"> class TestShortcodeStripping extends WPTestCase {
</span><span class="lines">@@ -310,4 +332,4 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>