Commit 3b665fe3 by Carsten Brandt

improved unit test SKIP detection

issue #4687
parent 869d7b7c
......@@ -48,6 +48,12 @@ class SphinxTestCase extends TestCase
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) {
$this->markTestSkipped('pdo and pdo_mysql extension are required.');
}
// check whether sphinx is running and skip tests if not.
if (preg_match('/host=([\w\d.]+)/i', $this->sphinxConfig['dsn'], $hm) && preg_match('/port=(\d+)/i', $this->sphinxConfig['dsn'], $pm)) {
if (!@stream_socket_client($hm[1] . ':' . $pm[1], $errorNumber, $errorDescription, 0.5)) {
$this->markTestSkipped('No redis server running at ' . $hm[1] . ':' . $pm[1] . ' : ' . $errorNumber . ' - ' . $errorDescription);
}
}
$config = self::getParam('sphinx');
if (!empty($config)) {
$this->sphinxConfig = $config['sphinx'];
......
......@@ -21,6 +21,11 @@ class MemCacheTest extends CacheTestCase
$this->markTestSkipped("memcache not installed. Skipping.");
}
// check whether memcached is running and skip tests if not.
if (!@stream_socket_client('127.0.0.1:11211', $errorNumber, $errorDescription, 0.5)) {
$this->markTestSkipped('No redis server running at ' . '127.0.0.1:11211' . ' : ' . $errorNumber . ' - ' . $errorDescription);
}
if ($this->_cacheInstance === null) {
$this->_cacheInstance = new MemCache();
}
......
......@@ -21,6 +21,11 @@ class MemCachedTest extends CacheTestCase
$this->markTestSkipped("memcached not installed. Skipping.");
}
// check whether memcached is running and skip tests if not.
if (!@stream_socket_client('127.0.0.1:11211', $errorNumber, $errorDescription, 0.5)) {
$this->markTestSkipped('No redis server running at ' . '127.0.0.1:11211' . ' : ' . $errorNumber . ' - ' . $errorDescription);
}
if ($this->_cacheInstance === null) {
$this->_cacheInstance = new MemCache(['useMemcached' => true]);
}
......
......@@ -122,7 +122,7 @@ class SqliteConnectionTest extends ConnectionTest
$config = [
'class' => 'yii\db\Connection',
'dsn' => 'sqlite:memory:',
'dsn' => 'sqlite::memory:',
];
$this->prepareDatabase($config, $fixture)->close();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment