Bitpay\Client\ClientTest::testCreatePayout PHP Метод

testCreatePayout() публичный Метод

public testCreatePayout ( )
    public function testCreatePayout()
    {
        $currency = $this->getMockCurrency();
        $currency->method('getCode')->will($this->returnValue('USD'));
        $token = $this->getMockToken();
        $payout = new \Bitpay\Payout();
        $payout->setCurrency($currency)->setEffectiveDate("1415853007000")->setPricingMethod('bitcoinbestbuy')->setNotificationUrl('https://bitpay.com')->setNotificationEmail('[email protected]')->setPricingMethod('bitcoinbestbuy')->setReference('your reference, can be json')->setAmount(5625)->setToken($token);
        $btc_amounts = array(\Bitpay\PayoutInstruction::STATUS_UNPAID => null, \Bitpay\PayoutInstruction::STATUS_PAID => '0');
        $instruction0 = new \Bitpay\PayoutInstruction();
        $instruction0->setId('Sra19AFU57Rx53rKQbbRKZ')->setAmount(1875)->setLabel('2')->setStatus(\Bitpay\PayoutInstruction::STATUS_UNPAID)->setBtc($btc_amounts)->setAddress('mzzsJ8G9KBmHPPVYaMxpYRetWRRec78FvF');
        $instruction1 = new \Bitpay\PayoutInstruction();
        $instruction1->setId('5SCdU1xNsEwrUFqKChYuAR')->setAmount(1875)->setLabel('3')->setStatus(\Bitpay\PayoutInstruction::STATUS_UNPAID)->setBtc($btc_amounts)->setAddress('mre3amN8KCFuy7gWCjhFXjuqkmoJMkd2gx');
        $instruction2 = new \Bitpay\PayoutInstruction();
        $instruction2->setId('5cHNbnmNuo8gRawnrFZsPy')->setAmount(1875)->setLabel('4')->setStatus(\Bitpay\PayoutInstruction::STATUS_UNPAID)->setBtc($btc_amounts)->setAddress('mre3amN8KCFuy7gWCjhFXjuqkmoJMkd2gx');
        $payout->addInstruction($instruction0)->addInstruction($instruction1)->addInstruction($instruction2);
        $response = $this->getMockResponse();
        $response->method('getBody')->willReturn(file_get_contents(__DIR__ . '/../../DataFixtures/payouts/7m7hSF3ws1LhnWUf17CXsJ.json'));
        $adapter = $this->getMockAdapter();
        $adapter->method('sendRequest')->willReturn($response);
        $this->client->setAdapter($adapter);
        $payout = $this->client->createPayout($payout);
        $this->assertInstanceOf('Bitpay\\PayoutInterface', $payout);
        $this->assertEquals('7m7hSF3ws1LhnWUf17CXsJ', $payout->getId());
        $this->assertEquals('Lwbnf9XAPCxDmy8wsRH3ct', $payout->getAccountId());
        $this->assertEquals(\Bitpay\Payout::STATUS_NEW, $payout->getStatus());
        $this->assertEquals(5625, $payout->getAmount());
        $this->assertEquals(null, $payout->getRate());
        $this->assertEquals(null, $payout->getBtcAmount());
        $this->assertEquals('bitcoinbestbuy', $payout->getPricingMethod());
        $this->assertEquals('your reference, can be json', $payout->getReference());
        $this->assertEquals('1415853007000', $payout->getEffectiveDate());
        $this->assertEquals('https://bitpay.com', $payout->getNotificationUrl());
        $this->assertEquals('[email protected]', $payout->getNotificationEmail());
        $this->assertEquals('8mZ37Gt91Wr7GXGPnB9zj1zwTcLGweRDka4axVBPi9Uxiiv7zZWvEKSgmFddQZA1Jy', $payout->getResponseToken());
        $instructions = $payout->getInstructions();
        $this->assertSame($instruction0, $instructions[0]);
        $this->assertSame($instruction1, $instructions[1]);
        $this->assertSame($instruction2, $instructions[2]);
    }