Add Drone CI
- Add drone test environment - Add drone config - apt phpunit - Fix api.php - Fix item.php - Fix DBStructure - Check if caching is possible during tests
This commit is contained in:
parent
b51dedd7e7
commit
d5dd12b8f8
19 changed files with 321 additions and 34 deletions
|
@ -80,7 +80,7 @@ class StaticDatabase extends Database
|
|||
{
|
||||
// Use environment variables for mysql if they are set beforehand
|
||||
if (!empty($server['MYSQL_HOST'])
|
||||
&& !empty($server['MYSQL_USERNAME'] || !empty($server['MYSQL_USER']))
|
||||
&& (!empty($server['MYSQL_USERNAME'] || !empty($server['MYSQL_USER'])))
|
||||
&& $server['MYSQL_PASSWORD'] !== false
|
||||
&& !empty($server['MYSQL_DATABASE']))
|
||||
{
|
||||
|
|
29
tests/phpunit.xml
Normal file
29
tests/phpunit.xml
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit
|
||||
bootstrap="bootstrap.php"
|
||||
verbose="true">
|
||||
<testsuite name='friendica'>
|
||||
<directory suffix='.php'>functional/</directory>
|
||||
<directory suffix='.php'>include/</directory>
|
||||
<directory suffix='.php'>src/</directory>
|
||||
<directory suffix='.php'>./</directory>
|
||||
</testsuite>
|
||||
<!-- Filters for Code Coverage -->
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">..</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">config/</directory>
|
||||
<directory suffix=".php">doc/</directory>
|
||||
<directory suffix=".php">images/</directory>
|
||||
<directory suffix=".php">library/</directory>
|
||||
<directory suffix=".php">spec/</directory>
|
||||
<directory suffix=".php">tests/</directory>
|
||||
<directory suffix=".php">view/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<listeners>
|
||||
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener" />
|
||||
</listeners>
|
||||
</phpunit>
|
|
@ -14,16 +14,22 @@ class MemcacheCacheTest extends MemoryCacheTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_host')
|
||||
->andReturn('localhost');
|
||||
->andReturn($host);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_port')
|
||||
->andReturn(11211);
|
||||
|
||||
$this->cache = new MemcacheCache('localhost', $configMock);
|
||||
try {
|
||||
$this->cache = new MemcacheCache($host, $configMock);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Memcache is not available');
|
||||
}
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,14 +16,20 @@ class MemcachedCacheTest extends MemoryCacheTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcached_hosts')
|
||||
->andReturn([0 => 'localhost, 11211']);
|
||||
->andReturn([0 => $host . ', 11211']);
|
||||
|
||||
$logger = new NullLogger();
|
||||
|
||||
$this->cache = new MemcachedCache('localhost', $configMock, $logger);
|
||||
try {
|
||||
$this->cache = new MemcachedCache($host, $configMock, $logger);
|
||||
} catch (\Exception $exception) {
|
||||
$this->markTestSkipped('Memcached is not available');
|
||||
}
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,10 +15,12 @@ class RedisCacheTest extends MemoryCacheTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_host')
|
||||
->andReturn('localhost');
|
||||
->andReturn($host);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_port')
|
||||
|
@ -33,7 +35,11 @@ class RedisCacheTest extends MemoryCacheTest
|
|||
->with('system', 'redis_password')
|
||||
->andReturn(null);
|
||||
|
||||
$this->cache = new RedisCache('localhost', $configMock);
|
||||
try {
|
||||
$this->cache = new RedisCache($host, $configMock);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Redis is not available.');
|
||||
}
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,15 +16,26 @@ class MemcacheCacheLockTest extends LockTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHE_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_host')
|
||||
->andReturn('localhost');
|
||||
->andReturn($host);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcache_port')
|
||||
->andReturn(11211);
|
||||
|
||||
return new CacheLock(new MemcacheCache('localhost', $configMock));
|
||||
$lock = null;
|
||||
|
||||
try {
|
||||
$cache = new MemcacheCache($host, $configMock);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Memcache is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,13 +17,24 @@ class MemcachedCacheLockTest extends LockTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['MEMCACHED_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'memcached_hosts')
|
||||
->andReturn([0 => 'localhost, 11211']);
|
||||
->andReturn([0 => $host . ', 11211']);
|
||||
|
||||
$logger = new NullLogger();
|
||||
|
||||
return new CacheLock(new MemcachedCache('localhost', $configMock, $logger));
|
||||
$lock = null;
|
||||
|
||||
try {
|
||||
$cache = new MemcachedCache($host, $configMock, $logger);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Memcached is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,10 +16,12 @@ class RedisCacheLockTest extends LockTest
|
|||
{
|
||||
$configMock = \Mockery::mock(Configuration::class);
|
||||
|
||||
$host = $_SERVER['REDIS_HOST'] ?? 'localhost';
|
||||
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_host')
|
||||
->andReturn('localhost');
|
||||
->andReturn($host);
|
||||
$configMock
|
||||
->shouldReceive('get')
|
||||
->with('system', 'redis_port')
|
||||
|
@ -34,6 +36,15 @@ class RedisCacheLockTest extends LockTest
|
|||
->with('system', 'redis_password')
|
||||
->andReturn(null);
|
||||
|
||||
return new CacheLock(new RedisCache('localhost', $configMock));
|
||||
$lock = null;
|
||||
|
||||
try {
|
||||
$cache = new RedisCache($host, $configMock);
|
||||
$lock = new CacheLock($cache);
|
||||
} catch (\Exception $e) {
|
||||
$this->markTestSkipped('Redis is not available');
|
||||
}
|
||||
|
||||
return $lock;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue