assertSame(['Campus', 'Offsite'], array_column($tree, 'locationname')); $assoc = Location::getLocationsAssoc(); $this->assertTrue($assoc[4]['isleaf']); $this->assertSame([1, 2], $assoc[4]['parents']); // Mapping respects depth and subnet size $this->assertSame(2, Location::mapIpToLocation('10.0.0.150')); $this->assertSame(1, Location::mapIpToLocation('10.0.0.50')); $this->assertSame(5, Location::mapIpToLocation('192.168.1.22')); } public function testUpdateMapIpToLocationIssuesUpdateSql(): void { $ret = Location::updateMapIpToLocation('uuid-1', '10.0.0.5'); $this->assertSame(1, $ret); $row = Database::queryFirst('SELECT subnetlocationid FROM machine WHERE machineuuid = :uuid', ['uuid' => 'uuid-1']); $this->assertSame(1, (int)$row['subnetlocationid']); } }