| 1 | package Zonemaster::Test::Example v1.0.1; | ||
| 2 | |||
| 3 | ### | ||
| 4 | ### This test module is meant to serve as an example when writing proper ones. | ||
| 5 | ### | ||
| 6 | |||
| 7 | use 5.14.2; | ||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | |||
| 11 | use Zonemaster; | ||
| 12 | use Zonemaster::Util; | ||
| 13 | |||
| 14 | ### | ||
| 15 | ### Entry points | ||
| 16 | ### | ||
| 17 | |||
| 18 | sub all { | ||
| 19 | my ( $class, $zone ) = @_; | ||
| 20 | my @results; | ||
| 21 | |||
| 22 | push @results, $class->placeholder if Zonemaster->config->should_run('placeholder'); | ||
| 23 | |||
| 24 | return @results; | ||
| 25 | } | ||
| 26 | |||
| 27 | ### | ||
| 28 | ### Metadata Exposure | ||
| 29 | ### | ||
| 30 | |||
| 31 | sub metadata { | ||
| 32 | my ( $class ) = @_; | ||
| 33 | |||
| 34 | return { placeholder => [qw( EXAMPLE_TAG )] }; | ||
| 35 | } | ||
| 36 | |||
| 37 | sub version { | ||
| 38 | return "$Zonemaster::Test::Example::VERSION"; | ||
| 39 | } | ||
| 40 | |||
| 41 | sub translation { | ||
| 42 | return { EXAMPLE_TAG => 'This is an example tag.', }; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub policy { | ||
| 46 | return { EXAMPLE_TAG => 'DEBUG', }; | ||
| 47 | } | ||
| 48 | |||
| 49 | ### | ||
| 50 | ### Tests | ||
| 51 | ### | ||
| 52 | |||
| 53 | sub placeholder { | ||
| 54 | my ( $class, $zone ) = @_; | ||
| 55 | my @results; | ||
| 56 | |||
| 57 | push @results, info( EXAMPLE_TAG => { example_arg => 'example_value' } ); | ||
| 58 | |||
| 59 | return @results; | ||
| 60 | } | ||
| 61 | |||
| 62 | 1; | ||
| 63 | |||
| 64 | =head1 NAME | ||
| 65 | |||
| 66 | Zonemaster::Test::Example - example module showing the expected structure of Zonemaster test modules | ||
| 67 | |||
| 68 | =head1 SYNOPSIS | ||
| 69 | |||
| 70 | my @results = Zonemaster::Test::Example->all($zone); | ||
| 71 | |||
| 72 | =head1 METHODS | ||
| 73 | |||
| 74 | =over | ||
| 75 | |||
| 76 | =item all($zone) | ||
| 77 | |||
| 78 | Runs the default set of tests and returns a list of log entries made by the tests. | ||
| 79 | |||
| 80 | =item metadata() | ||
| 81 | |||
| 82 | Returns a reference to a hash, the keys of which are the names of all test methods in the module, and the corresponding values are references to | ||
| 83 | lists with all the tags that the method can use in log entries. | ||
| 84 | |||
| 85 | =item translation() | ||
| 86 | |||
| 87 | Returns a reference to a nested hash, where the outermost keys are language | ||
| 88 | codes, the keys below that are message tags and their values are translation | ||
| 89 | strings. | ||
| 90 | |||
| 91 | =item policy() | ||
| 92 | |||
| 93 | Returns a reference to a hash with the default policy for the module. The keys | ||
| 94 | are message tags, and the corresponding values are their default log levels. | ||
| 95 | |||
| 96 | =item version() | ||
| 97 | |||
| 98 | Returns a version string for the module. | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | =head1 TESTS | ||
| 103 | |||
| 104 | =over | ||
| 105 | |||
| 106 | =item placeholder($zone) | ||
| 107 | |||
| 108 | Since this is an example module, this test does nothing except return a single log entry. | ||
| 109 | |||
| 110 | =back | ||
| 111 | |||
| 112 | =cut |