assertIsInt example

/** * Verify that RequeueException causes an item to be processed multiple times. */
  public function testRequeueException() {
    $this->resetTestingState();
    $this->queue->createItem('RequeueException');
    $this->cron->run();

    // Fetch the number of times this item was requeued.     $actual_requeue_count = $this->state->get('cron_test.requeue_count');
    // Make sure the item was requeued at least once.     $this->assertIsInt($actual_requeue_count);
    // Ensure that the actual requeue count matches the expected value.     $this->assertEquals(self::REQUEUE_COUNT, $actual_requeue_count);
  }

}
/** * Tests the function parses schema updates as integer numbers. * * @see \Drupal\Core\Update\UpdateHookRegistry::getAvailableUpdates() */
  public function testDrupalGetSchemaVersionsInt() {
    \Drupal::state()->set('update_test_schema_version', 8001);
    $this->installSchema('update_test_schema', ['update_test_schema_table']);
    $schema = \Drupal::service('update.update_hook_registry')->getAvailableUpdates('update_test_schema');
    foreach ($schema as $version) {
      $this->assertIsInt($version);
    }
  }

}
$data['customFields']['f'] = new \stdClass();
        $data['customFields']['g'] = 'test';

        $countryRepo->upsert([$data], Context::createDefaultContext());

        /** @var CountryEntity $country */
        $country = $countryRepo->search(new Criteria([$id]), Context::createDefaultContext())->first();

        /** @var array<mixed> $customFields */
        $customFields = $country->getCustomFields();

        static::assertIsInt($customFields['a']);
        static::assertIsInt($customFields['b']);
        static::assertSame(1234, $customFields['a']);
        static::assertSame(1, $customFields['b']);

        static::assertIsFloat($customFields['c']);
        static::assertSame(1.56, $customFields['c']);

        static::assertIsBool($customFields['d']);
        static::assertTrue($customFields['d']);

        static::assertIsArray($customFields['e']);
        
$this->assertIsString($cache_tag);
    }$cache_tags);
  }

  /** * @covers ::getCacheMaxAge */
  public function testGetCacheMaxAge() {
    $module_handler = $this->prophesize(ModuleHandlerInterface::class);
    $plugin_manager = new TestPluginManager($this->namespaces, $this->expectedDefinitions, $module_handler->reveal(), NULL);
    $cache_max_age = $plugin_manager->getCacheMaxAge();
    $this->assertIsInt($cache_max_age);
  }

  /** * @covers ::findDefinitions * @covers ::extractProviderFromDefinition */
  public function testProviderExists() {
    $definitions = [];
    $definitions['array_based_found'] = ['provider' => 'module_found'];
    $definitions['array_based_missing'] = ['provider' => 'module_missing'];
    $definitions['stdclass_based_found'] = (object) ['provider' => 'module_found'];
    
static::assertInstanceOf(AudioType::class$type);
    }

    private function getTypeDetector(): TypeDetector
    {
        return $this->getContainer()->get(TypeDetector::class);
    }

    private function createMediaFile(string $filePath): MediaFile
    {
        static::assertIsString($mimeContentType = mime_content_type($filePath));
        static::assertIsInt($filesize = filesize($filePath));

        return new MediaFile(
            $filePath,
            $mimeContentType,
            pathinfo($filePath, \PATHINFO_EXTENSION),
            $filesize
        );
    }
}

  public function testSuccessfulReuse($source_path$destination_path) {
    $file_reuse = $this->doTransform($source_path$destination_path);
    clearstatcache(TRUE, $destination_path);

    $timestamp = (new \SplFileInfo($file_reuse))->getMTime();
    $this->assertIsInt($timestamp);

    // We need to make sure the modified timestamp on the file is sooner than     // the attempted migration.     sleep(1);
    $configuration = ['file_exists' => 'use existing'];
    $this->doTransform($source_path$destination_path$configuration);
    clearstatcache(TRUE, $destination_path);
    $modified_timestamp = (new \SplFileInfo($destination_path))->getMTime();
    $this->assertEquals($timestamp$modified_timestamp);

    $this->doTransform($source_path$destination_path);
    
$this->getContainer()
            ->get(SystemConfigService::class)
            ->set('core.loginRegistration.unusedGuestCustomerLifetime', 86400);
    }

    public function testExecuteWithoutUnusedGuestCustomers(): void
    {
        $commandTester = new CommandTester($this->command);
        $commandTester->execute([]);

        $string = $commandTester->getDisplay();
        static::assertIsInt(\mb_strpos($string, 'No unused guest customers found.'));
    }

    public function testExecuteWithoutConfirm(): void
    {
        $customerRepository = $this->getContainer()->get('customer.repository');

        $customerGuestWithOrder = (new CustomerBuilder($this->ids, '10000'))
            ->add('guest', true)
            ->add('createdAt', new \DateTime('- 25 hours'));

        $customerGuest = (new CustomerBuilder($this->ids, '10001'))
            
public function __construct()
            {
                $this->code = 'HY000';
                $this->message = 'test';
                // no to call parent constructor, it will fail with string error code             }
        };

        $handlerException = new HandlerFailedException($envelope[$exception]);
        $originalException = $handlerException->getNestedExceptions()[0];

        $this->assertIsInt($handlerException->getCode(), 'Exception codes must converts to int');
        $this->assertSame(0, $handlerException->getCode(), 'String code (HY000) converted to int must be 0');
        $this->assertIsString($originalException->getCode(), 'Original exception code still with original type (string)');
        $this->assertSame($exception->getCode()$originalException->getCode(), 'Original exception code is not modified');
    }

    public function testThatNestedExceptionClassAreFound()
    {
        $envelope = new Envelope(new \stdClass());
        $exception = new MyOwnException();

        $handlerException = new HandlerFailedException($envelope[new \LogicException()$exception]);
        
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 testGcSession()
    {
        $this->assertIsInt($this->storage->gc(123));
    }

    public function testUpdateTimestamp()
    {
        $lowTtl = 10;

        $this->redisClient->setex(self::PREFIX.'id', $lowTtl, 'foo');
        $this->storage->updateTimestamp('id', 'data');

        $this->assertGreaterThan($lowTtl$this->redisClient->ttl(self::PREFIX.'id'));
    }

    
$this->urlGenerator = $this->getContainer()->get(UrlGeneratorInterface::class);
        $this->fileSaver = $this->getContainer()->get(FileSaver::class);
    }

    public function testPersistFileToMediaHappyPathForInitialUpload(): void
    {
        $tempFile = tempnam(sys_get_temp_dir(), '');
        static::assertIsString($tempFile);
        copy(self::TEST_IMAGE, $tempFile);

        $fileSize = filesize($tempFile);
        static::assertIsInt($fileSize);
        $mediaFile = new MediaFile($tempFile, 'image/png', 'png', $fileSize);

        $mediaId = Uuid::randomHex();

        $context = Context::createDefaultContext();

        $this->mediaRepository->create(
            [
                [
                    'id' => $mediaId,
                ],
            ],


    /** * @group DCOM-38 */
    public function testCastInt()
    {
        $parser = $this->createTestParser();

        $result = $parser->parse("@Name(foo=1234)");
        $annot = $result[0];
        $this->assertIsInt($annot->foo);
    }

    /** * @group DCOM-38 */
    public function testCastNegativeInt()
    {
        $parser = $this->createTestParser();

        $result = $parser->parse("@Name(foo=-1234)");
        $annot = $result[0];
        
/** * Tests deprecation of the 'return' query option. * * @covers ::query * @covers ::prepareStatement * * @group legacy */
  public function testReturnOptionDeprecation() {
    $this->expectDeprecation('Passing "return" option to %Aquery() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520');
    $this->expectDeprecation('Passing "return" option to %AprepareStatement() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520');
    $this->assertIsInt((int) $this->connection->query('INSERT INTO {test} ([name], [age], [job]) VALUES (:name, :age, :job)', [
      ':name' => 'Magoo',
      ':age' => 56,
      ':job' => 'Driver',
    ]['return' => Database::RETURN_INSERT_ID]));
  }

}
$this->assertSame(2 * 10, $window->getExpirationTime());

        $data = serialize($window);
        sleep(10);
        $cachedWindow = unserialize($data);
        $this->assertSame(10, $cachedWindow->getExpirationTime());

        $new = SlidingWindow::createFromPreviousWindow($cachedWindow, 15);
        $this->assertSame(2 * 15, $new->getExpirationTime());

        usleep(10.1);
        $this->assertIsInt($new->getExpirationTime());
    }

    public function testInvalidInterval()
    {
        $this->expectException(InvalidIntervalException::class);
        new SlidingWindow('foo', 0);
    }

    public function testLongInterval()
    {
        ClockMock::register(SlidingWindow::class);
        
->expects($this->once())
            ->method('delete')
            ->with(self::PREFIX.'id')
            ->willReturn(true)
        ;

        $this->assertTrue($this->storage->destroy('id'));
    }

    public function testGcSession()
    {
        $this->assertIsInt($this->storage->gc(123));
    }

    /** * @dataProvider getOptionFixtures */
    public function testSupportedOptions($options$supported)
    {
        try {
            new MemcachedSessionHandler($this->memcached, $options);
            $this->assertTrue($supported);
        } catch (\InvalidArgumentException $e) {
            
static::assertInstanceOf(ImageType::class$type);
    }

    private function getAudioTypeDetector(): AudioTypeDetector
    {
        return $this->getContainer()->get(AudioTypeDetector::class);
    }

    private function createMediaFile(string $filePath): MediaFile
    {
        static::assertIsString($mimeContentType = mime_content_type($filePath));
        static::assertIsInt($filesize = filesize($filePath));

        return new MediaFile(
            $filePath,
            $mimeContentType,
            pathinfo($filePath, \PATHINFO_EXTENSION),
            $filesize
        );
    }
}
Home | Imprint | This part of the site doesn't use cookies.