net_version
This commit is contained in:
parent
a512883519
commit
65734f1d7f
72
test/unit/NetTest.php
Normal file
72
test/unit/NetTest.php
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Test\Unit;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
|
use Test\TestCase;
|
||||||
|
|
||||||
|
class NetTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* net
|
||||||
|
*
|
||||||
|
* @var Web3\Net
|
||||||
|
*/
|
||||||
|
protected $net;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setUp
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->net = $this->web3->net;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testVersion
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testVersion()
|
||||||
|
{
|
||||||
|
$net = $this->net;
|
||||||
|
|
||||||
|
$net->version(function ($err, $version) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
if (isset($version->result)) {
|
||||||
|
$this->assertTrue(is_string($version->result));
|
||||||
|
} else {
|
||||||
|
$this->fail($version->error->message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testUnallowedMethod
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testUnallowedMethod()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$net = $this->net;
|
||||||
|
|
||||||
|
$net->hello(function ($err, $hello) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
if (isset($hello->result)) {
|
||||||
|
$this->assertTrue(true);
|
||||||
|
} else {
|
||||||
|
$this->fail($hello->error->message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user