assertContains example

$enrichedCustomEntities = $outerEnrichedCustomEntities->getEntities();

        foreach ($enrichedCustomEntities as $enrichedCustomEntity) {
            if (!\in_array($enrichedCustomEntity->getName(), self::EXPECTED_CMS_AWARE_ENTITY_NAMES, true)) {
                continue;
            }

            $fieldNames = array_map(static fn ($field) => $field->getName()$enrichedCustomEntity->getFields());

            static::assertCount(15, $fieldNames);

            static::assertContains('sw_title', $fieldNames);
            static::assertContains('sw_content', $fieldNames);
            static::assertContains('sw_cms_page', $fieldNames);
            static::assertContains('sw_slot_config', $fieldNames);
            static::assertContains('sw_categories', $fieldNames);
            static::assertContains('sw_og_image', $fieldNames);
            static::assertContains('sw_seo_meta_title', $fieldNames);
            static::assertContains('sw_seo_meta_description', $fieldNames);

            static::assertCount(1, $enrichedCustomEntity->getFlags());
            static::assertNotNull($enrichedCustomEntity->getFlags()['cms-aware']);
            static::assertContains(
                
$this->fieldStorage->expects($this->once())
      ->method('getConfigDependencyName')
      ->willReturn('field.storage.test_entity_type.test_field');

    $field = new FieldConfig([
      'field_name' => $this->fieldStorage->getName(),
      'entity_type' => 'test_entity_type',
      'bundle' => 'test_bundle',
      'field_type' => 'test_field',
    ]$this->entityTypeId);
    $dependencies = $field->calculateDependencies()->getDependencies();
    $this->assertContains('field.storage.test_entity_type.test_field', $dependencies['config']);
    $this->assertContains('test.test_entity_type.id', $dependencies['config']);
    $this->assertEquals(['test_module', 'test_module2', 'test_module3']$dependencies['module']);
  }

  /** * Tests that invalid bundles are handled. */
  public function testCalculateDependenciesIncorrectBundle() {
    $storage = $this->createMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
    $storage->expects($this->any())
      ->method('load')
      
$this->productRepository->create($products$this->salesChannelContext->getContext());

        $urlResult = $this->getProductUrlProvider()->getUrls($this->salesChannelContext, 3);
        $host = $this->getHost($this->salesChannelContext);
        $locations = array_map(fn ($url) => $host . '/' . $url->getLoc()$urlResult->getUrls());

        foreach ($products as $product) {
            $urlGenerate = $this->getComparisonUrl($product['id']);
            if ($product['id'] === $parentId) {
                static::assertNotContains($urlGenerate$locations);
            } else {
                static::assertContains($urlGenerate$locations);
            }
        }
    }

    public function testOnlyCanonicalVariantUrlGenerated(): void
    {
        $parentId = Uuid::randomHex();
        $canonicalProductId = Uuid::randomHex();
        $products = [
            array_merge([
                'id' => $parentId,
                

    public function testApplyWithEventDispatcherForAnnounce(bool $fired, array $context)
    {
        $definition = $this->createComplexWorkflowDefinition();
        $subject = new Subject();
        $eventDispatcher = new EventDispatcherMock();
        $workflow = new Workflow($definitionnew MethodMarkingStore()$eventDispatcher, 'workflow_name');

        $workflow->apply($subject, 't1', $context);

        if ($fired) {
            $this->assertContains('workflow.workflow_name.announce', $eventDispatcher->dispatchedEvents);
        } else {
            $this->assertNotContains('workflow.workflow_name.announce', $eventDispatcher->dispatchedEvents);
        }
    }

    public function testApplyDispatchesWithDisableEventInContext()
    {
        $transitions[] = new Transition('a-b', 'a', 'b');
        $transitions[] = new Transition('a-c', 'a', 'c');
        $definition = new Definition(['a', 'b', 'c']$transitions);

        
$in_not_finished = in_array($datum$declared_unique[MigrationState::NOT_FINISHED]);
      $found = $in_finished || $in_not_finished;
      $this->assertTrue($foundsprintf("No migration state found for version '%s' with source_module '%s' and destination_module '%s' declared in module '%s'", $version$data[1]$data[2]$data[0]));
    }

    // Remove the declared finished from the discovered, leaving just the not     // finished, if there are any. These should have an entry in the declared     // not finished.     $discovered_not_finished = array_diff($discovered_unique$declared_unique[MigrationState::FINISHED]);
    foreach ($discovered_not_finished as $datum) {
      $data = str_getcsv($datum);
      $this->assertContains($datum$declared_unique[MigrationState::NOT_FINISHED]sprintf("No migration found for version '%s' with source_module '%s' and destination_module '%s' declared in module '%s'", $version$data[1]$data[2]$data[0]));
    }
  }

  /** * Enable all available modules. */
  protected function enableAllModules() {
    // Install all available modules.     $module_handler = $this->container->get('module_handler');
    $modules = $this->coreModuleListDataProvider();
    $modules_enabled = $module_handler->getModuleList();
    

        );

        $response = json_decode($this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        static::assertArrayHasKey('elements', $response);
        static::assertCount(1, $response['elements']);
        static::assertArrayHasKey('translations', $response['elements'][0]);
        static::assertCount(2, $response['elements'][0]['translations']);

        $languages = \array_column($response['elements'][0]['translations'], 'languageId');
        static::assertContains(Defaults::LANGUAGE_SYSTEM, $languages);
        static::assertContains($this->ids->get('language')$languages);

        $names = \array_column($response['elements'][0]['translations'], 'name');
        static::assertContains('Test-Product', $names);
        static::assertContains('Other translation', $names);
    }

    /** * @group slow */
    public function testListingProductsLimit(): void
    {
'/store-api/language',
                [
                ]
            );

        $response = json_decode($this->browser->getResponse()->getContent(), true, 512, \JSON_THROW_ON_ERROR);

        $ids = array_column($response['elements'], 'id');
        $names = array_column($response['elements'], 'name');

        static::assertSame(2, $response['total']);
        static::assertContains($this->ids->get('language')$ids);
        static::assertContains($this->ids->get('language2')$ids);
        static::assertContains($this->ids->get('language2')$ids);
        static::assertContains('match', $names);
        static::assertContains('match2', $names);
        static::assertEmpty($response['elements'][0]['locale']);
    }

    public function testIncludes(): void
    {
        $this->browser
            ->request(
                
public function testOneToOne(IdsCollection $ids): void
    {
        $criteria = new Criteria();
        $criteria->addFilter(
            new NandFilter([new EqualsFilter('avatarUsers.id', null)])
        );

        $media = $this->getContainer()->get('media.repository')
            ->searchIds($criteria, Context::createDefaultContext());

        static::assertCount(1, $media->getIds());
        static::assertContains($ids->get('with-avatar')$media->getIds());
        static::assertNotContains($ids->get('without-avatar')$media->getIds());

        $criteria = new Criteria();
        $criteria->addFilter(new EqualsFilter('avatarUsers.id', null));

        $media = $this->getContainer()->get('media.repository')
            ->searchIds($criteria, Context::createDefaultContext());

        static::assertTrue(\count($media->getIds()) > 0);
        static::assertContains($ids->get('without-avatar')$media->getIds());
        static::assertNotContains($ids->get('with-avatar')$media->getIds());

        
private function testEventSystem(IdsCollection $ids, ContainerInterface $container): void
    {
        /** @var EntityRepository $blogRepository */
        $blogRepository = $container->get('custom_entity_blog.repository');

        $blogRepository->create([self::blog('blog-4', $ids)], Context::createDefaultContext());

        $event = $blogRepository->delete([['id' => $ids->get('blog-4')]], Context::createDefaultContext());

        static::assertSame(EntityWrittenContainerEvent::class$event::class);
        static::assertCount(1, $event->getPrimaryKeys('custom_entity_blog'));
        static::assertContains($ids->get('blog-4')$event->getPrimaryKeys('custom_entity_blog'));

        $cascade = $event->getPrimaryKeys('custom_entity_blog_products');
        static::assertCount(2, $cascade);

        $cascade = $event->getPrimaryKeys('ce_blog_comment');
        static::assertCount(2, $cascade);

        $cascade = $event->getPrimaryKeys('ce_blog_comment_translation');
        static::assertCount(2, $cascade);

        $cascade = $event->getPrimaryKeys('custom_entity_blog_translation');
        
$this->plugin->defineValueProcessPipeline($this->migration, 'body', $field_info);

    $process = $this->migration->getProcess();
    $this->assertSame('sub_process', $process['plugin']);
    $this->assertSame('body', $process['source']);
    $this->assertSame('value', $process['process']['value']);

    // Ensure that filter format IDs will be looked up in the filter format     // migrations.     $lookup = $process['process']['format'][2];
    $this->assertSame('migration_lookup', $lookup['plugin']);
    $this->assertContains('d6_filter_format', $lookup['migration']);
    $this->assertContains('d7_filter_format', $lookup['migration']);
    $this->assertSame('format', $lookup['source']);
  }

  /** * @covers ::defineValueProcessPipeline */
  public function testBooleanTextImplicitValueProcessPipeline() {
    $info = [
      'widget_type' => 'optionwidgets_onoff',
      'global_settings' => [
        


    private function assertDefaultActionButtons(): void
    {
        $actionButtons = $this->actionButtonRepository->search(new Criteria()$this->context)->getEntities();
        static::assertCount(2, $actionButtons);

        /** @var ActionButtonEntity[] $actionButtons */
        $actionButtons = $actionButtons->getElements();
        $actionNames = \array_map(fn (ActionButtonEntity $actionButton) => $actionButton->getAction()$actionButtons);

        static::assertContains('viewOrder', $actionNames);
        static::assertContains('doStuffWithProducts', $actionNames);
    }
}

    public function testComplete(array $input, array $expectedSuggestions, array $notExpectedSuggestions = [])
    {
        static::bootKernel(['test_case' => 'ContainerDebug', 'root_config' => 'config.yml', 'debug' => true]);

        $application = new Application(static::$kernel);
        $tester = new CommandCompletionTester($application->find('debug:container'));
        $suggestions = $tester->complete($input);

        foreach ($expectedSuggestions as $expectedSuggestion) {
            $this->assertContains($expectedSuggestion$suggestions);
        }
        foreach ($notExpectedSuggestions as $notExpectedSuggestion) {
            $this->assertNotContains($notExpectedSuggestion$suggestions);
        }
    }

    public static function provideCompletionSuggestions()
    {
        $serviceId = 'console.command.container_debug';
        $hiddenServiceId = '.console.command.container_debug.lazy';
        $interfaceServiceId = HttpKernelInterface::class;

        
public function testAliasCanBeFoundInTheDumpedContainerWhenBothTheAliasAndTheServiceArePublic()
    {
        $container = new ContainerBuilder();

        $container->register('foo', 'stdClass')->setPublic(true);
        $container->setAlias('bar', 'foo')->setPublic(true);

        $container->compile();

        // Bar is found in the compiled container         $service_ids = $container->getServiceIds();
        $this->assertContains('bar', $service_ids);

        $dumper = new PhpDumper($container);
        $dump = $dumper->dump(['class' => 'Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer']);
        eval('?>'.$dump);

        $container = new \Symfony_DI_PhpDumper_AliasesCanBeFoundInTheDumpedContainer();

        // Bar should still be found in the compiled container         $service_ids = $container->getServiceIds();
        $this->assertContains('bar', $service_ids);
    }

    
$build = [
      '#cache' => [
        'key' => 'foo',
      ],
      $local_action_manager->getActionsForRoute('menu_test.local_action7'),
    ];

    /** @var \Drupal\Core\Render\RendererInterface $renderer */
    $renderer = \Drupal::service('renderer');
    $renderer->renderRoot($build);

    $this->assertContains('menu_local_action7', $build[0]['menu_test.local_action7']['#cache']['tags']);
    $this->assertContains('url.query_args:menu_local_action7', $build[0]['menu_test.local_action7']['#cache']['contexts']);

    $this->assertContains('menu_local_action8', $build[0]['menu_test.local_action8']['#cache']['tags']);
    $this->assertContains('url.query_args:menu_local_action8', $build[0]['menu_test.local_action8']['#cache']['contexts']);

    $this->assertContains('menu_local_action7', $build['#cache']['tags']);
    $this->assertContains('url.query_args:menu_local_action7', $build['#cache']['contexts']);

    $this->assertContains('menu_local_action8', $build['#cache']['tags']);
    $this->assertContains('url.query_args:menu_local_action8', $build['#cache']['contexts']);
  }

}
public function testGetAvailableRelations(): void
    {
        $this->getBrowser()->request('GET', '/api/_action/attribute-set/relations');
        $response = $this->getBrowser()->getResponse();

        static::assertEquals(200, $response->getStatusCode());
        static::assertEquals('application/json', $response->headers->get('Content-Type'));

        $availableRelations = json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertNotEmpty($availableRelations);

        static::assertContains('product', $availableRelations);
        static::assertNotContains('product_translation', $availableRelations);

        static::assertContains('product_manufacturer', $availableRelations);
        static::assertNotContains('product-manufacturer', $availableRelations);
    }
}
Home | Imprint | This part of the site doesn't use cookies.