# POE::Test::Sequence - POE test helper to verify a sequence of events - perldoc - [phpMan]

## NAME
    [POE::Test::Sequence](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ATest%3A%3ASequence/markdown) - POE test helper to verify a sequence of events

## SYNOPSIS
      Sorry, there isn't a synopsis at this time.

      However, see t/90_regression/whjackson-followtail.t in POE's test
      suite for a full example.

## DESCRIPTION
    [POE::Test::Sequence](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ATest%3A%3ASequence/markdown) is a test helper that abstracts a lot of the tedious trickery needed to
    verify the relative ordering of events.

    With this module, one can test the sequence of events without necessarily relying on specific
    times elapsing between them.

  create_generic_session
    The create_generic_session() method creates a [POE::Session](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ASession/markdown) that routes all vents through the
    [POE::Test::Sequence](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ATest%3A%3ASequence/markdown) object. It returns the [POE::Session](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ASession/markdown) object, but the test program does not
    need to store it anywhere. In fact, it's recommended not to do that without understanding the
    implications.

    The implications can be found in the documentation for [POE::Kernel](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3AKernel/markdown) and [POE::Session](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ASession/markdown).

    An example of create_generic_session() can be found in POE's
    t/90_regression/leolo-alarm-adjust.t test program.

  new
    Create a new sequence object. Takes named parameter pairs, currently just "sequence", which
    references an array of steps. Each step is an array reference containing the expected event, a
    required parameter to that event, and a code reference for the optional next step to take after
    testing for that event.

      my $sequence = [POE::Test::Sequence](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ATest%3A%3ASequence/markdown)->new(
        sequence => [
        [ got_idle_event => 0, sub { append_to_log("text") } ],
        ...,
      ]
      );

### next
    they should. The third element is returned by next() and is suitable for use as a goto() target.
    See the next() method for more details.

  next
    The next() method requires an event name and a scalar parameter. These are compared to the first
    two elements of the next sequence step to make sure events are happening in the order in which
    they should.

      sub handle_start_event {
        goto $sequence->next("got_start_event", 0);
      }

  test_count
### test_count
    for test planning.

      use [Test::More](https://www.chedong.com/phpMan.php/perldoc/Test%3A%3AMore/markdown);
      my $sequence = [POE::Test::Sequence](https://www.chedong.com/phpMan.php/perldoc/POE%3A%3ATest%3A%3ASequence/markdown)->new( ... );
      plan tests => $sequence->test_count();

## BUGS
### create_generic_session
### next

AUTHORS & LICENSING
    Please see POE for more information about authors, contributors, and POE's licensing.

