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 private function useBaseUrl()
15 $baseUrl = \Mockery::mock(BaseURL::class);
16 $baseUrl->shouldReceive('getHostname')->andReturn('friendica.local')->once();
17 $dice = \Mockery::mock(Dice::class);
18 $dice->shouldReceive('create')->with(BaseURL::class, [])->andReturn($baseUrl);
23 private function assertGuid($guid, $length, $prefix = '')
25 $length -= strlen($prefix);
26 $this->assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
29 function testGuidWithoutParameter()
32 $guid = System::createGUID();
33 $this->assertGuid($guid, 16);
36 function testGuidWithSize32()
39 $guid = System::createGUID(32);
40 $this->assertGuid($guid, 32);
43 function testGuidWithSize64()
46 $guid = System::createGUID(64);
47 $this->assertGuid($guid, 64);
50 function testGuidWithPrefix()
52 $guid = System::createGUID(23, 'test');
53 $this->assertGuid($guid, 23, 'test');