isType example


    $defaults = [
      RouteObjectInterface::ROUTE_OBJECT => $route,
    ] + $raw_variables;

    $expected = $defaults;
    $expected['id'] = 'something_better!';
    $expected['_raw_variables'] = new InputBag($raw_variables);

    $this->paramConverterManager->expects($this->once())
      ->method('convert')
      ->with($this->isType('array'))
      ->willReturn($expected);

    $result = $this->paramConversionEnhancer->enhance($defaultsnew Request());

    $this->assertEquals($expected$result);

    // Now run with the results as the new defaults to ensure that the     // conversion is just run once.     $result = $this->paramConversionEnhancer->enhance($resultnew Request());

    $this->assertEquals($expected$result);
  }
$key = Crypt::randomBytesBase64();
    $this->privateKey->expects($this->any())
      ->method('get')
      ->willReturn($key);

    $this->sessionMetadata->expects($this->once())
      ->method('getCsrfTokenSeed')
      ->willReturn(NULL);

    $this->sessionMetadata->expects($this->once())
      ->method('setCsrfTokenSeed')
      ->with($this->isType('string'));

    $this->assertIsString($this->generator->get());
  }

  /** * Tests CsrfTokenGenerator::validate(). * * @covers ::validate */
  public function testValidate() {
    $this->setupDefaultExpectations();

    
'id' => 1,
      'literal' => 'this is a literal',
      'null' => NULL,
    ];

    $expected = $defaults;
    $expected['id'] = 'something_better!';

    $converter = $this->createMock('Drupal\Core\ParamConverter\ParamConverterInterface');
    $converter->expects($this->any())
      ->method('convert')
      ->with(1, $this->isType('array'), 'id', $this->isType('array'))
      ->willReturn('something_better!');
    $this->manager->addConverter($converter, 'test_convert');

    $result = $this->manager->convert($defaults);

    $this->assertEquals($expected$result);
  }

  /** * @covers ::convert */
  
/** * Tests that the source count is correct. * * @covers ::count */
  public function testCount() {
    // Mock the cache to validate set() receives appropriate arguments.     $container = new ContainerBuilder();
    $cache = $this->createMock(CacheBackendInterface::class);
    $cache->expects($this->any())->method('set')
      ->with($this->isType('string')$this->isType('int')$this->isType('int'));
    $container->set('cache.migrate', $cache);
    \Drupal::setContainer($container);

    // Test that the basic count works.     $source = $this->getSource();
    $this->assertEquals(1, $source->count());

    // Test caching the count works.     $source = $this->getSource(['cache_counts' => TRUE]);
    $this->assertEquals(1, $source->count());

    

  protected $fileUrlGenerator;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->fileUrlGenerator = $this->createMock(FileUrlGeneratorInterface::class);
    $this->fileUrlGenerator->expects($this->any())
      ->method('generateString')
      ->with($this->isType('string'))
      ->willReturnCallback(function D$uri) {
        return 'generated-relative-url:' . $uri;
      });
    $this->optimizer = new CssOptimizer($this->fileUrlGenerator);
  }

  /** * Provides data for the CSS asset optimizing test. */
  public function providerTestOptimize() {
    $path = 'core/tests/Drupal/Tests/Core/Asset/css_test_files/';
    
use Symfony\Component\Serializer\Tests\Fixtures\UpcomingNormalizerInterface as NormalizerInterface;

class TraceableNormalizerTest extends TestCase
{
    public function testForwardsToNormalizer()
    {
        $normalizer = $this->createMock(NormalizerInterface::class);
        $normalizer->method('getSupportedTypes')->willReturn(['*' => false]);
        $normalizer
            ->expects($this->once())
            ->method('normalize')
            ->with('data', 'format', $this->isType('array'))
            ->willReturn('normalized');

        $denormalizer = $this->createMock(DenormalizerInterface::class);
        $denormalizer->method('getSupportedTypes')->willReturn(['*' => false]);
        $denormalizer
            ->expects($this->once())
            ->method('denormalize')
            ->with('data', 'type', 'format', $this->isType('array'))
            ->willReturn('denormalized');

        $this->assertSame('normalized', (new TraceableNormalizer($normalizernew SerializerDataCollector()))->normalize('data', 'format'));
        
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface;

class TraceableSerializerTest extends TestCase
{
    public function testForwardsToSerializer()
    {
        $serializer = $this->createMock(Serializer::class);
        $serializer
            ->expects($this->once())
            ->method('serialize')
            ->with('data', 'format', $this->isType('array'))
            ->willReturn('serialized');
        $serializer
            ->expects($this->once())
            ->method('deserialize')
            ->with('data', 'type', 'format', $this->isType('array'))
            ->willReturn('deserialized');
        $serializer
            ->expects($this->once())
            ->method('normalize')
            ->with('data', 'format', $this->isType('array'))
            ->willReturn('normalized');
        
$this->assignThemeToDefaultSalesChannel();
    }

    public function testHandleThemeInstallOrUpdateWillRecompileThemeIfNecessary(): void
    {
        $installConfig = $this->configFactory->createFromBundle(new SimplePlugin(true, __DIR__ . '/fixtures/SimplePlugin'));

        $this->themeServiceMock->expects(static::once())
            ->method('compileTheme')
            ->with(
                TestDefaults::SALES_CHANNEL,
                static::isType('string'),
                static::isInstanceOf(Context::class),
                static::callback(fn (StorefrontPluginConfigurationCollection $configs): bool => $configs->count() === 2)
            );

        $configs = new StorefrontPluginConfigurationCollection([
            $this->configFactory->createFromBundle(new Storefront()),
            $installConfig,
        ]);

        $this->themeLifecycleHandler->handleThemeInstallOrUpdate($installConfig$configs, Context::createDefaultContext());
    }

    
$app = $this->getInstalledApp($this->context);

        $shopId = $this->changeAppUrl();

        $registrationsService = $this->createMock(AppRegistrationService::class);
        $registrationsService->expects(static::once())
            ->method('registerApp')
            ->with(
                static::callback(static fn (Manifest $manifest): bool => $manifest->getPath() === $appDir),
                $app->getId(),
                static::isType('string'),
                static::isInstanceOf(Context::class)
            );

        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
        $eventDispatcher->expects(static::once())
            ->method('dispatch')
            ->with(static::isInstanceOf(AppInstalledEvent::class));

        $reinstallAppsResolver = new ReinstallAppsStrategy(
            $this->getAppLoader($appDir),
            $this->getContainer()->get('app.repository'),
            

  public function testGenerate() {
    $this->urlGenerator->expects($this->once())
      ->method('generateFromRoute')
      ->with('test_route_1', []['fragment' => 'the-fragment'] + $this->defaultOptions)
      ->willReturn((new GeneratedUrl())->setGeneratedUrl('/test-route-1#the-fragment'));

    $this->moduleHandler->expects($this->once())
      ->method('alter')
      ->with('link', $this->isType('array'));

    $url = new Url('test_route_1', []['fragment' => 'the-fragment']);
    $url->setUrlGenerator($this->urlGenerator);

    $result = $this->linkGenerator->generate('Test', $url);
    $this->assertLink([
      'attributes' => [
        'href' => '/test-route-1#the-fragment',
      ],
      'content' => 'Test',
    ]$result);
  }
    $expected_cid = 'user_permissions_hash:administrator,authenticated';

    $mock_cache = new \stdClass();
    $mock_cache->data = 'test_hash_here';

    $this->staticCache->expects($this->once())
      ->method('get')
      ->with($expected_cid)
      ->willReturn(FALSE);
    $this->staticCache->expects($this->once())
      ->method('set')
      ->with($expected_cid$this->isType('string'));

    $this->cache->expects($this->once())
      ->method('get')
      ->with($expected_cid)
      ->willReturn($mock_cache);
    $this->cache->expects($this->never())
      ->method('set');

    $this->permissionsHash->generate($this->account2);
  }

  
use Symfony\Component\Serializer\Encoder\DecoderInterface;
use Symfony\Component\Serializer\Encoder\EncoderInterface;

class TraceableEncoderTest extends TestCase
{
    public function testForwardsToEncoder()
    {
        $encoder = $this->createMock(EncoderInterface::class);
        $encoder
            ->expects($this->once())
            ->method('encode')
            ->with('data', 'format', $this->isType('array'))
            ->willReturn('encoded');

        $decoder = $this->createMock(DecoderInterface::class);
        $decoder
            ->expects($this->once())
            ->method('decode')
            ->with('data', 'format', $this->isType('array'))
            ->willReturn('decoded');

        $this->assertSame('encoded', (new TraceableEncoder($encodernew SerializerDataCollector()))->encode('data', 'format'));
        $this->assertSame('decoded', (new TraceableEncoder($decodernew SerializerDataCollector()))->decode('data', 'format'));
    }
$pass = new MergeExtensionConfigurationPass();
        $pass->process($container);

        $this->assertEquals([$provider]$tmpProviders);
    }

    public function testExtensionLoadGetAMergeExtensionConfigurationContainerBuilderInstance()
    {
        $extension = $this->getMockBuilder(FooExtension::class)->onlyMethods(['load'])->getMock();
        $extension->expects($this->once())
            ->method('load')
            ->with($this->isType('array')$this->isInstanceOf(MergeExtensionConfigurationContainerBuilder::class))
        ;

        $container = new ContainerBuilder(new ParameterBag());
        $container->registerExtension($extension);
        $container->prependExtensionConfig('foo', []);

        $pass = new MergeExtensionConfigurationPass();
        $pass->process($container);
    }

    public function testExtensionConfigurationIsTrackedByDefault()
    {
$app = $this->getInstalledApp($this->context);

        $shopId = $this->changeAppUrl();

        $registrationsService = $this->createMock(AppRegistrationService::class);
        $registrationsService->expects(static::once())
            ->method('registerApp')
            ->with(
                static::callback(static fn (Manifest $manifest): bool => $manifest->getPath() === $appDir),
                $app->getId(),
                static::isType('string'),
                static::isInstanceOf(Context::class)
            );

        $moveShopPermanentlyResolver = new MoveShopPermanentlyStrategy(
            $this->getAppLoader($appDir),
            $this->getContainer()->get('app.repository'),
            $registrationsService,
            $this->systemConfigService
        );

        $moveShopPermanentlyResolver->resolve($this->context);

        
protected $fileCssGroup;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $state = $this->prophesize(StateInterface::class);
    $file_url_generator = $this->createMock(FileUrlGeneratorInterface::class);
    $file_url_generator->expects($this->any())
      ->method('generateString')
      ->with($this->isType('string'))
      ->willReturnCallback(function D$uri) {
         return 'generated-relative-url:' . $uri;
      });
    $state->get('system.css_js_query_string', '0')->shouldBeCalledOnce()->willReturn(NULL);
    $this->renderer = new CssCollectionRenderer($state->reveal()$file_url_generator);
    $this->fileCssGroup = [
      'group' => -100,
      'type' => 'file',
      'media' => 'all',
      'preprocess' => TRUE,
      'items' => [
        
Home | Imprint | This part of the site doesn't use cookies.