GithubHelp home page GithubHelp logo

Comments (7)

akDeveloper avatar akDeveloper commented on July 21, 2024

It seems that you want to test your pluging using some values that are stored in a cookie.

I dont think that you can use cookies in PHPUnit but i am not 100% sure about this, cause PHPUnit use cli command and not http.

You can add a setter method to your plugin where you pass cookies values and use this method in your tests.

from yaf.

pdeszynski avatar pdeszynski commented on July 21, 2024

Yes, but the solution would be a method which would allow me to fake headers for request by overwriting them. In such a case I wouldn't need real cookies support.

Adding setter method in a plugin also it's not a good solution because the code depends on cookies from Yaf_Request, in real app I won't be able to preset these cookies.

from yaf.

akDeveloper avatar akDeveloper commented on July 21, 2024

I see, so in your plugin you use for example $request->getCookies() method.And you want somehow to set some cookies to the Request object for testing right?

Then i think it is better to create a mock subclass of Yaf_Request as you mention in your first post and create setCookies() and getCookies() methods in this class.

from yaf.

pdeszynski avatar pdeszynski commented on July 21, 2024

For now it's done this way. I was wondering if there's better way to do this. It looks like it's currently the only possibility.

from yaf.

akDeveloper avatar akDeveloper commented on July 21, 2024

I think that you use the best way. Mocking classes are common in unit tests and allow flexible testing.

Besides there is no reason to add a setCookies() method in the core Request object, cause Request object should have headers for read only purpose. setCookies() method should have meaning if it was in Response object.

from yaf.

laruence avatar laruence commented on July 21, 2024

:)

from yaf.

pdeszynski avatar pdeszynski commented on July 21, 2024

Ok, I will leave it then this way. Thank you for the response (and sorry for making here the thread but I didn't found any other place where I would be able to ask a question about Yaf).

from yaf.

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.