Add multisite run for acceptance tests

[MAILPOET-1193]
This commit is contained in:
Pavel Dohnal
2018-01-18 12:23:33 +00:00
parent e77d00b179
commit ca6bde8a64
5 changed files with 222 additions and 8 deletions

1
.gitignore vendored
View File

@@ -22,3 +22,4 @@ assets/js/*.json
lang
.mp_svn
/nbproject/
tests/_data/acceptanceGenerated.sql

View File

@@ -231,6 +231,10 @@ class RoboFile extends \Robo\Tasks {
return $this->_exec('COMPOSE_HTTP_TIMEOUT=200 docker-compose run codeception --steps --debug -vvv');
}
function testAcceptanceMultisite() {
return $this->_exec('COMPOSE_HTTP_TIMEOUT=200 docker-compose run -e MULTISITE=1 codeception --steps --debug -vvv');
}
function deleteDocker() {
return $this->_exec('docker-compose down -v --remove-orphans --rmi all');
}

View File

@@ -34,11 +34,12 @@ modules:
dbHost: mysql
dbUser: wordpress
dbPassword: wordpress
domain: wordpress
WPDb:
dsn: 'mysql:host=mysql;dbname=wordpress'
user: wordpress
password: wordpress
dump: tests/_data/acceptanceDump.sql
dump: tests/_data/acceptanceGenerated.sql
populate: true
cleanup: false
url: 'http://wordpress'

View File

@@ -23,15 +23,75 @@ if ! $(wp-su core is-installed); then
echo "Installing WordPress"
if [ -z "${MULTISITE}" ]
then
echo "Running in single site mode"
wp-su core install --url=wordpress --title=tests --admin_user=admin --admin_email=test@test.com
echo "Configuring WordPress"
# The development version of Gravity Flow requires SCRIPT_DEBUG
wp-su core config --dbhost=mysql --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --extra-php="define( 'SCRIPT_DEBUG', true );" --force
cp /project/tests/_data/acceptanceDump.sql /project/tests/_data/acceptanceGenerated.sql
else
wp-su core multisite-install --url=wordpress --title=tests --admin_user=admin --admin_email=test@test.com
cp /project/tests/_data/acceptanceMultisiteDump.sql /project/tests/_data/acceptanceGenerated.sql
cat /project/tests/_data/acceptanceDump.sql >> /project/tests/_data/acceptanceGenerated.sql
echo "Running in multi site mode"
echo "
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
" > .htaccess
fi
else
if [ -z "${MULTISITE}" ] && $(wp-su core is-installed --network)
then
echo "xyxicdufd"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m-------------------------WARNING!!!!!!!!----------------------------"
echo -e "\033[0;31m- You are trying to run tests in single site mode -"
echo -e "\033[0;31m- But the container has been already installed in multi site mode -"
echo -e "\033[0;31m- You need to delete your installation first. Use ./do d:d -"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
exit
fi
if [ ! -z "${MULTISITE}" ] && ( ! $(wp-su core is-installed --network) )
then
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m-------------------------WARNING!!!!!!!!----------------------------"
echo -e "\033[0;31m- You are trying to run tests in multi site mode -"
echo -e "\033[0;31m- But the container has been already installed in single site mode -"
echo -e "\033[0;31m- You need to delete your installation first. Use ./do d:d -"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
echo -e "\033[0;31m--------------------------------------------------------------------"
exit
fi
fi
# Change default table prefix
sed -i "s/\$table_prefix = 'wp_';/\$table_prefix = 'mp_';/" ./wp-config.php
sed -i "s/define( *'WP_DEBUG', false *);/define('WP_DEBUG', true);define('WP_DEBUG_DISPLAY', true);define('WP_DEBUG_LOG', true);/" ./wp-config.php
# Load Composer dependencies
# Set KEEP_DEPS environment flag to not redownload them on each run, only for the 1st time, useful for development.

View File

@@ -0,0 +1,148 @@
-- Adminer 4.2.5 MySQL dump
SET NAMES utf8;
SET time_zone = '+00:00';
SET foreign_key_checks = 0;
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
--
-- Table structure for table `mp_blog_versions`
--
DROP TABLE IF EXISTS `mp_blog_versions`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mp_blog_versions` (
`blog_id` bigint(20) NOT NULL DEFAULT '0',
`db_version` varchar(20) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`last_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`blog_id`),
KEY `db_version` (`db_version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mp_blog_versions`
--
LOCK TABLES `mp_blog_versions` WRITE;
/*!40000 ALTER TABLE `mp_blog_versions` DISABLE KEYS */;
/*!40000 ALTER TABLE `mp_blog_versions` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mp_blogs`
--
DROP TABLE IF EXISTS `mp_blogs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mp_blogs` (
`blog_id` bigint(20) NOT NULL AUTO_INCREMENT,
`site_id` bigint(20) NOT NULL DEFAULT '0',
`domain` varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`path` varchar(100) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`last_updated` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`public` tinyint(2) NOT NULL DEFAULT '1',
`archived` tinyint(2) NOT NULL DEFAULT '0',
`mature` tinyint(2) NOT NULL DEFAULT '0',
`spam` tinyint(2) NOT NULL DEFAULT '0',
`deleted` tinyint(2) NOT NULL DEFAULT '0',
`lang_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`blog_id`),
KEY `domain` (`domain`(50),`path`(5)),
KEY `lang_id` (`lang_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mp_blogs`
--
LOCK TABLES `mp_blogs` WRITE;
/*!40000 ALTER TABLE `mp_blogs` DISABLE KEYS */;
INSERT INTO `mp_blogs` VALUES (1,1,'wordpress','/','2018-01-17 17:08:02','0000-00-00 00:00:00',1,0,0,0,0,0);
/*!40000 ALTER TABLE `mp_blogs` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mp_registration_log`
--
DROP TABLE IF EXISTS `mp_registration_log`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mp_registration_log` (
`ID` bigint(20) NOT NULL AUTO_INCREMENT,
`email` varchar(255) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`IP` varchar(30) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`blog_id` bigint(20) NOT NULL DEFAULT '0',
`date_registered` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`ID`),
KEY `IP` (`IP`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mp_registration_log`
--
LOCK TABLES `mp_registration_log` WRITE;
/*!40000 ALTER TABLE `mp_registration_log` DISABLE KEYS */;
/*!40000 ALTER TABLE `mp_registration_log` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mp_site`
--
DROP TABLE IF EXISTS `mp_site`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mp_site` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`domain` varchar(200) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
`path` varchar(100) COLLATE utf8mb4_unicode_520_ci NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `domain` (`domain`(140),`path`(51))
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mp_site`
--
LOCK TABLES `mp_site` WRITE;
/*!40000 ALTER TABLE `mp_site` DISABLE KEYS */;
INSERT INTO `mp_site` VALUES (1,'wordpress','/');
/*!40000 ALTER TABLE `mp_site` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `mp_sitemeta`
--
DROP TABLE IF EXISTS `mp_sitemeta`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `mp_sitemeta` (
`meta_id` bigint(20) NOT NULL AUTO_INCREMENT,
`site_id` bigint(20) NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_520_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_520_ci,
PRIMARY KEY (`meta_id`),
KEY `meta_key` (`meta_key`(191)),
KEY `site_id` (`site_id`)
) ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `mp_sitemeta`
--
LOCK TABLES `mp_sitemeta` WRITE;
/*!40000 ALTER TABLE `mp_sitemeta` DISABLE KEYS */;
INSERT INTO `mp_sitemeta` VALUES (1,1,'site_name','tests Sites'),(2,1,'admin_email','test@test.com'),(3,1,'admin_user_id','1'),(4,1,'registration','none'),(5,1,'upload_filetypes','jpg jpeg png gif mov avi mpg 3gp 3g2 midi mid pdf doc ppt odt pptx docx pps ppsx xls xlsx key mp3 ogg m4a wav mp4 m4v webm ogv flv'),(6,1,'blog_upload_space','100'),(7,1,'fileupload_maxk','1500'),(8,1,'site_admins','a:1:{i:0;s:5:\"admin\";}'),(9,1,'allowedthemes','a:1:{s:15:\"twentyseventeen\";b:1;}'),(10,1,'illegal_names','a:9:{i:0;s:3:\"www\";i:1;s:3:\"web\";i:2;s:4:\"root\";i:3;s:5:\"admin\";i:4;s:4:\"main\";i:5;s:6:\"invite\";i:6;s:13:\"administrator\";i:7;s:5:\"files\";i:8;s:4:\"blog\";}'),(11,1,'wpmu_upgrade_site','38590'),(12,1,'welcome_email','Howdy USERNAME,\n\nYour new SITE_NAME site has been successfully set up at:\nBLOG_URL\n\nYou can log in to the administrator account with the following information:\n\nUsername: USERNAME\nPassword: PASSWORD\nLog in here: BLOG_URLwp-login.php\n\nWe hope you enjoy your new site. Thanks!\n\n--The Team @ SITE_NAME'),(13,1,'first_post','Welcome to %s. This is your first post. Edit or delete it, then start blogging!'),(14,1,'siteurl','http://wordpress/'),(15,1,'add_new_users','0'),(16,1,'upload_space_check_disabled','1'),(17,1,'subdomain_install','0'),(18,1,'global_terms_enabled','0'),(19,1,'ms_files_rewriting','0'),(20,1,'initial_db_version','38590'),(21,1,'active_sitewide_plugins','a:0:{}'),(22,1,'WPLANG','en_US');
/*!40000 ALTER TABLE `mp_sitemeta` ENABLE KEYS */;
UNLOCK TABLES;