Comments (14)
@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.
I vote for option 1.
from zubr.
Should be a must for every PR.
from zubr.
I would have to agree. Does anyone feels like having a go at it..?
from zubr.
Fine with me. :-)
from zubr.
@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.
PHPUnit might work as well..?
from zubr.
AFAIR PHPUnit is not able to mock native functions.
As I see it we have two options
- find something that can mock native functions and write tests based on that (eg. Kahlan)
- 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.
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.
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.
@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.
@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.
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.
Closing this since we now have tests thanks to @radmen (#89).
from zubr.
Related Issues (20)
- Double-check Composer file
- `array_column` PSR2 errors
- Doc block guidelines HOT 7
- Slack
- Zubr isn't bundled with PHP HOT 4
- Implement validator tool HOT 2
- Automate adding functions and tests HOT 11
- xxxx
- Add test for array_count_values()
- array_change_key_case() has wrong default value
- array_change_key_case() has wrong doc format
- array_chunk() has wrong doc format
- array_chunk() has wrong doc format HOT 1
- array_combine() has wrong doc format
- Add test for array_fill_keys()
- Add test for array_fill()
- Add test for array_flip()
- Add test for array_keys()
- Remove dist folder? HOT 6
- Add a performance readme entry HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zubr.