/** * @return DataProviderInterface|DbTableDataProvider */ protected function getDataProvider() { if (!$this->provider) { $this->provider = new DbTableDataProvider(\ViewComponents\TestingHelpers\dbConnection(), 'test_users'); } return $this->provider; }
public static function get() { if (self::$connection === null) { self::$connection = new \Doctrine\DBAL\Connection(['pdo' => \ViewComponents\TestingHelpers\dbConnection()], new Driver()); } return self::$connection; }
public function setUp() { $this->data = new Query(\ViewComponents\TestingHelpers\dbConnection(), 'test_users'); $this->operations = new OperationCollection(); $this->service = new DbTableProcessingService(new DbTableProcessorResolver(), $this->operations, $this->data); $q = clone $this->data; $q->select = 'count(*)'; $s = $q->execute(); $this->totalCount = (int) $s->fetch(PDO::FETCH_NUM)[0]; }
public function test() { $connection = \ViewComponents\TestingHelpers\dbConnection(); self::assertInstanceOf(PDO::class, $connection); }
protected function getDataProvider($operations = []) { return isset($_GET['use-db']) && $_GET['use-db'] ? new DbTableDataProvider(\ViewComponents\TestingHelpers\dbConnection(), 'test_users', $operations) : new ArrayDataProvider($this->getUsersData(), $operations); }
protected function createDatabase() { echo "\tInitializing Database... "; $pdo = \ViewComponents\TestingHelpers\dbConnection(); $sql = file_get_contents($this->installerDir . '/resources/fixtures/db.sql'); $sql = str_replace('DB_NAME', getenv('DB_NAME'), $sql); foreach (explode(';', $sql) as $query) { if (!trim($query)) { continue; } // don't drop & create db for sqlite if (\ViewComponents\TestingHelpers\isSQLite() && (strpos($query, 'DATABASE') !== false || strpos($query, 'USE ') !== false)) { continue; } try { $stmt = $pdo->prepare($query); $stmt->execute(); } catch (\Exception $e) { echo $e; echo PHP_EOL, 'Query: ', $query; die; } } echo "Done.", PHP_EOL; }
/** * @return \PDO */ protected function connection() { return \ViewComponents\TestingHelpers\dbConnection(); }