-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added test tests/php_exceptions_007.phpt
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
Test V8::executeString() : PHP Exception handling (throwed inside magic method) | ||
--SKIPIF-- | ||
<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
class SomeClass { | ||
function someMethod($someVariable) { | ||
return $someVariable; | ||
} | ||
|
||
public function triggerException() { | ||
throw new Exception("Some exception"); | ||
} | ||
|
||
public function __get($key) { | ||
$this->triggerException(); | ||
} | ||
} | ||
|
||
function execute($code, $flags = V8Js::FLAG_NONE) { | ||
$js = new V8Js(); | ||
$js->output = new stdClass(); | ||
$js->SomeClassInstance = new SomeClass(); | ||
try { | ||
$js->executeString(" | ||
try { | ||
$code | ||
} catch(e) { | ||
PHP.output.result = 'Caught exception at javascript level : ' + e.getMessage(); | ||
} | ||
", '', $flags); | ||
print($js->output->result.PHP_EOL); | ||
} catch (Exception $e) { | ||
print( "Caught exception at php level : ".$e->getMessage().PHP_EOL); | ||
} | ||
} | ||
|
||
execute("PHP.SomeClassInstance.triggerException();"); | ||
execute("PHP.SomeClassInstance.someMethod(PHP.SomeClassInstance.TriggerMagicMethod);"); | ||
execute("PHP.SomeClassInstance.TriggerMagicMethod;"); | ||
execute("PHP.SomeClassInstance.triggerException();", V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); | ||
execute("PHP.SomeClassInstance.someMethod(PHP.SomeClassInstance.TriggerMagicMethod);", V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); | ||
execute("PHP.SomeClassInstance.TriggerMagicMethod;", V8Js::FLAG_PROPAGATE_PHP_EXCEPTIONS); | ||
?> | ||
===EOF=== | ||
--EXPECTF-- | ||
Caught exception at php level : Some exception | ||
Caught exception at php level : Some exception | ||
Caught exception at php level : Some exception | ||
Caught exception at javascript level : Some exception | ||
Caught exception at javascript level : Some exception | ||
Caught exception at javascript level : Some exception | ||
===EOF=== |