Replace acceptance tests dump with settings in DefaultsExtension

[MAILPOET-2302]
This commit is contained in:
Jan Jakeš
2019-09-02 10:11:26 +02:00
committed by M. Shull
parent 6c54dd1944
commit db22b87239
7 changed files with 72 additions and 781 deletions

1
.gitignore vendored
View File

@ -24,7 +24,6 @@ assets/dist
lang
.mp_svn
/nbproject/
tests/_data/acceptanceGenerated.sql
tests/_data/acceptanceBackup.sql
lib/DI/CachedContainer.php
prefixer/vendor

File diff suppressed because one or more lines are too long

View File

@ -1,148 +0,0 @@
-- 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,'test.local','/','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,'test.local','/');
/*!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','user'),(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://test.local/'),(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;

View File

@ -1 +0,0 @@
/* Replace this file with actual dump of your database */

View File

@ -11,6 +11,9 @@ class DefaultsExtension extends \Codeception\Extension {
];
public function setupDefaults(\Codeception\Event\SuiteEvent $e) {
$this->setupWordPress();
$this->setupWooCommerce();
$settings = new Settings();
$settings->withDefaultSettings();
@ -18,4 +21,72 @@ class DefaultsExtension extends \Codeception\Extension {
$user_flags->withDefaultFlags();
}
private function setupWordPress() {
update_option('siteurl', 'http://test.local', 'yes');
update_option('home', 'http://test.local', 'yes');
update_option('blogname', 'MP Dev', 'yes');
update_option('admin_email', 'test@example.com', 'yes');
update_option('gmt_offset', '0', 'yes');
update_option('users_can_register', '1', 'yes');
update_site_option('registration', 'user');
update_option('permalink_structure', '/%year%/%monthnum%/%day%/%postname%/', 'yes');
update_option('template', 'twentysixteen', 'yes');
update_option('stylesheet', 'twentysixteen', 'yes');
// posts & pages
$this->createPost('post', 'hello-world', 'Hello world!', 'Hello from WordPress.');
$this->createPost('mailpoet_page', '', 'MailPoet Page', '[mailpoet_page]');
// get rid of 'blog/' prefix that is added automatically to rewrite rules on multisite by default
// (init() loads 'permalink_structure' option from DB, flush_rules() regenerates 'rewrite_rules')
global $wp_rewrite;
$wp_rewrite->init();
$wp_rewrite->flush_rules();
}
private function setupWooCommerce() {
// address
update_option('woocommerce_store_address', 'Address', 'yes');
update_option('woocommerce_store_address_2', '', 'yes');
update_option('woocommerce_store_city', 'Paris', 'yes');
update_option('woocommerce_default_country', 'FR:*', 'yes');
update_option('woocommerce_store_postcode', '75000', 'yes');
// currency
update_option('woocommerce_currency', 'EUR', 'yes');
update_option('woocommerce_currency_pos', 'right', 'yes');
update_option('woocommerce_price_thousand_sep', ' ', 'yes');
update_option('woocommerce_price_decimal_sep', ',', 'yes');
// pages
$shop_page_id = $this->createPage('shop', 'Shop', '');
$cart_page_id = $this->createPage('cart', 'Cart', '[woocommerce_cart]');
$checkout_page_id = $this->createPage('checkout', 'Checkout', '[woocommerce_checkout]');
$my_account_page_id = $this->createPage('my-account', 'My account', '[woocommerce_my_account]');
update_option('woocommerce_shop_page_id', $shop_page_id, 'yes');
update_option('woocommerce_cart_page_id', $cart_page_id, 'yes');
update_option('woocommerce_checkout_page_id', $checkout_page_id, 'yes');
update_option('woocommerce_myaccount_page_id', $my_account_page_id, 'yes');
// other
update_option('woocommerce_bacs_settings', ['enabled' => 'yes'], 'yes');
update_option('woocommerce_cod_settings', ['enabled' => 'yes'], 'yes');
update_option('woocommerce_enable_signup_and_login_from_checkout', 'yes', 'no');
}
private function createPage($name, $tile, $content) {
return $this->createPost('page', $name, $tile, $content);
}
private function createPost($type, $name, $tile, $content) {
return wp_insert_post([
'post_author' => 1,
'post_type' => $type,
'post_name' => $name,
'post_title' => $tile,
'post_content' => $content,
'post_status' => 'publish',
]);
}
}

View File

@ -6,8 +6,7 @@ modules:
dsn: 'mysql:host=mysql;dbname=wordpress'
user: wordpress
password: wordpress
dump: tests/_data/acceptanceGenerated.sql
populate: true
populate: false
cleanup: false
url: 'http://test.local'
urlReplacement: true

View File

@ -39,12 +39,9 @@ WP_CORE_INSTALL_PARAMS="--url=test.local --title=tests --admin_user=admin --admi
if [ -z "${MULTISITE}" ]; then
echo 'Installing WordPress (single site mode)'
wp core install $WP_CORE_INSTALL_PARAMS
cp /project/tests/_data/acceptanceDump.sql /project/tests/_data/acceptanceGenerated.sql
else
echo 'Installing WordPress (multisite mode)'
wp core multisite-install $WP_CORE_INSTALL_PARAMS
cp /project/tests/_data/acceptanceMultisiteDump.sql /project/tests/_data/acceptanceGenerated.sql
cat /project/tests/_data/acceptanceDump.sql >> /project/tests/_data/acceptanceGenerated.sql
fi
# install WooCommerce (activate & deactivate it to populate DB for backup)