xref: /php-src/Zend/tests/gh9775_2.phpt (revision e8b8341d)
1--TEST--
2GH-9775: Pure enum in array_unique()
3--FILE--
4<?php
5
6enum Test
7{
8    case AUTHENTICATED;
9    case COURSES_ADMIN;
10    case BUNDLES_ADMIN;
11    case COURSES_REPORTING_ACCESS;
12    case B2B_DASHBOARD_ACCESS;
13    case INSTRUCTORS_ADMIN;
14    case USERS_ADMIN;
15    case COUPONS_ADMIN;
16}
17
18$instructorsAdmin = Test::INSTRUCTORS_ADMIN;
19
20$data = [
21    Test::COURSES_ADMIN,
22    Test::COURSES_REPORTING_ACCESS,
23    Test::BUNDLES_ADMIN,
24    Test::USERS_ADMIN,
25    Test::B2B_DASHBOARD_ACCESS,
26    Test::B2B_DASHBOARD_ACCESS,
27    Test::INSTRUCTORS_ADMIN,
28    &$instructorsAdmin,
29    Test::COUPONS_ADMIN,
30    Test::AUTHENTICATED,
31];
32
33$data = array_unique($data, flags: SORT_REGULAR);
34
35var_dump($data);
36
37?>
38--EXPECT--
39array(8) {
40  [0]=>
41  enum(Test::COURSES_ADMIN)
42  [1]=>
43  enum(Test::COURSES_REPORTING_ACCESS)
44  [2]=>
45  enum(Test::BUNDLES_ADMIN)
46  [3]=>
47  enum(Test::USERS_ADMIN)
48  [4]=>
49  enum(Test::B2B_DASHBOARD_ACCESS)
50  [6]=>
51  enum(Test::INSTRUCTORS_ADMIN)
52  [8]=>
53  enum(Test::COUPONS_ADMIN)
54  [9]=>
55  enum(Test::AUTHENTICATED)
56}
57