use Friendica\App;
use Friendica\BaseObject;
use Friendica\Render\FriendicaSmartyEngine;
+use Mockery\MockInterface;
use org\bovigo\vfs\vfsStreamDirectory;
/**
trait AppMockTrait
{
use ConfigMockTrait;
- use DBAMockTrait;
/**
- * @var App The Friendica global App Mock
+ * @var MockInterface|App The mocked Friendica\App
*/
protected $app;
$this->mockConfigGet('system', 'theme', 'testtheme');
// Mocking App and most used functions
- $this->app = \Mockery::mock('Friendica\App');
+ $this->app = \Mockery::mock(App::class);
$this->app
->shouldReceive('getBasePath')
->andReturn($root->url());
namespace Friendica\Test\Util;
+use Mockery\MockInterface;
+
/**
* Trait to Mock Config settings
*/
trait ConfigMockTrait
{
+ /**
+ * @var MockInterface The mocking interface of Friendica\Core\Config
+ */
private $configMock;
/**
namespace Friendica\Test\Util;
+use Mockery\MockInterface;
+
/**
* Trait to mock the DBA connection status
*/
trait DBAMockTrait
{
+ /**
+ * @var MockInterface The mocking interface of Friendica\Database\DBA
+ */
private $dbaMock;
+ /**
+ * Mocking DBA::connect()
+ *
+ * @param bool $return True, if the connect was successful, otherwise false
+ * @param null|int $times How often the method will get used
+ */
public function mockConnect($return = true, $times = null)
{
if (!isset($this->dbaMock)) {
->andReturn($return);
}
+ /**
+ * Mocking DBA::connected()
+ *
+ * @param bool $return True, if the DB is connected, otherwise false
+ * @param null|int $times How often the method will get used
+ */
public function mockConnected($return = true, $times = null)
{
if (!isset($this->dbaMock)) {
namespace Friendica\Test\Util;
+use Mockery\MockInterface;
+
/**
* Trait to mock the DBStructure connection status
*/
trait DBStructureMockTrait
{
+ /**
+ * @var MockInterface The mocking interface of Friendica\Database\DBStructure
+ */
private $dbStructure;
+ /**
+ * Mocking DBStructure::update()
+ *
+ * @param array $args The arguments for the update call
+ * @param bool $return True, if the connect was successful, otherwise false
+ * @param null|int $times How often the method will get used
+ */
public function mockUpdate($args = [], $return = true, $times = null)
{
if (!isset($this->dbStructure)) {
->andReturn($return);
}
+ /**
+ * Mocking DBStructure::existsTable()
+ *
+ * @param string $tableName The name of the table to check
+ * @param bool $return True, if the connect was successful, otherwise false
+ * @param null|int $times How often the method will get used
+ */
public function mockExistsTable($tableName, $return = true, $times = null)
{
if (!isset($this->dbStructure)) {
*/
protected $root;
+ /**
+ * Sets up the Virtual File System for Friendica with common files (config, dbstructure)
+ */
protected function setUpVfsDir() {
// the used directories inside the App class
$structure = [
$this->setConfigFile('dbstructure.php');
}
+ /**
+ * Copying a config file from the file system to the Virtual File System
+ *
+ * @param string $filename The filename of the config file
+ */
protected function setConfigFile($filename)
{
$file = dirname(__DIR__) . DIRECTORY_SEPARATOR .
}
}
+ /**
+ * Delets a config file from the Virtual File System
+ *
+ * @param string $filename The filename of the config file
+ */
protected function delConfigFile($filename)
{
if ($this->root->hasChild('config/' . $filename)) {
namespace Friendica\Test\src\Core\Console;
use Friendica\Core\Console\AutomaticInstallation;
+use Friendica\Test\Util\DBAMockTrait;
use Friendica\Test\Util\DBStructureMockTrait;
use org\bovigo\vfs\vfsStream;
*/
class AutomaticInstallationConsoleTest extends ConsoleTest
{
+ use DBAMockTrait;
use DBStructureMockTrait;
private $db_host;
$console = new AutomaticInstallation();
- $returnStr = $this->dumpExecute($console);
+ $txt = $this->dumpExecute($console);
- $this->assertFinished($returnStr, true);
+ $this->assertFinished($txt, true);
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.ini.php'));
$console->setOption('urlpath', '/friendica');
- $returnStr = $this->dumpExecute($console);
+ $txt = $this->dumpExecute($console);
- $this->assertFinished($returnStr, true);
+ $this->assertFinished($txt, true);
$this->assertTrue($this->root->hasChild('config' . DIRECTORY_SEPARATOR . 'local.ini.php'));
$console = new AutomaticInstallation();
- $returnStr = $this->dumpExecute($console);
+ $txt = $this->dumpExecute($console);
- $this->assertStuckDB($returnStr);
+ $this->assertStuckDB($txt);
}
public function testGetHelp()