<?php
/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
namespace Friendica\Test\src\App;
use Detection\MobileDetect;
+use Friendica\App\Arguments;
use Friendica\App\Mode;
-use Friendica\App\Module;
-use Friendica\Core\Config\Cache\Cache;
+use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Database\Database;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\VFSTrait;
self::assertFalse($mode->has(Mode::DBAVAILABLE));
}
- public function testWithoutDatabaseSetup()
- {
- $this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
-
- $this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
- $this->databaseMock->shouldReceive('fetchFirst')
- ->with('SHOW TABLES LIKE \'config\'')->andReturn(false)->once();
-
- $mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
-
- self::assertFalse($mode->isNormal());
- self::assertTrue($mode->isInstall());
-
- self::assertTrue($mode->has(Mode::LOCALCONFIGPRESENT));
- }
-
public function testWithMaintenanceMode()
{
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
- $this->databaseMock->shouldReceive('fetchFirst')
- ->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(true)->once();
self::assertFalse($mode->isNormal());
self::assertFalse($mode->isInstall());
- self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertFalse($mode->has(Mode::MAINTENANCEDISABLED));
}
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
- $this->databaseMock->shouldReceive('fetchFirst')
- ->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(false)->once();
- $this->databaseMock->shouldReceive('selectFirst')
- ->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
- ->andReturn(['v' => null])->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
self::assertTrue($mode->isNormal());
self::assertFalse($mode->isInstall());
- self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
}
$this->basePathMock->shouldReceive('getPath')->andReturn($this->root->url())->once();
$this->databaseMock->shouldReceive('connected')->andReturn(true)->once();
- $this->databaseMock->shouldReceive('fetchFirst')
- ->with('SHOW TABLES LIKE \'config\'')->andReturn(true)->once();
$this->configCacheMock->shouldReceive('get')->with('system', 'maintenance')
->andReturn(false)->once();
- $this->databaseMock->shouldReceive('selectFirst')
- ->with('config', ['v'], ['cat' => 'system', 'k' => 'maintenance'])
- ->andReturn(['v' => '0'])->once();
$mode = (new Mode())->determine($this->basePathMock, $this->databaseMock, $this->configCacheMock);
self::assertTrue($mode->isNormal());
self::assertFalse($mode->isInstall());
- self::assertTrue($mode->has(Mode::DBCONFIGAVAILABLE));
self::assertTrue($mode->has(Mode::MAINTENANCEDISABLED));
}
public function testIsBackendNotIsBackend()
{
$server = [];
- $module = new Module();
+ $args = new Arguments();
$mobileDetect = new MobileDetect();
- $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect);
self::assertTrue($mode->isBackend());
}
public function testIsBackendButIndex()
{
$server = [];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], true);
+ $args = new Arguments('', '', Mode::BACKEND_MODULES[0]);
$mobileDetect = new MobileDetect();
- $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(false, $server, $args, $mobileDetect);
self::assertTrue($mode->isBackend());
}
public function testIsNotBackend()
{
$server = [];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
+ $args = new Arguments('', '', Arguments::DEFAULT_MODULE);
$mobileDetect = new MobileDetect();
- $mode = (new Mode())->determineRunMode(false, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(false, $server, $args, $mobileDetect);
self::assertFalse($mode->isBackend());
}
'HTTP_X_REQUESTED_WITH' => 'xmlhttprequest',
];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
+ $args = new Arguments('', '', Arguments::DEFAULT_MODULE);
$mobileDetect = new MobileDetect();
- $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect);
self::assertTrue($mode->isAjax());
}
public function testIsNotAjax()
{
$server = [];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
+ $args = new Arguments('', '', Arguments::DEFAULT_MODULE);
$mobileDetect = new MobileDetect();
- $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect);
self::assertFalse($mode->isAjax());
}
public function testIsMobileIsTablet()
{
$server = [];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
+ $args = new Arguments('', '', Arguments::DEFAULT_MODULE);
$mobileDetect = Mockery::mock(MobileDetect::class);
$mobileDetect->shouldReceive('isMobile')->andReturn(true);
$mobileDetect->shouldReceive('isTablet')->andReturn(true);
- $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect);
self::assertTrue($mode->isMobile());
self::assertTrue($mode->isTablet());
public function testIsNotMobileIsNotTablet()
{
$server = [];
- $module = new Module(Module::DEFAULT, Module::DEFAULT_CLASS, [], false);
+ $args = new Arguments('', '', Arguments::DEFAULT_MODULE);
$mobileDetect = Mockery::mock(MobileDetect::class);
$mobileDetect->shouldReceive('isMobile')->andReturn(false);
$mobileDetect->shouldReceive('isTablet')->andReturn(false);
- $mode = (new Mode())->determineRunMode(true, $module, $server, $mobileDetect);
+ $mode = (new Mode())->determineRunMode(true, $server, $args, $mobileDetect);
self::assertFalse($mode->isMobile());
self::assertFalse($mode->isTablet());