shouldNotBeCalled example

public function testRollback(array $id_map_records, bool $rollback_called = TRUE, array $source_id_keys = ['source'], array $destination_id_keys = ['destination'], int $expected_result = MigrationInterface::RESULT_COMPLETED) {
    $id_map = $this
      ->getTestRollbackIdMap($id_map_records$source_id_keys$destination_id_keys)
      ->reveal();

    $migration = $this->getMigration($id_map);
    $destination = $this->prophesize(MigrateDestinationInterface::class);
    if ($rollback_called) {
      $destination->rollback($id_map->currentDestination())->shouldBeCalled();
    }
    else {
      $destination->rollback()->shouldNotBeCalled();
    }
    $migration
      ->method('getDestinationPlugin')
      ->willReturn($destination->reveal());

    $executable = new TestMigrateExecutable($migration$this->message, $this->eventDispatcher);

    $this->assertEquals($expected_result$executable->rollback());
  }

  /** * Data provider for ::testRollback. * * @return array * The test cases. */
$theme = 'stark';
    // When the theme is the system default, an empty string is provided as the     // theme token. See system_js_settings_alter().     $theme_token = '';

    $request = new Request([]);
    $request->query->set('ajax_page_state', ['theme' => $theme, 'theme_token' => $theme_token]);
    $request->request = new InputBag($request->request->all());
    $this->requestStack->push($request);
    $route_match = RouteMatch::createFromRequest($request);

    $this->tokenGenerator->validate(Argument::cetera())->shouldNotBeCalled();

    $result = $this->negotiator->determineActiveTheme($route_match);
    $this->assertSame($theme$result);
  }

}
$container->set('config.manager', $this->configManager->reveal());
    $container->set('language_manager', $this->languageManager->reveal());
    \Drupal::setContainer($container);

  }

  /** * @covers ::create * @covers ::doCreate */
  public function testCreateWithPredefinedUuid() {
    $this->cacheTagsInvalidator->invalidateTags(Argument::cetera())->shouldNotBeCalled();

    $entity = $this->getMockEntity();
    $entity->set('id', 'foo');
    $entity->set('langcode', 'hu');
    $entity->set('uuid', 'baz');
    $entity->setOriginalId('foo');
    $entity->enforceIsNew();

    $this->moduleHandler->invokeAll('test_entity_type_create', [$entity])
      ->shouldBeCalled();
    $this->moduleHandler->invokeAll('entity_create', [$entity, 'test_entity_type'])
      
$entity_with_layout = $this->prophesize(FieldableEntityInterface::class);
      $entity_with_layout->hasField(OverridesSectionStorage::FIELD_NAME)->willReturn(TRUE);
      $this->entityRepository->getActive($expected_entity_type_id, 'entity_with_layout')->willReturn($entity_with_layout->reveal());

      $entity_type = new EntityType([
        'id' => $expected_entity_type_id,
      ]);
      $this->entityTypeManager->getDefinition($expected_entity_type_id)->willReturn($entity_type);
    }
    else {
      $this->entityRepository->getActive(Argument::any())->shouldNotBeCalled();
    }

    $method = new \ReflectionMethod($this->plugin, 'extractEntityFromRoute');
    $result = $method->invoke($this->plugin, $value$defaults);
    if ($success) {
      $this->assertInstanceOf(FieldableEntityInterface::class$result);
    }
    else {
      $this->assertNull($result);
    }
  }

  
// Ensure the migration plugin manager returns our migration.     $migration_plugin_manager->createInstances(Argument::exact(['destination_migration']))
      ->willReturn(['destination_migration' => $destination_migration->reveal()]);

    $configuration = [
      'no_stub' => TRUE,
      'migration' => 'destination_migration',
    ];

    $migration_plugin->id()->willReturn('actual_migration');
    $destination_migration->getDestinationPlugin(TRUE)->shouldNotBeCalled();

    $migration = MigrationLookup::create($this->prepareContainer()$configuration, '', []$migration_plugin->reveal());
    $result = $migration->transform(1, $this->migrateExecutable, $this->row, '');
    $this->assertNull($result);
  }

  /** * @covers ::transform */
  public function testTransformWithStubbing() {
    $migration_plugin = $this->prophesize(MigrationInterface::class);
    

  public function testGetLayout(array $contexts, bool $should_context_apply) {
    $layout = $this->prophesize(LayoutInterface::class);
    $layout_plugin_manager = $this->prophesize(LayoutPluginManagerInterface::class);
    $layout_plugin_manager->createInstance('layout_onecol', [])->willReturn($layout->reveal());

    $context_handler = $this->prophesize(ContextHandlerInterface::class);
    if ($should_context_apply) {
      $context_handler->applyContextMapping($layout->reveal()$contexts)->shouldBeCalled();
    }
    else {
      $context_handler->applyContextMapping($layout->reveal()$contexts)->shouldNotBeCalled();
    }

    $container = new ContainerBuilder();
    $container->set('plugin.manager.core.layout', $layout_plugin_manager->reveal());
    $container->set('context.handler', $context_handler->reveal());
    \Drupal::setContainer($container);

    $output = $this->section->getLayout($contexts);
    $this->assertSame($layout->reveal()$output);
  }

  

  public function testExtractEntityFromRoute($success$expected_entity_id$value, array $defaults) {
    if ($expected_entity_id) {
      $entity_storage = $this->prophesize(EntityStorageInterface::class);
      $entity_storage->load($expected_entity_id)->willReturn('the_return_value');

      $this->entityTypeManager->getDefinition('entity_view_display')->willReturn(new EntityType(['id' => 'entity_view_display']));
      $this->entityTypeManager->getStorage('entity_view_display')->willReturn($entity_storage->reveal());
    }
    else {
      $this->entityTypeManager->getDefinition('entity_view_display')->shouldNotBeCalled();
      $this->entityTypeManager->getStorage('entity_view_display')->shouldNotBeCalled();
    }

    $method = new \ReflectionMethod($this->plugin, 'extractEntityFromRoute');
    $result = $method->invoke($this->plugin, $value$defaults);
    if ($success) {
      $this->assertEquals('the_return_value', $result);
    }
    else {
      $this->assertNull($result);
    }
  }
$plugin->hasFormClass('standard_class')->willReturn(TRUE);
    $plugin->getFormClass('standard_class')->willReturn(get_class($expected));

    $form_object = $this->manager->createInstance($plugin->reveal(), 'standard_class');
    $this->assertSame($expected$form_object);
  }

  /** * @covers ::createInstance */
  public function testCreateInstanceUsingPlugin() {
    $this->classResolver->getInstanceFromDefinition(Argument::cetera())->shouldNotBeCalled();

    $plugin = $this->prophesize(PluginWithFormsInterface::class)->willImplement(PluginFormInterface::class);
    $plugin->hasFormClass('configure')->willReturn(TRUE);
    $plugin->getFormClass('configure')->willReturn(get_class($plugin->reveal()));

    $form_object = $this->manager->createInstance($plugin->reveal(), 'configure');
    $this->assertSame($plugin->reveal()$form_object);
  }

  /** * @covers ::createInstance */

  public function testBlockAccessEntityNotAllowed($expected$entity_access) {
    $entity = $this->prophesize(FieldableEntityInterface::class);
    $block = $this->getTestBlock($entity);

    $account = $this->prophesize(AccountInterface::class);
    $entity->access('view', $account->reveal(), TRUE)->willReturn($entity_access);
    $entity->hasField()->shouldNotBeCalled();

    $access = $block->access($account->reveal(), TRUE);
    $this->assertSame($expected$access->isAllowed());
  }

  /** * Provides test data for ::testBlockAccessEntityNotAllowed(). */
  public function providerTestBlockAccessNotAllowed() {
    $data = [];
    $data['entity_forbidden'] = [
      
$entity = $this->prophesize(ContentEntityInterface::class)->willImplement(\IteratorAggregate::class);
      $entity->getEntityTypeId()->willReturn('test_content');
      $entity->getIterator()->willReturn(new \ArrayIterator([]));
      $entity->bundle()->willReturn($bundle);
      $content_entity_storage->create(['the_bundle_key' => $bundle])
        ->willReturn($entity->reveal())
        ->shouldBeCalled();
    }

    // Creating entities with sample values can lead to performance issues when     // called many times. Ensure that createWithSampleValues() is not called.     $content_entity_storage->createWithSampleValues(Argument::any())->shouldNotBeCalled();

    $entity_type = new EntityType([
      'id' => 'test_content',
      'entity_keys' => [
        'bundle' => 'the_bundle_key',
      ],
    ]);

    $this->entityTypeManager->getStorage('test_content')->willReturn($content_entity_storage->reveal());

    $this->entityTypeManager->getDefinition('test_content')->willReturn($entity_type);
    

  public function testConvertNoType() {
    $section_storage_manager = $this->prophesize(SectionStorageManagerInterface::class);
    $converter = new LayoutSectionStorageParamConverter($section_storage_manager->reveal());

    $value = 'some_value';
    $definition = ['layout_builder_tempstore' => TRUE];
    $name = 'the_parameter_name';
    $defaults = ['section_storage_type' => NULL];

    $section_storage_manager->hasDefinition()->shouldNotBeCalled();
    $section_storage_manager->load()->shouldNotBeCalled();

    $result = $converter->convert($value$definition$name$defaults);
    $this->assertNull($result);
  }

  /** * @covers ::convert */
  public function testConvertInvalidConverter() {
    $section_storage_manager = $this->prophesize(SectionStorageManagerInterface::class);
    
$context->getContextValue()->willReturn($layout_entity);
      $contexts['layout_builder.entity'] = $context->reveal();

      $block->setAccessDependency($layout_entity)->shouldBeCalled();
    }
    else {
      $block = $this->prophesize(BlockPluginInterface::class);
    }

    $access_result = AccessResult::forbidden();
    $block->access($this->account->reveal(), TRUE)->willReturn($access_result)->shouldBeCalled();
    $block->getCacheContexts()->shouldNotBeCalled();
    $block->getCacheTags()->shouldNotBeCalled();
    $block->getCacheMaxAge()->shouldNotBeCalled();
    $block->getConfiguration()->shouldNotBeCalled();
    $block->getPluginId()->shouldNotBeCalled();
    $block->getBaseId()->shouldNotBeCalled();
    $block->getDerivativeId()->shouldNotBeCalled();

    $block_content = ['#markup' => 'The block content.'];
    $block->build()->willReturn($block_content);
    $this->blockManager->createInstance('some_block_id', ['id' => 'some_block_id'])->willReturn($block->reveal());

    
public function testPasswordCheckSupported() {
    $validPassword = 'valid password';

    // cspell:disable     $passwordHash = '$S$5TOxWPdvJRs0P/xZBdrrPlGgzViOS0drHu3jaIjitesfttrp18bk';
    $passwordLayered = 'U$S$5vNHDQyLqCTvsYBLWBUWXJWhA0m3DTpBh04acFEOGB.bKBclhKgo';
    // cspell:enable
    $invalidPassword = 'invalid password';

    $corePassword = $this->prophesize(PasswordInterface::class);
    $corePassword->check()->shouldNotBeCalled();

    $passwordService = new PhpassHashedPassword($corePassword->reveal());

    $result = $passwordService->check($validPassword$passwordHash);
    $this->assertTrue($result, 'Accepts valid passwords created prior to 10.1.x');
    $result = $passwordService->check($invalidPassword$passwordHash);
    $this->assertFalse($result, 'Rejects invalid passwords created prior to 10.1.x');

    $result = $passwordService->check($validPassword$passwordLayered);
    $this->assertTrue($result, 'Accepts valid passwords migrated from sites running 6.x');
    $result = $passwordService->check($invalidPassword$passwordLayered);
    

    ];
    $regions = $layout_definition->getRegions();
    $this->assertEquals($expected_regions$regions);
    $this->assertInstanceOf(TranslatableMarkup::class$regions['main']['label']);
  }

  /** * @covers ::processDefinition */
  public function testProcessDefinition() {
    $this->moduleHandler->alter('layout', Argument::type('array'))->shouldNotBeCalled();
    $this->expectException(InvalidPluginDefinitionException::class);
    $this->expectExceptionMessage('The "module_a_derived_layout:array_based" layout definition must extend ' . LayoutDefinition::class);
    $module_a_provided_layout = <<<'EOS' module_a_derived_layout: deriver: \Drupal\Tests\Core\Layout\LayoutDeriver array_based: true EOS;
    vfsStream::create([
      'modules' => [
        'module_a' => [
          'module_a.layouts.yml' => $module_a_provided_layout,
        ],
$date_sql->setFieldTimezoneOffset($field, 42);
    $this->assertEquals("(foobar.field + 42)", $field);
  }

  /** * Tests setting the database offset. * * @covers ::setTimezoneOffset */
  public function testSetTimezoneOffset() {
    $database = $this->prophesize(Connection::class);
    $database->query()->shouldNotBeCalled();
    $date_sql = new SqliteDateSql($database->reveal());
    $date_sql->setTimezoneOffset(42);
  }

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