From 8c2258dd2eed18028f1d607b2aab1f8b1a1c15c2 Mon Sep 17 00:00:00 2001 From: Philipp Holzer Date: Mon, 9 Jul 2018 21:48:47 +0200 Subject: [PATCH] switched back to origin TestCase structure --- tests/ApiTest.php | 13 +++++++++++++ tests/DatabaseTest.php | 28 ---------------------------- tests/src/Core/Cache/CacheTest.php | 14 ++++++++++++++ tests/src/Core/Lock/LockTest.php | 15 +++++++++++++++ 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/tests/ApiTest.php b/tests/ApiTest.php index a562901983..c8443512c8 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -5,6 +5,7 @@ namespace Friendica\Test; +use Friendica\App; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Network\BadRequestException; @@ -25,8 +26,13 @@ class ApiTest extends DatabaseTest */ protected function setUp() { + global $a; parent::setUp(); + // Reusable App object + $this->app = new App(__DIR__.'/../'); + $a = $this->app; + // User data that the test database is populated with $this->selfUser = [ 'id' => 42, @@ -56,6 +62,13 @@ class ApiTest extends DatabaseTest 'authenticated' => true, 'uid' => $this->selfUser['id'] ]; + + // Default config + Config::set('config', 'hostname', 'localhost'); + Config::set('system', 'throttle_limit_day', 100); + Config::set('system', 'throttle_limit_week', 100); + Config::set('system', 'throttle_limit_month', 100); + Config::set('system', 'theme', 'system_theme'); } /** diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php index 04509724ac..e79e9237be 100644 --- a/tests/DatabaseTest.php +++ b/tests/DatabaseTest.php @@ -6,8 +6,6 @@ namespace Friendica\Test; use dba; -use Friendica\App; -use Friendica\Core\Config; use Friendica\Database\DBStructure; use PHPUnit_Extensions_Database_DB_IDatabaseConnection; use PHPUnit\DbUnit\DataSet\YamlDataSet; @@ -19,35 +17,9 @@ use PHPUnit\Framework\TestCase; */ abstract class DatabaseTest extends TestCase { - /** - * @var \Friendica\App - */ - protected $app; use TestCaseTrait; - /** - * Creates basic instances for testing with databases - * - * @throws \Exception - */ - protected function setUp() - { - global $a; - parent::setUp(); - - // Reusable App object - $this->app = new App(__DIR__.'/../'); - $a = $this->app; - - // Default config - Config::set('config', 'hostname', 'localhost'); - Config::set('system', 'throttle_limit_day', 100); - Config::set('system', 'throttle_limit_week', 100); - Config::set('system', 'throttle_limit_month', 100); - Config::set('system', 'theme', 'system_theme'); - } - /** * Renames an eventually existing .htconfig.php to .htconfig.php.tmp * Creates a new .htconfig.php for bin/worker.php execution diff --git a/tests/src/Core/Cache/CacheTest.php b/tests/src/Core/Cache/CacheTest.php index bbbb6506a4..5be0e4b893 100644 --- a/tests/src/Core/Cache/CacheTest.php +++ b/tests/src/Core/Cache/CacheTest.php @@ -2,6 +2,8 @@ namespace Friendica\Test\src\Core\Cache; +use Friendica\App; +use Friendica\Core\Config; use Friendica\Test\DatabaseTest; use Friendica\Util\DateTimeFormat; @@ -16,8 +18,20 @@ abstract class CacheTest extends DatabaseTest protected function setUp() { + global $a; parent::setUp(); $this->instance = $this->getInstance(); + + // Reusable App object + $this->app = new App(__DIR__.'/../'); + $a = $this->app; + + // Default config + Config::set('config', 'hostname', 'localhost'); + Config::set('system', 'throttle_limit_day', 100); + Config::set('system', 'throttle_limit_week', 100); + Config::set('system', 'throttle_limit_month', 100); + Config::set('system', 'theme', 'system_theme'); } function testSimple() { diff --git a/tests/src/Core/Lock/LockTest.php b/tests/src/Core/Lock/LockTest.php index c8acd74067..dafbd74a6f 100644 --- a/tests/src/Core/Lock/LockTest.php +++ b/tests/src/Core/Lock/LockTest.php @@ -2,7 +2,10 @@ namespace Friendica\Test\src\Core\Lock; +use Friendica\App; +use Friendica\Core\Config; use Friendica\Test\DatabaseTest; +use PHPUnit\Framework\TestCase; abstract class LockTest extends DatabaseTest { @@ -15,8 +18,20 @@ abstract class LockTest extends DatabaseTest protected function setUp() { + global $a; parent::setUp(); $this->instance = $this->getInstance(); + + // Reusable App object + $this->app = new App(__DIR__.'/../'); + $a = $this->app; + + // Default config + Config::set('config', 'hostname', 'localhost'); + Config::set('system', 'throttle_limit_day', 100); + Config::set('system', 'throttle_limit_week', 100); + Config::set('system', 'throttle_limit_month', 100); + Config::set('system', 'theme', 'system_theme'); } public function testLock() {