protected function setUp() { parent::setUp(); try { $this->driver = $this->getDriver(); } catch (PrerequisiteException $e) { Environment::skip($e->getMessage()); } }
protected function setUp() { parent::setUp(); if (!$this->prepared) { try { $this->databaseTester->prepareDatabaseTest(); } catch (DBALException $ex) { if (preg_match('~unknown database|access denied|2002|no such file~i', $ex->getMessage())) { Environment::skip('No test SQL database available'); } else { throw $ex; } } $this->prepared = TRUE; } else { $this->databaseTester->clearDatabase(); } }
/** @internal */ private function __testbench_createContainer() { if (!class_exists('Doctrine\\DBAL\\Connection')) { \Tester\Environment::skip('TDoctrine trait supports only Doctrine at this moment.'); } $container = \Testbench\ContainerFactory::create(FALSE); /** @var ConnectionMock $db */ $db = $container->getByType('Doctrine\\DBAL\\Connection'); if (!$db instanceof ConnectionMock) { $serviceNames = $container->findByType('Doctrine\\DBAL\\Connection'); throw new \LogicException(sprintf('The service %s should be instance of Ant\\Tests\\ConnectionMock, to allow lazy schema initialization.', reset($serviceNames))); } $db->onConnect[] = function (ConnectionMock $db) use($container) { if ($this->__testbench_databaseName !== NULL) { return; } try { $this->setupDatabase($db, $container); } catch (\Exception $e) { \Tester\Assert::fail($e->getMessage()); } }; return $container; }
protected function changeRunLevel($testSpeed = \Testbench::FINE) { if ((int) getenv('RUNLEVEL') < $testSpeed) { \Tester\Environment::skip("Required runlevel '{$testSpeed}' but current runlevel is '" . (int) getenv('RUNLEVEL') . "' (higher runlevel means slower tests)\n" . "You can run this test with environment variable: 'RUNLEVEL={$testSpeed} vendor/bin/run-tests ...'\n"); } }