Index: tests/phpunit/includes/testcase.php
===================================================================
--- tests/phpunit/includes/testcase.php	(revision 30586)
+++ tests/phpunit/includes/testcase.php	(working copy)
@@ -262,10 +262,17 @@
 	}
 
 	function assertEqualSets( $expected, $actual ) {
-		$this->assertEquals( array(), array_diff( $expected, $actual ) );
-		$this->assertEquals( array(), array_diff( $actual, $expected ) );
+		sort( $expected );
+		sort( $actual );
+		$this->assertEquals( $expected, $actual );
 	}
 
+	function assertEqualSetsWithIndex( $expected, $actual ) {
+		ksort( $expected );
+		ksort( $actual );
+		$this->assertEquals( $expected, $actual );
+	}
+
 	function go_to( $url ) {
 		// note: the WP and WP_Query classes like to silently fetch parameters
 		// from all over the place (globals, GET, etc), which makes it tricky
Index: tests/phpunit/tests/testhelpers.php
===================================================================
--- tests/phpunit/tests/testhelpers.php	(revision 0)
+++ tests/phpunit/tests/testhelpers.php	(working copy)
@@ -0,0 +1,204 @@
+<?php
+
+/**
+ * @group phpunit
+ */
+class Tests_TestHelpers extends WP_UnitTestCase {
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_equal_sets() {
+		$this->assertEqualSets( array( 1, 2, 3 ), array( 1, 2, 3 ) );
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_equal_sets() {
+		$this->assertEqualSets( array( 1, 2, 3 ), array( 2, 3, 1 ) );
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_unequal_sets() {
+		$passed = true;
+		try {
+			$this->assertEqualSets( array( 1, 2, 3 ), array( 1, 2, 3, 4 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			// assertEqualSets failed, as we want it to
+			$passed = false;
+		}
+
+		try {
+			$this->assertEqualSets( array( 1, 2, 3, 4 ), array( 1, 2, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_unequal_sets() {
+		try {
+			$this->assertEqualSets( array( 1, 2, 3 ), array( 3, 4, 2, 1 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			return;
+		}
+
+		$this->fail();
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_sets_with_repeated_values() {
+		try {
+			$this->assertEqualSets( array( 1, 2, 3 ), array( 1, 2, 3, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			return;
+		}
+
+		$this->fail();
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_sets_with_repeated_values() {
+		try {
+			$this->assertEqualSets( array( 1, 2, 3 ), array( 2, 3, 1, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			return;
+		}
+
+		$this->fail();
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_equal_sets_with_index() {
+		$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 1, 2, 3 ) );
+		$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'a' => 1, 'b' => 2, 'c' => 3 ) );
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_equal_sets_with_index() {
+		$passed = true;
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 2, 3, 1 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'b' => 2, 'c' => 3, 'a' => 1 ) );
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_unequal_sets_with_index() {
+		$passed = true;
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 1, 2, 3, 4 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3, 4 ), array( 1, 2, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+		try {
+			$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		try {
+			$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 4 ), array( 'a' => 1, 'b' => 2, 'c' => 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_unequal_sets_with_index() {
+		$passed = true;
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 3, 4, 2, 1 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+		try {
+			$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'c' => 3, 'b' => 2, 'd' => 4, 'a' => 1 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_ordered_sets_with_repeated_values_with_index() {
+		$passed = true;
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 1, 2, 3, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+		try {
+			$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'a' => 1, 'b' => 2, 'c' => 3, 'd' => 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+
+	/**
+	 * @ticket 30522
+	 */
+	function test_unordered_sets_with_repeated_values_with_index() {
+		$passed = true;
+		try {
+			$this->assertEqualSetsWithIndex( array( 1, 2, 3 ), array( 2, 3, 1, 3 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+		try {
+			$this->assertEqualSetsWithIndex( array( 'a' => 1, 'b' => 2, 'c' => 3 ), array( 'c' => 3, 'b' => 2, 'd' => 3, 'a' => 1 ) );
+		} catch ( PHPUnit_Framework_ExpectationFailedException $ex ) {
+			$passed = false;
+		}
+
+		if ( $passed ) {
+			$this->fail();
+		}
+	}
+}

Property changes on: tests/phpunit/tests/testhelpers.php
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
