summaryrefslogtreecommitdiff
path: root/ext/standard/tests/network/net_get_interfaces_001.phpt
blob: 522278e90d89a7837ba138571b95eecb1b65989f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
--TEST--
net_get_interfaces IPv4 Loopback
--SKIPIF--
<?php
function_exists('net_get_interfaces') || print 'skip';
--FILE--
<?php

// Test that we have exactly one unicast address with the address 127.0.0.1
// On linux this will often be named "lo", but even that isn't guaranteed.

$ifaces = net_get_interfaces();

$found = false;
foreach ($ifaces as $iface) {
  foreach ($iface['unicast'] as $unicast) {
    if (($unicast['address'] ?? null) === '127.0.0.1') {
      $found = true;
      break 2;
    }
  }
}

var_dump($found);
if (!$found) {
  // Extra diagnostics!
  var_dump($ifaces);
}
--EXPECT--
bool(true)