Back

Hi #pest experts, I need your help.
I want to integrate tests with pest but as my app makes heavy use of github.com/omniphx/forrest

(an eloquent layer on top of salesforce) and I don't know how to do tests it without having to connect to salesforce.
Would it be possible to fake this calls so I don't have to have a salesforce instance to polute?

2

541

If it's presented as an eloquent driver (i.e. eloquent treats the salesforce API like a database), then you could just use an SQLite database to back those models in tests.

1

593

In response to @samlev

Hmm, this seems very interesting. I'll look into the library to see if it supports it. I'm worried is not but I'll look if I can edit the library to support it. Do you happen to know another driver where it works like that so I can look at code for reference?

1

470

  • No matching results...
  • Searching...

/ 1000

Ok after digging in the code a bit I didn't find how to replace the "database" with sqlite but apparently here: github.com/omniphx/forrest/blob/b9a62e2bd4d3b5e3ddfa779b93d1cf8c86e51b00/src/Omniphx/Forrest/Providers/Laravel/ForrestServiceProvider.php#L27

it instantiates a guzzle http client.

If I remember it correctly, Laravel's Http Client should be an almost drop-in replacement for it (because it wraps it).

I'm thinking that if I replace guzzle with laravel client I should be able to use the Http::fake() function of laravel.

I'm daydreaming or is there a small chance for it to work?

1

536

I've seen it done before on a project that used github.com/PortableStudios/eloquent-zoho

- but that driver is built differently - it completely acts like a database driver (complete with schema builder/migrations) so it can easily be swapped for another database driver for testing or local development.

The eloquent driver that wraps around Forest doesn't seem to be the same type of thing - it swaps out methods in the `Model` instead of actually providing a replacement driver.

1

147

Ah, that kind of driver would be beyond my current knowledge to implement.
I’ll see if I have better luck with the Http::fake() route.
That seems to be the fastest approach and would be ideal, as I’d still like to test which API calls are sent and how they function.
Thank you for the reference, being abble to implement a complete eloquent database driver would be a nice skill to have in the future but is not achievable today due to time constraints.

60