<!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>[Tests][1071] trunk/tests: this completes the initial set of slash 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><a href="http://unit-tests.trac.wordpress.org/changeset/1071">1071</a></dd>
<dt>Author</dt> <dd>alexkingorg</dd>
<dt>Date</dt> <dd>2012-10-04 05:02:37 +0000 (Thu, 04 Oct 2012)</dd>
</dl>

<h3>Log Message</h3>
<pre>this completes the initial set of slash tests</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunktestsmetaslashesphp">trunk/tests/meta/slashes.php</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>trunk/tests/attachment/</li>
<li><a href="#trunktestsattachmentslashesphp">trunk/tests/attachment/slashes.php</a></li>
<li><a href="#trunktestsoptionslashesphp">trunk/tests/option/slashes.php</a></li>
<li>trunk/tests/term/</li>
<li><a href="#trunkteststermslashesphp">trunk/tests/term/slashes.php</a></li>
<li><a href="#trunktestsuserslashesphp">trunk/tests/user/slashes.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsattachmentslashesphp"></a>
<div class="addfile"><h4>Added: trunk/tests/attachment/slashes.php (0 => 1071)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/attachment/slashes.php                                (rev 0)
+++ trunk/tests/attachment/slashes.php        2012-10-04 05:02:37 UTC (rev 1071)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+&lt;?php
+
+/**
+ * @group attachment
+ * @group slashes
+ * @ticket 21767
+ */
+class Tests_Attachment_Slashes extends WP_UnitTestCase {
+        function setUp() {
+                parent::setUp();
+                $this-&gt;author_id = $this-&gt;factory-&gt;user-&gt;create( array( 'role' =&gt; 'editor' ) );
+                $this-&gt;old_current_user = get_current_user_id();
+                wp_set_current_user( $this-&gt;author_id );
+                
+                // it is important to test with both even and odd numbered slashes as
+                // kses does a strip-then-add slashes in some of it's function calls
+                $this-&gt;slash_1 = 'String with 1 slash \\';
+                $this-&gt;slash_2 = 'String with 2 slashes \\\\';
+                $this-&gt;slash_3 = 'String with 3 slashes \\\\\\';
+                $this-&gt;slash_4 = 'String with 4 slashes \\\\\\\\';
+                $this-&gt;slash_5 = 'String with 5 slashes \\\\\\\\\\';
+                $this-&gt;slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
+                $this-&gt;slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+        }
+
+        function tearDown() {
+                wp_set_current_user( $this-&gt;old_current_user );
+                parent::tearDown();
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_wp_insert_attachment() {
+                $id = wp_insert_attachment(array(
+                        'post_status' =&gt; 'publish',
+                        'post_title' =&gt; $this-&gt;slash_1,
+                        'post_content_filtered' =&gt; $this-&gt;slash_3,
+                        'post_excerpt' =&gt; $this-&gt;slash_5,
+                        'post_type' =&gt; 'post'
+                ));
+                $post = get_post( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, $post-&gt;post_title );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $post-&gt;post_content_filtered );
+                $this-&gt;assertEquals( $this-&gt;slash_5, $post-&gt;post_excerpt );
+
+                $id = wp_insert_attachment(array(
+                        'post_status' =&gt; 'publish',
+                        'post_title' =&gt; $this-&gt;slash_2,
+                        'post_content_filtered' =&gt; $this-&gt;slash_4,
+                        'post_excerpt' =&gt; $this-&gt;slash_6,
+                        'post_type' =&gt; 'post'
+                ));
+                $post = get_post( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, $post-&gt;post_title );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $post-&gt;post_content_filtered );
+                $this-&gt;assertEquals( $this-&gt;slash_6, $post-&gt;post_excerpt );
+        }
+
+}
</ins></span></pre></div>
<a id="trunktestsmetaslashesphp"></a>
<div class="modfile"><h4>Modified: trunk/tests/meta/slashes.php (1070 => 1071)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/meta/slashes.php        2012-10-03 12:21:47 UTC (rev 1070)
+++ trunk/tests/meta/slashes.php        2012-10-04 05:02:37 UTC (rev 1071)
</span><span class="lines">@@ -220,4 +220,56 @@
</span><span class="cx">                 $this-&gt;assertEquals( $this-&gt;slash_6, get_comment_meta( $id, 'slash_test_3', true ) );
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_add_user_meta() {
+                $id = $this-&gt;factory-&gt;user-&gt;create();
+
+                add_user_meta( $id, 'slash_test_1', $this-&gt;slash_1 );
+                add_user_meta( $id, 'slash_test_2', $this-&gt;slash_3 );
+                add_user_meta( $id, 'slash_test_3', $this-&gt;slash_5 );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, get_user_meta( $id, 'slash_test_1', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_3, get_user_meta( $id, 'slash_test_2', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_5, get_user_meta( $id, 'slash_test_3', true ) );
+
+                add_user_meta( $id, 'slash_test_4', $this-&gt;slash_2 );
+                add_user_meta( $id, 'slash_test_5', $this-&gt;slash_4 );
+                add_user_meta( $id, 'slash_test_6', $this-&gt;slash_6 );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, get_user_meta( $id, 'slash_test_4', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_4, get_user_meta( $id, 'slash_test_5', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_6, get_user_meta( $id, 'slash_test_6', true ) );
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_update_user_meta() {
+                $id = $this-&gt;factory-&gt;user-&gt;create();
+
+                add_user_meta( $id, 'slash_test_1', 'foo' );
+                add_user_meta( $id, 'slash_test_2', 'foo' );
+                add_user_meta( $id, 'slash_test_3', 'foo' );
+
+                update_user_meta( $id, 'slash_test_1', $this-&gt;slash_1 );
+                update_user_meta( $id, 'slash_test_2', $this-&gt;slash_3 );
+                update_user_meta( $id, 'slash_test_3', $this-&gt;slash_5 );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, get_user_meta( $id, 'slash_test_1', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_3, get_user_meta( $id, 'slash_test_2', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_5, get_user_meta( $id, 'slash_test_3', true ) );
+
+                update_user_meta( $id, 'slash_test_1', $this-&gt;slash_2 );
+                update_user_meta( $id, 'slash_test_2', $this-&gt;slash_4 );
+                update_user_meta( $id, 'slash_test_3', $this-&gt;slash_6 );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, get_user_meta( $id, 'slash_test_1', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_4, get_user_meta( $id, 'slash_test_2', true ) );
+                $this-&gt;assertEquals( $this-&gt;slash_6, get_user_meta( $id, 'slash_test_3', true ) );
+        }
+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunktestsoptionslashesphp"></a>
<div class="addfile"><h4>Added: trunk/tests/option/slashes.php (0 => 1071)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/option/slashes.php                                (rev 0)
+++ trunk/tests/option/slashes.php        2012-10-04 05:02:37 UTC (rev 1071)
</span><span class="lines">@@ -0,0 +1,57 @@
</span><ins>+&lt;?php
+
+/**
+ * @group option
+ * @group slashes
+ * @ticket 21767
+ */
+class Tests_Option_Slashes extends WP_UnitTestCase {
+        function setUp() {
+                parent::setUp();
+                // it is important to test with both even and odd numbered slashes as
+                // kses does a strip-then-add slashes in some of it's function calls
+                $this-&gt;slash_1 = 'String with 1 slash \\';
+                $this-&gt;slash_2 = 'String with 2 slashes \\\\';
+                $this-&gt;slash_3 = 'String with 3 slashes \\\\\\';
+                $this-&gt;slash_4 = 'String with 4 slashes \\\\\\\\';
+                $this-&gt;slash_5 = 'String with 5 slashes \\\\\\\\\\';
+                $this-&gt;slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
+                $this-&gt;slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_add_option() {
+                add_option( 'slash_test_1', $this-&gt;slash_1 );
+                add_option( 'slash_test_2', $this-&gt;slash_2 );
+                add_option( 'slash_test_3', $this-&gt;slash_3 );
+                add_option( 'slash_test_4', $this-&gt;slash_4 );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, get_option( 'slash_test_1' ) );
+                $this-&gt;assertEquals( $this-&gt;slash_2, get_option( 'slash_test_2' ) );
+                $this-&gt;assertEquals( $this-&gt;slash_3, get_option( 'slash_test_3' ) );
+                $this-&gt;assertEquals( $this-&gt;slash_4, get_option( 'slash_test_4' ) );
+        }
+        
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_update_option() {
+                add_option( 'slash_test_5', 'foo' );
+                
+                update_option( 'slash_test_5', $this-&gt;slash_1 );
+                $this-&gt;assertEquals( $this-&gt;slash_1, get_option( 'slash_test_5' ) );
+
+                update_option( 'slash_test_5', $this-&gt;slash_2 );
+                $this-&gt;assertEquals( $this-&gt;slash_2, get_option( 'slash_test_5' ) );
+
+                update_option( 'slash_test_5', $this-&gt;slash_3 );
+                $this-&gt;assertEquals( $this-&gt;slash_3, get_option( 'slash_test_5' ) );
+
+                update_option( 'slash_test_5', $this-&gt;slash_4 );
+                $this-&gt;assertEquals( $this-&gt;slash_4, get_option( 'slash_test_5' ) );
+        }
+}
</ins></span></pre></div>
<a id="trunkteststermslashesphp"></a>
<div class="addfile"><h4>Added: trunk/tests/term/slashes.php (0 => 1071)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/term/slashes.php                                (rev 0)
+++ trunk/tests/term/slashes.php        2012-10-04 05:02:37 UTC (rev 1071)
</span><span class="lines">@@ -0,0 +1,264 @@
</span><ins>+&lt;?php
+
+/**
+ * @group term
+ * @group slashes
+ * @ticket 21767
+ */
+class Tests_Term_Slashes extends WP_Ajax_UnitTestCase {
+        function setUp() {
+                parent::setUp();
+                $this-&gt;author_id = $this-&gt;factory-&gt;user-&gt;create( array( 'role' =&gt; 'administrator' ) );
+                $this-&gt;old_current_user = get_current_user_id();
+                wp_set_current_user( $this-&gt;author_id );
+
+                $this-&gt;slash_1 = 'String with 1 slash \\';
+                $this-&gt;slash_2 = 'String with 2 slashes \\\\';
+                $this-&gt;slash_3 = 'String with 3 slashes \\\\\\';
+                $this-&gt;slash_4 = 'String with 4 slashes \\\\\\\\';
+                $this-&gt;slash_5 = 'String with 5 slashes \\\\\\\\\\';
+                $this-&gt;slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
+                $this-&gt;slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+        }
+
+        function tearDown() {
+                wp_set_current_user( $this-&gt;old_current_user );
+                parent::tearDown();
+        }
+
+        /**
+         * Tests the controller function that expects slashed data
+         *
+         */
+        function test__wp_ajax_add_hierarchical_term() {
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST = array(
+                        '_ajax_nonce-add-category' =&gt; wp_create_nonce( 'add-category' ),
+                        'taxonomy' =&gt; 'category',
+                        'newcategory' =&gt; $this-&gt;slash_1
+                );
+                $_POST = add_magic_quotes( $_POST );
+                
+                // Make the request
+                try {
+                        $this-&gt;_handleAjax( 'add-category' );
+                } catch ( WPAjaxDieContinueException $e ) {
+                        unset( $e );
+                }
+                
+                $term = get_term_by( 'slug', 'string-with-1-slash', 'category' );
+                $this-&gt;assertEquals( $this-&gt;slash_1, $term-&gt;name );
+
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST = array(
+                        '_ajax_nonce-add-category' =&gt; wp_create_nonce( 'add-category' ),
+                        'taxonomy' =&gt; 'category',
+                        'newcategory' =&gt; $this-&gt;slash_3
+                );
+                $_POST = add_magic_quotes( $_POST );
+                
+                // Make the request
+                try {
+                        $this-&gt;_handleAjax( 'add-category' );
+                } catch ( WPAjaxDieContinueException $e ) {
+                        unset( $e );
+                }
+                
+                $term = get_term_by( 'slug', 'string-with-3-slashes', 'category' );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;name );
+
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST = array(
+                        '_ajax_nonce-add-category' =&gt; wp_create_nonce( 'add-category' ),
+                        'taxonomy' =&gt; 'category',
+                        'newcategory' =&gt; $this-&gt;slash_2
+                );
+                $_POST = add_magic_quotes( $_POST );
+                
+                // Make the request
+                try {
+                        $this-&gt;_handleAjax( 'add-category' );
+                } catch ( WPAjaxDieContinueException $e ) {
+                        unset( $e );
+                }
+                
+                $term = get_term_by( 'slug', 'string-with-2-slashes', 'category' );
+                $this-&gt;assertEquals( $this-&gt;slash_2, $term-&gt;name );
+
+        }
+        
+        /**
+         * Tests the controller function that expects slashed data
+         *
+         */
+        function test_wp_ajax_add_tag() {
+                $taxonomies = array(
+                        'category',
+                        'post_tag'
+                );
+                foreach ( $taxonomies as $taxonomy ) {
+                        $_POST = $_GET = $_REQUEST = array();
+                        
+                        $_POST = array(
+                                '_wpnonce_add-tag' =&gt; wp_create_nonce( 'add-tag' ),
+                                'taxonomy' =&gt; $taxonomy,
+                                'slug' =&gt; 'controller_slash_test_1_'.$taxonomy,
+                                'tag-name' =&gt; $this-&gt;slash_1,
+                                'description' =&gt; $this-&gt;slash_3
+                        );
+                        $_POST = add_magic_quotes( $_POST );
+                        
+                        // Make the request
+                        try {
+                                $this-&gt;_handleAjax( 'add-tag' );
+                        } catch ( WPAjaxDieContinueException $e ) {
+                                unset( $e );
+                        }
+                        
+                        $term = get_term_by( 'slug', 'controller_slash_test_1_'.$taxonomy, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_1, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;description );
+
+                        $_POST = array(
+                                '_wpnonce_add-tag' =&gt; wp_create_nonce( 'add-tag' ),
+                                'taxonomy' =&gt; $taxonomy,
+                                'slug' =&gt; 'controller_slash_test_2_'.$taxonomy,
+                                'tag-name' =&gt; $this-&gt;slash_3,
+                                'description' =&gt; $this-&gt;slash_5
+                        );
+                        $_POST = add_magic_quotes( $_POST );
+                        
+                        // Make the request
+                        try {
+                                $this-&gt;_handleAjax( 'add-tag' );
+                        } catch ( WPAjaxDieContinueException $e ) {
+                                unset( $e );
+                        }
+                        
+                        $term = get_term_by( 'slug', 'controller_slash_test_2_'.$taxonomy, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_5, $term-&gt;description );
+
+                        $_POST = array(
+                                '_wpnonce_add-tag' =&gt; wp_create_nonce( 'add-tag' ),
+                                'taxonomy' =&gt; $taxonomy,
+                                'slug' =&gt; 'controller_slash_test_3_'.$taxonomy,
+                                'tag-name' =&gt; $this-&gt;slash_2,
+                                'description' =&gt; $this-&gt;slash_4
+                        );
+                        $_POST = add_magic_quotes( $_POST );
+                        
+                        // Make the request
+                        try {
+                                $this-&gt;_handleAjax( 'add-tag' );
+                        } catch ( WPAjaxDieContinueException $e ) {
+                                unset( $e );
+                        }
+                        
+                        $term = get_term_by( 'slug', 'controller_slash_test_3_'.$taxonomy, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_2, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_4, $term-&gt;description );
+                }
+        }
+        
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_wp_insert_term() {
+                $taxonomies = array(
+                        'category',
+                        'post_tag'
+                );
+                foreach ( $taxonomies as $taxonomy ) {
+                        $insert = wp_insert_term(
+                                $this-&gt;slash_1,
+                                $taxonomy,
+                                array(
+                                        'slug' =&gt; 'slash_test_1_'.$taxonomy,
+                                        'description' =&gt; $this-&gt;slash_3
+                                )
+                        );
+                        $term = get_term( $insert['term_id'], $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_1, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;description );
+        
+                        $insert = wp_insert_term(
+                                $this-&gt;slash_3,
+                                $taxonomy,
+                                array(
+                                        'slug' =&gt; 'slash_test_2_'.$taxonomy,
+                                        'description' =&gt; $this-&gt;slash_5
+                                )
+                        );
+                        $term = get_term( $insert['term_id'], $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_5, $term-&gt;description );
+        
+                        $insert = wp_insert_term(
+                                $this-&gt;slash_2,
+                                $taxonomy,
+                                array(
+                                        'slug' =&gt; 'slash_test_3_'.$taxonomy,
+                                        'description' =&gt; $this-&gt;slash_4
+                                )
+                        );
+                        $term = get_term( $insert['term_id'], $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_2, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_4, $term-&gt;description );
+                }
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_wp_update_term() {
+                $taxonomies = array(
+                        'category',
+                        'post_tag'
+                );
+                foreach ( $taxonomies as $taxonomy ) {
+                        $id = $this-&gt;factory-&gt;term-&gt;create(array(
+                                'taxonomy' =&gt; $taxonomy
+                        ));
+        
+                        $update = wp_update_term(
+                                $id,
+                                $taxonomy,
+                                array(
+                                        'name' =&gt; $this-&gt;slash_1,
+                                        'description' =&gt; $this-&gt;slash_3
+                                )
+                        );
+
+                        $term = get_term( $id, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_1, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;description );
+        
+                        $update = wp_update_term(
+                                $id,
+                                $taxonomy,
+                                array(
+                                        'name' =&gt; $this-&gt;slash_3,
+                                        'description' =&gt; $this-&gt;slash_5
+                                )
+                        );
+                        $term = get_term( $id, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_3, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_5, $term-&gt;description );
+        
+                        $update = wp_update_term(
+                                $id,
+                                $taxonomy,
+                                array(
+                                        'name' =&gt; $this-&gt;slash_2,
+                                        'description' =&gt; $this-&gt;slash_4
+                                )
+                        );
+                        $term = get_term( $id, $taxonomy );
+                        $this-&gt;assertEquals( $this-&gt;slash_2, $term-&gt;name );
+                        $this-&gt;assertEquals( $this-&gt;slash_4, $term-&gt;description );
+                }
+        }
+}
</ins></span></pre></div>
<a id="trunktestsuserslashesphp"></a>
<div class="addfile"><h4>Added: trunk/tests/user/slashes.php (0 => 1071)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/tests/user/slashes.php                                (rev 0)
+++ trunk/tests/user/slashes.php        2012-10-04 05:02:37 UTC (rev 1071)
</span><span class="lines">@@ -0,0 +1,210 @@
</span><ins>+&lt;?php
+
+/**
+ * @group user
+ * @group slashes
+ * @ticket 21767
+ */
+class Tests_User_Slashes extends WP_UnitTestCase {
+        function setUp() {
+                parent::setUp();
+                $this-&gt;author_id = $this-&gt;factory-&gt;user-&gt;create( array( 'role' =&gt; 'administrator' ) );
+                $this-&gt;old_current_user = get_current_user_id();
+                wp_set_current_user( $this-&gt;author_id );
+                
+                // it is important to test with both even and odd numbered slashes as
+                // kses does a strip-then-add slashes in some of it's function calls
+                $this-&gt;slash_1 = 'String with 1 slash \\';
+                $this-&gt;slash_2 = 'String with 2 slashes \\\\';
+                $this-&gt;slash_3 = 'String with 3 slashes \\\\\\';
+                $this-&gt;slash_4 = 'String with 4 slashes \\\\\\\\';
+                $this-&gt;slash_5 = 'String with 5 slashes \\\\\\\\\\';
+                $this-&gt;slash_6 = 'String with 6 slashes \\\\\\\\\\\\';
+                $this-&gt;slash_7 = 'String with 7 slashes \\\\\\\\\\\\\\';
+        }
+
+        function tearDown() {
+                wp_set_current_user( $this-&gt;old_current_user );
+                parent::tearDown();
+        }
+
+        /**
+         * Tests the controller function that expects slashed data
+         *
+         */
+        function test_add_user() {
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST['user_login'] = 'slash_example_user_1';
+                $_POST['pass1'] = 'password';
+                $_POST['pass2'] = 'password';
+                $_POST['role'] = 'subscriber';
+                $_POST['email'] = 'user1@example.com';
+                $_POST['first_name'] = $this-&gt;slash_1;
+                $_POST['last_name'] = $this-&gt;slash_3;
+                $_POST['nickname'] = $this-&gt;slash_5;
+                $_POST['display_name'] = $this-&gt;slash_7;
+                $_POST['description'] = $this-&gt;slash_3;
+                $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
+
+                $id = add_user();
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_5, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_7, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;description );
+
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST['user_login'] = 'slash_example_user_2';
+                $_POST['pass1'] = 'password';
+                $_POST['pass2'] = 'password';
+                $_POST['role'] = 'subscriber';
+                $_POST['email'] = 'user2@example.com';
+                $_POST['first_name'] = $this-&gt;slash_2;
+                $_POST['last_name'] = $this-&gt;slash_4;
+                $_POST['nickname'] = $this-&gt;slash_6;
+                $_POST['display_name'] = $this-&gt;slash_2;
+                $_POST['description'] = $this-&gt;slash_4;
+                $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
+
+                $id = add_user();
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_6, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;description );
+        }
+
+        /**
+         * Tests the controller function that expects slashed data
+         *
+         */
+        function test_edit_user() {
+                $id = $this-&gt;factory-&gt;user-&gt;create();
+
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST['role'] = 'subscriber';
+                $_POST['email'] = 'user1@example.com';
+                $_POST['first_name'] = $this-&gt;slash_1;
+                $_POST['last_name'] = $this-&gt;slash_3;
+                $_POST['nickname'] = $this-&gt;slash_5;
+                $_POST['display_name'] = $this-&gt;slash_7;
+                $_POST['description'] = $this-&gt;slash_3;
+                $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
+
+                $id = edit_user( $id );
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_5, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_7, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;description );
+
+                $_POST = $_GET = $_REQUEST = array();
+                $_POST['role'] = 'subscriber';
+                $_POST['email'] = 'user2@example.com';
+                $_POST['first_name'] = $this-&gt;slash_2;
+                $_POST['last_name'] = $this-&gt;slash_4;
+                $_POST['nickname'] = $this-&gt;slash_6;
+                $_POST['display_name'] = $this-&gt;slash_2;
+                $_POST['description'] = $this-&gt;slash_4;
+                $_POST = add_magic_quotes( $_POST ); // the edit_post() function will strip slashes
+
+                $id = edit_user( $id );
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_6, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;description );
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_wp_insert_user() {
+                $id = wp_insert_user(array(
+                        'user_login' =&gt; 'slash_example_user_3',
+                        'role' =&gt; 'subscriber',
+                        'email' =&gt; 'user3@example.com',
+                        'first_name' =&gt; $this-&gt;slash_1,
+                        'last_name' =&gt; $this-&gt;slash_3,
+                        'nickname' =&gt; $this-&gt;slash_5,
+                        'display_name' =&gt; $this-&gt;slash_7,
+                        'description' =&gt; $this-&gt;slash_3,
+                ));
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_5, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_7, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;description );
+
+                $id = wp_insert_user(array(
+                        'user_login' =&gt; 'slash_example_user_4',
+                        'role' =&gt; 'subscriber',
+                        'email' =&gt; 'user3@example.com',
+                        'first_name' =&gt; $this-&gt;slash_2,
+                        'last_name' =&gt; $this-&gt;slash_4,
+                        'nickname' =&gt; $this-&gt;slash_6,
+                        'display_name' =&gt; $this-&gt;slash_2,
+                        'description' =&gt; $this-&gt;slash_4,
+                ));
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_6, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;description );
+        }
+
+        /**
+         * Tests the model function that expects un-slashed data
+         *
+         */
+        function test_wp_update_user() {
+                $id = $this-&gt;factory-&gt;user-&gt;create();
+                $id = wp_update_user(array(
+                        'ID' =&gt; $id,
+                        'role' =&gt; 'subscriber',
+                        'first_name' =&gt; $this-&gt;slash_1,
+                        'last_name' =&gt; $this-&gt;slash_3,
+                        'nickname' =&gt; $this-&gt;slash_5,
+                        'display_name' =&gt; $this-&gt;slash_7,
+                        'description' =&gt; $this-&gt;slash_3,
+                ));
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_1, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_5, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_7, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_3, $user-&gt;description );
+
+                $id = wp_update_user(array(
+                        'ID' =&gt; $id,
+                        'role' =&gt; 'subscriber',
+                        'first_name' =&gt; $this-&gt;slash_2,
+                        'last_name' =&gt; $this-&gt;slash_4,
+                        'nickname' =&gt; $this-&gt;slash_6,
+                        'display_name' =&gt; $this-&gt;slash_2,
+                        'description' =&gt; $this-&gt;slash_4,
+                ));
+                $user = get_user_to_edit( $id );
+
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;first_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;last_name );
+                $this-&gt;assertEquals( $this-&gt;slash_6, $user-&gt;nickname );
+                $this-&gt;assertEquals( $this-&gt;slash_2, $user-&gt;display_name );
+                $this-&gt;assertEquals( $this-&gt;slash_4, $user-&gt;description );
+        }
+
+}
</ins><span class="cx">\ No newline at end of file
</span></span></pre>
</div>
</div>

</body>
</html>