PHP Classes

File: tests/test_zip_bundle.php

Recommend this page to a friend!
  Packages of Matthew Asham   Binkterm PHP   tests/test_zip_bundle.php   Download  
File: tests/test_zip_bundle.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: 5 days ago
Size: 1,311 bytes
 

Contents

Class file image Download
<?php

// Test script for zip bundle processing
require_once __DIR__ . '/../vendor/autoload.php';

use
BinktermPHP\BinkdProcessor;
use
BinktermPHP\Database;

echo
"Testing zip bundle processing...\n";

// Initialize database
Database::getInstance();

// Create test zip with dummy packet
$testZip = __DIR__ . '/../data/inbound/test_bundle.zip';
$zip = new ZipArchive();

if (
$zip->open($testZip, ZipArchive::CREATE) === TRUE) {
   
// Create a minimal test packet content (this is just for testing the extraction)
   
$dummyPacketContent = str_repeat("\x00", 58) . pack('v', 0); // Header + terminator
   
$zip->addFromString('test.pkt', $dummyPacketContent);
   
$zip->close();
    echo
"Created test zip bundle: $testZip\n";
} else {
    echo
"Failed to create test zip\n";
    exit(
1);
}

// Test the processor
try {
   
$processor = new BinkdProcessor();
   
$processed = $processor->processInboundPackets();
    echo
"Processed $processed packets from bundles\n";
   
   
// Check if zip was removed (indicates successful processing)
   
if (!file_exists($testZip)) {
        echo
"? Test zip bundle was processed and removed\n";
    } else {
        echo
"? Test zip bundle still exists\n";
    }
   
} catch (
Exception $e) {
    echo
"Error: " . $e->getMessage() . "\n";
}

echo
"Test complete.\n";