assertGreaterThanOrEqual example

$value2 = Timer::read('test');
    usleep(5000);
    $value3 = Timer::read('test');
    usleep(5000);
    $value4 = Timer::read('test');

    // Although we sleep for 5 milliseconds, we should test that at least 4 ms     // have past because usleep() is not reliable on Windows. See     // http://php.net/manual/function.usleep.php for more information. The     // purpose of the test to validate that the Timer class can measure elapsed     // time not the granularity of usleep() on a particular OS.     $this->assertGreaterThanOrEqual(4, $value, 'Timer failed to measure at least 4 milliseconds of sleeping while running.');

    $this->assertGreaterThanOrEqual($value + 4, $value2, 'Timer failed to measure at least 8 milliseconds of sleeping while running.');

    $this->assertGreaterThanOrEqual($value2 + 4, $value3, 'Timer failed to measure at least 12 milliseconds of sleeping while running.');

    $this->assertGreaterThanOrEqual($value3 + 4, $value4, 'Timer failed to measure at least 16 milliseconds of sleeping while running.');

    // Stop the timer.     $value5 = Timer::stop('test');
    $this->assertGreaterThanOrEqual($value4$value5['time'], 'Timer measured after stopping was not greater than last measurement.');

    
$this->assertEquals(LOCALE_TRANSLATION_CURRENT, $status['contrib_module_one']['de']->type, 'Translation of contrib_module_one found');
    $this->assertEquals(LOCALE_TRANSLATION_CURRENT, $status['contrib_module_two']['de']->type, 'Translation of contrib_module_two found');
    $this->assertEquals(LOCALE_TRANSLATION_CURRENT, $status['contrib_module_three']['de']->type, 'Translation of contrib_module_three found');

    // Check the new translation status.     // The static cache needs to be flushed first to get the most recent data     // from the database. The function was called earlier during this test.     drupal_static_reset('locale_translation_get_file_history');
    $history = locale_translation_get_file_history();
    // Verify that the translation of contrib_module_one is imported and     // updated.     $this->assertGreaterThanOrEqual($this->timestampNow, $history['contrib_module_one']['de']->timestamp);
    $this->assertGreaterThanOrEqual($this->timestampNow, $history['contrib_module_one']['de']->last_checked);
    $this->assertEquals($this->timestampNew, $history['contrib_module_two']['de']->timestamp, 'Translation of contrib_module_two is imported');
    // Verify that the translation of contrib_module_two is updated.     $this->assertGreaterThanOrEqual($this->timestampNow, $history['contrib_module_two']['de']->last_checked);
    $this->assertEquals($this->timestampMedium, $history['contrib_module_three']['de']->timestamp, 'Translation of contrib_module_three is not imported');
    $this->assertEquals($this->timestampMedium, $history['contrib_module_three']['de']->last_checked, 'Translation of contrib_module_three is not updated');

    // Check whether existing translations have (not) been overwritten.     // cSpell:disable     $this->assertEquals('Januar_1', t('January', []['langcode' => 'de']), 'Translation of January');
    $this->assertEquals('Februar_2', t('February', []['langcode' => 'de']), 'Translation of February');
    


    public function testSetExpiration()
    {
        $key = new Key(uniqid(__METHOD__, true));

        /** @var PersistingStoreInterface $store */
        $store = $this->getStore();

        $store->save($key);
        $store->putOffExpiration($key, 1);
        $this->assertGreaterThanOrEqual(0, $key->getRemainingLifetime());
        $this->assertLessThanOrEqual(1, $key->getRemainingLifetime());
    }

    public function testExpiredLockCleaned()
    {
        $resource = uniqid(__METHOD__, true);

        $key1 = new Key($resource);
        $key2 = new Key($resource);

        /** @var PersistingStoreInterface $store */
        
$collection->expects($this->once())
            ->method('findOne')
            ->willReturnCallback(function D$criteria) use ($testTimeout) {
                $this->assertArrayHasKey($this->options['id_field']$criteria);
                $this->assertEquals('foo', $criteria[$this->options['id_field']]);

                $this->assertArrayHasKey($this->options['expiry_field']$criteria);
                $this->assertArrayHasKey('$gte', $criteria[$this->options['expiry_field']]);

                $this->assertInstanceOf(\MongoDB\BSON\UTCDateTime::class$criteria[$this->options['expiry_field']]['$gte']);
                $this->assertGreaterThanOrEqual(round((string) $criteria[$this->options['expiry_field']]['$gte'] / 1000)$testTimeout);

                return [
                    $this->options['id_field'] => 'foo',
                    $this->options['expiry_field'] => new \MongoDB\BSON\UTCDateTime(),
                    $this->options['data_field'] => new \MongoDB\BSON\Binary('bar', \MongoDB\BSON\Binary::TYPE_OLD_BINARY),
                ];
            });

        $this->assertEquals('bar', $this->storage->read('foo'));
    }

    
$this->webhookEventMessageHandler)($webhookEventMessage);

        $timestamp = time();
        $request = $this->getLastRequest();
        static::assertInstanceOf(RequestInterface::class$request);
        $payload = $request->getBody()->getContents();
        $body = json_decode($payload, true, 512, \JSON_THROW_ON_ERROR);

        static::assertEquals('POST', $request->getMethod());
        static::assertEquals($body['body'], 'payload');
        static::assertGreaterThanOrEqual($body['timestamp']$timestamp);
        static::assertTrue($request->hasHeader('sw-version'));
        static::assertEquals($request->getHeaderLine('sw-version'), '6.4');
        static::assertEquals($request->getHeaderLine(AuthMiddleware::SHOPWARE_USER_LANGUAGE), 'en-GB');
        static::assertEquals($request->getHeaderLine(AuthMiddleware::SHOPWARE_CONTEXT_LANGUAGE), Defaults::LANGUAGE_SYSTEM);
        static::assertTrue($request->hasHeader('shopware-shop-signature'));
        static::assertEquals(
            hash_hmac('sha256', $payload, 's3cr3t'),
            $request->getHeaderLine('shopware-shop-signature')
        );

        $webhookEventLog = $webhookEventLogRepository->search(new Criteria([$webhookEventId]), Context::createDefaultContext())->first();

        
$assert_session->elementTextNotContains('css', '#field_twin_media-media-library-wrapper', 'Cat');
    $assert_session->elementTextContains('css', '#field_twin_media-media-library-wrapper', 'Turtle');
    $assert_session->elementTextNotContains('css', '#field_twin_media-media-library-wrapper', 'Snake');
    // Assert the open button is disabled.     $this->assertTrue($assert_session->elementExists('css', '.js-media-library-open-button[name^="field_twin_media"]')->hasAttribute('data-disabled-focus'));
    $this->assertTrue($assert_session->elementExists('css', '.js-media-library-open-button[name^="field_twin_media"]')->hasAttribute('disabled'));
    $this->assertJsCondition('jQuery("#field_twin_media-media-library-wrapper .js-media-library-open-button").is(":disabled")');

    // Assert the selection is cleared when the modal is closed.     $this->openMediaLibraryForField('field_unlimited_media');
    $checkboxes = $this->getCheckboxes();
    $this->assertGreaterThanOrEqual(4, count($checkboxes));
    // Nothing is selected yet.     $this->assertFalse($checkboxes[0]->isChecked());
    $this->assertFalse($checkboxes[1]->isChecked());
    $this->assertFalse($checkboxes[2]->isChecked());
    $this->assertFalse($checkboxes[3]->isChecked());
    $this->assertSelectedMediaCount('0 items selected');
    // Select the first 2 items.     $checkboxes[0]->click();
    $this->assertSelectedMediaCount('1 item selected');
    $checkboxes[1]->click();
    $this->assertSelectedMediaCount('2 items selected');
    
$key = new Key('key', 1);
        $store = $this->createMock(PersistingStoreInterface::class);
        $semaphore = new Semaphore($key$store);

        $store
            ->expects($this->once())
            ->method('save')
            ->with($key, 300.0)
        ;

        $this->assertTrue($semaphore->acquire());
        $this->assertGreaterThanOrEqual(299.0, $key->getRemainingLifetime());
    }

    public function testAcquireReturnsFalse()
    {
        $key = new Key('key', 1);
        $store = $this->createMock(PersistingStoreInterface::class);
        $semaphore = new Semaphore($key$store);

        $store
            ->expects($this->once())
            ->method('save')
            
static::assertEquals(1, $result->count());

        $element = $result->first();
        static::assertNotNull($element);
        static::assertEquals(3, $element->getTotal());
        static::assertEquals('Test Cross Selling', $element->getCrossSelling()->getName());

        $lastPrice = 0;
        foreach ($element->getProducts() as $product) {
            $productPrice = $product->getCurrencyPrice(Defaults::CURRENCY);
            static::assertNotNull($productPrice);
            static::assertGreaterThanOrEqual($lastPrice$productPrice->getGross());
            $lastPrice = $productPrice->getGross();
        }
    }

    public function testLoadForProduct(): void
    {
        $productId = Uuid::randomHex();

        $productData = $this->getProductData($productId);
        $productData['crossSellings'] = [[
            'name' => 'Test Cross Selling',
            
public function testSetGet() {
    $backend = $this->getCacheBackend();

    $this->assertFalse($backend->get('test1'), "Backend does not contain data for cache id test1.");
    $with_backslash = ['foo' => '\Drupal\foo\Bar'];
    $backend->set('test1', $with_backslash);
    $cached = $backend->get('test1');
    $this->assertIsObject($cached);
    $this->assertSame($with_backslash$cached->data);
    $this->assertTrue($cached->valid, 'Item is marked as valid.');
    // We need to round because microtime may be rounded up in the backend.     $this->assertGreaterThanOrEqual(REQUEST_TIME, $cached->created);
    $this->assertLessThanOrEqual(round(microtime(TRUE), 3)$cached->created);
    $this->assertEquals(Cache::PERMANENT, $cached->expire, 'Expire time is correct.');

    $this->assertFalse($backend->get('test2'), "Backend does not contain data for cache id test2.");
    $backend->set('test2', ['value' => 3], REQUEST_TIME + 3);
    $cached = $backend->get('test2');
    $this->assertIsObject($cached);
    $this->assertSame(['value' => 3]$cached->data);
    $this->assertTrue($cached->valid, 'Item is marked as valid.');
    $this->assertGreaterThanOrEqual(REQUEST_TIME, $cached->created);
    $this->assertLessThanOrEqual(round(microtime(TRUE), 3)$cached->created);
    
$query = $this->connection->select('test');
    $query->addField('test', 'name');
    $age_field = $query->addField('test', 'age', 'age');
    $query->orderBy($age_field);
    $result = $query->execute();

    $num_records = 0;
    $last_age = 0;
    foreach ($result as $record) {
      $num_records++;
      // Verify that the results are returned in the correct order.       $this->assertGreaterThanOrEqual($last_age$record->age);
      $last_age = $record->age;
    }

    $this->assertEquals(4, $num_records, 'Returned the correct number of rows.');
  }

  /** * Tests multiple ORDER BY. */
  public function testSimpleSelectMultiOrdered() {
    $query = $this->connection->select('test');
    
'id' => Uuid::randomBytes(),
            'rule_id' => $this->testRule['id'],
            'type' => 'customerIsNewCustomer',
            'value' => '{"isNew":true}',
            'created_at' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),
        ];
    }

    public function testUpdate(): void
    {
        $this->addTestConditions();
        static::assertGreaterThanOrEqual(1, $this->getIsNewCustomerConditions());

        $this->migration->update($this->connection);
        $this->migration->update($this->connection);
        static::assertCount(0, $this->getIsNewCustomerConditions());
        static::assertNull($this->getTestRule()['payload'], 'the migrated rule payload should be empty');
        $value = json_decode((string) $this->getDaysSinceFirstLoginConditions()['value'], true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals('=', $value['operator']);
        static::assertEquals(0, $value['daysPassed']);

        $this->removeTestConditions();
    }

    

    public function testJitter(float $multiplier, int $previousRetries)
    {
        $strategy = new GenericRetryStrategy([], 1000, $multiplier, 0, 1);
        $min = 2000;
        $max = 0;
        for ($i = 0; $i < 50; ++$i) {
            $delay = $strategy->getDelay($this->getContext($previousRetries, 'GET', 'http://example.com/', 200), null, null);
            $min = min($min$delay);
            $max = max($max$delay);
        }
        $this->assertGreaterThanOrEqual(1000, $max - $min);
        $this->assertGreaterThanOrEqual(1000, $max);
        $this->assertLessThanOrEqual(1000, $min);
    }

    public static function provideJitter(): iterable
    {
        // multiplier, previousRetries         yield [1, 0];
        yield [1.1, 2];
    }

    
$sut = new TraceableHttpClient(new NativeHttpClient()$sw);
        $response = $sut->request('GET', 'http://localhost:8057');

        $chunkCount = 0;
        foreach ($sut->stream([$response]) as $chunk) {
            ++$chunkCount;
        }

        $this->assertArrayHasKey('__root__', $sections = $sw->getSections());
        $this->assertCount(1, $events = $sections['__root__']->getEvents());
        $this->assertArrayHasKey('GET http://localhost:8057', $events);
        $this->assertGreaterThanOrEqual($chunkCount, \count($events['GET http://localhost:8057']->getPeriods()));
    }

    public function testStopwatchStreamError()
    {
        $sw = new Stopwatch(true);
        $sut = new TraceableHttpClient(new NativeHttpClient()$sw);
        $response = $sut->request('GET', 'http://localhost:8057/404');

        try {
            $chunkCount = 0;
            foreach ($sut->stream([$response]) as $chunk) {
                
$this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));
        $this->assertEquals('data', $this->redisClient->get(self::PREFIX.'id'));
    }

    public function testUseSessionGcMaxLifetimeAsTimeToLive()
    {
        $this->storage->write('id', 'data');
        $ttl = $this->redisClient->ttl(self::PREFIX.'id');

        $this->assertLessThanOrEqual(\ini_get('session.gc_maxlifetime')$ttl);
        $this->assertGreaterThanOrEqual(0, $ttl);
    }

    public function testDestroySession()
    {
        $this->redisClient->set(self::PREFIX.'id', 'foo');

        $this->assertTrue((bool) $this->redisClient->exists(self::PREFIX.'id'));
        $this->assertTrue($this->storage->destroy('id'));
        $this->assertFalse((bool) $this->redisClient->exists(self::PREFIX.'id'));
    }

    
// Trigger a call that does not have file in the backtrace.     call_user_func_array([Database::getConnection(), 'query']['SELECT [age] FROM {test} WHERE [name] = :name', [':name' => 'Ringo']])->fetchCol();

    $queries = Database::getLog('testing', 'default');

    $this->assertCount(3, $queries, 'Correct number of queries recorded.');

    foreach ($queries as $query) {
      $this->assertEquals(__FUNCTION__, $query['caller']['function'], 'Correct function in query log.');
      $this->assertIsFloat($query['start']);
      $this->assertGreaterThanOrEqual($start$query['start']);
    }
  }

  /** * Tests that we can run two logs in parallel. */
  public function testEnableMultiLogging() {
    Database::startLog('testing1');

    $this->connection->query('SELECT [name] FROM {test} WHERE [age] > :age', [':age' => 25])->fetchCol();

    
Home | Imprint | This part of the site doesn't use cookies.