[svn:PHP-Sandwich] rev 1406 - in PHP-Sandwich/trunk: . PHP t

[email protected] 19 Jul 2005 13:36:05 -0000
Newsgroups perl.php.sandwich.dev
Message-ID <[email protected]>
Author: gschlossnagle
Date: Tue Jul 19 06:36:04 2005
New Revision: 1406

Modified:
   PHP-Sandwich/trunk/PHP.xs
   PHP-Sandwich/trunk/PHP/Interpreter.pm
   PHP-Sandwich/trunk/phpfuncs.c
   PHP-Sandwich/trunk/t/1.t
   PHP-Sandwich/trunk/t/14.t
   PHP-Sandwich/trunk/t/18.t
   PHP-Sandwich/trunk/t/19.t
   PHP-Sandwich/trunk/t/3.t
   PHP-Sandwich/trunk/t/4.t
   PHP-Sandwich/trunk/t/5.t
   PHP-Sandwich/trunk/t/7.t
Log:
some test cleanups


Modified: PHP-Sandwich/trunk/PHP.xs
==============================================================================
--- PHP-Sandwich/trunk/PHP.xs	(original)
+++ PHP-Sandwich/trunk/PHP.xs	Tue Jul 19 06:36:04 2005
@@ -535,7 +535,7 @@ SV *SAND_include(interp, file)
   OUTPUT:
     RETVAL
 
-SV *SAND_call(method_name, interp, ...)
+SV *SAND_call(interp, method_name, ...)
   PHP_Interpreter interp;
   char *method_name;
   CODE:

Modified: PHP-Sandwich/trunk/PHP/Interpreter.pm
==============================================================================
--- PHP-Sandwich/trunk/PHP/Interpreter.pm	(original)
+++ PHP-Sandwich/trunk/PHP/Interpreter.pm	Tue Jul 19 06:36:04 2005
@@ -6,8 +6,10 @@ use vars qw($VERSION @ISA @EXPORT @EXPOR
 
 sub AUTOLOAD {
   my $sub = $AUTOLOAD;
+  my $self = shift;
   $sub =~ s/.*:://;
   unshift @_, $sub;
+  unshift @_, $self;
   goto &call;
 }
 

Modified: PHP-Sandwich/trunk/phpfuncs.c
==============================================================================
--- PHP-Sandwich/trunk/phpfuncs.c	(original)
+++ PHP-Sandwich/trunk/phpfuncs.c	Tue Jul 19 06:36:04 2005
@@ -109,21 +109,23 @@ PHP_METHOD(perl, getvariable)
   aTHX = pl->perl;
 #endif
   var = NULL;
-  
-  switch (name[0]) {
-    case '$':
-      var =  get_sv(name + 1, FALSE);
-      break;
-    case '@':
-      var = (SV *) get_av(name + 1, FALSE);
-      break;
-    case '%':
-      var = (SV *) get_hv(name + 1, FALSE);
-      break;
-    default:
-      RETURN_NULL();
+  if(strchr(name, '[') || strchr(name, '{')) {
+    var = eval_pv(name, FALSE);
+  } else {
+    switch (name[0]) {
+      case '$':
+        var =  get_sv(name + 1, FALSE);
+        break;
+      case '@':
+        var = (SV *) get_av(name + 1, FALSE);
+        break;
+      case '%':
+        var = (SV *) get_hv(name + 1, FALSE);
+        break;
+      default:
+        RETURN_NULL();
+    }
   }
-      
   if (var != NULL) {
     retval = SvZval(var TSRMLS_CC);
     RETURN_ZVAL(retval, 1, 0);

Modified: PHP-Sandwich/trunk/t/1.t
==============================================================================
--- PHP-Sandwich/trunk/t/1.t	(original)
+++ PHP-Sandwich/trunk/t/1.t	Tue Jul 19 06:36:04 2005
@@ -6,7 +6,9 @@ BEGIN {
     use_ok 'PHP' or die;
     use_ok 'PHP::Interpreter' or die;
 }
-
+# weird hack for include path
+chdir('t');
 ok my $p = new PHP::Interpreter(), "Create new PHP interpreter";
-ok my $a1 = $p->include('/home/george/PHP-Sandwich/trunk/t/test.inc')->call('ident', 1), "Including a PHP file and executing a function off it";
+ok $p->include('test.inc');
+my $a1 = $p->call('ident', 1), "Including a PHP file and executing a function off it";
 is $a1, 1, 'We should get the proper value from the ident() function';

Modified: PHP-Sandwich/trunk/t/14.t
==============================================================================
--- PHP-Sandwich/trunk/t/14.t	(original)
+++ PHP-Sandwich/trunk/t/14.t	Tue Jul 19 06:36:04 2005
@@ -18,19 +18,19 @@ ok my $p = PHP::Interpreter->new, "Creat
 ok $p->eval(q/
     function foo() {
         $perl = Perl::getInstance();
-        $value = $perl->getVariable('@var');
+        $value = $perl->getVariable('@main::var');
         return $value;
     }
     function bar() {
         $perl = Perl::getInstance();
-        $value = $perl->getVariable('$var[0]');
+        $value = $perl->getVariable('$main::var[0]');
         return $value;
     }
 /), 'Define PHP function that returns Perl values';
-my @phpval = $p->foo();
-ok $phpval[0] == 'hello', 'Check return value of PHP foo()';
-my $phpval = $p->bar();
-ok $phpval == 'hello', 'Check return value of PHP bar()';
+my $phpval = $p->foo();
+ok $phpval->[0] eq 'hello', 'Check return value of PHP foo()';
+$phpval = $p->bar();
+ok $phpval eq 'hello', 'Check return value of PHP bar()';
 ok $p->eval(q/
   $a = new StdClass();
   $a->name = 'george';

Modified: PHP-Sandwich/trunk/t/18.t
==============================================================================
--- PHP-Sandwich/trunk/t/18.t	(original)
+++ PHP-Sandwich/trunk/t/18.t	Tue Jul 19 06:36:04 2005
@@ -1,6 +1,5 @@
-#!/opt/ecelerity/3rdParty/bin/perl
 use strict;
-use Test::More tests => 6;
+use Test::More tests => 7;
 
 BEGIN {
     diag "Testing Passing interpreter globals";

Modified: PHP-Sandwich/trunk/t/19.t
==============================================================================
--- PHP-Sandwich/trunk/t/19.t	(original)
+++ PHP-Sandwich/trunk/t/19.t	Tue Jul 19 06:36:04 2005
@@ -1,6 +1,6 @@
 #!/opt/ecelerity/3rdParty/bin/perl
 use strict;
-use Test::More tests => 6;
+use Test::More tests => 15;
 
 BEGIN {
     diag "Testing Output Buffering";
@@ -41,7 +41,7 @@ is $output, 'data', 'check output buffer
 
 my $output2;
 sub pr { $output2 .= @_[0]; }
-ok my $p = PHP::Interpreter->new(
+ok $p = PHP::Interpreter->new(
   {
     'BRIC' => 
       {'special' => 'data',},

Modified: PHP-Sandwich/trunk/t/3.t
==============================================================================
--- PHP-Sandwich/trunk/t/3.t	(original)
+++ PHP-Sandwich/trunk/t/3.t	Tue Jul 19 06:36:04 2005
@@ -9,10 +9,10 @@ BEGIN {
 }
 
 diag "Testing passing Perl AVs to PHP functions.";
-
+# weird include path hack
+chdir('t');
 ok my $p = PHP::Interpreter->new, "Create new PHP interpreter";
-ok $p->include('/home/george/PHP-Sandwich/trunk/t/test.inc');
-  'include PHP testing suite';
+ok $p->include('test.inc'), 'include PHP testing suite';
 my @list = ('I', 'AM', 'AN', 'ARRAY');
 ok my $newlist = $p->ident(\@list), 'Pass an AV into PHP, return an AV.';
 is_deeply $newlist, \@list, "Checking arrays are identical.";

Modified: PHP-Sandwich/trunk/t/4.t
==============================================================================
--- PHP-Sandwich/trunk/t/4.t	(original)
+++ PHP-Sandwich/trunk/t/4.t	Tue Jul 19 06:36:04 2005
@@ -1,6 +1,4 @@
-#!/opt/ecelerity/3rdParty/bin/perl 
 use strict;
-#use ExtUtils::testlib;
 use Test::More tests => 6;
 
 BEGIN {
@@ -10,8 +8,10 @@ BEGIN {
 
 diag "Test pashing hashes from Perl->PHP->Perl";
 
+# weird include path hack
+chdir('t');
 ok my $p = new PHP::Interpreter(), "Create new PHP interpreter";
-ok $p->include('/home/george/PHP-Sandwich/trunk/t/test.inc'), "include() PHP testing functions.";
+ok $p->include('test.inc'), "include() PHP testing functions.";
 my $hash = { 'a' => 'alpha', 'b' => 'beta', 'c' => 'charlie' };
 ok my $arg = $p->ident($hash), "Pass a hash into PHP, recieve a hash back";
 

Modified: PHP-Sandwich/trunk/t/5.t
==============================================================================
--- PHP-Sandwich/trunk/t/5.t	(original)
+++ PHP-Sandwich/trunk/t/5.t	Tue Jul 19 06:36:04 2005
@@ -9,8 +9,10 @@ BEGIN {
   use_ok 'PHP::Interpreter' or die;
 }
 
+# weird include path hack
+chdir('t');
 ok my $p = new PHP::Interpreter(), "Creating a new PHP::Interpreter.";
-ok $p->include('/home/george/PHP-Sandwich/trunk/t/test.inc'), "including PHP testing functions.";
+ok $p->include('test.inc'), "including PHP testing functions.";
 my @list = ('I', 'AM', 'AN', ['NESTED', 'ARRAY']);
 ok my $arg = $p->ident(\@list), "Pass in a nested array and return it.";
 is_deeply $arg, \@list, "Testing that return array equals passed array.";

Modified: PHP-Sandwich/trunk/t/7.t
==============================================================================
--- PHP-Sandwich/trunk/t/7.t	(original)
+++ PHP-Sandwich/trunk/t/7.t	Tue Jul 19 06:36:04 2005
@@ -1,19 +1,21 @@
 #!/opt/ecelerity/3rdParty/bin/perl 
 use strict;
-use Test::More tests => 8;
+use Test::More tests => 9;
 
 BEGIN {
     diag '3 ways of calling methods.';
     use_ok 'PHP' or die;
     use_ok 'PHP::Interpreter' or die;
 }
-my $inc = '/home/george/PHP-Sandwich/trunk/t/test.inc';
+my $inc = 'test.inc';
+# weird include path hack
+chdir('t');
 ok my $p = new PHP::Interpreter(), "Create new PHP interpreter";
 ok my $a1 = $p->include($inc)->call('ident', 1), 
   "Including a PHP file and executing a function off iti via call";
 
 ok my $p2 = new PHP::Interpreter(), "Create new PHP interpreter";
-ok my $a1 = $p2->include($inc)->ident(1), 
+ok $a1 = $p2->include($inc)->ident(1), 
   "Including a PHP file and executing a function off iti via AUTOLOAD";
 
 ok my $p3 = new PHP::Interpreter(), "Create new PHP interpreter";