Papa Joe Dee
Papa Joe Dee

Reputation: 303

How to mock Stripe classes in PHP Codeception

I am trying to mock a simple Stripe\Customer instance in a unit test. The method only uses this instance to retrieve the name property. In my test, the make statement looks like this:

$customer = $this->makeEmpty(Customer::class, ['name' => $cust_nm]);

Codeception returns the following error:

Could not add property name, class Stripe\Customer implements __set method, and no name property exists

I have also tried to use makeEmptyExcept but get the same error message. All I really want is to pass the object to a method and pull a property or two.

Any suggestions?

Upvotes: 1

Views: 607

Answers (1)

Naktibalda
Naktibalda

Reputation: 14120

Don't mock it, simply create an instance and set a property.

$customer = new Customer();
$customer->name = $cust_nm;

Upvotes: 1

Related Questions