3 namespace Friendica\Test\src\Core;
6 use Friendica\App\BaseURL;
7 use Friendica\Core\System;
9 use PHPUnit\Framework\TestCase;
11 class SystemTest extends TestCase
13 protected function setUp()
17 $baseUrl = \Mockery::mock(BaseURL::class);
18 $baseUrl->shouldReceive('getHostname')->andReturn('friendica.local')->once();
19 $dice = \Mockery::mock(Dice::class);
20 $dice->shouldReceive('create')->with(BaseURL::class, [])->andReturn($baseUrl);
25 private function assertGuid($guid, $length, $prefix = '')
27 $length -= strlen($prefix);
28 $this->assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
31 function testGuidWithoutParameter()
33 $guid = System::createGUID();
34 $this->assertGuid($guid, 16);
37 function testGuidWithSize32() {
38 $guid = System::createGUID(32);
39 $this->assertGuid($guid, 32);
42 function testGuidWithSize64() {
43 $guid = System::createGUID(64);
44 $this->assertGuid($guid, 64);
47 function testGuidWithPrefix() {
48 $guid = System::createGUID(23, 'test');
49 $this->assertGuid($guid, 23, 'test');