GithubHelp home page GithubHelp logo

No tests? about zubr HOT 14 CLOSED

radmen avatar radmen commented on July 19, 2024 3
No tests?

from zubr.

Comments (14)

 avatar commented on July 19, 2024 1

@radmen @szepeviktor @nkkollaw what about Kahlan? It allows to stub on php function so it will be easy to test whether functions are proxing the valid php functions. I can wrote some tests today

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024 1

I vote for option 1.

from zubr.

szepeviktor avatar szepeviktor commented on July 19, 2024

Should be a must for every PR.

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

I would have to agree. Does anyone feels like having a go at it..?

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

Fine with me. :-)

from zubr.

radmen avatar radmen commented on July 19, 2024

@damian-dziaduch-gforces Kahlan looks like an interesting choice. I've no experience with this tool, yet if you will prepare an example I'd gladly use it ;)

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

PHPUnit might work as well..?

from zubr.

radmen avatar radmen commented on July 19, 2024

AFAIR PHPUnit is not able to mock native functions.

As I see it we have two options

  1. find something that can mock native functions and write tests based on that (eg. Kahlan)
  2. write tests which simply compare results of wrapper with native functions

Ad. 1
I think this is safer - if mocking library works as intended we will make sure that wrapper function calls the correct function with correct arguments passed.

Ad. 2
This option is less secure - we're checking only results of calls, so it's possible that wrapper function may work in a different matter as wrapped function.

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

So, this is where we got to so far:

@damian-dziaduch-gforces says: Kahlan stubs on php functions works only when you test psr0 / psr4 classes - it mocks composer autoloader. So it will not work with functions

@radmen says: In this case, we can simply create a class with static methods instead of separate functions.

@radmen , that would mean that you like \PHP\PHP::str_pos() better than \PHP\str_pos(), or would you create a wrapper class that just called the function to make Kahlan work?

from zubr.

radmen avatar radmen commented on July 19, 2024

that would mean that you like \PHP\PHP::str_pos() better than \PHP\str_pos(), or would you create a wrapper class that just called the function to make Kahlan work?

I'd create wrapper class only to make Kahlan work :)

Yet, writing a god class (with lots of LOC) is not a good idea. After some time it may be hard to maintain.

Regarding limitations of Kahlan I'm suggesting to keep writing plain wrapper functions and test them with PHPUnit (comparing results of wrapper and wrapped function).

As I imagine the code will go through code-review so we can assume that reviewer will take care of checking if the wrapper is calling the correct function.

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

@radmen : That sounds good to me. Can you create a stub/example and add it to a CONTRIBUTE.md file? You know more about tests than I do. Also, should I add you as a collaborator?

from zubr.

radmen avatar radmen commented on July 19, 2024

@nkkollaw I'm not very good at writing docs. If possible I'd like to leave writing CONTRIBUTE.md to you :)

However, I can create a simple foundation for development - basic structure, one (or two) functions with tests etc.

Also, should I add you as a collaborator?

That's much of responsibility ;) I don't know for now if I'll have enough time for such thing. IMO let's keep things as they are right now.

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

However, I can create a simple foundation for development - basic structure, one (or two) functions with tests etc.

That would be absolutely great. I'll then write the documentation.

from zubr.

nkkollaw avatar nkkollaw commented on July 19, 2024

Closing this since we now have tests thanks to @radmen (#89).

from zubr.

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.