verze-app / solana-php-sdk

Simple PHP SDK for Solana JSON RPC endpoints
MIT License
88 stars 45 forks source link

Check for missing account data #6

Closed exzachlyvv closed 3 years ago

exzachlyvv commented 3 years ago

Closes #5 - throw an exception if we got a null response.

In the PR, I also added guzzle and orchestra testbench dependencies. This allows us to test the Http facade from unit tests.

exzachlyvv commented 3 years ago

This is actually really helpful for when the Http validation code asserts that the same random int was returned.

if ($response['id'] !== $this->randomKey) {
    throw new InvalidIdResponseException();
}

I like the idea of unit testing down to the Http level.

A few solutions come to mind:

  1. Make the randomInt public so we can reference it in unit tests.
  2. Wrap the randomInt in some Facade so we can mock an expected values in unit tests.

What do you think?

mattstauffer commented 3 years ago

I think public gettable probably is the simplest

exzachlyvv commented 3 years ago

Got this one cleaned up 💪