Code Monkey home page Code Monkey logo

Comments (2)

guzzilar avatar guzzilar commented on September 27, 2024

@ahirota Hi, this might not related to the solution that you are looking for, but would you mind to share a case where you want to connect to the real API server for a unit test script? Is there any specific reason to bypass the fixture files?

from omise-php.

ahirota avatar ahirota commented on September 27, 2024

@guzzilar To Preface, I've created a Repository to handle calls to the Omise API. My test suites are all designed to test basic functionality within my application and I'd need to connect to the real API server in order for my tests to pass.

One of my test suites generates a new customer with a customer token, tests creating charges, creating and destroying charge schedules, adding and removing cards from the customer, and then finally removing the customer all together. If I were to use the default fixture files, the act of creating a new customer with email: [email protected] and any other parameters, returns with the response saved in the fixture files.

Here's a code example:

  public function testCustomer()
    {
        // create
        $customer = $this->OmiseRepository->makeCustomer('[email protected]', 333);
        self::assertEquals('[email protected]', $customer->email);

        // delete
        $bool = $this->OmiseRepository->destroyCustomerById($customer->id);
        self::assertTrue($bool);
    }

In this test, both assertions fail because new customer data is never created. The response is always taken from the fixture files. This issue extends to customer tokens and beyond.

I guess my main issue is that I don't want to test the package itself, but rather the extensions and wrappers I've created, and using PHPunit calls _executeTest for any Omise API related functions.

from omise-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.