@@ -468,6 +468,178 @@ Feature: Test that WP-CLI Behat steps work as expected
468468 When I launch in the background `wp eval 'sleep(2); echo "done";' `
469469 # Background process should not block, continuing immediately
470470
471+ @require-wp
472+ Scenario : Install plugins and themes from WordPress.org
473+ Given a WP installation
474+ And these installed themes:
475+ """
476+ twentysixteen
477+ """
478+ And these installed and active plugins:
479+ """
480+ wordpress-importer --version=0.8
481+ """
482+ Then the wp-content/themes/twentysixteen/style.css file should exist
483+
484+ When I run `wp plugin get wordpress-importer --fields=status,version --format=csv`
485+ Then STDOUT should contain:
486+ """
487+ status,active
488+ version,0.8
489+ """
490+
491+ @require-wp
492+ Scenario : Install cached plugins and themes without requests to WordPress.org
493+ Given a WP installation
494+ And these installed themes:
495+ """
496+ twentysixteen
497+ oceanly-green
498+ """
499+ And these installed plugins:
500+ """
501+ wordpress-importer --version=0.8
502+ """
503+ And a non-existent wp-content/themes/twentysixteen directory
504+ And a non-existent wp-content/themes/oceanly-green directory
505+ And a non-existent wp-content/themes/oceanly directory
506+ And a non-existent wp-content/plugins/wordpress-importer directory
507+ And a wp-content/mu-plugins/block-http-requests.php file:
508+ """
509+ <?php
510+ add_filter(
511+ 'pre_http_request',
512+ static function () {
513+ return new WP_Error( 'http_request_blocked', 'HTTP requests are blocked.' );
514+ }
515+ );
516+ """
517+
518+ When these installed themes:
519+ """
520+ oceanly-green
521+ """
522+ And these installed and active themes:
523+ """
524+ twentysixteen
525+ """
526+ And these installed and active plugins:
527+ """
528+ wordpress-importer --version=0.8
529+ """
530+ And I run `wp theme list --status=active --field=name`
531+ Then STDOUT should be:
532+ """
533+ twentysixteen
534+ """
535+
536+ When I run `wp plugin get wordpress-importer --fields=status,version --format=csv`
537+ Then STDOUT should contain:
538+ """
539+ status,active
540+ version,0.8
541+ """
542+ And the wp-content/themes/oceanly-green/style.css file should exist
543+ And the wp-content/themes/oceanly/style.css file should exist
544+
545+ @require-wp
546+ Scenario : Keep only the listed themes
547+ Given a WP installation
548+ And only these installed themes:
549+ """
550+ twentysixteen
551+ twentyseventeen
552+ """
553+
554+ When I run `wp theme list --format=count`
555+ Then STDOUT should be:
556+ """
557+ 2
558+ """
559+ And the wp-content/themes/twentysixteen/style.css file should exist
560+ And the wp-content/themes/twentyseventeen/style.css file should exist
561+
562+ @require-wp
563+ Scenario : Keep only the listed theme and activate it
564+ Given a WP installation
565+ And only these installed and active themes:
566+ """
567+ twentysixteen
568+ """
569+
570+ When I run `wp theme list --fields=name,status --format=csv`
571+ Then STDOUT should be:
572+ """
573+ name,status
574+ twentysixteen,active
575+ """
576+
577+ @require-wp
578+ Scenario : Run setup commands in a single process
579+ Given a WP installation
580+ And these setup commands:
581+ | command | save |
582+ | wp eval 'echo wp_insert_post ( [ "post_title " => "First ", "post_status " => "publish " ] );' | POST_ID |
583+ | wp eval 'echo get_the_title ( {POST_ID } );' | TITLE |
584+ | wp eval 'echo getmypid ();' | FIRST |
585+ | wp eval 'echo getmypid ();' | SECOND |
586+ | wp config set WP_CLI_TEST_CONSTANT "a value " | |
587+
588+ When I run `wp eval 'echo get_post_field( "post_title", {POST_ID} ) . "|{TITLE}";' `
589+ Then STDOUT should be:
590+ """
591+ First|First
592+ """
593+
594+ When I run `wp eval 'echo "{FIRST}" === "{SECOND}" ? "same process" : "different processes";' `
595+ Then STDOUT should be:
596+ """
597+ same process
598+ """
599+ And the wp-config.php file should contain:
600+ """
601+ 'WP_CLI_TEST_CONSTANT', 'a value'
602+ """
603+
604+ @require-wp
605+ Scenario : Use the plugin and theme directories of a WP installation
606+ Given a WP installation
607+ Then the {PLUGIN_DIR}/akismet directory should exist
608+ And the {THEME_DIR} directory should exist
609+
610+ # Skipped on Windows because WordPress mixes path separators in these paths there.
611+ @require-wp @skip-windows
612+ Scenario : Plugin and theme directory variables match the WordPress constants
613+ Given a WP installation
614+ When I run `wp eval 'echo WP_PLUGIN_DIR;' `
615+ Then STDOUT should be:
616+ """
617+ {PLUGIN_DIR}
618+ """
619+
620+ When I run `wp eval 'echo get_theme_root();' `
621+ Then STDOUT should be:
622+ """
623+ {THEME_DIR}
624+ """
625+
626+ # Skipped on Windows because WordPress mixes path separators in these paths there.
627+ @require-wp @skip-windows
628+ Scenario : Plugin and theme directory variables follow a custom wp-content directory
629+ Given a WP installation
630+ And a custom wp-content directory
631+ When I run `wp eval 'echo WP_PLUGIN_DIR;' `
632+ Then STDOUT should be:
633+ """
634+ {PLUGIN_DIR}
635+ """
636+
637+ When I run `wp eval 'echo get_theme_root();' `
638+ Then STDOUT should be:
639+ """
640+ {THEME_DIR}
641+ """
642+
471643 @require-wp
472644 Scenario : Test custom wp-content directory
473645 Given a WP installation
@@ -479,6 +651,8 @@ Feature: Test that WP-CLI Behat steps work as expected
479651 """
480652 WP_CONTENT_DIR
481653 """
654+ And the {PLUGIN_DIR} directory should exist
655+ And the {THEME_DIR} directory should exist
482656
483657 @require-wp
484658 Scenario : Test WP multisite installation
@@ -525,6 +699,18 @@ Feature: Test that WP-CLI Behat steps work as expected
525699 When I run `wp core version`
526700 Then STDOUT should not be empty
527701
702+ When I run `wp eval 'echo WP_PLUGIN_DIR;' `
703+ Then STDOUT should be:
704+ """
705+ {PLUGIN_DIR}
706+ """
707+
708+ When I run `wp eval 'echo get_theme_root();' `
709+ Then STDOUT should be:
710+ """
711+ {THEME_DIR}
712+ """
713+
528714 # Skipped on Windows because of curl getaddrinfo() errors.
529715 @require-wp @require-composer @skip-windows
530716 Scenario : Test WP installation with Composer and custom vendor directory
0 commit comments