lua callbacks are now object bound
[phplua.git] / tests / 012.phpt
blob6c86ec1e1482fd0c93987b5f4201fea5759ace15
1 --TEST--
2 Calling PHP class methods from LUA
3 --SKIPIF--
4 <?php if (!extension_loaded("lua")) print "skip"; ?>
5 --FILE--
6 <?php
7 class test
9   protected $x=0;
11   public function test()
12   {
13     print ($this->x++).": ".str_repeat("test",10)."\n";
14   }
17 function two()
19   print str_repeat("two",10)."\n";
23 function one($x,$y,$z)
25   var_dump($x,$y,$z);
26   print str_repeat("one",10)."\n";
27   return "test";
29 $test=new test;
31 $lua=new lua;
32 $lua->expose_function("php_one","one");
33 $lua->expose_function("php_two","two");
34 $lua->expose_function("php_three",array($test,"test"));
35 $lua->evaluatefile(dirname(__FILE__)."/012.lua");
36 var_dump($lua->peter);
38 --EXPECTF--
39 0: testtesttesttesttesttesttesttesttesttest
40 string(7) "string1"
41 float(5)
42 string(7) "string2"
43 oneoneoneoneoneoneoneoneoneone
44 test
45 string(4) "hmmm"
46 float(5)
47 string(4) "test"
48 oneoneoneoneoneoneoneoneoneone
49 test
50 1: testtesttesttesttesttesttesttesttesttest
51 twotwotwotwotwotwotwotwotwotwo
52 2: testtesttesttesttesttesttesttesttesttest
53 bool(true)