Add tests for InstanceManager and remove Decorator hook logic (avoid complex Dice logic)

This commit is contained in:
Philipp Holzer 2023-07-17 00:10:15 +02:00
commit 93af6f0564
Signed by: nupplaPhil
GPG key ID: 24A7501396EB5432
14 changed files with 218 additions and 390 deletions

View file

@ -21,7 +21,7 @@
namespace Friendica\Test\Util\Hooks\InstanceMocks;
class FakeInstance
class FakeInstance implements IAmADecoratedInterface
{
protected $aText = null;
protected $cBool = null;
@ -39,6 +39,8 @@ class FakeInstance
$this->aText = $aText;
$this->cBool = $cBool;
$this->bText = $bText;
return '';
}
public function getAText(): ?string

View file

@ -25,14 +25,14 @@ class FakeInstanceDecorator implements IAmADecoratedInterface
{
public static $countInstance = 0;
const PREFIX = 'prefix1';
/** @var IAmADecoratedInterface */
protected $orig;
protected $prefix = '';
public function __construct(IAmADecoratedInterface $orig, string $prefix = '')
public function __construct(IAmADecoratedInterface $orig)
{
$this->orig = $orig;
$this->prefix = $prefix;
self::$countInstance++;
}
@ -44,16 +44,16 @@ class FakeInstanceDecorator implements IAmADecoratedInterface
public function getAText(): ?string
{
return $this->prefix . $this->orig->getAText();
return static::PREFIX . $this->orig->getAText();
}
public function getBText(): ?string
{
return $this->prefix . $this->orig->getBText();
return static::PREFIX . $this->orig->getBText();
}
public function getCBool(): ?bool
{
return $this->prefix . $this->orig->getCBool();
return static::PREFIX . $this->orig->getCBool();
}
}