Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
MultiReturnerTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Ethereum;
4 
6 
13 {
14 
23  public function testGetBoolean()
24  {
25  $result = $this->contract->getBoolean();
26  $this->assertEquals(true, $result->val());
27  }
28 
37  public function testGetInteger()
38  {
39  $result = $this->contract->getInteger();
40  $this->assertEquals(99, $result->val());
41  }
42 
51  public function testGetBytes1()
52  {
53  $result = $this->contract->getBytes1();
54  // @todo THIS IS WRONG Solidity will give me a 0x61. So we should cut off at "61"
55  // $this->assertEquals('6100000000000000000000000000000000000000000000000000000000000000', $result->val());
56  $this->assertEquals('61', $result->val());
57  }
58 
59  public function testGetBytes8()
60  {
61  $result = $this->contract->getBytes8();
62  $this->assertEquals('6161616161616161', $result->val());
63  }
64 
65 
66  public function testGetBytes16()
67  {
68  $result = $this->contract->getBytes16();
69  $this->assertEquals('61616161616161616161616161616161', $result->val());
70  }
71 
80  public function testGetBytes32()
81  {
82  $result = $this->contract->getBytes32();
83  $this->assertEquals('6162630000000000000000000000000000000000000000000000000000000000',
84  $result->val());
85  }
86 
95  public function testGetBytes()
96  {
97  $result = $this->contract->getBytes();
98  $this->assertEquals('616263', $result->val());
99  }
100 
106  public function testGetBytesLong()
107  {
108  $result = $this->contract->getBytesLong();
109  $this->assertEquals('616263616263616263636162636162636162636361626361626361626363616263616263616263636162636162636162636361626361626361626363',
110  $result->val());
111  }
112 
122  public function testGetTwoBytes32()
123  {
124  $result = $this->contract->getTwoBytes32();
125 
126  $a = $result[0]->val() === '6162630000000000000000000000000000000000000000000000000000000000';
127  $b = $result[1]->val() === '78797a0000000000000000000000000000000000000000000000000000000000';
128  $expect = ($a && $b);
129  $this->assertTrue($expect);
130  }
131 
139  public function testGetDynamicDataMixedTwo()
140  {
141  $result = $this->contract->getDynamicDataMixedTwo();
142 
143  $this->assertEquals('78797a0000000000000000000000000000000000000000000000000000000000',
144  $result[0]->val());
145  $this->assertEquals('616263', $result[1]->val());
146  }
147 
155  public function testGetDynamicData()
156  {
157  $result = $this->contract->getDynamicData();
158  $this->assertEquals('616263', $result[0]->val());
159  $this->assertEquals('78797a', $result[1]->val());
160  }
161 
170  public function testGetDynamicTripple()
171  {
172  $result = $this->contract->getDynamicTripple();
173  $this->assertEquals('616263', $result[0]->val());
174  $this->assertEquals('646566', $result[1]->val());
175  $this->assertEquals('676869', $result[2]->val());
176  }
177 
185  public function testGetDynamicDataMixedOne()
186  {
187  $result = $this->contract->getDynamicDataMixedOne();
188  $this->assertEquals('616263', $result[0]->val());
189  $this->assertEquals('78797a0000000000000000000000000000000000000000000000000000000000', $result[1]->val());
190  }
191 
192 
198  public function testUndefinedMethod()
199  {
200  $exception_message_expected = 'Called undefined contract method: testUndefined.';
201  try {
202  $x = new EthS('Hello!!');
203  $this->contract->testUndefined($x);
204  } catch (\Exception $exception) {
205  $this->assertEquals($exception->getMessage(),
206  $exception_message_expected);
207  }
208  }
209 
210 
217  public function testGetLotsOfBytes()
218  {
219  $result = $this->contract->getLotsOfBytes();
220  $this->assertEquals(
221  '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1',
222  $result->hexVal()
223  );
224  }
225 
226 
239  // @todo Implement Lists.
240 
241 // public function testGetListOfInteger()
242 // {
243 // $result = $this->contract->getListOfInteger();
244 // $VAL = $result->val();
245 // $this->assertEquals(
246 // '--> TBD',
247 // $result->hexVal()
248 // );
249 // }
250 
251 
252 
253 }
Definition: Abi.php:3