diff --git a/RoboFile.php b/RoboFile.php index f7cee306f3..7f261cd140 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -14,10 +14,11 @@ class RoboFile extends \Robo\Tasks { } function watch() { - $files = array(// global admin styles - 'assets/css/src/admin.styl', - // rtl specific styles - 'assets/css/src/rtl.styl' + $files = array( + // global admin styles + 'assets/css/src/admin.styl', + // rtl specific styles + 'assets/css/src/rtl.styl' ); $command = array( @@ -28,11 +29,15 @@ class RoboFile extends \Robo\Tasks { } function makepot() { - $this->_exec('grunt makepot' . ' --gruntfile ' . __DIR__ . '/tasks/makepot/makepot.js' . ' --base_path ' . __DIR__); + $this->_exec('grunt makepot' . ' --gruntfile ' + . __DIR__ . '/tasks/makepot/makepot.js' + . ' --base_path ' . __DIR__); } function pushpot() { - $this->_exec('grunt pushpot' . ' --gruntfile ' . __DIR__ . '/tasks/makepot/makepot.js' . ' --base_path ' . __DIR__); + $this->_exec('grunt pushpot' . ' --gruntfile ' + . __DIR__ . '/tasks/makepot/makepot.js' + . ' --base_path ' . __DIR__); } function testUnit() { diff --git a/lib/Models/Model.php b/lib/Models/Model.php index 8199089d43..b7442b1407 100644 --- a/lib/Models/Model.php +++ b/lib/Models/Model.php @@ -1,13 +1,11 @@ init()); + $customValidators = new CustomValidator(); + parent::__construct($customValidators->init()); } } \ No newline at end of file diff --git a/lib/Models/Setting.php b/lib/Models/Setting.php index 7de6d5c02d..e4adb3275c 100644 --- a/lib/Models/Setting.php +++ b/lib/Models/Setting.php @@ -1,9 +1,7 @@ writeln('Loading WP core...'); $wordpress_path = getenv('WP_TEST_PATH'); - if ($wordpress_path) { if (file_exists($wordpress_path . '/wp-load.php')) { require_once(getenv('WP_TEST_PATH') . '/wp-load.php'); @@ -12,13 +12,13 @@ if ($wordpress_path) { throw new Exception("You need to specify the path to your WordPress installation\n`WP_TEST_PATH` in your .env file"); } -global $wpdb; +$console->writeln('Cleaning up database...'); +$models = array( + "Subscriber", + "Setting" +); -// clean database on each run -$truncate_commands = $wpdb->get_results("SELECT concat('TRUNCATE TABLE `', TABLE_NAME, '`;') as `truncate` - FROM INFORMATION_SCHEMA.TABLES - WHERE TABLE_SCHEMA = '" . Env::$db_name . "' AND TABLE_NAME LIKE '" . Env::$db_prefix . "%'"); -foreach ($truncate_commands as $command) { - $wpdb->query($command->truncate); +foreach ($models as $model) { + Model::factory("\MailPoet\Models\\" . $model) + ->delete_many(); } -