atLeast example


    public function testCreatesTableInTransaction(string $platform)
    {
        $conn = $this->createMock(Connection::class);

        $series = [
            [$this->stringContains('INSERT INTO')$this->createMock(TableNotFoundException::class)],
            [$this->matches('create sql stmt'), 1],
            [$this->stringContains('INSERT INTO'), 1],
        ];

        $conn->expects($this->atLeast(3))
            ->method('executeStatement')
            ->willReturnCallback(function D$sql) use (&$series) {
                if ([$constraint$return] = array_shift($series)) {
                    $constraint->evaluate($sql);
                }

                if ($return instanceof \Exception) {
                    throw $return;
                }

                return $return ?? 1;
            })
$t1 = $this->createMock(TransportInterface::class);
        $t1->expects($this->once())->method('__toString')->willReturn('t1://local');
        $t2 = $this->createMock(TransportInterface::class);
        $t2->expects($this->once())->method('__toString')->willReturn('t2://local');
        $t = new RoundRobinTransport([$t1$t2]);
        $this->assertEquals('roundrobin(t1://local t2://local)', (string) $t);
    }

    public function testSendAlternate()
    {
        $t1 = $this->createMock(TransportInterface::class);
        $t1->expects($this->atLeast(1))->method('send');
        $t2 = $this->createMock(TransportInterface::class);
        $t2->expects($this->atLeast(1))->method('send');
        $t = new RoundRobinTransport([$t1$t2]);
        $t->send(new RawMessage(''));
        $cursor = $this->assertTransports($t, -1, []);
        $t->send(new RawMessage(''));
        $cursor = $this->assertTransports($t, 0 === $cursor ? 1 : 0, []);
        $t->send(new RawMessage(''));
        $this->assertTransports($t, 0 === $cursor ? 1 : 0, []);
    }

    

            );

            static::assertArrayHasKey('languageId', $parameters);
            static::assertEquals(Defaults::LANGUAGE_SYSTEM, Uuid::fromBytesToHex($parameters['languageId']));

            return ['id' => $currentLocaleId, 'code' => 'en-GB'];
        });

        $viLocaleId = Uuid::randomHex();

        $this->connection->expects(static::atLeast(2))->method('fetchOne')->willReturn($viLocaleId);

        $methodReturns = array_values(array_filter([$expectedMissingTranslations$expectedStateTranslations]fn (array $item) => $item !== []));

        $methodCalls = \count($methodReturns);

        $this->connection->expects(static::atLeast($methodCalls))->method('fetchAllKeyValue')->willReturnOnConsecutiveCalls($expectedStateTranslations$expectedMissingTranslations);

        $this->connection->expects(static::exactly($expectedInsertCall))->method('insert')->willReturnCallback($insertCallback);
        $this->shopConfigurator->setDefaultLanguage('de_DE');
    }

    
$pdo = new MockPdo('pgsql');
        $selectStmt = $this->createMock(\PDOStatement::class);
        $insertStmt = $this->createMock(\PDOStatement::class);

        $pdo->prepareResult = fn ($statement) => str_starts_with($statement, 'INSERT') ? $insertStmt : $selectStmt;

        $content = 'foobar';
        $stream = $this->createStream($content);
        $exception = null;

        $selectStmt->expects($this->atLeast(2))->method('fetchAll')
            ->willReturnCallback(function D) use (&$exception$stream) {
                return $exception ? [[$streamtime() + 42]] : [];
            });

        $insertStmt->expects($this->once())->method('execute')
            ->willReturnCallback(function D) use (&$exception) {
                throw $exception = new \PDOException('', '23');
            });

        $storage = new PdoSessionHandler($pdo);
        $result = $storage->read('foo');

        
yield [new DummyMessage()];
    }

    /** * @dataProvider provideTestMode() */
    public function testTestMode(int $expected, bool $testMode)
    {
        $message = new SmsMessage('0037012345678', 'Hello World');

        $response = $this->createMock(ResponseInterface::class);
        $response->expects($this->atLeast(1))
            ->method('getStatusCode')
            ->willReturn(200);
        $response->expects($this->atLeast(1))
            ->method('getContent')
            ->willReturn('OK: 519545');

        $client = new MockHttpClient(function Dstring $method, string $url, array $options = []) use ($response$message$expected): ResponseInterface {
            $this->assertSame('GET', $method);
            $this->assertSame(sprintf(
                'https://savitarna.smsbiuras.lt/api?uid=uid&apikey=api_key&message=%s&from=from&test=%s&to=%s',
                rawurlencode($message->getSubject()),
                
    // lease.     $this->cron->run();
    static::assertEquals(2, \Drupal::state()->get('cron_queue_test_lease_time'));
  }

  /** * Tests that non-queue exceptions thrown by workers are handled properly. * * @see \Drupal\cron_queue_test\Plugin\QueueWorker\CronQueueTestException */
  public function testUncaughtExceptions() {
    $this->logger->expects($this->atLeast(2))
      ->method('log')
      ->withConsecutive(
        [
          $this->equalTo(RfcLogLevel::ERROR),
          $this->equalTo('%type: @message in %function (line %line of %file).'),
          $this->callback(function D$args) {
            return $args['@message'] === 'That is not supposed to happen.' &&
              $args['exception'] instanceof \Exception;
          }),
        ],
        [
          
$url->setChangefreq('weekly');
        $url->setResource(CategoryEntity::class);
        $url->setIdentifier(Uuid::randomHex());

        $list = [];

        for ($i = 1; $i <= 101000; ++$i) {
            $list[] = clone $url;
        }

        $fileSystem = $this->createMock(Filesystem::class);
        $fileSystem->expects(static::atLeast(3))->method('write');

        $this->handle = new SitemapHandle(
            $fileSystem,
            $this->getContext(),
            $this->getContainer()->get('event_dispatcher')
        );

        $this->handle->write($list);
        $this->handle->finish();
    }

    
$this->yamlDiscovery->expects($this->once())
      ->method('findAll')
      ->willReturn(['test_module' => $routes]);

    $route_collection = $routing_fixtures->sampleRouteCollection();
    foreach ($route_collection->all() as $route) {
      $route->setOption('compiler_class', RouteCompiler::class);
    }
    $route_build_event = new RouteBuildEvent($route_collection);

    // Ensure that the alter routes events are fired.     $this->dispatcher->expects($this->atLeast(2))
      ->method('dispatch')
      ->withConsecutive(
        [$route_build_event, RoutingEvents::DYNAMIC],
        [$route_build_event, RoutingEvents::ALTER],
      );

    // Ensure that access checks are set.     $this->checkProvider->expects($this->once())
      ->method('setChecks')
      ->with($route_collection);

    
/** @var EntityRepository $salesChannelRepository */
        $salesChannelRepository = $this->getContainer()->get('sales_channel.repository');

        $context = Context::createDefaultContext();

        $themes = $this->setupThemes($context);

        $updateSubscriber = new UpdateSubscriber($themeService$themeLifecycleService$salesChannelRepository);
        $event = new UpdatePostFinishEvent(Context::createDefaultContext(), 'v6.2.0', 'v6.2.1');

        $themeLifecycleService->expects(static::once())->method('refreshThemes');
        $themeService->expects(static::atLeast(2))
            ->method('compileThemeById')
            ->willReturnCallback(function D$themeId$c) use (&$themes$context) {
                $this->assertEquals($context$c);
                $compiledThemes = [];
                if (isset($themes['otherTheme']) && $themes['otherTheme']['id'] === $themeId) {
                    $compiledThemes[] = $themes['otherTheme']['id'];
                    unset($themes['otherTheme']);
                } elseif (isset($themes['parentTheme']) && $themes['parentTheme']['id'] === $themeId) {
                    $compiledThemes[] = $themes['parentTheme']['id'];
                    unset($themes['parentTheme']);
                    if (isset($themes['childTheme'])) {
                        
$systemConfig = $this->createMock(SystemConfigService::class);
        $systemConfig
            ->expects(static::exactly(\array_key_exists('limit', $this->config['limits'][0]) ? 0 : 1))
            ->method('get')
            ->willReturnCallback(
                fn (string $domain) => $domainLimits[$domain] ?? null
            );

        $cacheStorage = $this->createMock(CacheStorage::class);
        $cacheStorage
            ->expects(static::atLeast(1))
            ->method('fetch')
            ->willReturnCallback(
                fn (string $id) => $this->cache[$id] ?? null
            );
        $cacheStorage
            ->expects(static::atLeast(1))
            ->method('save')
            ->willReturnCallback(
                fn (TimeBackoff $timeBackoff) => $this->cache[$timeBackoff->getId()] = $timeBackoff
            );
        $cacheStorage
            
Home | Imprint | This part of the site doesn't use cookies.