/** * @param \Doctrine\Common\Annotations\AnnotationException $e * * @return string */ public static function highlightAnnotationLine(AnnotationException $e) { foreach ($e->getTrace() as $step) { if (@$step['class'] . @$step['type'] . @$step['function'] !== 'Doctrine\\Common\\Annotations\\DocParser->parse') { continue; } $context = Strings::match($step['args'][1], '~^(?P<type>[^\\s]+)\\s*(?P<class>[^:]+)(?:::\\$?(?P<property>[^\\(]+))?$~i'); break; } if (!isset($context)) { return FALSE; } $refl = Nette\Reflection\ClassType::from($context['class']); $file = $refl->getFileName(); $line = NULL; if ($context['type'] === 'property') { $refl = $refl->getProperty($context['property']); $line = Kdyby\Doctrine\Helpers::getPropertyLine($refl); } elseif ($context['type'] === 'method') { $refl = $refl->getProperty($context['method']); } if (($errorLine = self::calculateErrorLine($refl, $e, $line)) === NULL) { return FALSE; } $dump = BlueScreen::highlightFile($file, $errorLine); return '<p><b>File:</b> ' . self::editorLink($file, $errorLine) . '</p>' . $dump; }
/** @internal */ private function setupDatabase(ConnectionMock $db, $container) { $this->__testbench_databaseName = 'db_tests_' . getmypid(); $this->dropDatabase($db); $this->createDatabase($db); if (isset($container->parameters['testbench']['sqls'])) { foreach ($container->parameters['testbench']['sqls'] as $file) { \Kdyby\Doctrine\Helpers::loadFromFile($db, $file); } } register_shutdown_function(function () use($db) { $this->dropDatabase($db); }); }
public static function setupDoctrineDatabase(Nette\DI\Container $sl, $sqls = array(), $prefix = 'kdyby', &$id = NULL) { $db = $sl->getByType('Kdyby\\Doctrine\\Connection'); // default connection /** @var \Kdyby\Doctrine\Connection $db */ $testDbName = $prefix . '_test_' . ($id = $id ?: getmypid()); $db->exec("DROP DATABASE IF EXISTS `{$testDbName}`"); $db->exec("CREATE DATABASE `{$testDbName}`"); $db->exec("USE `{$testDbName}`"); foreach ($sqls as $file) { Kdyby\Doctrine\Helpers::loadFromFile($db, $file); } // drop on shutdown register_shutdown_function(function () use($db, $testDbName) { $db->exec("DROP DATABASE IF EXISTS `{$testDbName}`"); }); return $testDbName; }
/** * @param Connection $connection * @param string[] $files */ public function loadFiles(Connection $connection, array $files) { foreach ($files as $file) { Helpers::loadFromFile($connection, $file); } }
/** * {@inheritdoc} * @return NativeQueryBuilder */ public function orWhere($where) { return call_user_func_array('parent::orWhere', Helpers::separateParameters($this, func_get_args())); }