YCTest.php 1.86 KB
<?php 
namespace Yjtec\LaravelCloud\Tests;
use PHPUnit\Framework\TestCase;
use Yjtec\LaravelCloud\YC;
class YCTest extends TestCase{

    public function testGatewayHasNoKey(){
        $gateway = 'http://www.hnyjkj.com';
        $yc = new YC([
            'http' => [
                'gateway' => [
                    'uri' => $gateway
                ]
            ]
        ]);

        $this->assertEquals($gateway,$yc->gateway());
        $this->assertEquals($gateway.'/'.'scenter',$yc->gateway('scenter'));
    }

    public function testGatewayHasKey(){
        $gateway = 'http://www.hnyjkj.com';
        $scenter = 'http://inner.scenter.360vrsh.com';
        $yc = new YC([
            'http' => [
                'gateway' => [
                    'uri' => $gateway
                ],
                'scenter' => [
                    'gateway' => $scenter
                ]
            ]
        ]);
        $this->assertEquals($scenter,$yc->gateway('scenter'));
    }

    public function testHttp(){
        $gateway = 'http://www.hnyjkj.com';
        $scenter = 'http://inner.scenter.360vrsh.com';
        $yc = new YC([
            'http' => [
                'gateway' => [
                    'uri' => $gateway
                ],
                'scenter' => [
                    'uri' => $scenter
                ]
            ]
        ]);
        $this->assertEquals($scenter,$yc->http('scenter'));
    }

    public function testRpcWithValue(){
        $yc = new YC([
            'rpc' => [
                'scenter' => [
                    'uri' => 'tcp://89.89.89.89:9000'
                ]
            ]
        ]);

        $this->assertEquals('tcp://89.89.89.89:9000',$yc->rpc('scenter'));
    }

    public function testRpcWithEmpty(){
        $yc = new YC([
            'rpc' => []
        ]);
        $this->assertEquals('tcp://127.0.0.1',$yc->rpc('scenter'));
    }
}