Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
SmartContractBytesTest.php
Go to the documentation of this file.
1 <?php
2 namespace Ethereum;
13 {
21  public function testBytes32Length()
22  {
23  $result = $this->contract->bytes32Length(new EthD32('0x'.md5(1).md5(1)));
24  $this->assertEquals(32, $result->val());
25  }
26 
34  public function testBytesLength()
35  {
36  $x = new EthBytes(md5(1).md5(1).md5(1).md5(1));
37  $y = $this->contract->bytesLength($x);
38  $this->assertEquals(64, $y->val());
39  }
40 
48  public function testBytesReturn()
49  {
50  $someBytes = md5(5) . md5(2) . md5(3) . md5(4);
51  $x = $this->contract->bytesReturn(new EthBytes($someBytes));
52  $this->assertEquals($someBytes, $x->val());
53  }
54 
62  public function testStringReturn()
63  {
64  $str = 'Hello little string.';
65  $strObj = new EthS($str);
66  $hex = $strObj->hexVal();
67  $x = $this->contract->stringReturn($strObj);
68  $this->assertEquals($str, $x->val());
69  }
70 
71 
77  public function testUndefinedMethod()
78  {
79  $exception_message_expected = 'Called undefined contract method: testUndefined.';
80  try {
81  $x = new EthS('Hello!!');
82  $this->contract->testUndefined($x);
83  } catch (\Exception $exception) {
84  $this->assertEquals($exception->getMessage(), $exception_message_expected);
85  }
86  }
87 }
Definition: Abi.php:3