PHP Classes

File: tests/test_real_address_search.php

Recommend this page to a friend!
  Packages of Matthew Asham   Binkterm PHP   tests/test_real_address_search.php   Download  
File: tests/test_real_address_search.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Binkterm PHP
Bulletin board system based on the Web
Author: By
Last change:
Date: 1 month ago
Size: 1,951 bytes
 

Contents

Class file image Download
<?php

require_once __DIR__ . '/../vendor/autoload.php';

use
BinktermPHP\Nodelist\NodelistManager;

$nodelistManager = new NodelistManager();

echo
"Testing address search with real nodelist data...\n\n";

// Test with addresses that should exist based on the sample
$testAddresses = [
   
'1:1/1', // Should find Nick Andre
   
'1:1/19', // Should find Andrew Leary
   
'1:1/101', // Should find Jason Bock
];

foreach (
$testAddresses as $testAddress) {
    echo
"=== Searching for: '$testAddress' ===\n";
   
   
// Test our new search_term logic
   
$criteria = ['search_term' => $testAddress];
   
$results = $nodelistManager->searchNodes($criteria);
   
    if (
$results && count($results) > 0) {
        echo
"? Found " . count($results) . " result(s) using search_term:\n";
        foreach (
$results as $node) {
            echo
" {$node['full_address']} - {$node['sysop_name']} ({$node['location']})\n";
        }
    } else {
        echo
"? No results found using search_term\n";
    }
   
   
// Also test the direct findNode method for comparison
   
$directResult = $nodelistManager->findNode($testAddress);
    if (
$directResult) {
        echo
"? Direct findNode result: {$directResult['full_address']} - {$directResult['sysop_name']}\n";
    } else {
        echo
"? Direct findNode: No result\n";
    }
   
    echo
"\n";
}

// Also test a text search to make sure we didn't break that
echo "=== Testing text search (should still work) ===\n";
$textCriteria = ['search_term' => 'Nick'];
$textResults = $nodelistManager->searchNodes($textCriteria);
if (
$textResults && count($textResults) > 0) {
    echo
"? Found " . count($textResults) . " result(s) for text search 'Nick':\n";
    foreach (
array_slice($textResults, 0, 3) as $node) {
        echo
" {$node['full_address']} - {$node['sysop_name']} ({$node['location']})\n";
    }
} else {
    echo
"? No results found for text search 'Nick'\n";
}