PageRenderTime 43ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/features/scaffold.feature

https://github.com/rclilly/wp-cli
Gherkin Specification | 201 lines | 175 code | 24 blank | 2 comment | 7 complexity | 32dba12b81197324488da6735dd805ab MD5 | raw file
  1. Feature: WordPress code scaffolding
  2. Background:
  3. Given a WP install
  4. @theme
  5. Scenario: Scaffold a child theme
  6. Given I run `wp theme path`
  7. And save STDOUT as {THEME_DIR}
  8. When I run `wp scaffold child-theme zombieland --parent_theme=umbrella --theme_name=Zombieland --author=Tallahassee --author_uri=http://www.wp-cli.org --theme_uri=http://www.zombieland.com --activate`
  9. Then STDOUT should not be empty
  10. And the {THEME_DIR}/zombieland/style.css file should exist
  11. @tax @cpt
  12. Scenario: Scaffold a Custom Taxonomy and Custom Post Type and write it to active theme
  13. Given I run `wp eval 'echo STYLESHEETPATH;'`
  14. And save STDOUT as {STYLESHEETPATH}
  15. When I run `wp scaffold taxonomy zombie-speed --theme`
  16. Then the {STYLESHEETPATH}/taxonomies/zombie-speed.php file should exist
  17. When I run `wp scaffold post-type zombie --theme`
  18. Then the {STYLESHEETPATH}/post-types/zombie.php file should exist
  19. # Test for all flags but --label, --theme, --plugin and --raw
  20. @tax
  21. Scenario: Scaffold a Custom Taxonomy and attach it to CPTs including one that is prefixed and has a text domain
  22. When I run `wp scaffold taxonomy zombie-speed --post_types="prefix-zombie,wraith" --textdomain=zombieland`
  23. Then STDOUT should contain:
  24. """
  25. __( 'Zombie speeds'
  26. """
  27. And STDOUT should contain:
  28. """
  29. array( 'prefix-zombie', 'wraith' )
  30. """
  31. And STDOUT should contain:
  32. """
  33. __( 'Zombie speeds', 'zombieland'
  34. """
  35. @tax
  36. Scenario: Scaffold a Custom Taxonomy with label "Speed"
  37. When I run `wp scaffold taxonomy zombie-speed --label="Speed"`
  38. Then STDOUT should contain:
  39. """
  40. __( 'Speeds'
  41. """
  42. And STDOUT should contain:
  43. """
  44. _x( 'Speed', 'taxonomy general name',
  45. """
  46. # Test for all flags but --label, --theme, --plugin and --raw
  47. @cpt
  48. Scenario: Scaffold a Custom Post Type
  49. When I run `wp scaffold post-type zombie --textdomain=zombieland`
  50. Then STDOUT should contain:
  51. """
  52. __( 'Zombies'
  53. """
  54. And STDOUT should contain:
  55. """
  56. __( 'Zombies', 'zombieland'
  57. """
  58. Scenario: CPT slug is too long
  59. When I try `wp scaffold post-type slugiswaytoolonginfact`
  60. Then STDERR should be:
  61. """
  62. Error: Post type slugs cannot exceed 20 characters in length.
  63. """
  64. @cpt
  65. Scenario: Scaffold a Custom Post Type with label
  66. When I run `wp scaffold post-type zombie --label="Brain eater"`
  67. Then STDOUT should contain:
  68. """
  69. __( 'Brain eaters'
  70. """
  71. Scenario: Scaffold a plugin
  72. Given I run `wp plugin path`
  73. And save STDOUT as {PLUGIN_DIR}
  74. When I run `wp scaffold plugin hello-world`
  75. Then STDOUT should not be empty
  76. And the {PLUGIN_DIR}/hello-world/hello-world.php file should exist
  77. And the {PLUGIN_DIR}/hello-world/readme.txt file should exist
  78. Scenario: Scaffold plugin tests
  79. When I run `wp plugin path`
  80. Then save STDOUT as {PLUGIN_DIR}
  81. When I run `wp scaffold plugin hello-world --skip-tests`
  82. Then STDOUT should not be empty
  83. And the {PLUGIN_DIR}/hello-world/hello-world.php file should exist
  84. And the {PLUGIN_DIR}/hello-world/readme.txt file should exist
  85. And the {PLUGIN_DIR}/hello-world/tests directory should not exist
  86. When I run `wp scaffold plugin-tests hello-world`
  87. Then STDOUT should not be empty
  88. And the {PLUGIN_DIR}/hello-world/tests directory should contain:
  89. """
  90. bootstrap.php
  91. test-sample.php
  92. """
  93. And the {PLUGIN_DIR}/hello-world/bin directory should contain:
  94. """
  95. install-wp-tests.sh
  96. """
  97. And the {PLUGIN_DIR}/hello-world/phpunit.xml file should exist
  98. And the {PLUGIN_DIR}/hello-world/.travis.yml file should exist
  99. When I run `wp eval "if ( is_executable( '{PLUGIN_DIR}/hello-world/bin/install-wp-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
  100. Then STDOUT should be:
  101. """
  102. executable
  103. """
  104. Scenario: Scaffold package tests
  105. Given a community-command/command.php file:
  106. """
  107. <?php
  108. """
  109. And a community-command/composer.json file:
  110. """
  111. {
  112. "name": "wp-cli/community-command",
  113. "description": "A demo community command.",
  114. "license": "MIT",
  115. "minimum-stability": "dev",
  116. "require": {
  117. },
  118. "autoload": {
  119. "files": [ "dictator.php" ]
  120. },
  121. "require-dev": {
  122. "behat/behat": "~2.5"
  123. }
  124. }
  125. """
  126. And a invalid-command/command.php file:
  127. """
  128. <?php
  129. """
  130. When I run `wp scaffold package-tests community-command`
  131. Then STDOUT should not be empty
  132. And the community-command/.travis.yml file should exist
  133. And the community-command/bin/install-package-tests.sh file should exist
  134. And the community-command/utils/get-package-require-from-composer.php file should exist
  135. And the community-command/features directory should contain:
  136. """
  137. bootstrap
  138. extra
  139. load-wp-cli.feature
  140. steps
  141. """
  142. And the community-command/features/bootstrap directory should contain:
  143. """
  144. FeatureContext.php
  145. Process.php
  146. support.php
  147. utils.php
  148. """
  149. And the community-command/features/steps directory should contain:
  150. """
  151. given.php
  152. then.php
  153. when.php
  154. """
  155. And the community-command/features/extra directory should contain:
  156. """
  157. no-mail.php
  158. """
  159. When I run `wp eval "if ( is_executable( 'community-command/bin/install-package-tests.sh' ) ) { echo 'executable'; } else { exit( 1 ); }"`
  160. Then STDOUT should be:
  161. """
  162. executable
  163. """
  164. When I try `wp scaffold package-tests invalid-command`
  165. Then STDERR should be:
  166. """
  167. Error: Invalid package directory. composer.json file must be present.
  168. """
  169. Scenario: Scaffold starter code for a theme
  170. Given I run `wp theme path`
  171. And save STDOUT as {THEME_DIR}
  172. When I run `wp scaffold _s starter-theme`
  173. Then STDOUT should contain:
  174. """
  175. Success: Created theme 'Starter-theme'.
  176. """
  177. And the {THEME_DIR}/starter-theme/style.css file should exist