Esempio n. 1
0
 protected function createMockRequest($url = 'http://localhost:3000/', $response_file = 'test_ok.txt')
 {
     $errornot = Services_ErrorNot::getInstance(true)->setUrl($url)->setApi('test-key');
     $mock_network = createMockRequest($response_file, 'MyMockAdapter');
     $errornot->setNetworkAdapter($mock_network);
     return array($errornot, $mock_network);
 }
<?php

require_once 'HTTP/Request2.php';
require_once dirname(__FILE__) . '/../errornot.php';
require_once 'mock.php';
function myExceptionHandler($e)
{
    if ($e->getMessage() == 'test') {
        exit(3);
    }
    exit(4);
}
set_exception_handler('myExceptionHandler');
class MockAdapterWithNotify extends Http_Request2_Adapter_Mock
{
    public function sendRequest(HTTP_Request2 $request)
    {
        return $this->createResponseFromString("HTTP/1.1 200 OK\nServer: Apache\nOK\n");
    }
}
$mock_network = createMockRequest('test_ok.txt', 'MockAdapterWithNotify');
$errornot = Services_ErrorNot::getInstance(true)->setUrl('http://localhost:3000/')->setApi('test-key')->registerExceptionHandler()->setNetworkAdapter($mock_network);
throw new Exception('test');
exit(0);