Annotation of embedaddon/php/ext/standard/tests/class_object/get_declared_traits_basic_001.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test get_declared_traits() function : basic functionality
3: --FILE--
4: <?php
5: /* Prototype : proto array get_declared_traits()
6: * Description: Returns an array of all declared traits.
7: * Source code: Zend/zend_builtin_functions.c
8: * Alias to functions:
9: */
10:
11:
12: echo "*** Testing get_declared_traits() : basic functionality ***\n";
13:
14: trait MyTrait {}
15:
16: // Zero arguments
17: echo "\n-- Testing get_declared_traits() function with Zero arguments --\n";
18: var_dump(get_declared_traits());
19:
20: foreach (get_declared_traits() as $trait) {
21: if (!trait_exists($trait)) {
22: echo "Error: $trait is not a valid trait.\n";
23: }
24: }
25:
26: echo "\n-- Ensure trait is listed --\n";
27: var_dump(in_array('MyTrait', get_declared_traits()));
28:
29: echo "\n-- Ensure userspace interfaces are not listed --\n";
30: interface I {}
31: var_dump(in_array( 'I', get_declared_traits()));
32:
33: echo "\n-- Ensure userspace classes are not listed --\n";
34: class MyClass {}
35: var_dump(in_array( 'MyClass', get_declared_traits()));
36:
37:
38: echo "Done";
39: ?>
40: --EXPECTF--
41: *** Testing get_declared_traits() : basic functionality ***
42:
43: -- Testing get_declared_traits() function with Zero arguments --
44: array(%d) {
45: %a
46: }
47:
48: -- Ensure trait is listed --
49: bool(true)
50:
51: -- Ensure userspace interfaces are not listed --
52: bool(false)
53:
54: -- Ensure userspace classes are not listed --
55: bool(false)
56: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>