Fix tests

This commit is contained in:
Philipp Holzer 2019-07-26 15:54:14 +02:00
parent 2a87464c97
commit 07aaf292ec
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
12 changed files with 134 additions and 144 deletions

View file

@ -3,7 +3,7 @@
namespace Friendica\Test\src\Core\Cache;
use Friendica\Core\Cache\IMemoryCacheDriver;
use Friendica\Core\Logger;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
abstract class MemoryCacheTest extends CacheTest
@ -15,9 +15,13 @@ abstract class MemoryCacheTest extends CacheTest
protected function setUp()
{
Logger::init(new NullLogger());
parent::setUp();
$logger = new NullLogger();
$this->dice->shouldReceive('create')
->with(LoggerInterface::class)
->andReturn($logger);
if (!($this->instance instanceof IMemoryCacheDriver)) {
throw new \Exception('MemoryCacheTest unsupported');
}

View file

@ -3,6 +3,8 @@
// this is in the same namespace as Install for mocking 'function_exists'
namespace Friendica\Core;
use Dice\Dice;
use Friendica\BaseObject;
use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Network\CurlResult;
use Friendica\Object\Image;
@ -27,7 +29,16 @@ class InstallerTest extends MockedTest
$this->setUpVfsDir();
$this->l10nMock = \Mockery::mock(\Friendica\Core\L10n\L10n::class);
L10n::init($this->l10nMock);
/** @var Dice|MockInterface $dice */
$dice = \Mockery::mock(Dice::class)->makePartial();
$dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
$dice->shouldReceive('create')
->with(\Friendica\Core\L10n\L10n::class)
->andReturn($this->l10nMock);
BaseObject::setDependencyInjection($dice);
}
private function mockL10nT(string $text, $times = null)

View file

@ -2,10 +2,10 @@
namespace Friendica\Test\src\Core\Lock;
use Friendica\Core\Logger;
use Friendica\Test\MockedTest;
use Friendica\Test\Util\AppMockTrait;
use Friendica\Test\Util\VFSTrait;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
abstract class LockTest extends MockedTest
@ -34,7 +34,10 @@ abstract class LockTest extends MockedTest
->shouldReceive('getHostname')
->andReturn('friendica.local');
Logger::init(new NullLogger());
$logger = new NullLogger();
$this->dice->shouldReceive('create')
->with(LoggerInterface::class)
->andReturn($logger);
parent::setUp();
$this->instance = $this->getInstance();