<?php
namespace Liaison\Test\Disabled;
/**
* For this to work with method calls that are not found, you need to set an error handler & throw an ErrorException like:
* ```
* public function throwError($errno, $errstr, $errfile, $errline) {
* throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
* }
* ```
*/
class ExceptionCatcher extends \Tlf\Tester {
public function testCatchMethodNotFound(){
// due to significant internal changes, i think the exception catcher would need to change. idk. don't care right now.
$this->disable();
return;
$method_name = 'nahnahnah';
$ns = 'catch-test';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$addon = new \Lia\Addon($package);
$lia->addMethod('xyz', function(){return 'xyz';});
$lia->addMethod($ns.'.def', function(){return 'def';});
$lia->addMethod($ns.'.addon.abc', function(){return 'abc';});
try {
$line = __LINE__ + 1;
$addon->$method_name();
} catch (\Exception $e){
ob_start();
\Lia\ExceptionCatcher::message($e);
$output = ob_get_clean();
}
echo "\n\n##### output message:\n";
echo $output;
$this->str_contains($output, "Message: Api method `${method_name}` does note exist on Lia");
$this->str_contains($output, '- File: ' . __FILE__);
$this->str_contains($output, '- Line: '. $line);
$this->str_contains($output, '- Function: __call');
}
}