ExceptionCatcher.php

<?php

namespace Liaison\Test;


class ExceptionCatcher extends \Taeluf\Tester {

    public function testCatchMethodNotFound(){
        $ns = 'catch-test';
        $lia = new \Lia();
        $package = new \LiaProto\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->xyz();
        } catch (\Exception $e){
            ob_start();
            \LiaProto\Catcher::message($e);
            $output = ob_get_clean();
        }
        echo "\n\n##### output message:\n";
        echo $output;
        $this->str_contains($output, 'Message: Api method `xyz` does note exist on Lia');
        $this->str_contains($output, '- File: ' . __FILE__);
        $this->str_contains($output, '- Line: '. $line);
        $this->str_contains($output, '- Function: __call');

    }

}