/** * @param ConnectionInterface $connection * @param bool $create_tables_if_missing * @param LoggerInterface|null $log */ public function __construct(ConnectionInterface &$connection, $create_tables_if_missing = true, LoggerInterface &$log = null) { $this->connection = $connection; $this->log = $log; if ($create_tables_if_missing && !$this->connection->tableExists(self::PROMISES_TABLE_NAME)) { if ($this->log) { $this->log->info('Creating {table_name} table', ['table_name' => self::PROMISES_TABLE_NAME]); } $this->connection->execute('CREATE TABLE IF NOT EXISTS `' . self::PROMISES_TABLE_NAME . "` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `signature` varchar(191) NOT NULL DEFAULT '',\n `created_at` datetime DEFAULT NULL,\n `settlement` enum(?, ?) DEFAULT NULL,\n `settled_at` datetime DEFAULT NULL,\n PRIMARY KEY (`id`),\n UNIQUE (`signature`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;", PromiseInterface::FULFILLED, PromiseInterface::REJECTED); } }
/** * Tear down test environment. */ public function tearDown() { foreach ([MySqlQueue::BATCHES_TABLE_NAME, MySqlQueue::JOBS_TABLE_NAME, MySqlQueue::FAILED_JOBS_TABLE_NAME, 'email_log'] as $table_name) { if ($this->connection->tableExists($table_name)) { $this->connection->dropTable($table_name); } } if ($this->link) { $this->link->close(); } if (is_file($this->log_file_path)) { unlink($this->log_file_path); } parent::tearDown(); }