I've already write successfully a Web-Api unit test for a Custom API. But I'm wondering if there is a way to automatically create a Mock for input data for the API?

For example, AccountManagement have:

     * Create customer account. Perform necessary business operations like sending email.
     * @param \Magento\Customer\Api\Data\CustomerInterface $customer
     * @param string $password
     * @param string $redirectUrl
     * @return \Magento\Customer\Api\Data\CustomerInterface
     * @throws \Magento\Framework\Exception\LocalizedException
    public function createAccount(
        \Magento\Customer\Api\Data\CustomerInterface $customer,
        $password = null,
        $redirectUrl = ''

There a way to create a Mock for the CustomerInterface using PHPUnit?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.