Table of contents:
This is a demo project to provide an example of my skills on object oriented programming using PHP, writing PHPUnit unitary tests and, taking advantage of tools like Composer (a dependency manager for PHP), Git (a distributed version control system) and, the Unix Shell. Also reflects my knowledge of modern development platforms like GitHub (an online source code repositories hub), Codecov (for code coverage insights) and, CircleCI (continuous integration and continuous delivery).
This project has not been wrote in any case thinking to be used in production, but can be used as you wants under your total responsability. You can also fork it and, use as a foundation for your own project if you found it useful.
OoWordpressNonces is a Composer package for WordPress to deal with WordPress Nonces using an Object Oriented Programming approach.
It does not replaces the original WordPress Nonces system, this package is only a wrapper, using an OOP approach, to the original WordPress Nonces functions.
The code is simple, self explanatory and, it is fully documented. On the code source, each class method has a link to the original WordPress function it wraps. For more details you can view the official WordPress documentation for Nonces
You can install OoWordpressNonces by adding this package repository specification to your project's composer.json
file:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/josepcrespo/oo-wordpress-nonces"
}
],
"require": {
"josepcrespo/oo-wordpress-nonces": "master"
}
}
and then run php composer.phar update
.
In this section, you can get the instructions to setup this project on your local machine for development and testing purposes.
Clone the project using Git:
git clone https://github.com/josepcrespo/oo-wordpress-nonces.git
or, download a ZIP file with all the project files: https://github.com/josepcrespo/oo-wordpress-nonces/archive/master.zip
Before starting to install Composer:
- PHP installed on your system is a mandatory requirement. If your development environment runs on macOS, I recommend install it using Homebrew
- Before starting to use Homebrew it is very recommended to have Xcode installed and updated. You can install/update Xcode using the macOS App Store.
- If you are using macOS, you also need to install the Xcode Command Line Tools. To install/update the Xcode Command Line Tools, write this command using the Terminal.app (after having Xcode installed or updated):
xcode-select --install
To quickly install Composer in the current directory, please, refer to the official Composer download page for updated instructions.
To install the defined dependencies for your project, just run the Composer install command into the project root directory using the Terminal.app (if you are using macOS) or with your preferred Shell:
php composer.phar install
You may want to look into the official Composer guidelines for Installing Dependencies for more details.
If you used the --filename
option on the Composer installation
- Maybe you installed your Composer using the
--filename
installer option, for example in this way:php composer-setup.php --filename=composer
In that case, you should runcomposer install
in order to install the dependencies.
The Unitary Tests of this package has been made using PHPUnit.
cp phpunit.xml.dist phpunit.xml
vendor/bin/phpunit
After running the tests, you can view the tests coverage results by opening the index.html
file created under the tests/code-coverage-reports/html-format/
folder.
If PHPUnit throws an error message saying that it can not find some Class used in the tests.
- Use the following Composer's command and, then re-run the tests.
php composer.phar dump-autoload
You need Xdebug PHP extension enabled.
- PHPUnit's code coverage functionality is configured by default for this project. It makes use of the PHP_CodeCoverage component, which in turn leverages the code coverage functionality provided by the Xdebug extension for PHP.
- If you don't want to see code coverage or, you can not properly enable the Xdebug extension, you can remove the full
entry present in the phpunit.xml configuration file.