xref: /php-src/ext/standard/tests/http/gh15650.phpt (revision 1b9568d3)
1--TEST--
2GH-15650: http_build_query() with enum
3--FILE--
4<?php
5
6enum E1: string {
7    case C = 'hello world!';
8}
9
10enum E2: int {
11    case C = 42;
12}
13
14enum E3 {
15    case C;
16}
17
18echo http_build_query(['e1' => E1::C, 'e2' => E2::C]), "\n";
19
20try {
21    echo http_build_query(['e3' => E3::C]);
22} catch (Throwable $e) {
23    echo get_class($e), ': ', $e->getMessage(), "\n";
24}
25
26try {
27    echo http_build_query(E1::C);
28} catch (Throwable $e) {
29    echo get_class($e), ': ', $e->getMessage(), "\n";
30}
31
32?>
33--EXPECT--
34e1=hello+world%21&e2=42
35ValueError: Unbacked enum E3 cannot be converted to a string
36TypeError: http_build_query(): Argument #1 ($data) must be of type array, E1 given
37