moved get_guid to System::createGUID
This commit is contained in:
parent
3a179860e5
commit
c829e43725
21 changed files with 105 additions and 88 deletions
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace Friendica\Test;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Network\BadRequestException;
|
||||
|
@ -26,13 +25,8 @@ 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,
|
||||
|
@ -62,13 +56,6 @@ 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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
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;
|
||||
|
@ -17,9 +19,35 @@ 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
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Friendica\Test\src\Core\Cache;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Test\DatabaseTest;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
||||
|
@ -18,20 +16,8 @@ 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() {
|
||||
|
|
|
@ -2,10 +2,7 @@
|
|||
|
||||
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
|
||||
{
|
||||
|
@ -18,20 +15,8 @@ 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() {
|
||||
|
|
25
tests/src/Core/SystemTest.php
Normal file
25
tests/src/Core/SystemTest.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Friendica\Test\src\Core;
|
||||
|
||||
use Friendica\Core\System;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class SystemTest extends TestCase
|
||||
{
|
||||
private function assertGuid($guid, $length)
|
||||
{
|
||||
$this->assertRegExp("/^[a-z0-9]{" . $length . "}?$/", $guid);
|
||||
}
|
||||
|
||||
function testGuidWithoutParameter()
|
||||
{
|
||||
$guid = System::createGUID();
|
||||
$this->assertGuid($guid, 16);
|
||||
}
|
||||
|
||||
function testGuidWithSize() {
|
||||
$guid = System::createGUID(20);
|
||||
$this->assertGuid($guid, 20);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue