Skip to content

Commit

Permalink
[CMSP-459] Updates behat tests and behaviors. (#430)
Browse files Browse the repository at this point in the history
* Updates behat tests and behaviors.

* Updates behat tests and behaviors.

* port diff from #426

* tabs to spaces

* don't enable redis as part of the prepare step
we end up making a dozen differnet enable redis requests and inevitably a lot of those fail because there are so many happening simultaneously (assumption). It's okay to just enable it and leave it on, rather than turning it on and off.

---------

Co-authored-by: Ryan Wagner <ryan.wagner@pantheon.io>
Co-authored-by: Chris Reynolds <chris@jazzsequence.com>
  • Loading branch information
3 people committed Jun 26, 2023
1 parent b38d97c commit c89740d
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 5 deletions.
3 changes: 2 additions & 1 deletion behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ default:
suites:
default:
paths:
- tests/behat
- tests/behat/
contexts:
- Behat\MinkExtension\Context\MinkContext
- PantheonSystems\PantheonWordPressUpstreamTests\Behat\AdminLogIn
- behat\features\bootstrap\WpRedisFeatureContext
extensions:
Behat\MinkExtension:
# base_url set by ENV
Expand Down
3 changes: 0 additions & 3 deletions bin/behat-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ set -ex
terminus env:create $TERMINUS_SITE.dev $TERMINUS_ENV
terminus env:wipe $SITE_ENV --yes

# Enable Redis
terminus redis:enable $TERMINUS_SITE

###
# Get all necessary environment details.
###
Expand Down
4 changes: 4 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,9 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
},
"autoload": {
"psr-4": { "behat\\features\\bootstrap\\": "tests/behat/features/bootstrap/" }
}

}
35 changes: 35 additions & 0 deletions tests/behat/features/bootstrap/WpRedisFeatureContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
// features/bootstrap/WPRedisFeatureContext.php

namespace behat\features\bootstrap;

use Behat\Behat\Context\Context;

class WpRedisFeatureContext implements Context
{

/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
}

/**
* Waits a certain number of seconds.
*
* @param int $seconds
* How long to wait.
*
* @When I wait :seconds second(s)
*/
public function wait($seconds)
{
sleep($seconds);
}

}
1 change: 1 addition & 0 deletions tests/behat/load-wp.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Feature: Load WordPress
When I go to "/wp-admin/options-general.php"
And I fill in "blogname" with "Pantheon WordPress Site"
And I press "submit"
When I wait "1" second
Then print current URL
And I should see "Settings saved."

Expand Down
8 changes: 7 additions & 1 deletion tests/behat/wp-redis.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,10 @@ Feature: WP Redis
Then I should see "Redis Calls:"
And I should see "Cache Hits:"
And I should see "Cache Misses:"
And I should see "- get:"
And I should see "Redis Calls:"

# We call the same page twice to give Redis an opportunity to cache
# something so that `get` actually fires.
When I am on "/?redis_debug"
Then I should see "Group:"
Then I should see "- get"

0 comments on commit c89740d

Please sign in to comment.