Test::Path::Router(3pm)

Test::Path::Router3pm

A testing module for testing routes

Usage

  use Test::More plan => 1;
  use Test::Path::Router;
  my $router = Path::Router->new;
  # ... define some routes
  path_ok($router, 'admin/remove_user/56', '... this is a valid path');
  path_is($router,
      'admin/edit_user/5',
      {
          controller => 'admin',
          action     => 'edit_user',
          id         => 5,
      },
  '... the path and mapping match');
  mapping_ok($router, {
      controller => 'admin',
      action     => 'edit_user',
      id         => 5,
  }, '... this maps to a valid path');
  mapping_is($router,
      {
          controller => 'admin',
          action     => 'edit_user',
          id         => 5,
      },
      'admin/edit_user/5',
  '... the mapping and path match');
  routes_ok($router, {
      'admin' => {
          controller => 'admin',
          action     => 'index',
      },
      'admin/add_user' => {
          controller => 'admin',
          action     => 'add_user',
      },
      'admin/edit_user/5' => {
          controller => 'admin',
          action     => 'edit_user',
          id         => 5,
      }
  },
  "... our routes are valid");

Version

version 0.15

Overview

This module helps in testing out your path routes, to make sure they are valid.

Exported functions

path_ok ($router, $path, ?$message)
path_not_ok ($router, $path, ?$message)
path_is ($router, $path, $mapping, ?$message)
mapping_ok ($router, $mapping, ?$message)
mapping_not_ok ($router, $mapping, ?$message)
mapping_is ($router, $mapping, $path, ?$message)
routes_ok ($router, \%test_routes, ?$message)

This test function will accept a set of %test_routes which will get checked against your $router instance. This will check to be sure that all paths in %test_routes procude the expected mappings, and that all mappings also produce the expected paths. It basically assures you that your paths are roundtrippable, so that you can be confident in them.

Releases

5 releases since Debian 9 (Stretch); the text changed 3 times.

  1. 9–10
  2. 11
  3. 12
  4. 13

Bugs

All complex software has bugs lurking in it, and this module is no exception. If you find a bug please either email me, or add the bug to cpan-RT.

Author

Stevan Little <[email protected]>

Author

Stevan Little <[email protected]>

From libpath-router-perl 0.15-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.