GithubHelp home page GithubHelp logo

wp-stubs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

wp-stubs's Issues

[Feature Request]: support WP constants

Is your feature request related to a problem?

The stubs does not include WP constants like DAY_IN_SECONDS so we get psalm issues in our PR's

Describe the desired solution

A file with WP defined constants is included into latest.php

Describe the alternatives that you have considered

havent thought in an alternative

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Add more utilities to stub WordPress functions in wp-stubs

Right now, WP Stubs already covers all those functions that you have to stubs in 90% of the cases, when you write enough unit tests for your code.

However, there are many functions that are not used so often, but still they are used quite enough and same enough to avoid duplication in every unit test setup.

Here's a link of all the functions I've spotted.

home_url()

Also if this function is very simple and in most of the case the stub only returns a static string, it is used really a lot and in many cases it must be stubbed with a callback usage.

Examples of usage here.

sanitize_text_field()

This is used quite often as well, however I see that sometimes it is aliased with a callback very specific to a single test, so maybe it needs to be called in a separate function?

Examples of usage here.

wp_validate_boolean()

Also if this is one of the less stubbed, I believe we can assume it always will need the same alias, so probably it worth to be centralized as well.

Example of usage here.

add_query_arg()

This isn't very used neither, but it's very boring to stub if you need to alias it.

Examples of usage here and here.

wp_slash()

Again, not used so often but very simple to centralize in my opinion.

How to proceed

I think that one of the important things to decide, in addition to specific aliases, is how to "group" the stubs. Right now, the package provides the functions stubTranslationFunctions() and stubEscapeFunctions() and we can assume that if I need one of the functions stubbed there, then I need also the others. However, about the functions named above, I could want a generic alias for certain functions but some specific alias created by me for others, and I am not sure that the package allows to "override" the alias in some way.

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.