Make PHPStan passing
This commit is contained in:
@@ -2,4 +2,7 @@ parameters:
|
||||
reportUnmatchedIgnoredErrors: false
|
||||
|
||||
ignoreErrors:
|
||||
- '/Cannot access offset 0 on callable\./'
|
||||
- '/Cannot access offset 1 on callable\./'
|
||||
- '/Method FriendsOfBehat\\SymfonyExtension\\Context\\Environment\\InitialisedContextServiceEnvironment::bindCallee\(\) should return callable/'
|
||||
- '/Cannot call method [a-zA-Z0-9]+\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null\./'
|
||||
|
||||
@@ -60,11 +60,12 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @param UninitialisedContextServiceEnvironment $uninitializedEnvironment
|
||||
*
|
||||
* @throws EnvironmentIsolationException
|
||||
*/
|
||||
public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null): Environment
|
||||
{
|
||||
/** @var UninitialisedContextServiceEnvironment $uninitializedEnvironment */
|
||||
$this->assertEnvironmentCanBeIsolated($uninitializedEnvironment, $testSubject);
|
||||
|
||||
$environment = new InitialisedContextServiceEnvironment($uninitializedEnvironment->getSuite());
|
||||
@@ -136,22 +137,31 @@ final class ContextServiceEnvironmentHandler implements EnvironmentHandler
|
||||
return $class;
|
||||
}
|
||||
|
||||
throw new \Exception('wtf?');
|
||||
throw new \DomainException(sprintf('There is no service or class "%s".', $contextId));
|
||||
}
|
||||
|
||||
private function getContext(string $contextId): Context
|
||||
{
|
||||
if ($this->getContainer()->has($contextId)) {
|
||||
return $this->getContainer()->get($contextId);
|
||||
}
|
||||
|
||||
$class = '\\' . ltrim($contextId, '\\');
|
||||
|
||||
if (class_exists($class)) {
|
||||
return new $class();
|
||||
if ($this->getContainer()->has($contextId)) {
|
||||
$context = $this->getContainer()->get($contextId);
|
||||
} elseif (class_exists($class)) {
|
||||
$context = new $class();
|
||||
} else {
|
||||
throw new \DomainException(sprintf('There is no service or class "%s".', $contextId));
|
||||
}
|
||||
|
||||
throw new \Exception('wtf?');
|
||||
if (!$context instanceof Context) {
|
||||
throw new \DomainException(sprintf(
|
||||
'Context "%s" referenced as "%s" needs to implement "%s".',
|
||||
get_class($context),
|
||||
$contextId,
|
||||
Context::class
|
||||
));
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
private function getContainer(): ContainerInterface
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace FriendsOfBehat\SymfonyExtension\Driver;
|
||||
|
||||
use Behat\Mink\Driver\BrowserKitDriver;
|
||||
use Symfony\Component\BrowserKit\Client;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
final class SymfonyDriver extends BrowserKitDriver
|
||||
@@ -21,6 +22,16 @@ final class SymfonyDriver extends BrowserKitDriver
|
||||
));
|
||||
}
|
||||
|
||||
parent::__construct($kernel->getContainer()->get('test.client'), $baseUrl);
|
||||
$testClient = $kernel->getContainer()->get('test.client');
|
||||
|
||||
if (!$testClient instanceof Client) {
|
||||
throw new \RuntimeException(sprintf(
|
||||
'Service "test.client" should be an instance of "%s", "%s" given.',
|
||||
Client::class,
|
||||
get_class($testClient)
|
||||
));
|
||||
}
|
||||
|
||||
parent::__construct($testClient, $baseUrl);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user