<?php

namespace BitPaySDK\Test\Exceptions;

use BitPaySDK\Exceptions\InvoicePaymentException;
use PHPUnit\Framework\TestCase;

class InvoicePaymentExceptionTest extends TestCase
{

  public function testDefaultApiCode()
  {
    $exception = $this->createClassObject();
    
    $this->assertEquals('000000', $exception->getApiCode());
  }

  public function testInstanceOf()
  {
    $exception = $this->createClassObject();
    $this->assertInstanceOf(InvoicePaymentException::class, $exception);
  }

  public function testDefaultMessage()
  {
    $exception = $this->createClassObject();
    
    $this->assertEquals(
      'BITPAY-INVOICE-PAY-UPDATE: Failed to pay invoice-> ',
      $exception->getMessage()
    );
  }

  public function testDefaultCode()
  {
    $exception = $this->createClassObject();
    
    $this->assertEquals(107, $exception->getCode());
  }

  public function testGetApiCode()
  {
    $exception = new InvoicePaymentException(
      'My test message',
      107,
      null,
      'CUSTOM-API-CODE'
    );

    $this->assertEquals('CUSTOM-API-CODE', $exception->getApiCode());
  }

  private function createClassObject()
  {
    return new InvoicePaymentException();
  }
}