<?php
+/**
+ * @copyright Copyright (C) 2010-2023, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
namespace Friendica\Test\src\Console;
use Friendica\App;
use Friendica\App\Mode;
use Friendica\Console\Lock;
-use Friendica\Core\Lock\ILock;
+use Friendica\Core\Lock\Capability\ICanLock;
+use Mockery;
use Mockery\MockInterface;
class LockConsoleTest extends ConsoleTest
private $appMode;
/**
- * @var ILock|MockInterface
+ * @var ICanLock|MockInterface
*/
private $lockMock;
- protected function setUp()
+ protected function setUp() : void
{
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(ICanLock::class);
}
public function testList()
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'list');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Listing all Locks:\ntest\ntest2\n2 locks found\n", $txt);
+ self::assertEquals("Listing all Locks:\ntest\ntest2\n2 locks found\n", $txt);
}
public function testListPrefix()
$console->setArgument(0, 'list');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Listing all Locks starting with \"test\":\ntest\ntest2\n2 locks found\n", $txt);
+ self::assertEquals("Listing all Locks starting with \"test\":\ntest\ntest2\n2 locks found\n", $txt);
}
public function testDelLock()
$console->setArgument(0, 'del');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Lock 'test' released.\n", $txt);
+ self::assertEquals("Lock 'test' released.\n", $txt);
}
public function testDelUnknownLock()
$console->setArgument(0, 'del');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Couldn't release Lock 'test'\n", $txt);
+ self::assertEquals("Couldn't release Lock 'test'\n", $txt);
}
public function testSetLock()
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Lock 'test' acquired.\n", $txt);
+ self::assertEquals("Lock 'test' acquired.\n", $txt);
}
public function testSetLockIsLocked()
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("[Error] 'test' is already set.\n", $txt);
+ self::assertEquals("[Error] 'test' is already set.\n", $txt);
}
public function testSetLockNotWorking()
$console->setArgument(0, 'set');
$console->setArgument(1, 'test');
$txt = $this->dumpExecute($console);
- $this->assertEquals("[Error] Unable to lock 'test'.\n", $txt);
+ self::assertEquals("[Error] Unable to lock 'test'.\n", $txt);
}
public function testReleaseAll()
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'clear');
$txt = $this->dumpExecute($console);
- $this->assertEquals("Locks successfully cleared.\n", $txt);
+ self::assertEquals("Locks successfully cleared.\n", $txt);
}
public function testReleaseAllFailed()
$console = new Lock($this->appMode, $this->lockMock, $this->consoleArgv);
$console->setArgument(0, 'clear');
$txt = $this->dumpExecute($console);
- $this->assertEquals("[Error] Unable to clear the locks.\n", $txt);
+ self::assertEquals("[Error] Unable to clear the locks.\n", $txt);
}
public function testGetHelp()
$txt = $this->dumpExecute($console);
- $this->assertEquals($txt, $theHelp);
+ self::assertEquals($txt, $theHelp);
}
}