Fix a lot of notices/warnings/deprecation notes in the test directory
This commit is contained in:
parent
efaec26b1d
commit
d55ecb9288
77 changed files with 428 additions and 558 deletions
|
@ -35,6 +35,7 @@ use Friendica\Test\Util\DBStructureMockTrait;
|
|||
use Friendica\Test\Util\RendererMockTrait;
|
||||
use Friendica\Test\Util\VFSTrait;
|
||||
use Friendica\Util\Logger\VoidLogger;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use org\bovigo\vfs\vfsStreamFile;
|
||||
|
@ -77,7 +78,7 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
|||
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
||||
static::markTestSkipped('Needs class \'Installer\' as constructing argument for console tests');
|
||||
|
||||
parent::setUp();
|
||||
|
||||
|
@ -87,9 +88,9 @@ class AutomaticInstallationConsoleTest extends ConsoleTest
|
|||
$this->root->getChild('config')
|
||||
->removeChild('local.config.php');
|
||||
}
|
||||
$this->dice = \Mockery::mock(Dice::class)->makePartial();
|
||||
$this->dice = Mockery::mock(Dice::class)->makePartial();
|
||||
|
||||
$l10nMock = \Mockery::mock(L10n::class);
|
||||
$l10nMock = Mockery::mock(L10n::class);
|
||||
$l10nMock->shouldReceive('t')->andReturnUsing(function ($args) { return $args; });
|
||||
|
||||
$this->dice->shouldReceive('create')
|
||||
|
@ -400,7 +401,7 @@ FIN;
|
|||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||
$this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
|
||||
|
||||
$console = new AutomaticInstallation($this->consoleArgv);
|
||||
$console->setOption('url', 'http://friendica.local');
|
||||
|
@ -502,7 +503,7 @@ CONF;
|
|||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||
$this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
|
||||
|
||||
self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
|
||||
self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
|
||||
|
@ -540,7 +541,7 @@ CONF;
|
|||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||
$this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
|
||||
|
||||
self::assertTrue(putenv('MYSQL_HOST=' . $data['database']['hostname']));
|
||||
self::assertTrue(putenv('MYSQL_PORT=' . $data['database']['port']));
|
||||
|
@ -576,7 +577,7 @@ CONF;
|
|||
$this->mockUpdate([$this->root->url(), false, true, true], null, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||
$this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
|
||||
|
||||
$console = new AutomaticInstallation($this->consoleArgv);
|
||||
|
||||
|
@ -611,7 +612,7 @@ CONF;
|
|||
$this->mockConnect(false, 1);
|
||||
|
||||
$this->mockGetMarkupTemplate('local.config.tpl', 'testTemplate', 1);
|
||||
$this->mockReplaceMacros('testTemplate', \Mockery::any(), '', 1);
|
||||
$this->mockReplaceMacros('testTemplate', Mockery::any(), '', 1);
|
||||
|
||||
$console = new AutomaticInstallation($this->consoleArgv);
|
||||
$console->setOption('url', 'http://friendica.local');
|
||||
|
|
|
@ -25,6 +25,8 @@ use Friendica\App;
|
|||
use Friendica\App\Mode;
|
||||
use Friendica\Console\Config;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Mockery;
|
||||
use Mockery\LegacyMockInterface;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class ConfigConsoleTest extends ConsoleTest
|
||||
|
@ -33,27 +35,27 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
* @var App\Mode|MockInterface $appMode
|
||||
*/
|
||||
private $appMode;
|
||||
/** @var IConfig|\Mockery\LegacyMockInterface|MockInterface */
|
||||
/** @var IConfig|LegacyMockInterface|MockInterface */
|
||||
private $configMock;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
\Mockery::getConfiguration()->setConstantsMap([
|
||||
Mockery::getConfiguration()->setConstantsMap([
|
||||
Mode::class => [
|
||||
'DBCONFIGAVAILABLE' => 0
|
||||
]
|
||||
'DBCONFIGAVAILABLE' => 0,
|
||||
],
|
||||
]);
|
||||
|
||||
$this->appMode = \Mockery::mock(App\Mode::class);
|
||||
$this->appMode = Mockery::mock(App\Mode::class);
|
||||
$this->appMode->shouldReceive('has')
|
||||
->andReturn(true);
|
||||
->andReturn(true);
|
||||
|
||||
$this->configMock = \Mockery::mock(IConfig::class);
|
||||
$this->configMock = Mockery::mock(IConfig::class);
|
||||
}
|
||||
|
||||
function testSetGetKeyValue()
|
||||
public function testSetGetKeyValue()
|
||||
{
|
||||
$this->configMock
|
||||
->shouldReceive('set')
|
||||
|
@ -98,7 +100,8 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
self::assertEquals("config.test => \n", $txt);
|
||||
}
|
||||
|
||||
function testSetArrayValue() {
|
||||
public function testSetArrayValue()
|
||||
{
|
||||
$testArray = [1, 2, 3];
|
||||
$this->configMock
|
||||
->shouldReceive('get')
|
||||
|
@ -115,19 +118,21 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
self::assertEquals("[Error] config.test is an array and can't be set using this command.\n", $txt);
|
||||
}
|
||||
|
||||
function testTooManyArguments() {
|
||||
public function testTooManyArguments()
|
||||
{
|
||||
$console = new Config($this->appMode, $this->configMock, $this->consoleArgv);
|
||||
$console->setArgument(0, 'config');
|
||||
$console->setArgument(1, 'test');
|
||||
$console->setArgument(2, 'it');
|
||||
$console->setArgument(3, 'now');
|
||||
$txt = $this->dumpExecute($console);
|
||||
$txt = $this->dumpExecute($console);
|
||||
$assertion = '[Warning] Too many arguments';
|
||||
$firstline = substr($txt, 0, strlen($assertion));
|
||||
self::assertEquals($assertion, $firstline);
|
||||
}
|
||||
|
||||
function testVerbose() {
|
||||
public function testVerbose()
|
||||
{
|
||||
$this->configMock
|
||||
->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
|
@ -138,7 +143,7 @@ class ConfigConsoleTest extends ConsoleTest
|
|||
$console->setArgument(1, 'it');
|
||||
$console->setOption('v', 1);
|
||||
$executable = $this->consoleArgv[0];
|
||||
$assertion = <<<CONF
|
||||
$assertion = <<<CONF
|
||||
Executable: {$executable}
|
||||
Class: Friendica\Console\Config
|
||||
Arguments: array (
|
||||
|
@ -151,11 +156,12 @@ Options: array (
|
|||
test.it => now
|
||||
|
||||
CONF;
|
||||
$txt = $this->dumpExecute($console);
|
||||
$txt = $this->dumpExecute($console);
|
||||
self::assertEquals($assertion, $txt);
|
||||
}
|
||||
|
||||
function testUnableToSet() {
|
||||
public function testUnableToSet()
|
||||
{
|
||||
$this->configMock
|
||||
->shouldReceive('set')
|
||||
->with('test', 'it', 'now')
|
||||
|
@ -164,7 +170,7 @@ CONF;
|
|||
$this->configMock
|
||||
->shouldReceive('get')
|
||||
->with('test', 'it')
|
||||
->andReturn(NULL)
|
||||
->andReturn(null)
|
||||
->once();
|
||||
$console = new Config($this->appMode, $this->configMock, [$this->consoleArgv]);
|
||||
$console->setArgument(0, 'test');
|
||||
|
|
|
@ -46,7 +46,7 @@ abstract class ConsoleTest extends MockedTest
|
|||
*
|
||||
* @return string the output of the execution
|
||||
*/
|
||||
protected function dumpExecute($console)
|
||||
protected function dumpExecute(Console $console)
|
||||
{
|
||||
Intercept::reset();
|
||||
$console->execute();
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\App;
|
|||
use Friendica\App\Mode;
|
||||
use Friendica\Console\Lock;
|
||||
use Friendica\Core\Lock\ILock;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class LockConsoleTest extends ConsoleTest
|
||||
|
@ -43,17 +44,17 @@ class LockConsoleTest extends ConsoleTest
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
\Mockery::getConfiguration()->setConstantsMap([
|
||||
Mockery::getConfiguration()->setConstantsMap([
|
||||
Mode::class => [
|
||||
'DBCONFIGAVAILABLE' => 0
|
||||
]
|
||||
]);
|
||||
|
||||
$this->appMode = \Mockery::mock(App\Mode::class);
|
||||
$this->appMode = Mockery::mock(App\Mode::class);
|
||||
$this->appMode->shouldReceive('has')
|
||||
->andReturn(true);
|
||||
|
||||
$this->lockMock = \Mockery::mock(ILock::class);
|
||||
$this->lockMock = Mockery::mock(ILock::class);
|
||||
}
|
||||
|
||||
public function testList()
|
||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Test\src\Console;
|
|||
|
||||
use Friendica\Console\ServerBlock;
|
||||
use Friendica\Core\Config\IConfig;
|
||||
use Mockery;
|
||||
|
||||
class ServerBlockConsoleTest extends ConsoleTest
|
||||
{
|
||||
|
@ -36,12 +37,16 @@ class ServerBlockConsoleTest extends ConsoleTest
|
|||
'reason' => 'Illegal content',
|
||||
]
|
||||
];
|
||||
/**
|
||||
* @var IConfig|Mockery\LegacyMockInterface|Mockery\MockInterface
|
||||
*/
|
||||
private $configMock;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->configMock = \Mockery::mock(IConfig::class);
|
||||
$this->configMock = Mockery::mock(IConfig::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue