Skip to content

Commit 072503e

Browse files
Added tests for tables command and testing docs (#6)
* Added tests for tables command and testing docs * Stop running tests as cron job * Dummy * Revert "Dummy" This reverts commit 96aeaad. * Intentionally break test * Revert "Intentionally break test" This reverts commit 6de86ee.
1 parent e8a0970 commit 072503e

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

.github/workflows/testing.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
branches:
77
- main
88
- master
9-
schedule:
10-
- cron: "17 1 * * *" # Run every day on a seemly random time.
119

1210
jobs:
1311
test:

TESTING.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Testing
2+
3+
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).
4+
5+
The test cases are located in `features/*.feature`.
6+
7+
## Running tests locally
8+
9+
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:
10+
11+
```
12+
WP_CLI_TEST_DBTYPE=sqlite vendor/bin/behat
13+
```

features/sqlite_tables.feature

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Feature: WP-CLI SQLite Tables Command
2+
In order to export individual tables from a WordPress SQLite table
3+
As a website administrator
4+
I need to be able to list the tables contained in the database
5+
6+
Background:
7+
Given a WP installation
8+
9+
@require-sqlite
10+
Scenario: Successfully list the tables in the SQLite database
11+
When I run `wp sqlite tables`
12+
Then STDOUT should contain:
13+
"""
14+
wp_users
15+
wp_usermeta
16+
wp_termmeta
17+
wp_terms
18+
wp_term_taxonomy
19+
wp_term_relationships
20+
wp_commentmeta
21+
wp_comments
22+
wp_links
23+
wp_options
24+
wp_postmeta
25+
wp_posts
26+
"""
27+
28+
@require-sqlite
29+
Scenario: Successfully list the tables in the SQLite database in a CSV format
30+
When I run `wp sqlite tables --format=csv`
31+
Then STDOUT should contain:
32+
"""
33+
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
34+
"""

0 commit comments

Comments
 (0)