OSDN Git Service

option: add tests
authorscribu <mail@scribu.net>
Sat, 18 May 2013 16:04:42 +0000 (19:04 +0300)
committerscribu <mail@scribu.net>
Sat, 18 May 2013 16:04:42 +0000 (19:04 +0300)
features/option.feature [new file with mode: 0644]
php/commands/option.php

diff --git a/features/option.feature b/features/option.feature
new file mode 100644 (file)
index 0000000..0ab33e8
--- /dev/null
@@ -0,0 +1,28 @@
+Feature: Manage WordPress options
+
+  Scenario: Option CRUD
+    Given a WP install
+
+    When I run `wp option add foo 'bar'`
+    Then STDOUT should be empty
+
+    When I run `wp option get foo`
+    Then STDOUT should be:
+    """
+    bar
+    """
+
+    When I run `wp option set foo '[ 1, 2 ]' --format=json`
+    Then STDOUT should be empty
+
+    When I run `wp option get foo --format=json`
+    Then STDOUT should be:
+    """
+    [1,2]
+    """
+
+    When I run `wp option delete foo`
+    Then STDOUT should be empty
+
+    When I try `wp option get foo`
+    Then the return code should be 1
index 525a89a..361a1f7 100644 (file)
@@ -10,7 +10,7 @@ class Option_Command extends WP_CLI_Command {
        /**
         * Get an option.
         *
-        * @synopsis <key> [--json]
+        * @synopsis <key> [--format=<format>]
         */
        public function get( $args, $assoc_args ) {
                list( $key ) = $args;
@@ -26,7 +26,7 @@ class Option_Command extends WP_CLI_Command {
        /**
         * Add an option.
         *
-        * @synopsis <key> <value> [--json]
+        * @synopsis <key> [--format=<format>]
         */
        public function add( $args, $assoc_args ) {
                $key = $args[0];
@@ -42,7 +42,7 @@ class Option_Command extends WP_CLI_Command {
         * Update an option.
         *
         * @alias set
-        * @synopsis <key> <value> [--json]
+        * @synopsis <key> [--format=<format>]
         */
        public function update( $args, $assoc_args ) {
                $key = $args[0];