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

[email protected] 22 Oct 2005 06:41:31 -0000
Newsgroups perl.php.sandwich.dev
Message-ID <[email protected]>
Author: theory
Date: Fri Oct 21 23:41:30 2005
New Revision: 2163

Added:
   PHP-Sandwich/trunk/t/test_symbols.t
Modified:
   PHP-Sandwich/trunk/MANIFEST
Log:
Added some new failing tests and missing files in MANIFEST.

Modified: PHP-Sandwich/trunk/MANIFEST
==============================================================================
--- PHP-Sandwich/trunk/MANIFEST	(original)
+++ PHP-Sandwich/trunk/MANIFEST	Fri Oct 21 23:41:30 2005
@@ -1,5 +1,7 @@
+Changes
 lib/PHP/Interpreter.pm
 lib/PHP/Interpreter/Class.pm
+lib/PHP/Interpreter/Resource.pm
 Makefile.PL
 MANIFEST			This list of files
 META.yml
@@ -34,5 +36,6 @@ t/pod.t
 t/pod_coverage.t
 t/test.inc
 t/test_perl_classes.t
+t/test_symbols.t
 TODO
 typemap

Added: PHP-Sandwich/trunk/t/test_symbols.t
==============================================================================
--- (empty file)
+++ PHP-Sandwich/trunk/t/test_symbols.t	Fri Oct 21 23:41:30 2005
@@ -0,0 +1,38 @@
+#!/opt/ecelerity/3rdParty/bin/perl -w
+use strict;
+use Test::More tests => 10;
+use Test::Builder;
+
+BEGIN {
+    use_ok 'PHP::Interpreter' or die;
+}
+
+my $output;
+ok my $php = PHP::Interpreter->new({
+    OUTPUT => \$output,
+    hash  => { one => 1, two => 2 },
+    array => [1, 2, 3],
+    code  => sub { 'hello' },
+    fh    => *DATA,
+}), 'Create new PHP interpreter with various symbols';
+
+ok $php->eval(q/echo $hash['one'], ', ', $hash['two'];/), 'Access the hash';
+
+is $output, '1, 2', 'Check the hash output';
+$php->clear_output;
+
+ok $php->eval(q/echo implode(', ', $array);/), 'Access the array';
+
+is $output, '1, 2, 3', 'Check the array output';
+$php->clear_output;
+
+$php->eval(q/echo fread($fh, 100)/), 'Access the file handle';
+is $output, 'File handle output.', 'Check the file handle output';
+$php->clear_output;
+
+ok $php->eval(q/code();/), 'Execute the code'; # Maybe $code()?
+is $output, 'hello', 'Check the code output';
+$php->clear_output;
+
+__DATA__
+File handle output.