Adapt tests to use new BaseURL UriInterface
This commit is contained in:
parent
402d45d490
commit
9e6d95284b
|
@ -34,13 +34,11 @@ class BBCodeTest extends FixtureTest
|
||||||
DI::config()->set('system', 'remove_multiplicated_lines', false);
|
DI::config()->set('system', 'remove_multiplicated_lines', false);
|
||||||
DI::config()->set('system', 'no_oembed', false);
|
DI::config()->set('system', 'no_oembed', false);
|
||||||
DI::config()->set('system', 'allowed_link_protocols', []);
|
DI::config()->set('system', 'allowed_link_protocols', []);
|
||||||
DI::config()->set('system', 'url', 'friendica.local');
|
DI::config()->set('system', 'url', 'https://friendica.local');
|
||||||
DI::config()->set('system', 'no_smilies', false);
|
DI::config()->set('system', 'no_smilies', false);
|
||||||
DI::config()->set('system', 'big_emojis', false);
|
DI::config()->set('system', 'big_emojis', false);
|
||||||
DI::config()->set('system', 'allowed_oembed', '');
|
DI::config()->set('system', 'allowed_oembed', '');
|
||||||
|
|
||||||
DI::baseUrl()->save('friendica.local', DI::baseUrl()::SSL_POLICY_FULL, '');
|
|
||||||
|
|
||||||
$config = \HTMLPurifier_HTML5Config::createDefault();
|
$config = \HTMLPurifier_HTML5Config::createDefault();
|
||||||
$config->set('HTML.Doctype', 'HTML5');
|
$config->set('HTML.Doctype', 'HTML5');
|
||||||
$config->set('Attr.AllowedRel', [
|
$config->set('Attr.AllowedRel', [
|
||||||
|
|
|
@ -32,7 +32,7 @@ class SystemTest extends TestCase
|
||||||
private function useBaseUrl()
|
private function useBaseUrl()
|
||||||
{
|
{
|
||||||
$baseUrl = \Mockery::mock(BaseURL::class);
|
$baseUrl = \Mockery::mock(BaseURL::class);
|
||||||
$baseUrl->shouldReceive('getHostname')->andReturn('friendica.local')->once();
|
$baseUrl->shouldReceive('getHost')->andReturn('friendica.local')->once();
|
||||||
$dice = \Mockery::mock(Dice::class);
|
$dice = \Mockery::mock(Dice::class);
|
||||||
$dice->shouldReceive('create')->with(BaseURL::class)->andReturn($baseUrl);
|
$dice->shouldReceive('create')->with(BaseURL::class)->andReturn($baseUrl);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class CookieTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testInstance()
|
public function testInstance()
|
||||||
{
|
{
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn('1235')->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn('1235')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
@ -127,7 +127,7 @@ class CookieTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testGet(array $cookieData, bool $hasValues, $uid, $hash, $ip)
|
public function testGet(array $cookieData, bool $hasValues, $uid, $hash, $ip)
|
||||||
{
|
{
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn('1235')->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn('1235')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
@ -188,7 +188,7 @@ class CookieTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testCheck(string $serverPrivateKey, string $userPrivateKey, string $password, string $assertHash, bool $assertTrue)
|
public function testCheck(string $serverPrivateKey, string $userPrivateKey, string $password, string $assertHash, bool $assertTrue)
|
||||||
{
|
{
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverPrivateKey)->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverPrivateKey)->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn('7')->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
@ -248,7 +248,7 @@ class CookieTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testSet($serverKey, $uid, $password, $privateKey, $assertHash, $remoteIp, $serverArray)
|
public function testSet($serverKey, $uid, $password, $privateKey, $assertHash, $remoteIp, $serverArray)
|
||||||
{
|
{
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverKey)->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverKey)->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
@ -275,7 +275,7 @@ class CookieTest extends MockedTest
|
||||||
*/
|
*/
|
||||||
public function testDoubleSet($serverKey, $uid, $password, $privateKey, $assertHash, $remoteIp, $serverArray)
|
public function testDoubleSet($serverKey, $uid, $password, $privateKey, $assertHash, $remoteIp, $serverArray)
|
||||||
{
|
{
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverKey)->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn($serverKey)->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
@ -301,7 +301,7 @@ class CookieTest extends MockedTest
|
||||||
Cookie::NAME => 'test'
|
Cookie::NAME => 'test'
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->baseUrl->shouldReceive('getSSLPolicy')->andReturn(true)->once();
|
$this->baseUrl->shouldReceive('getScheme')->andReturn('https')->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn(24)->once();
|
$this->config->shouldReceive('get')->with('system', 'site_prvkey')->andReturn(24)->once();
|
||||||
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
$this->config->shouldReceive('get')->with('system', 'auth_cookie_lifetime', Cookie::DEFAULT_EXPIRE)->andReturn(Cookie::DEFAULT_EXPIRE)->once();
|
||||||
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
$this->config->shouldReceive('get')->with('proxy', 'trusted_proxies', '')->andReturn('')->once();
|
||||||
|
|
|
@ -21,12 +21,9 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
namespace Friendica\Test\src\Module\Api\GnuSocial\GnuSocial;
|
||||||
|
|
||||||
use Friendica\App\BaseURL;
|
|
||||||
use Friendica\App\Router;
|
|
||||||
use Friendica\DI;
|
use Friendica\DI;
|
||||||
use Friendica\Module\Api\GNUSocial\GNUSocial\Config;
|
use Friendica\Module\Api\GNUSocial\GNUSocial\Config;
|
||||||
use Friendica\Test\src\Module\Api\ApiTest;
|
use Friendica\Test\src\Module\Api\ApiTest;
|
||||||
use Friendica\Test\Util\VFSTrait;
|
|
||||||
|
|
||||||
class ConfigTest extends ApiTest
|
class ConfigTest extends ApiTest
|
||||||
{
|
{
|
||||||
|
@ -35,13 +32,11 @@ class ConfigTest extends ApiTest
|
||||||
*/
|
*/
|
||||||
public function testApiStatusnetConfig()
|
public function testApiStatusnetConfig()
|
||||||
{
|
{
|
||||||
DI::config()->set('system', 'ssl_policy', BaseURL::SSL_POLICY_FULL);
|
|
||||||
|
|
||||||
$response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
|
$response = (new Config(DI::app(), DI::l10n(), DI::baseUrl(), DI::args(), DI::logger(), DI::profiler(), DI::apiResponse(), []))
|
||||||
->run($this->httpExceptionMock);
|
->run($this->httpExceptionMock);
|
||||||
$json = $this->toJson($response);
|
$json = $this->toJson($response);
|
||||||
|
|
||||||
self::assertEquals(DI::config()->get('config', 'hostname'), $json->site->server);
|
self::assertEquals(DI::baseUrl()->getHost(), $json->site->server);
|
||||||
self::assertEquals(DI::config()->get('system', 'theme'), $json->site->theme);
|
self::assertEquals(DI::config()->get('system', 'theme'), $json->site->theme);
|
||||||
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $json->site->logo);
|
self::assertEquals(DI::baseUrl() . '/images/friendica-64.png', $json->site->logo);
|
||||||
self::assertTrue($json->site->fancy);
|
self::assertTrue($json->site->fancy);
|
||||||
|
|
|
@ -68,8 +68,8 @@ class EMailerTest extends MockedTest
|
||||||
$this->pConfig = \Mockery::mock(IManagePersonalConfigValues::class);
|
$this->pConfig = \Mockery::mock(IManagePersonalConfigValues::class);
|
||||||
$this->l10n = \Mockery::mock(L10n::class);
|
$this->l10n = \Mockery::mock(L10n::class);
|
||||||
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
||||||
$this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');
|
$this->baseUrl->shouldReceive('getHost')->andReturn('friendica.local');
|
||||||
$this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
|
$this->baseUrl->shouldReceive('__toString')->andReturn('http://friendica.local');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
|
|
|
@ -60,8 +60,8 @@ class MailBuilderTest extends MockedTest
|
||||||
$this->config = \Mockery::mock(IManageConfigValues::class);
|
$this->config = \Mockery::mock(IManageConfigValues::class);
|
||||||
$this->l10n = \Mockery::mock(L10n::class);
|
$this->l10n = \Mockery::mock(L10n::class);
|
||||||
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
||||||
$this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');
|
$this->baseUrl->shouldReceive('getHost')->andReturn('friendica.local');
|
||||||
$this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
|
$this->baseUrl->shouldReceive('__toString')->andReturn('http://friendica.local');
|
||||||
|
|
||||||
$this->defaultHeaders = [];
|
$this->defaultHeaders = [];
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ class SystemMailBuilderTest extends MockedTest
|
||||||
return $msg;
|
return $msg;
|
||||||
});
|
});
|
||||||
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
$this->baseUrl = \Mockery::mock(BaseURL::class);
|
||||||
$this->baseUrl->shouldReceive('getHostname')->andReturn('friendica.local');
|
$this->baseUrl->shouldReceive('getHost')->andReturn('friendica.local');
|
||||||
$this->baseUrl->shouldReceive('get')->andReturn('http://friendica.local');
|
$this->baseUrl->shouldReceive('__toString')->andReturn('http://friendica.local');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user