L337xyz
Server: LiteSpeed
System: Linux in-mum-web831.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64
User: u786315844 (786315844)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/.wp-cli/packages/vendor/wp-cli/entity-command/features/user-term.feature
Feature: Manage user term

  Scenario: Userterm CRUD
    Given a WP install
    And a wp-content/plugins/test-add-tax/plugin.php file:
      """
      <?php
      // Plugin Name: Test Add Tax

      function add_cli_tax(){
        register_taxonomy( 'user_type', 'user' );
      }

      add_action('init','add_cli_tax');
      """
    And I run `wp plugin activate test-add-tax`

    When I run `wp user term add 1 user_type foo`
    Then STDOUT should be:
      """
      Success: Added term.
      """

    When I run `wp user term list 1 user_type --fields=name,slug,taxonomy`
    Then STDOUT should be a table containing rows:
      | name | slug | taxonomy |
      | foo  | foo  | user_type |

    When I run `wp user term add 1 user_type bar`
    Then STDOUT should be:
      """
      Success: Added term.
      """

    When I run `wp user term list 1 user_type --fields=name,slug,taxonomy`
    Then STDOUT should be a table containing rows:
      | name | slug | taxonomy |
      | foo  | foo  | user_type |
      | bar  | bar  | user_type |

    When I run `wp user term list 1 user_type --format=ids`
    Then STDOUT should be:
      """
      3 2
      """

    When I run `wp user term set 1 user_type new`
    Then STDOUT should be:
      """
      Success: Set term.
      """

    When I run `wp user term list 1 user_type --fields=name,slug,taxonomy --format=count`
    Then STDOUT should be:
      """
      1
      """

    When I run `wp user term remove 1 user_type new`
    Then STDOUT should be:
      """
      Success: Removed term.
      """

    When I run `wp user term list 1 user_type --fields=name,slug,taxonomy --format=count`
    Then STDOUT should be:
      """
      0
      """

  Scenario: Multiple user term
    Given a WP install

    And a wp-content/plugins/test-add-tax/plugin.php file:
      """
      <?php
      // Plugin Name: Test Add Tax

      function add_cli_tax(){
        register_taxonomy( 'user_type', 'user' );
      }

      add_action('init','add_cli_tax');
      """
    And I run `wp plugin activate test-add-tax`

    When I run `wp user term add 1 user_type apple`
    And I run `wp user term add 1 user_type apple`
    Then STDOUT should contain:
      """
      Success: Added term.
      """

    When I run `wp user term set 1 user_type apple1 apple2`
    Then STDOUT should contain:
      """
      Success: Set terms.
      """

    When I run `wp user term list 1 user_type --format=json --fields=name,slug,taxonomy`
    Then STDOUT should contain:
      """
      [{"name":"apple1","slug":"apple1","taxonomy":"user_type"},{"name":"apple2","slug":"apple2","taxonomy":"user_type"}]
      """

  Scenario: Userterm Add invalid tax
    Given a WP install

    When I try `wp user term add 1 boo foo2`
    Then the return code should be 1
    And STDERR should be:
      """
      Error: Invalid taxonomy boo.
      """