function __construct($which_fixtures) { if (is_null(self::$_fixtures)) { self::$_dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';charset=' . DB_CHARSET, DB_USER, DB_PASSWORD); self::$_fixtures = new SimpleYamlFixtures(self::$_dbh); self::$fixture_dir = plugin_dir_path(CSM_PLUGIN_FILE) . '/tests/fixtures/'; self::$php_env = array('now' => new SimpleDateTime(), 'secs_per_min' => 60, 'secs_per_hour' => 60 * 60, 'secs_per_day' => 60 * 60 * 24, 'secs_per_week' => 60 * 60 * 24 * 7); $fixture_files = preg_grep('/.*\\.yml$/', scandir(self::$fixture_dir)); foreach ($fixture_files as $fixture_file) { $table = basename($fixture_file, '.yml'); $auto_id_column = array_get(self::$auto_id_fixtures, $table, false); self::$_fixtures->enqueue_yaml($table, self::$fixture_dir . $fixture_file, array('auto_id' => $auto_id_column, 'id_column' => is_string($auto_id_column) ? $auto_id_column : 'id', 'auto_ref' => true, 'php_env' => self::$php_env)); } do_action('csm_migrate_db'); } $this->dbh = self::$_dbh; $this->fixtures = self::$_fixtures; $this->which_fixtures = $which_fixtures; }