Refactor L10n for testing

- Moving L10n to L10n\L10n
- Adding constructor information
- Adding to factory
- simplify/speedup tests
This commit is contained in:
Philipp Holzer 2019-07-09 21:44:02 +02:00
parent 966043712f
commit eb024a3718
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
13 changed files with 596 additions and 450 deletions

View file

@ -1,46 +0,0 @@
<?php
namespace Friendica\Test\Util;
use Friendica\Core\L10n;
use Mockery\MockInterface;
trait L10nMockTrait
{
/**
* @var MockInterface The interface for L10n mocks
*/
private $l10nMock;
/**
* Mocking the 'L10n::t()' method
*
* @param null|string $input Either an input (string) or null for EVERY input is possible
* @param null|int $times How often will it get called
* @param null|string $return Either an return (string) or null for return the input
*/
public function mockL10nT($input = null, $times = null, $return = null)
{
if (!isset($this->l10nMock)) {
$this->l10nMock = \Mockery::mock('alias:' . L10n::class);
}
$with = isset($input) ? $input : \Mockery::any();
$return = isset($return) ? $return : $with;
if ($return instanceof \Mockery\Matcher\Any) {
$this->l10nMock
->shouldReceive('t')
->with($with)
->times($times)
->andReturnUsing(function($arg) { return $arg; });
} else {
$this->l10nMock
->shouldReceive('t')
->with($with)
->times($times)
->andReturn($return);
}
}
}