1--TEST--
2get_error_code()
3--SKIPIF--
4<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
5--FILE--
6<?php
7
8/*
9 * Retrieve error code.
10 */
11
12
13/*
14 * Check if error code equals to expected one.
15 */
16function check_rc( $rc, $expected )
17{
18    return ( $rc === $expected ? "ok" : "failed" ) . "\n";
19}
20
21function ut_main()
22{
23    $res = '';
24    $coll = ut_coll_create( 'ru_RU' );
25
26    // Try specifying a correct attribute.
27    ut_coll_get_attribute( $coll, Collator::NORMALIZATION_MODE );
28    $status = ut_coll_get_error_code( $coll );
29    $res .= check_rc( $status, U_ZERO_ERROR );
30
31    // Try specifying an incorrect attribute.
32    ut_coll_get_attribute( $coll, 12345 );
33    $status = ut_coll_get_error_code( $coll );
34    $res .= check_rc( $status, U_ILLEGAL_ARGUMENT_ERROR );
35
36    return $res;
37}
38
39# Suppress warning messages.
40error_reporting( E_ERROR );
41
42include_once( 'ut_common.inc' );
43ut_run();
44?>
45--EXPECT--
46ok
47ok
48