protected function setUp()
 {
     define('MODEL_DIR', '\\Test\\Model');
     //define('DEBUG_MODE', true);
     $this->injector = new Injector();
     $this->injector->share(Database::class);
     $this->database = $this->injector->make('Minute\\Database\\Database', [true]);
     try {
         $this->pdo = $this->database->getPdo();
     } catch (\PDOException $e) {
         $this->markTestSkipped('Database connection error: ' . $e->getMessage());
     }
     parent::setUp();
 }
Example #2
0
 public function getTargetUserIds(int $ar_list_id) : array
 {
     return $this->qCache->get("ar-list-id-{$ar_list_id}", function () use($ar_list_id) {
         $results = ['positive' => [], 'negative' => []];
         if ($list = MArList::find($ar_list_id)) {
             $sqls = MArListSql::where('ar_list_id', '=', $ar_list_id)->get();
             foreach ($sqls as $sql) {
                 $users = $this->qCache->get(md5($sql->sql), function () use($sql) {
                     foreach ($this->db->getPdo()->query($sql->sql) as $row) {
                         $results[] = $row[0];
                     }
                     return $results ?? [];
                 });
                 $results[$sql->type] = array_merge($results[$sql->type], $users);
             }
         }
         return array_diff($results['positive'], $results['negative']) ?: [];
     }, 3600);
 }
Example #3
0
 public function getConfiguration()
 {
     $conn = ['environments' => ['default_database' => 'dev', "default_migration_table" => "m_phinx_logs", 'dev' => ['name' => $this->database->getDsn()['database'], 'connection' => $this->database->getPdo()]]];
     $paths = ['paths' => ['migrations' => __DIR__ . '/db/migrations']];
     return array_merge($paths, $conn);
 }