Init
This commit is contained in:
28
tests/toolkit/TestCase/BaseContainerTestCase.php
Normal file
28
tests/toolkit/TestCase/BaseContainerTestCase.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Toolkit\TestCase;
|
||||
|
||||
use Nette\DI\Container;
|
||||
|
||||
abstract class BaseContainerTestCase extends BaseTestCase
|
||||
{
|
||||
|
||||
/** @var Container */
|
||||
protected $container;
|
||||
|
||||
public function __construct(Container $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
protected function getService(string $class): object
|
||||
{
|
||||
if (strpos($class, '\\')) {
|
||||
/** @phpstan-var class-string<mixed> $class */
|
||||
return $this->container->getByType($class);
|
||||
} else {
|
||||
return $this->container->getService($class);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user