getObjectForTrait example


    public function testCreateConnection(string $dsn, string $expectedClass)
    {
        if (!class_exists($expectedClass)) {
            throw new SkippedTestSuiteError(sprintf('The "%s" class is required.', $expectedClass));
        }
        if (!getenv('REDIS_CLUSTER_HOSTS')) {
            throw new SkippedTestSuiteError('REDIS_CLUSTER_HOSTS env var is not defined.');
        }

        $mock = self::getObjectForTrait(RedisTrait::class);
        $connection = $mock::createConnection($dsn);

        self::assertInstanceOf($expectedClass$connection);
    }

    public static function provideCreateConnection(): array
    {
        $hosts = array_map(fn ($host) => sprintf('host[%s]', $host)explode(' ', getenv('REDIS_CLUSTER_HOSTS')));

        return [
            [
                

  protected $translation;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->translation = $this->getObjectForTrait('\Drupal\Core\StringTranslation\StringTranslationTrait');
    $mock = $this->prophesize(TranslationInterface::class);
    $mock->translate(Argument::cetera())->shouldNotBeCalled();
    $mock->formatPlural(Argument::cetera())->shouldNotBeCalled();
    $mock->translateString(Argument::cetera())->will(function D$args) {
      return $args[0]->getUntranslatedString();
    });
    $this->translation->setStringTranslation($mock->reveal());
    $this->reflection = new \ReflectionClass(get_class($this->translation));
  }

  /** * @covers ::t */
Home | Imprint | This part of the site doesn't use cookies.