File: bugfix-rt61177.t

package info (click to toggle)
libnumber-phone-perl 3.6006-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 136,072 kB
  • sloc: perl: 2,719; makefile: 2
file content (30 lines) | stat: -rw-r--r-- 1,104 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl -w

use strict;
use lib 't/inc';
use fatalwarnings;

use lib 't/lib'; # for mocking of the UK

use Test::More;

END { done_testing(); }

use Number::Phone;
use Number::Phone::Country qw(noexport);

is(Number::Phone->new("442087712924")->country_code(), 44, "known countries return objects");
is(Number::Phone->new("+442087712924")->country_code(), 44, "known countries with a + return objects");
is(Number::Phone->new("+447979866975")->format(), '+44 7979 866975' , "format() works (sanity check cos it changes later)");

# let's break the UK
$Number::Phone::Country::idd_codes{'44'} = 'MOCK';
$Number::Phone::Country::prefix_codes{'MOCK'} = ['44',   '00',  undef];

foreach my $prefix ('', '+') {
  my $object = Number::Phone->new($prefix."447979866975");
  isa_ok($object, 'Number::Phone::StubCountry', "unknown countries return minimal objects".($prefix? " with a +" : ""));
  isa_ok($object, 'Number::Phone::StubCountry::MOCK', "class hierarchy is correct");
  is($object->country_code(), '44', "->country_code works");
  is($object->format(), '+44 7979 866975', "->format works");
}