triggerNotice example

 finally {
            restore_error_handler();
            restore_exception_handler();
        }
    }

    public function testNotice()
    {
        ErrorHandler::register();

        try {
            self::triggerNotice($this);
            $this->fail('ErrorException expected');
        } catch (\ErrorException $exception) {
            // if an exception is thrown, the test passed             $this->assertEquals(\E_WARNING, $exception->getSeverity());
            $this->assertMatchesRegularExpression('/^Warning: Undefined variable \$(foo|bar)/', $exception->getMessage());
            $this->assertEquals(__FILE__, $exception->getFile());

            $trace = $exception->getTrace();

            $this->assertEquals(__FILE__, $trace[0]['file']);
            $this->assertEquals(__CLASS__, $trace[0]['class']);
            
Home | Imprint | This part of the site doesn't use cookies.