bu-ist / bu-blocks

A repository for storing all BU WordPress blocks for the new WordPress editor
https://bu-ist.github.io/bu-blocks/
1 stars 0 forks source link

BU Blocks

Contributors: toddmilliken
Tags: gutenberg, blocks
Requires at least: 4.9.8
Tested up to: 5.4
Stable tag: trunk
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

BU Blocks is a WordPress plugin that registers additional blocks for the new WordPress editor.

Description

BU Blocks provides content editors with additional blocks for the new WordPress editor. These blocks were built for various sites within the BU WordPress ecosystem and have been tested and designed to be re-used for any project.

How to run Visual Regression Testing

To make testing changes to this plugin easier, you may wish to test your sandbox against an existing website. This is possible to do using wp-cli and the bu-webdiff library, which allows you to pull a list of URLs to test, and then test the differences locally in npm. This is just like you do during a WordPress upgrade.

For example, let's say I cloned the BU Blocks demo site to my sandbox. Here, I am grabbing a list of all the pages that are on that demo site in my sandbox.

wp post list --post_type=page --url=https://id-ashley.cms-devl.bu.edu/bu-blocks/ --fields=url --format=csv

From here, you could copy and paste the URLs into a text file and use the npm instructions to run visual regression testing locally.

You'll need to ssh into your sandbox to do this, just like if you were looking for PHP error logs.

Dependencies

Installation Instructions

  1. Download this repository and either upload the zip file to the Add New plugin screen, or upload the contents of this repository to the /wp-content/plugins/ directory.
  2. Activate the plugin through the 'Plugins' menu in WordPress.

Resources

This plugin was built using a few open source plugin boilerplate examples:

Create Guten Block

This project was bootstrapped with Create Guten Block.

Below you will find some information on how to run scripts.

You can find the most recent version of this guide here.

πŸ‘‰ npm start

πŸ‘‰ npm run build

πŸ‘‰ npm run eject

Running PHPUnit tests locally in docker

Requirements

Running tests locally in docker requires docker and docker-compose to be installed in your machine.

You can download it here https://www.docker.com/community-edition#/download.

Note: docker-compose comes with Docker for Mac and Docker for Windows. On linux you need to install docker-compose separately.

Steps

  1. Go to the plugin/theme directory.
    cd /path/to/plugin
  2. Run the wpdc up command to initialize and setup docker containers.
    bash bin/wpdc.sh up
  3. Run the wpdc test command to run phpunit (as long as the containers are running, you can edit your files and run this command as many times as you want).
    bash bin/wpdc.sh test
  4. Run the wpdc down command to stop and remove containers when you are done testing.
    bash bin/wpdc.sh down

Docker commands in bin/wpdc.sh script

up

Starts docker containers and sets up WordPress testing environment so that we can use the test command. Usage

bash bin/wpdc.sh up [php-version] [wp-version]

It takes 2 optional arguments:

  1. [php-version]

    The php version we want to test. Normally a 2 digit version like 5.6, 7.0, 7.1. It defaults to latest (which at the moment resolves to 7.1 but can change in the future).

  2. [wp-version]

    The WordPress version we want to test. It can be a 1, 2 or 3 digit version like: 4, 4.9, 4.7.3. It defaults to latest.

Examples

bash bin/wpdc.sh up
bash bin/wpdc.sh up latest
bash bin/wpdc.sh up latest latest
bash bin/wpdc.sh up 7.0
bash bin/wpdc.sh up 7.0 latest
bash bin/wpdc.sh up latest 4.6
bash bin/wpdc.sh up 7.1-apache 4.7
bash bin/wpdc.sh up latest 4.8
bash bin/wpdc.sh up 5.6 4.3

down

Stops and removes everything created with the up command. Usage

bash bin/wpdc.sh down

It takes no arguments.

test

Runs the phpunit tests inside the docker container. Usage

bash bin/wpdc.sh test

It takes no arguments.