summaryrefslogtreecommitdiff
path: root/ext/com_dotnet/tests
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/com_dotnet/tests
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/com_dotnet/tests')
-rw-r--r--ext/com_dotnet/tests/27974.phpt43
-rw-r--r--ext/com_dotnet/tests/bug33386.phpt40
-rw-r--r--ext/com_dotnet/tests/bug34272.phpt22
-rw-r--r--ext/com_dotnet/tests/bug39596.phpt23
-rw-r--r--ext/com_dotnet/tests/bug39606.phpt22
-rw-r--r--ext/com_dotnet/tests/bug45280.phpt19
-rw-r--r--ext/com_dotnet/tests/bug49192.phpt27
-rw-r--r--ext/com_dotnet/tests/variants.phpt637
8 files changed, 833 insertions, 0 deletions
diff --git a/ext/com_dotnet/tests/27974.phpt b/ext/com_dotnet/tests/27974.phpt
new file mode 100644
index 0000000..30c42b6
--- /dev/null
+++ b/ext/com_dotnet/tests/27974.phpt
@@ -0,0 +1,43 @@
+--TEST--
+COM: mapping a safearray
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php // $Id$
+error_reporting(E_ALL);
+
+try {
+ $v = new VARIANT(array("123", "456", "789"));
+ var_dump($v);
+ print $v[0] . "\n";
+ print $v[1] . "\n";
+ print $v[2] . "\n";
+ $v[1] = "hello";
+ foreach ($v as $item) {
+ var_dump($item);
+ }
+ try {
+ $v[3] = "shouldn't work";
+ } catch (com_exception $e) {
+ if ($e->getCode() != DISP_E_BADINDEX) {
+ throw $e;
+ }
+ echo "Got BADINDEX exception OK!\n";
+ }
+ echo "OK!";
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+object(variant)#1 (0) {
+}
+123
+456
+789
+string(3) "123"
+string(5) "hello"
+string(3) "789"
+Got BADINDEX exception OK!
+OK!
diff --git a/ext/com_dotnet/tests/bug33386.phpt b/ext/com_dotnet/tests/bug33386.phpt
new file mode 100644
index 0000000..e57f127
--- /dev/null
+++ b/ext/com_dotnet/tests/bug33386.phpt
@@ -0,0 +1,40 @@
+--TEST--
+Bug #33386 (ScriptControl only sees last function of class)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+class twoFuncs {
+ public function func1() { echo " func one\n"; }
+ public function func2() { echo " func two\n"; }
+}
+
+try {
+ $ciTF = new twoFuncs;
+
+ $oScript = new COM("MSScriptControl.ScriptControl");
+ $oScript->Language = "VBScript";
+
+ $oScript->AddObject ("tfA", $ciTF, true);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfA.func$i");
+ $oScript->ExecuteStatement ("func$i");
+ }
+ $oScript->AddObject ("tfB", $ciTF);
+ foreach (array(1,2) as $i) {
+ $oScript->ExecuteStatement ("tfB.func$i");
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+ func one
+ func one
+ func two
+ func two
+ func one
+ func two
diff --git a/ext/com_dotnet/tests/bug34272.phpt b/ext/com_dotnet/tests/bug34272.phpt
new file mode 100644
index 0000000..3a65e2c
--- /dev/null
+++ b/ext/com_dotnet/tests/bug34272.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #34272 (empty array onto COM object blows up)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+try {
+ $dict = new COM("Scripting.Dictionary");
+ $dict->add('foo', array());
+ print sizeof($dict['foo'])."\n";
+ $dict->add('bar', array(23));
+ print sizeof($dict['bar'])." \n";
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+0
+1
diff --git a/ext/com_dotnet/tests/bug39596.phpt b/ext/com_dotnet/tests/bug39596.phpt
new file mode 100644
index 0000000..dc8d1ef
--- /dev/null
+++ b/ext/com_dotnet/tests/bug39596.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #39596 (Creating Variant of type VT_ARRAY)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+try {
+ $binding_string = array('aaa','bbb','ccc');
+ $v = new VARIANT( $binding_string, VT_ARRAY );
+ foreach ($v AS $element) {
+ print $element."\n";
+ }
+} catch (Exception $e) {
+ print $e;
+}
+?>
+--EXPECT--
+aaa
+bbb
+ccc
diff --git a/ext/com_dotnet/tests/bug39606.phpt b/ext/com_dotnet/tests/bug39606.phpt
new file mode 100644
index 0000000..4487c1d
--- /dev/null
+++ b/ext/com_dotnet/tests/bug39606.phpt
@@ -0,0 +1,22 @@
+--TEST--
+COM: Loading typelib corrupts memory
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php // $Id$
+error_reporting(E_ALL);
+
+$arEnv = array_change_key_case($_SERVER, CASE_UPPER);
+
+$root = dirname($arEnv['COMSPEC']);
+$typelib = $root.'\activeds.tlb';
+
+var_dump(com_load_typelib($typelib));
+var_dump(com_load_typelib($typelib));
+?>
+===DONE===
+--EXPECT--
+bool(true)
+bool(true)
+===DONE=== \ No newline at end of file
diff --git a/ext/com_dotnet/tests/bug45280.phpt b/ext/com_dotnet/tests/bug45280.phpt
new file mode 100644
index 0000000..a1f7e18
--- /dev/null
+++ b/ext/com_dotnet/tests/bug45280.phpt
@@ -0,0 +1,19 @@
+--TEST--
+Bug #45280 (Reflection of instantiated COM classes causes PHP to crash)
+--SKIPIF--
+<?php
+if (!extension_loaded("reflection")){ echo "skip, no reflection support present"; }
+if (!extension_loaded("com_dotnet")){ echo "skip COM/.Net support not present"; }
+?>
+--FILE--
+<?php
+$dict = new COM("Scripting.Dictionary");
+
+ob_start();
+ReflectionObject::export($dict);
+ob_get_clean();
+
+echo 'done';
+?>
+--EXPECT--
+done
diff --git a/ext/com_dotnet/tests/bug49192.phpt b/ext/com_dotnet/tests/bug49192.phpt
new file mode 100644
index 0000000..ccbf237
--- /dev/null
+++ b/ext/com_dotnet/tests/bug49192.phpt
@@ -0,0 +1,27 @@
+--TEST--
+Bug #49192 (PHP crashes when GC invoked on COM object)
+--SKIPIF--
+<?php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--XFAIL--
+1
+--FILE--
+<?php
+
+// this test fails to load ADO
+//
+// a change in windows longhorn x64(affecting vista, 7, 8, 2008, 2008r2) broke ADO.
+//
+// there is a fix available, but user has to install it.
+// given that ADO was deprecated a long time ago in favor of newer APIs,
+// I don't think its worth the trouble of making the user install the fix to
+// get an accurate test run. its better to just not run the test or expect it to fail.
+//
+// see: http://support.microsoft.com/kb/2517589
+// see: http://www.infoq.com/news/2011/10/ADO-Win7
+
+$dbConnection = new Com('ADODB.Connection');
+var_dump(gc_collect_cycles());
+?>
+--EXPECT--
+int(0)
diff --git a/ext/com_dotnet/tests/variants.phpt b/ext/com_dotnet/tests/variants.phpt
new file mode 100644
index 0000000..0fd27be
--- /dev/null
+++ b/ext/com_dotnet/tests/variants.phpt
@@ -0,0 +1,637 @@
+--TEST--
+COM: General variant tests
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>
+--FILE--
+<?php // $Id$
+error_reporting(E_ALL);
+
+$v = new VARIANT();
+if (VT_EMPTY != variant_get_type($v)) {
+ echo "VT_EMPTY: bork\n";
+}
+
+$values = array(VT_I4 => 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false);
+$binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div',
+ 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor');
+
+foreach ($values as $t => $val) {
+ $v = new VARIANT($val);
+ if ($t != variant_get_type($v)) {
+ printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val);
+ print $v . "\n";
+ }
+ $results = array();
+
+ foreach ($values as $op2) {
+ echo "--\n";
+ foreach ($binary_ops as $op) {
+ try {
+ echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n";
+ } catch (com_exception $e) {
+ echo "$op:\n";
+ echo "\tvariant_$op($v, $op2)\n";
+ echo "\texception " . $e->getMessage();
+ printf("\tcode %08x\n\n", $e->getCode());
+ }
+ }
+ }
+}
+
+echo "OK!";
+?>
+--EXPECT--
+--
+add: 84
+cat: 4242
+sub: 0
+mul: 1764
+and: 42
+div: 1
+eqv: -1
+idiv: 1
+imp: -1
+mod: 0
+or: 42
+pow: 1.50130937545297E+68
+xor: 0
+--
+add: 45.5
+cat: 423.5
+sub: 38.5
+mul: 147
+and: 0
+div: 12
+eqv: -47
+idiv: 10
+imp: -43
+mod: 2
+or: 46
+pow: 480145.116863642
+xor: 46
+--
+add:
+ variant_add(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+cat: 42hello
+sub:
+ variant_sub(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(42, hello)
+ exception Type mismatch.
+ code 80020005
+
+--
+add: 42
+cat: 42False
+sub: 42
+mul: 0
+and: 0
+div:
+ variant_div(42, )
+ exception Division by zero.
+ code 80020012
+
+eqv: -43
+idiv:
+ variant_idiv(42, )
+ exception Division by zero.
+ code 80020012
+
+imp: -43
+mod:
+ variant_mod(42, )
+ exception Division by zero.
+ code 80020012
+
+or: 42
+pow: 1
+xor: 42
+--
+add: 45.5
+cat: 3.542
+sub: -38.5
+mul: 147
+and: 0
+div: 8.33333333333333E-02
+eqv: -47
+idiv: 0
+imp: -5
+mod: 4
+or: 46
+pow: 7.09345573078604E+22
+xor: 46
+--
+add: 7
+cat: 3.53.5
+sub: 0
+mul: 12.25
+and: 4
+div: 1
+eqv: -1
+idiv: 1
+imp: -1
+mod: 0
+or: 4
+pow: 80.2117802289664
+xor: 0
+--
+add:
+ variant_add(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+cat: 3.5hello
+sub:
+ variant_sub(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(3.5, hello)
+ exception Type mismatch.
+ code 80020005
+
+--
+add: 3.5
+cat: 3.5False
+sub: 3.5
+mul: 0
+and: 0
+div:
+ variant_div(3.5, )
+ exception Division by zero.
+ code 80020012
+
+eqv: -5
+idiv:
+ variant_idiv(3.5, )
+ exception Division by zero.
+ code 80020012
+
+imp: -5
+mod:
+ variant_mod(3.5, )
+ exception Division by zero.
+ code 80020012
+
+or: 4
+pow: 1
+xor: 4
+--
+add:
+ variant_add(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+cat: hello42
+sub:
+ variant_sub(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(hello, 42)
+ exception Type mismatch.
+ code 80020005
+
+--
+add:
+ variant_add(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+cat: hello3.5
+sub:
+ variant_sub(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(hello, 3.5)
+ exception Type mismatch.
+ code 80020005
+
+--
+add: hellohello
+cat: hellohello
+sub:
+ variant_sub(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(hello, hello)
+ exception Type mismatch.
+ code 80020005
+
+--
+add:
+ variant_add(hello, )
+ exception Type mismatch.
+ code 80020005
+
+cat: helloFalse
+sub:
+ variant_sub(hello, )
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(hello, )
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(hello, )
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(hello, )
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(hello, )
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(hello, )
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(hello, )
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(hello, )
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(hello, )
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(hello, )
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(hello, )
+ exception Type mismatch.
+ code 80020005
+
+--
+add: 42
+cat: False42
+sub: -42
+mul: 0
+and: 0
+div: 0
+eqv: -43
+idiv: 0
+imp: -1
+mod: 0
+or: 42
+pow: 0
+xor: 42
+--
+add: 3.5
+cat: False3.5
+sub: -3.5
+mul: 0
+and: 0
+div: 0
+eqv: -5
+idiv: 0
+imp: -1
+mod: 0
+or: 4
+pow: 0
+xor: 4
+--
+add:
+ variant_add(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+cat: Falsehello
+sub:
+ variant_sub(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+mul:
+ variant_mul(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+and:
+ variant_and(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+div:
+ variant_div(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+eqv:
+ variant_eqv(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+idiv:
+ variant_idiv(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+imp:
+ variant_imp(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+mod:
+ variant_mod(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+or:
+ variant_or(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+pow:
+ variant_pow(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+xor:
+ variant_xor(0, hello)
+ exception Type mismatch.
+ code 80020005
+
+--
+add: 0
+cat: FalseFalse
+sub: 0
+mul: 0
+and: 0
+div:
+ variant_div(0, )
+ exception Out of present range.
+ code 8002000a
+
+eqv: -1
+idiv:
+ variant_idiv(0, )
+ exception Division by zero.
+ code 80020012
+
+imp: -1
+mod:
+ variant_mod(0, )
+ exception Division by zero.
+ code 80020012
+
+or: 0
+pow: 1
+xor: 0
+OK!