---
name: "Test::Path::Router"
section: "3pm"
platform: "linux"
package: "libpath-router-perl"
version: "0.15-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Test::Path::Router"
---

# Test::Path::Router(3pm)

A testing module for testing routes

## NAME

Test::Path::Router - A testing module for testing routes

## VERSION

version 0.15

## SYNOPSIS

```
  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");
```

## DESCRIPTION

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.

## 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 \<stevan@cpan.org\>

## COPYRIGHT AND LICENSE

Copyright 2008-2011 Infinity Interactive, Inc.

\<http://www.iinteractive.com\>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

## AUTHOR

Stevan Little \<stevan@cpan.org\>

## COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Infinity Interactive.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
