Merge pull request #5993 from nupplaphil/fix_testing

Fix testing
This commit is contained in:
Hypolite Petovan 2018-10-22 15:16:33 -04:00 committed by GitHub
commit 768d1d3f76
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 24 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,21 +23,6 @@ abstract class DatabaseTest extends TestCase
{
use TestCaseTrait;
/**
* @var App The Friendica App
*/
protected $app;
protected function setUp()
{
// 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.
*
@ -53,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()
{