PHP 8.3.31
Preview: reader_006.phpt Size: 1.44 KB
/proc/self/root/opt/alt/tests/alt-php82-phpiredis_1.0.1-1.el8/reader_006.phpt

--TEST--
[READER] Set custom error handler

--SKIPIF--
<?php
require_once 'testsuite_skipif.inc';

--FILE--
<?php

$expectedErrorText = 'ERR after handler';


function error_handler($err) {
    return $err." after handler";
}

$reader = phpiredis_reader_create();

phpiredis_reader_feed($reader, "-ERR\r\n");
$reply = phpiredis_reader_get_reply($reader);
if ($reply !== 'ERR') {
    echo "Reply '$reply' != 'ERR' on line ".__LINE__." \n";
}

phpiredis_reader_set_error_handler($reader, 'error_handler');
phpiredis_reader_feed($reader, "-ERR\r\n");
$reply = phpiredis_reader_get_reply($reader);
if ($reply != $expectedErrorText) {
    echo "Reply '$reply' != '$expectedErrorText' on line ".__LINE__." \n";
}

$failResult = @phpiredis_reader_set_error_handler($reader, 'fake_error_handler');
if ($failResult !== FALSE) {
    echo "Did not get FALSE when creating a fake_error_handler \n";
}

phpiredis_reader_feed($reader, "-ERR\r\n");
$reply = phpiredis_reader_get_reply($reader);
if ($reply != $expectedErrorText) {
    echo "Reply '$reply' is not equal to '$expectedErrorText' on line ".__LINE__." \n";
}

$result = phpiredis_reader_set_error_handler($reader, NULL);
if ($result !== TRUE) {
    echo "Result '$result' is not true when setting NULL error handler'";
}

phpiredis_reader_feed($reader, "-ERR\r\n");
$reply = phpiredis_reader_get_reply($reader);
if ($reply !== 'ERR') {
    echo "Reply '$reply' is not equal to 'ERR' on line ".__LINE__." \n";
}

--EXPECT--

Directory Contents

Dirs: 0 × Files: 30

Name Size Perms Modified Actions
283 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
321 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
510 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
389 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
378 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
534 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
445 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
651 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
425 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
469 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
466 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
257 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
1.07 KB lrw-r--r-- 2023-05-18 13:46:45
Edit Download
1.17 KB lrw-r--r-- 2023-05-18 13:46:45
Edit Download
540 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
824 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
1.44 KB lrw-r--r-- 2023-05-18 13:46:45
Edit Download
951 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
860 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
538 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
446 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
571 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
371 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
699 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
240 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
353 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
118 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
146 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
645 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download
682 B lrw-r--r-- 2023-05-18 13:46:45
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).