1--TEST--
2Interface of the class mysqli_warning - TODO
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6require_once('skipifemb.inc');
7require_once('skipifconnectfailure.inc');
8require_once('connect.inc');
9
10if (!$TEST_EXPERIMENTAL)
11    die("skip - experimental (= unsupported) feature");
12?>
13--FILE--
14<?php
15    require('connect.inc');
16
17    $warning = new mysqli_warning();
18    $warning = new mysqli_warning(null);
19    $warning = new mysqli_warning(null, null);
20
21    $mysqli = new mysqli();
22    $warning = new mysqli_warning($mysqli);
23
24    $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
25    $stmt = new mysqli_stmt($mysqli);
26    $warning = new mysqli_warning($stmt);
27
28    $stmt = $mysqli->stmt_init();
29    $warning = new mysqli_warning($stmt);
30
31    $obj = new stdClass();
32    $warning = new mysqli_warning($obj);
33
34    include("table.inc");
35    $mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
36    $res = $mysqli->query('INSERT INTO test(id, label) VALUES (1, "zz")');
37    $warning = mysqli_get_warnings($mysqli);
38
39    printf("Parent class:\n");
40    var_dump(get_parent_class($warning));
41
42    printf("\nMethods:\n");
43    $methods = get_class_methods($warning);
44    $expected_methods = array(
45        'next'                      => true,
46    );
47
48    foreach ($methods as $k => $method) {
49        if (isset($expected_methods[$method])) {
50            unset($methods[$k]);
51            unset($expected_methods[$method]);
52        }
53    }
54    if (!empty($methods)) {
55        printf("Dumping list of unexpected methods.\n");
56        var_dump($methods);
57    }
58    if (!empty($expected_methods)) {
59        printf("Dumping list of missing methods.\n");
60        var_dump($expected_methods);
61    }
62    if (empty($methods) && empty($expected_methods))
63        printf("ok\n");
64
65    printf("\nClass variables:\n");
66    $variables = get_class_vars(get_class($mysqli));
67    sort($variables);
68    foreach ($variables as $k => $var)
69        printf("%s\n", $var);
70
71    printf("\nObject variables:\n");
72    $variables = get_object_vars($mysqli);
73    foreach ($variables as $k => $var)
74        printf("%s\n", $var);
75
76    printf("\nMagic, magic properties:\n");
77
78    assert('' === $warning->message);
79    printf("warning->message = '%s'\n", $warning->message);
80
81    assert('' === $warning->sqlstate);
82    printf("warning->sqlstate= '%s'\n", $warning->sqlstate);
83
84    assert(0 === $warning->errno);
85    printf("warning->errno = '%s'\n", $warning->errno);
86
87    printf("\nAccess to undefined properties:\n");
88    printf("warning->unknown = '%s'\n", @$warning->unknown);
89
90    print "done!";
91?>
92--CLEAN--
93<?php
94    require_once("clean_table.inc");
95?>
96--EXPECTF--
97Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
98
99Warning: mysqli_warning::mysqli_warning() expects parameter 1 to be object, null given in %s on line %d
100
101Warning: Wrong parameter count for mysqli_warning::mysqli_warning() in %s on line %d
102
103Warning: mysqli_warning::mysqli_warning(): Couldn't fetch mysqli in %s on line %d
104
105Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
106 in %s on line %d
107
108Warning: mysqli_warning::mysqli_warning(): invalid object or resource mysqli_stmt
109 in %s on line %d
110
111Warning: mysqli_warning::mysqli_warning(): invalid class argument in /home/nixnutz/php6_mysqlnd/ext/mysqli/tests/mysqli_class_mysqli_warning.php on line 19
112
113Warning: mysqli_warning::mysqli_warning(): No warnings found in %s on line %d
114Parent class:
115bool(false)
116
117Methods:
118ok
119
120Class variables:
121
122Object variables:
123
124Magic, magic properties:
125warning->message = ''
126warning->sqlstate= ''
127warning->errno = ''
128
129Access to undefined properties:
130
131warning->unknown = ''
132done!
133