Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ on:
branches:
- main
- master
schedule:
- cron: "17 1 * * *" # Run every day on a seemly random time.

jobs:
test:
Expand Down
13 changes: 13 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Testing

This repo uses the [BDD](https://en.wikipedia.org/wiki/Behavior-driven_development) testing framework [Behat](https://docs.behat.org/en/latest/). It means we use plain text files to describe "scenarios" containing keywords like "given", "when", and "then". This methodology was [chosen](https://github.com/Automattic/wp-cli-sqlite-command/issues/3) because it's what WP CLI itself uses to [test commands](https://github.com/wp-cli/wp-cli-tests).

The test cases are located in `features/*.feature`.

## Running tests locally

The test cases depend on real WordPress installations, meaning the usual PHP and MySQL dependencies are required. However, we can opt to use SQLite instead of MySQL to make running the tests locally easier. Here's how to run the full test suite with a SQLite database:

```
WP_CLI_TEST_DBTYPE=sqlite vendor/bin/behat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I missed that before, and I was running those tests by providing a path to MySQL.

```
34 changes: 34 additions & 0 deletions features/sqlite_tables.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Feature: WP-CLI SQLite Tables Command
In order to export individual tables from a WordPress SQLite table
As a website administrator
I need to be able to list the tables contained in the database

Background:
Given a WP installation

@require-sqlite
Scenario: Successfully list the tables in the SQLite database
When I run `wp sqlite tables`
Then STDOUT should contain:
"""
wp_users
wp_usermeta
wp_termmeta
wp_terms
wp_term_taxonomy
wp_term_relationships
wp_commentmeta
wp_comments
wp_links
wp_options
wp_postmeta
wp_posts
"""

@require-sqlite
Scenario: Successfully list the tables in the SQLite database in a CSV format
When I run `wp sqlite tables --format=csv`
Then STDOUT should contain:
"""
wp_users,wp_usermeta,wp_termmeta,wp_terms,wp_term_taxonomy,wp_term_relationships,wp_commentmeta,wp_comments,wp_links,wp_options,wp_postmeta,wp_posts
"""