<!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>[42255] trunk/tests/phpunit/tests/general: General: Add complete test coverage for `WP_Error`.</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42255">42255</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42255","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>DrewAPicture</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-11-29 02:18:25 +0000 (Wed, 29 Nov 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>General: Add complete test coverage for `WP_Error`.

See <a href="https://core.trac.wordpress.org/ticket/42742">#42742</a>.</pre>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsgeneralwpErrorphp">trunk/tests/phpunit/tests/general/wpError.php</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunktestsphpunittestsgeneralerrorsphp">trunk/tests/phpunit/tests/general/errors.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunktestsphpunittestsgeneralerrorsphp"></a>
<div class="delfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Deleted: trunk/tests/phpunit/tests/general/errors.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/errors.php      2017-11-28 18:11:15 UTC (rev 42254)
+++ trunk/tests/phpunit/tests/general/errors.php        2017-11-29 02:18:25 UTC (rev 42255)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,63 +0,0 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-<?php
-/**
- * Tests for error handling and the WP_Error class.
- *
- * @group general
- */
-class Tests_General_Errors extends WP_UnitTestCase {
-
-       function test_create_error() {
-               $error = new WP_Error( 'foo', 'message', 'data' );
-
-               $this->assertWPError( $error );
-               $this->assertEquals( 'foo', $error->get_error_code() );
-               $this->assertEquals( 'message', $error->get_error_message() );
-               $this->assertEquals( 'data', $error->get_error_data() );
-       }
-
-       function test_add_error() {
-               $error = new WP_Error();
-               $error->add( 'foo', 'message', 'data' );
-
-               $this->assertWPError( $error );
-               $this->assertEquals( 'foo', $error->get_error_code() );
-               $this->assertEquals( 'message', $error->get_error_message() );
-               $this->assertEquals( 'data', $error->get_error_data() );
-       }
-
-       function test_multiple_errors() {
-               $error = new WP_Error();
-               $error->add( 'foo', 'foo message', 'foo data' );
-               $error->add( 'bar', 'bar message', 'bar data' );
-
-               $this->assertWPError( $error );
-               $this->assertEquals( 'foo', $error->get_error_code() );
-               $this->assertEquals( 'foo message', $error->get_error_message() );
-               $this->assertEquals( 'foo data', $error->get_error_data() );
-
-               $this->assertEquals( array( 'foo', 'bar' ), $error->get_error_codes() );
-               $this->assertEquals( array( 'foo message', 'bar message' ), $error->get_error_messages() );
-               $this->assertEquals( 'foo data', $error->get_error_data( 'foo' ) );
-               $this->assertEquals( 'bar data', $error->get_error_data( 'bar' ) );
-       }
-
-       /**
-        * @ticket 28092
-        */
-       function test_remove_error() {
-               $error = new WP_Error();
-               $error->add( 'foo', 'This is the first error message', 'some error data' );
-               $error->add( 'foo', 'This is the second error message' );
-               $error->add( 'bar', 'This is another error' );
-
-               $error->remove( 'foo' );
-
-               // Check the error has been removed.
-               $this->assertEmpty( $error->get_error_data( 'foo' ) );
-               $this->assertEmpty( $error->get_error_messages( 'foo' ) );
-               
-               // The 'bar' error should now be the 'first' error retrieved.
-               $this->assertEquals( 'bar', $error->get_error_code() );
-               $this->assertEmpty( $error->get_error_data() );
-       }
-}
</del></span></pre></div>
<a id="trunktestsphpunittestsgeneralwpErrorphpfromrev42254trunktestsphpunittestsgeneralerrorsphp"></a>
<div class="copfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Copied: trunk/tests/phpunit/tests/general/wpError.php (from rev 42254, trunk/tests/phpunit/tests/general/errors.php)</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/general/wpError.php                             (rev 0)
+++ trunk/tests/phpunit/tests/general/wpError.php       2017-11-29 02:18:25 UTC (rev 42255)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -0,0 +1,746 @@
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+<?php
+/**
+ * Tests for error handling and the WP_Error class.
+ *
+ * @group general
+ * @group errors
+ */
+class Tests_WP_Error extends WP_UnitTestCase {
+
+       /**
+        * WP_Error fixture.
+        *
+        * @var WP_Error
+        */
+       public $WP_Error;
+
+       /**
+        * Set up.
+        */
+       public function setUp() {
+               parent::setUp();
+
+               $this->WP_Error = new WP_Error();
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_should_be_of_type_WP_Error() {
+               $this->assertWPError( $this->WP_Error );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_default_empty_parameters_should_add_no_errors() {
+               $this->assertEmpty( $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_empty_code_should_add_no_code() {
+               $this->assertSame( '', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_empty_code_should_add_no_message() {
+               $this->assertSame( '', $this->WP_Error->get_error_message() );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_empty_code_should_add_no_error_data() {
+               $this->assertEmpty( $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_empty_message_should_add_error_with_that_code() {
+               $wp_error = new WP_Error( 'code' );
+
+               $this->assertSame( 'code', $wp_error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_empty_message_should_add_error_with_that_code_and_empty_message() {
+               $wp_error = new WP_Error( 'code' );
+
+               $this->assertSame( '', $wp_error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_empty_message_and_empty_data_should_add_error_but_not_associated_data() {
+               $wp_error = new WP_Error( 'code' );
+
+               $this->assertSame( null, $wp_error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_empty_message_and_non_empty_data_should_add_error_with_empty_message_and_that_stored_data() {
+               $wp_error = new WP_Error( 'code', '', 'data' );
+
+               $this->assertSame( 'data', $wp_error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_message_should_add_error_with_that_code() {
+               $wp_error = new WP_Error( 'code', 'message' );
+
+               $this->assertSame( 'code', $wp_error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_message_should_add_error_with_that_message() {
+               $wp_error = new WP_Error( 'code', 'message' );
+
+               $this->assertSame( 'message', $wp_error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_code() {
+               $wp_error = new WP_Error( 'code', 'message', 'data' );
+
+               $this->assertSame( 'code', $wp_error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_message() {
+               $wp_error = new WP_Error( 'code', 'message', 'data' );
+
+               $this->assertSame( 'message', $wp_error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error
+        */
+       public function test_WP_Error_with_code_and_message_and_data_should_add_error_with_that_data() {
+               $wp_error = new WP_Error( 'code', 'message', 'data' );
+
+               $this->assertSame( 'data', $wp_error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_codes()
+        */
+       public function test_get_error_codes_with_no_errors_should_return_empty_array() {
+               $this->assertEmpty( $this->WP_Error->get_error_codes() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_codes()
+        */
+       public function test_get_error_codes_with_one_error_should_return_an_array_with_only_that_code() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertEqualSets( array( 'code' ), $this->WP_Error->get_error_codes() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_codes()
+        */
+       public function test_get_error_codes_with_nultiple_errors_should_return_an_array_of_those_codes() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $expected = array( 'code', 'code2' );
+
+               $this->assertEqualSets( $expected, $this->WP_Error->get_error_codes() );
+       }
+
+       /**
+        * @covers WP_Error:get_error_code()
+        */
+       public function test_get_error_code_with_no_errors_should_return_an_empty_string() {
+               $this->assertSame( '', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error:get_error_code()
+        */
+       public function test_get_error_code_with_one_error_should_return_that_error_code() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( 'code', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error:get_error_code()
+        */
+       public function test_get_error_code_with_multiple_errors_should_return_only_the_first_error_code() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->assertSame( 'code', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_empty_code_and_no_errors_should_return_an_empty_array() {
+               $this->assertEmpty( $this->WP_Error->get_error_messages() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_empty_code_one_error_should_return_an_array_with_that_message() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertEqualSets( array( 'message' ), $this->WP_Error->get_error_messages() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_empty_code_multiple_errors_should_return_an_array_of_messages() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->assertEqualSets( array( 'message', 'message2' ), $this->WP_Error->get_error_messages() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_an_invalid_code_should_return_an_empty_array() {
+               $this->assertEmpty( $this->WP_Error->get_error_messages( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_one_error_should_return_an_array_with_that_message() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertEqualSets( array( 'message' ), $this->WP_Error->get_error_messages( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_messages()
+        */
+       public function test_get_error_messages_with_multiple_errors_same_code_should_return_an_array_with_all_messages() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code', 'message2' );
+
+               $this->assertequalSets( array( 'message', 'message2' ), $this->WP_Error->get_error_messages( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_empty_code_and_no_errors_should_return_an_empty_string() {
+               $this->assertSame( '', $this->WP_Error->get_error_message() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_empty_code_and_one_error_should_return_that_message() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( 'message', $this->WP_Error->get_error_message() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_empty_code_and_multiple_errors_should_return_the_first_message() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->assertSame( 'message', $this->WP_Error->get_error_message() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_empty_code_and_multiple_errors_multiple_codes_should_return_the_first_message() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+               $this->WP_Error->add( 'code', 'message2' );
+
+               $this->assertSame( 'message', $this->WP_Error->get_error_message() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_invalid_code_and_no_errors_should_return_empty_string() {
+               $this->assertSame( '', $this->WP_Error->get_error_message( 'invalid' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_invalid_code_and_one_error_should_return_an_empty_string() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( '', $this->WP_Error->get_error_message( 'invalid' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_message()
+        */
+       public function test_get_error_message_with_invalid_code_and_multiple_errors_should_return_an_empty_string() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->assertSame( '', $this->WP_Error->get_error_message( 'invalid' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_and_no_errors_should_evaluate_as_null() {
+               $this->assertSame( null, $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_one_error_no_data_should_evaluate_as_null() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( null, $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_multiple_errors_no_data_should_evaluate_as_null() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->assertSame( null, $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_and_one_error_with_data_should_return_that_data() {
+               $expected = array( 'data-key' => 'data-value' );
+               $this->WP_Error->add( 'code', 'message', $expected );
+
+               $this->assertEqualSetsWithIndex( $expected, $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_and_multiple_errors_different_codes_should_return_the_last_data_of_the_first_code() {
+               $expected = array( 'data-key' => 'data-value' );
+               $this->WP_Error->add( 'code', 'message', $expected );
+               $this->WP_Error->add( 'code2', 'message2', 'data2' );
+
+               $this->assertEqualSetsWithIndex( $expected, $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_empty_code_and_multiple_errors_same_code_should_return_the_last_data_of_the_first_code() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+               $this->WP_Error->add( 'code', 'message2', 'data2' );
+               $this->WP_Error->add( 'code2', 'message2', 'data3' );
+
+               $this->assertSame( 'data2', $this->WP_Error->get_error_data() );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_code_and_no_errors_should_evaluate_as_null() {
+               $this->assertSame( null, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_code_and_one_error_with_no_data_should_evaluate_as_null() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( null, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_code_and_one_error_with_data_should_return_that_data() {
+               $expected = array( 'data-key' => 'data-value' );
+               $this->WP_Error->add( 'code', 'message', $expected );
+
+               $this->assertEqualSetsWithIndex( $expected, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_code_and_multiple_errors_different_codes_should_return_the_last_stored_data_of_the_code() {
+               $expected = array( 'data3' );
+               $this->WP_Error->add( 'code', 'message', 'data' );
+               $this->WP_Error->add( 'code2', 'message2', 'data2' );
+               $this->WP_Error->add( 'code', 'message3', $expected );
+
+               $this->assertEqualSetsWithIndex( $expected, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::get_error_data()
+        */
+       public function test_get_error_data_with_code_and_multiple_errors_same_code_should_return_the_last_stored_data() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+               $this->WP_Error->add( 'code', 'message2', 'data2' );
+               $this->WP_Error->add( 'code2', 'message3', 'data3' );
+
+               $this->assertSame( 'data2', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_key_to_errors_array() {
+               $this->WP_Error->add( '', '', 'data' );
+
+               $this->assertArrayHasKey( '', $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_empty_code_empty_message_empty_data_should_add_empty_message_to_errors_array_under_empty_key() {
+               $this->WP_Error->add( '', '', 'data' );
+
+               $this->assertEqualSetsWithIndex( array( '' => array( '' ) ), $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_empty_code_empty_message_empty_data_should_not_alter_data() {
+               $this->WP_Error->add( '', '', '' );
+
+               $this->assertEmpty( $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_empty_code_empty_message_non_empty_data_should_store_data_under_an_empty_code_key() {
+               $this->WP_Error->add( '', '', 'data' );
+
+               $this->assertEqualSetsWithIndex( array( '' => 'data' ), $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_empty_message_empty_data_should_add_error_with_code() {
+               $this->WP_Error->add( 'code', '' );
+
+               $this->assertSame( 'code', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_empty_message_empty_data_should_add_error_with_empty_message() {
+               $this->WP_Error->add( 'code', '' );
+
+               $this->assertSame( '', $this->WP_Error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_empty_message_empty_data_should_not_add_error_data() {
+               $this->WP_Error->add( 'code', '' );
+
+               $this->assertSame( null, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_message_and_empty_data_should_should_add_error_with_that_message() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( 'message', $this->WP_Error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_message_and_empty_data_should_not_alter_stored_data() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->assertSame( null, $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_empty_message_and_data_should_add_error_with_that_code() {
+               $this->WP_Error->add( 'code', '', 'data' );
+
+               $this->assertSame( 'code', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_empty_message_and_data_should_store_that_data() {
+               $this->WP_Error->add( 'code', '', 'data' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_code() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+
+               $this->assertSame( 'code', $this->WP_Error->get_error_code() );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_message_and_data_should_add_an_error_with_that_message() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+
+               $this->assertSame( 'message', $this->WP_Error->get_error_message( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_with_code_and_message_and_data_should_store_that_data() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_multiple_times_with_the_same_code_should_add_additional_messages_for_that_code() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code', 'message2' );
+
+               $expected = array( 'message', 'message2' );
+
+               $this->assertEqualSets( $expected, $this->WP_Error->get_error_messages( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add()
+        */
+       public function test_add_multiple_times_with_the_same_code_and_different_data_should_store_only_the_last_added_data() {
+               $this->WP_Error->add( 'code', 'message', 'data-bar' );
+               $this->WP_Error->add( 'code', 'message2', 'data-baz' );
+
+               $this->assertSame( 'data-baz', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_empty_data_empty_code_should_create_orphaned_data_with_no_error() {
+               $this->WP_Error->add_data( '' );
+
+               $this->assertEmpty( $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_empty_data_empty_code_no_errors_should_create_data_under_an_empty_code_key() {
+               $this->WP_Error->add_data( '' );
+
+               $this->assertEqualSets( array( '' => '' ), $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_empty_code_and_one_error_should_store_the_data_under_that_code() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add_data( 'data' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_empty_code_and_multiple_errors_with_different_codes_should_store_it_under_the_first_code() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+
+               $this->WP_Error->add_data( 'data' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_empty_code_and_multiple_errors_with_same_code_should_store_it_under_the_first_code() {
+               $this->WP_Error->add( 'code', 'message' );
+               $this->WP_Error->add( 'code2', 'message2' );
+               $this->WP_Error->add( 'code', 'message3' );
+
+               $this->WP_Error->add_data( 'data' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_and_code_and_no_errors_should_create_orphaned_data_with_no_error() {
+               $this->WP_Error->add_data( 'data', 'code' );
+
+               $this->assertEmpty( $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_and_code_no_errors_should_create_data_under_that_code_key() {
+               $this->WP_Error->add_data( 'data', 'code' );
+
+               $this->assertEqualSets( array( 'code' => 'data' ), $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_and_code_one_error_different_code_should_create_orphaned_data_with_no_error() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->WP_Error->add_data( 'data', 'code2' );
+
+               $this->assertEqualSetsWithIndex( array( 'code' => array( 'message' ) ), $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_and_code_one_error_different_code_should_create_data_under_that_code_key() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->WP_Error->add_data( 'data', 'code2' );
+
+               $this->assertEqualSetsWithIndex( array( 'code2' => 'data' ), $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::add_data()
+        */
+       public function test_add_data_with_data_and_code_should_add_data() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->WP_Error->add_data( 'data', 'code' );
+
+               $this->assertSame( 'data', $this->WP_Error->get_error_data( 'code' ) );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_with_no_errors_should_affect_nothing() {
+               $before = $this->WP_Error->errors;
+
+               $this->WP_Error->remove( 'code' );
+
+               $after = $this->WP_Error->errors;
+
+               $this->assertEqualSetsWithIndex( $before, $after );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_empty_code_no_errors_should_affect_nothing() {
+               $before = $this->WP_Error->errors;
+
+               $this->WP_Error->remove( '' );
+
+               $after = $this->WP_Error->errors;
+
+               $this->assertEqualSetsWithIndex( $before, $after );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error() {
+               $before = $this->WP_Error->errors;
+
+               $this->WP_Error->add( '', 'message' );
+
+               $this->WP_Error->remove( '' );
+
+               $after = $this->WP_Error->errors;
+
+               $this->assertEqualSetsWithIndex( $before, $after );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_empty_code_and_one_error_with_empty_string_code_should_remove_error_data() {
+               $this->WP_Error->add( '', 'message', 'data' );
+
+               $this->WP_Error->remove( '' );
+
+               $after = $this->WP_Error->error_data;
+
+               $this->assertEmpty( $this->WP_Error->error_data );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_should_remove_the_error_with_the_given_code() {
+               $this->WP_Error->add( 'code', 'message' );
+
+               $this->WP_Error->remove( 'code' );
+
+               $this->assertEmpty( $this->WP_Error->errors );
+       }
+
+       /**
+        * @covers WP_Error::remove()
+        */
+       public function test_remove_should_remove_the_error_data_associated_with_the_given_code() {
+               $this->WP_Error->add( 'code', 'message', 'data' );
+
+               $this->WP_Error->remove( 'code' );
+
+               $this->assertEmpty( $this->WP_Error->error_data );
+       }
+
+}
</ins></span></pre>
</div>
</div>

</body>
</html>