mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-17 04:15:15 +02:00
Refactor L10n for testing
- Moving L10n to L10n\L10n - Adding constructor information - Adding to factory - simplify/speedup tests
This commit is contained in:
parent
966043712f
commit
eb024a3718
13 changed files with 596 additions and 450 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue