xref: /PHP-8.2/ext/com_dotnet/tests/27974.phpt (revision 56f90492)
1--TEST--
2COM: mapping a safearray
3--EXTENSIONS--
4com_dotnet
5--FILE--
6<?php
7error_reporting(E_ALL);
8
9try {
10    $v = new VARIANT(array("123", "456", "789"));
11    var_dump($v);
12    print $v[0] . "\n";
13    print $v[1] . "\n";
14    print $v[2] . "\n";
15    $v[1] = "hello";
16    foreach ($v as $item) {
17        var_dump($item);
18    }
19    try {
20        $v[3] = "shouldn't work";
21    } catch (com_exception $e) {
22        if ($e->getCode() != DISP_E_BADINDEX) {
23            throw $e;
24        }
25        echo "Got BADINDEX exception OK!\n";
26    }
27    echo "OK!";
28} catch (Exception $e) {
29    print $e;
30}
31?>
32--EXPECT--
33object(variant)#1 (0) {
34}
35123
36456
37789
38string(3) "123"
39string(5) "hello"
40string(3) "789"
41Got BADINDEX exception OK!
42OK!
43