1--TEST--
2msgfmt_get/set_pattern()
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7
8/*
9 * Get/set pattern.
10 */
11
12
13function ut_main()
14{
15    $res_str = '';
16    $fmt = ut_msgfmt_create( "en_US", "{0,number} monkeys on {1,number} trees" );
17
18    // Get default patten.
19    $res_str .= "Default pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
20    $res_str .= "Formatting result: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
21
22    // Set a new pattern.
23    $pattern = "{0,number} trees hosting {1,number} monkeys";
24    $res = ut_msgfmt_set_pattern( $fmt, $pattern );
25    if( $res === false )
26        $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n";
27
28    // Check if the pattern has been changed.
29    $res = ut_msgfmt_get_pattern( $fmt );
30    if( $res === false )
31        $res_str .= ut_msgfmt_get_error_message( $fmt ) . " (" . ut_msgfmt_get_error_code( $fmt ) . ")\n";
32    $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
33    $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
34
35    ut_msgfmt_set_pattern($fmt, str_repeat($pattern, 10));
36    $res_str .= "New pattern: '" . ut_msgfmt_get_pattern( $fmt ) . "'\n";
37    $res_str .= "Formatted message: " . ut_msgfmt_format( $fmt, array(123, 456) ) . "\n";
38
39
40    return $res_str;
41}
42
43include_once( 'ut_common.inc' );
44ut_run();
45
46?>
47--EXPECT--
48Default pattern: '{0,number} monkeys on {1,number} trees'
49Formatting result: 123 monkeys on 456 trees
50New pattern: '{0,number} trees hosting {1,number} monkeys'
51Formatted message: 123 trees hosting 456 monkeys
52New pattern: '{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys{0,number} trees hosting {1,number} monkeys'
53Formatted message: 123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys123 trees hosting 456 monkeys
54