assertLessThanOrEqual example


  }

  /** * Tests the Drupal 6 content block to Drupal 8 migration. */
  public function testBlockMigration() {
    /** @var \Drupal\block_content\Entity\BlockContent $block */
    $block = BlockContent::load(1);
    $this->assertSame('My block 1', $block->label());
    $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
    $this->assertLessThanOrEqual(time()$block->getChangedTime());
    $this->assertSame('en', $block->language()->getId());
    $this->assertSame('<h3>My first content block body</h3>', $block->body->value);
    $this->assertSame('full_html', $block->body->format);

    $block = BlockContent::load(2);
    $this->assertSame('My block 2', $block->label());
    $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
    $this->assertLessThanOrEqual(time()$block->getChangedTime());
    $this->assertSame('en', $block->language()->getId());
    $this->assertSame('<h3>My second content block body</h3>', $block->body->value);
    $this->assertSame('full_html', $block->body->format);
  }
$this->assertTrue($this->storage->write('id', 'data'));

        $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'));
    }

    

    public function assertCloseEnough(int $expected$actual, string $message = '', int $tolerance = 1)
    {
        $difference = abs($expected - (int) floor($actual));

        $this->assertLessThanOrEqual($tolerance$difference$message);
    }

    /** * Custom function to test that two values are "close enough". * This is intended for extended execution time testing, * where the result is close but not exactly equal to the * expected time, for reasons beyond our control. * * @param mixed $expected * @param mixed $actual * * @return bool|void * * @throws Exception */
// Maximum size.     if ($this->container->get('image.factory')->getToolkitId()) {
      // Copy the image so that the original doesn't get resized.       copy('core/misc/druplicon.png', 'temporary://druplicon.png');
      $this->image->setFileUri('temporary://druplicon.png');

      $errors = file_validate_image_resolution($this->image, '10x5');
      $this->assertCount(0, $errors, 'No errors should be reported when an oversized image can be scaled down.');

      $image = $this->container->get('image.factory')->get($this->image->getFileUri());
      // Verify that the image was scaled to the correct width and height.       $this->assertLessThanOrEqual(10, $image->getWidth());
      $this->assertLessThanOrEqual(5, $image->getHeight());

      // Once again, now with negative width and height to force an error.       copy('core/misc/druplicon.png', 'temporary://druplicon.png');
      $this->image->setFileUri('temporary://druplicon.png');
      $errors = file_validate_image_resolution($this->image, '-10x-5');
      $this->assertCount(1, $errors, 'An error reported for an oversized image that can not be scaled down.');

      \Drupal::service('file_system')->unlink('temporary://druplicon.png');
    }
    else {
      
$cache
            ->method('doFetch')
            ->willReturn(['2:']);

        $reflectionClass = new \ReflectionClass(AbstractAdapter::class);

        $reflectionMethod = $reflectionClass->getMethod('getId');

        // No versioning enabled         $this->assertEquals('--------------------------:------------', $reflectionMethod->invokeArgs($cache[str_repeat('-', 12)]));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 12)])));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 23)])));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 40)])));

        $reflectionProperty = $reflectionClass->getProperty('versioningIsEnabled');
        $reflectionProperty->setValue($cache, true);

        // Versioning enabled         $this->assertEquals('--------------------------:2:------------', $reflectionMethod->invokeArgs($cache[str_repeat('-', 12)]));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 12)])));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 23)])));
        $this->assertLessThanOrEqual(50, \strlen($reflectionMethod->invokeArgs($cache[str_repeat('-', 40)])));
    }
$constraints = $unique ? [$this->prophesize(UniqueFieldConstraint::class)] : [];
      $definition->getConstraint('UniqueField')->willReturn($constraints);
      $definition->getSetting('max_length')->willReturn($max_length);
      for ($i = 0; $i < 1000; $i++) {
        $sample_value = StringItem::generateSampleValue($definition->reveal());
        // When the field value needs to be unique, the generated sample value         // should match the maximum length to ensure sufficient entropy.         if ($unique) {
          $this->assertEquals($max_lengthmb_strlen($sample_value['value']));
        }
        else {
          $this->assertLessThanOrEqual($max_lengthmb_strlen($sample_value['value']));
        }
      }
    }
  }

  /** * Data provider for maximum-lengths. * * @return array * Test cases. */
  

        $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];
    }

    private function getContext($retryCount$method$url$statusCode): AsyncContext
    {
        
$query = $this->connection->select('test');
    $query->addField('test', 'name');
    $age_field = $query->addField('test', 'age', 'age');
    $query->orderBy($age_field, 'DESC');
    $result = $query->execute();

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

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

}
public function testPauseReplace()
    {
        $client = $this->getHttpClient(__FUNCTION__);
        $response = $client->request('GET', 'http://localhost:8057/');

        $time = microtime(true);
        $response->getInfo('pause_handler')(10);
        $response->getInfo('pause_handler')(0.5);
        $this->assertSame(200, $response->getStatusCode());
        $this->assertGreaterThanOrEqual(0.5, microtime(true) - $time);
        $this->assertLessThanOrEqual(5, microtime(true) - $time);
    }

    public function testPauseDuringBody()
    {
        $client = $this->getHttpClient(__FUNCTION__);
        $response = $client->request('GET', 'http://localhost:8057/timeout-body');

        $time = microtime(true);
        $this->assertSame(200, $response->getStatusCode());
        $response->getInfo('pause_handler')(1);
        $response->getContent();
        
$bag->initialize($array);
        $this->assertEquals(1000, $bag->getLifetime());
    }

    public function testGetCreated()
    {
        $this->assertEquals(1234567, $this->bag->getCreated());
    }

    public function testGetLastUsed()
    {
        $this->assertLessThanOrEqual(time()$this->bag->getLastUsed());
    }

    public function testClear()
    {
        $this->bag->clear();

        // the clear method has no side effects, we just want to ensure it doesn't trigger any exceptions         $this->addToAssertionCount(1);
    }

    public function testSkipLastUsedUpdate()
    {

  public function testGenerateSampleValue(int $max_length): void {
    $definition = $this->prophesize(FieldDefinitionInterface::class);
    $definition->getSetting('max_length')->willReturn($max_length);

    for ($i = 0; $i < 1000; $i++) {
      $sample_value = UserNameItem::generateSampleValue($definition->reveal());
      $this->assertLessThanOrEqual($max_lengthmb_strlen($sample_value['value']));
      $this->assertEquals(trim($sample_value['value'], ' ')$sample_value['value']);
    }
  }

  /** * Data provider for maximum-lengths. * * @return array * Test cases. */
  public function providerMaxLength(): array {
    
$output = MailFormatHelper::htmlToText($input);
    $eol = Settings::get('mail_line_endings', PHP_EOL);

    $maximum_line_length = 0;
    foreach (explode($eol$output) as $line) {
      // We must use strlen() rather than mb_strlen() in order to count octets       // rather than characters.       $maximum_line_length = max($maximum_line_lengthstrlen($line . $eol));
    }
    // Verify that the maximum line length found was less than or equal to 1000     // characters as per RFC 821.     $this->assertLessThanOrEqual(1000, $maximum_line_length);
  }

  /** * Tests that trailing whitespace is removed before newlines. * * @see \Drupal\Core\Mail\MailFormatHelper::wrapMail() */
  public function testRemoveTrailingWhitespace() {
    $text = "Hi there! \nEarth";
    $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
    $this->assertNotEquals(" ", substr($mail_lines[0], -1), 'Trailing whitespace removed.');
  }
$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);
    $this->assertEquals(REQUEST_TIME + 3, $cached->expire, 'Expire time is correct.');

    
$inner->method('getNextRunDate')->willReturn($time);

        $trigger = new JitterTrigger($inner);

        $values = array_map(
            fn () => (int) $trigger->getNextRunDate($time)?->getTimestamp(),
            array_fill(0, 100, null)
        );

        foreach ($values as $value) {
            $this->assertGreaterThanOrEqual($time->getTimestamp()$value);
            $this->assertLessThanOrEqual($time->getTimestamp() + 60, $value);
        }

        $values = array_unique($values);

        $this->assertGreaterThan(1, \count($values));
    }
}
$query = [];
    parse_str($iframe_url['query']$query);
    $this->assertSame($video_url$query['url']);
    $this->assertNotEmpty($query['hash']);
    // Ensure that the outer iframe's width respects the formatter settings.     $this->assertSame('240', $iframe->getAttribute('width'));
    // Check the inner iframe to make sure that CSS has been applied to scale it     // correctly, regardless of whatever its width attribute may be (the fixture     // hard-codes it to 480).     $inner_frame = 'frames[0].document.querySelector("iframe")';
    $this->assertSame('480', $session->evaluateScript("$inner_frame.getAttribute('width')"));
    $this->assertLessThanOrEqual(240, $session->evaluateScript("$inner_frame.clientWidth"));

    // The oEmbed content iFrame should be visible.     $assert_session->elementExists('css', 'iframe.media-oembed-content');
    // The thumbnail should not be displayed.     $assert_session->elementNotExists('css', 'img');

    // Load the media and check that all fields are properly populated.     $media = Media::load(1);
    $this->assertSame('Drupal Rap Video - Schipulcon09', $media->getName());
    $this->assertSame('480', $media->field_string_width->value);
    $this->assertSame('360', $media->field_string_height->value);

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