Skip to content

Commit a4e6b1f

Browse files
committed
Add behat tests for redis and database for both local and global options
1 parent 390161f commit a4e6b1f

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

features/bootstrap/FeatureContext.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ public static function cleanup(AfterFeatureScope $scope)
405405
'www.example3.test',
406406
'labels.test',
407407
'wpcache.test',
408+
'wp-local-db.test',
409+
'wp-local-redis.test',
410+
'wp-local-db-redis.test'
408411
];
409412

410413
$result = EE::launch( 'sudo bin/ee site list --format=text',false, true );
@@ -422,4 +425,31 @@ public static function cleanup(AfterFeatureScope $scope)
422425
unlink('ee-old.phar');
423426
}
424427
}
428+
429+
/**
430+
* @Then Check global redis cache for :site
431+
*/
432+
public function checkGlobalRedisCacheOfSite($site)
433+
{
434+
exec("docker exec -it ee-global-redis redis-cli set 'easyengine' 'rock'");
435+
$output = exec("docker exec -it ee-global-redis redis-cli get 'easyengine'");
436+
if ( '"rock"' !== $output ) {
437+
throw new Exception("Global redis not working for $site site. Getting '$output' instead of 'rock'");
438+
}
439+
exec("docker exec -it ee-global-redis redis-cli del 'easyengine'");
440+
}
441+
442+
/**
443+
* @Then Check local redis cache for :site
444+
*/
445+
public function checkLocalRedisCacheOfSite($site)
446+
{
447+
$site_root_folder = EE_SITE_ROOT . '/' . $site;
448+
exec("cd $site_root_folder && docker-compose exec redis redis-cli set 'easyengine' 'rock'");
449+
$output = exec("cd $site_root_folder && docker-compose exec redis redis-cli get 'easyengine'");
450+
if ( '"rock"' !== $output ) {
451+
throw new Exception("Local redis not working for $site site. Getting '$output' instead of 'rock'.");
452+
}
453+
exec("cd $site_root_folder && docker-compose exec redis redis-cli del 'easyengine'");
454+
}
425455
}

features/site.feature

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,33 @@ Feature: Site Command
188188
| db |
189189
| redis |
190190
| phpmyadmin |
191+
192+
Scenario: Create WordPress site with local DB and global redis
193+
When I run 'bin/ee site create wp-local-db.test --cache --type=wp --local-db'
194+
Then After delay of 5 seconds
195+
And The site 'wp-local-db.test' should have webroot
196+
And The site 'wp-local-db.test' should have WordPress
197+
And Request on 'wp-local-db.test' should contain following headers:
198+
| header |
199+
| HTTP/1.1 200 OK |
200+
And Check global redis cache for 'wp-local-db.test'
201+
202+
Scenario: Create WordPress site with local redis and global db
203+
When I run 'bin/ee site create wp-local-redis.test --cache --type=wp --with-local-redis'
204+
Then After delay of 5 seconds
205+
And The site 'wp-local-redis.test' should have webroot
206+
And The site 'wp-local-redis.test' should have WordPress
207+
And Request on 'wp-local-redis.test' should contain following headers:
208+
| header |
209+
| HTTP/1.1 200 OK |
210+
And Check local redis cache for 'wp-local-redis.test'
211+
212+
Scenario: Create WordPress site with local DB and local redis
213+
When I run 'bin/ee site create wp-local-db-redis.test --cache --type=wp --local-db --with-local-redis'
214+
Then After delay of 5 seconds
215+
And The site 'wp-local-db-redis.test' should have webroot
216+
And The site 'wp-local-db-redis.test' should have WordPress
217+
And Request on 'wp-local-db-redis.test' should contain following headers:
218+
| header |
219+
| HTTP/1.1 200 OK |
220+
And Check local redis cache for 'wp-local-db-redis.test'

0 commit comments

Comments
 (0)