Fix Testing

This commit is contained in:
Philipp Holzer 2018-10-22 20:59:51 +02:00
parent cbb9a2e8b7
commit 4a82708cbf
No known key found for this signature in database
GPG Key ID: 517BE60E2CE5C8A5
4 changed files with 22 additions and 26 deletions

View File

@ -12,6 +12,8 @@ use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Network\HTTPException;
require_once __DIR__.'/../include/api.php';
/**
* Tests for the API functions.
*
@ -20,7 +22,6 @@ use Friendica\Network\HTTPException;
*/
class ApiTest extends DatabaseTest
{
/**
* Create variables used by tests.
*/
@ -28,7 +29,7 @@ class ApiTest extends DatabaseTest
{
parent::setUp();
require_once __DIR__.'/../include/api.php';
$this->app = BaseObject::getApp();
// User data that the test database is populated with
$this->selfUser = [
@ -60,6 +61,10 @@ class ApiTest extends DatabaseTest
'uid' => $this->selfUser['id']
];
Config::set('system', 'url', 'http://localhost');
Config::set('system', 'hostname', 'localhost');
Config::set('system', 'worker_dont_fork', true);
// Default config
Config::set('config', 'hostname', 'localhost');
Config::set('system', 'throttle_limit_day', 100);

View File

@ -14,6 +14,8 @@ use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\Framework\TestCase;
use PHPUnit_Extensions_Database_DB_IDatabaseConnection;
require_once __DIR__.'/../boot.php';
/**
* Abstract class used by tests that need a database.
*/
@ -21,23 +23,6 @@ abstract class DatabaseTest extends TestCase
{
use TestCaseTrait;
/**
* @var App The Friendica App
*/
protected $app;
protected function setUp()
{
require_once __DIR__.'/../boot.php';
// Reusable App object
$this->app = BaseObject::getApp();
Config::set('system', 'url', 'http://localhost');
Config::set('system', 'hostname', 'localhost');
Config::set('system', 'worker_dont_fork', true);
}
/**
* Get database connection.
*
@ -55,6 +40,11 @@ abstract class DatabaseTest extends TestCase
$this->markTestSkipped('Please set the MYSQL_* environment variables to your test database credentials.');
}
DBA::connect(getenv('MYSQL_HOST'),
getenv('MYSQL_USERNAME'),
getenv('MYSQL_PASSWORD'),
getenv('MYSQL_DATABASE'));
if (!DBA::connected()) {
$this->markTestSkipped('Could not connect to the database.');
}

View File

@ -270,9 +270,13 @@ CONF;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testNoDatabaseConnection()
{
// TODO DBA mocking for whole console tests make this test work again
$this->markTestSkipped('DBA is already loaded, we have to mock the whole App to make it work');
$dbaMock = \Mockery::mock('alias:Friendica\Database\DBA');
$dbaMock
->shouldReceive('connected')

View File

@ -6,6 +6,10 @@ namespace Friendica\Core;
use Friendica\Test\Util\VFSTrait;
use PHPUnit\Framework\TestCase;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class InstallTest extends TestCase
{
use VFSTrait;
@ -48,7 +52,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testCheckKeys()
{
@ -63,7 +66,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testCheckFunctions()
{
@ -141,7 +143,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testCheckLocalIni()
{
@ -160,7 +161,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testCheckHtAccessFail()
{
@ -201,7 +201,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testCheckHtAccessWork()
{
@ -241,7 +240,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testImagick()
{
@ -264,7 +262,6 @@ class InstallTest extends TestCase
/**
* @small
* @runInSeparateProcess
*/
public function testImagickNotFound()
{