<?php 
/**
 * Plugin Name: Test Did Action
 * Plugin URI: https://core.trac.wordpress.org/ticket/35357
 * Author: Chris Christoff
 * Version: 1.0
 */

/**
 * Based on patch 3 for ticket 35357. Requires
 * patch has been applied before activating this plugin.
 *
 * The first function that hooks in will output 0, as no
 * functions have run on the action before it. The second
 * function outputs 1, as test_did_action_action1 has run
 * before it. The third function outputs 2, as test_did_action_action1
 * and test_did_action_action2 has run before it.
 *
 * Finally the script dies and outputs 3, as 3 functions total
 * executed on the action.
 *
 * The result is a var_dump of (ints) 0 then 1 then 2 then 3.
 */

add_action( 'init', 'test_did_action' );
function test_did_action(){
	$string = 'test';
	do_action( 'test_did_action', $string );
	var_dump( did_action( 'test_did_action' ) ); // Outputs 3
	wp_die();
}

function test_did_action_action1( $string ){
	var_dump( did_action( 'test_did_action' ) ); // Outputs 0
	echo $string . '1';
}
add_action( 'test_did_action', 'test_did_action_action1', 10, 1 );

function test_did_action_action2( $string ){
	var_dump( did_action( 'test_did_action' ) ); // Outputs 1
	echo $string . '1';
}
add_action( 'test_did_action', 'test_did_action_action2', 11, 1 );

function test_did_action_action3( $string ){
	var_dump( did_action( 'test_did_action' ) ); // Outputs 2
	echo $string . '1';
}
add_action( 'test_did_action', 'test_did_action_action3', 12, 1 );