X-Git-Url: http://git.inspyration.org/?a=blobdiff_plain;f=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDbalFunctionalTestCase.php;fp=vendor%2Fdoctrine%2Fdbal%2Ftests%2FDoctrine%2FTests%2FDbalFunctionalTestCase.php;h=27dd1495d7899456649b02b9bfe72acd9d95bd73;hb=8b04b2d11798dee4f3e1358e4f43e97a6df851f6;hp=0000000000000000000000000000000000000000;hpb=73568cf05a785a45f94ca3f2351d9e07bf917958;p=zf2.biz%2Fapplication_blanche.git diff --git a/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php new file mode 100644 index 0000000..27dd149 --- /dev/null +++ b/vendor/doctrine/dbal/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -0,0 +1,77 @@ +close(); + self::$_sharedConn = null; + } + } + + protected function setUp() + { + if ( ! isset(self::$_sharedConn)) { + self::$_sharedConn = TestUtil::getConnection(); + } + $this->_conn = self::$_sharedConn; + + $this->_sqlLoggerStack = new \Doctrine\DBAL\Logging\DebugStack(); + $this->_conn->getConfiguration()->setSQLLogger($this->_sqlLoggerStack); + } + + protected function onNotSuccessfulTest(\Exception $e) + { + if ($e instanceof \PHPUnit_Framework_AssertionFailedError) { + throw $e; + } + + if(isset($this->_sqlLoggerStack->queries) && count($this->_sqlLoggerStack->queries)) { + $queries = ""; + $i = count($this->_sqlLoggerStack->queries); + foreach (array_reverse($this->_sqlLoggerStack->queries) AS $query) { + $params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array()); + $queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL; + $i--; + } + + $trace = $e->getTrace(); + $traceMsg = ""; + foreach($trace AS $part) { + if(isset($part['file'])) { + if(strpos($part['file'], "PHPUnit/") !== false) { + // Beginning with PHPUnit files we don't print the trace anymore. + break; + } + + $traceMsg .= $part['file'].":".$part['line'].PHP_EOL; + } + } + + $message = "[".get_class($e)."] ".$e->getMessage().PHP_EOL.PHP_EOL."With queries:".PHP_EOL.$queries.PHP_EOL."Trace:".PHP_EOL.$traceMsg; + + throw new \Exception($message, (int)$e->getCode(), $e); + } + throw $e; + } +}