disableOriginalConstructor example

$this->localTaskDerivative->setApplicableMenuViews($result);

    $definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
    $this->assertEquals([]$definitions);
  }

  /** * Tests fetching the derivatives on a view with without a local task. */
  public function testGetDerivativeDefinitionsWithoutLocalTask() {
    $executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
      ->disableOriginalConstructor()
      ->getMock();
    $display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
      ->onlyMethods(['getOption'])
      ->disableOriginalConstructor()
      ->getMockForAbstractClass();
    $display_plugin->expects($this->once())
      ->method('getOption')
      ->with('menu')
      ->willReturn(['type' => 'normal']);
    $executable->display_handler = $display_plugin;

    
$transformed_value = $this->plugin->transform([2, '<?php', []]$this->migrateExecutable, $this->row, 'destination_property');
    $this->assertEmpty($transformed_value);
  }

  /** * @covers ::transform */
  public function testTransformException() {
    $this->moduleHandler->moduleExists('php')->willReturn(FALSE);
    $migrate_lookup = $this->prophesize(MigrateLookupInterface::class);
    $this->row = $this->getMockBuilder('Drupal\migrate\Row')
      ->disableOriginalConstructor()
      ->onlyMethods(['getSourceProperty'])
      ->getMock();
    $this->row->expects($this->exactly(2))
      ->method('getSourceProperty')
      ->willReturnMap([['bid', 99]['module', 'foobar']]);
    $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', []$this->moduleHandler->reveal()$migrate_lookup->reveal());
    $this->expectException(MigrateSkipRowException::class);
    $this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration.");
    $this->plugin->transform([2, '<?php', []]$this->migrateExecutable, $this->row, 'destination_property');
  }

}
'will throw exception', NULL, TRUE, 'data_type'],
    ];
  }

  /** * @covers ::getContextValue * @dataProvider providerGetContextValue */
  public function testGetContextValue($expected$context_value$is_required$data_type) {
    // Mock a Context object.     $mock_context = $this->getMockBuilder('Drupal\Component\Plugin\Context\Context')
      ->disableOriginalConstructor()
      ->onlyMethods(['getContextDefinition'])
      ->getMock();

    // If the context value exists, getContextValue() behaves like a normal     // getter.     if ($context_value) {
      // Set visibility of contextValue.       $ref_context_value = new \ReflectionProperty($mock_context, 'contextValue');
      // Set contextValue to a testable state.       $ref_context_value->setValue($mock_context$context_value);
      // Exercise getContextValue().
$this->assertEquals('test', $result, 'Sandbox policy allows get* functions to be called.');
  }

  /** * Tests that valid methods can be called from within Twig templates. * * Currently the following methods are whitelisted: id, label, bundle, and * get. */
  public function testEntitySafeMethods() {
    $entity = $this->getMockBuilder('Drupal\Core\Entity\ContentEntityBase')
      ->disableOriginalConstructor()
      ->getMock();
    $entity->expects($this->atLeastOnce())
      ->method('get')
      ->with('title')
      ->willReturn('test');
    $result = $this->twig->render('{{ entity.get("title") }}', ['entity' => $entity]);
    $this->assertEquals('test', $result, 'Sandbox policy allows get() to be called.');

    $entity = $this->createMock('Drupal\Core\Entity\EntityInterface');
    $entity->expects($this->atLeastOnce())
      ->method('id')
      
use RulesTestFixtureBehaviour;

    private const KEY_PACKAGER_COUNT = 'PACKAGER_COUNT';
    private const KEY_SORTER_PRICE_ASC = 'PRICE_ASC';

    private MockObject&SalesChannelContext $context;

    protected function setUp(): void
    {
        parent::setUp();

        $this->context = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
    }

    /** * This test verifies that our line item matching works correctly with 1 rule. * We create a group with a rule for minimum item price of 50. * This means, that only line items with 50 or higher, are matched * with a positive result. * * @group lineitemgroup */
    public function testMatchesForSingleRule(): void
    {
\Drupal::setContainer($container);
  }

  /** * @covers ::viewsForm */
  public function testViewsForm(): void {
    $row = new ResultRow();

    $field = $this->getMockBuilder(MediaLibrarySelectForm::class)
      ->onlyMethods(['getEntity'])
      ->disableOriginalConstructor()
      ->getMock();
    $field->expects($this->any())
      ->method('getEntity')
      ->willReturn(NULL);

    $container = new ContainerBuilder();
    $container->set('string_translation', $this->createMock(TranslationInterface::class));
    \Drupal::setContainer($container);

    $query = $this->getMockBuilder(ParameterBag::class)
      ->onlyMethods(['all'])
      
/** * @param array<array{sql: string, params: array<mixed>|null, types: array<mixed>|null, executionMS?: int}> $queries */
    private function createCollector(array $queries): ConnectionProfiler
    {
        $debugDataHolder = new BacktraceDebugDataHolder(['default']);
        $config = new Configuration();
        $config->setMiddlewares([new ProfilingMiddleware($debugDataHolder)]);

        $connection = $this->getMockBuilder(Connection::class)
            ->disableOriginalConstructor()
            ->getMock();
        $connection->expects(static::any())
            ->method('getDatabasePlatform')
            ->willReturn(new MySqlPlatform());
        $connection->expects(static::any())
            ->method('getConfiguration')
            ->willReturn($config);

        $collector = new ConnectionProfiler($connection);
        foreach ($queries as $queryData) {
            $query = new Query($queryData['sql'] ?? '');
            

  public function testViewsForm(): void {
    $row = new ResultRow();

    $container = new ContainerBuilder();
    $container->set('string_translation', $this->createMock(TranslationInterface::class));
    \Drupal::setContainer($container);

    $field = $this->getMockBuilder(BulkForm::class)
      ->onlyMethods(['getEntityType', 'getEntity'])
      ->disableOriginalConstructor()
      ->getMock();
    $field->expects($this->any())
      ->method('getEntityType')
      ->willReturn('foo');
    $field->expects($this->any())
      ->method('getEntity')
      ->willReturn(NULL);

    $query = $this->getMockBuilder(QueryPluginBase::class)
      ->onlyMethods(['getEntityTableInfo'])
      ->disableOriginalConstructor()
      

  protected $themeNegotiator;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->themeAccessCheck = $this->getMockBuilder('\Drupal\Core\Theme\ThemeAccessCheck')
      ->disableOriginalConstructor()
      ->getMock();
    $this->container = new ContainerBuilder();
  }

  /** * Tests determining the theme. * * @see \Drupal\Core\Theme\ThemeNegotiator::determineActiveTheme() */
  public function testDetermineActiveTheme() {
    $negotiator = $this->createMock('Drupal\Core\Theme\ThemeNegotiatorInterface');
    

        $form = new Form($dom->getElementsByTagName('form')->item(0), 'http://example.com');

        $this->assertInstanceOf(ChoiceFormField::class$form->get('option'));
    }

    protected function getFormFieldMock($name$value = null)
    {
        $field = $this
            ->getMockBuilder(FormField::class)
            ->onlyMethods(['getName', 'getValue', 'setValue', 'initialize'])
            ->disableOriginalConstructor()
            ->getMock()
        ;

        $field
            ->expects($this->any())
            ->method('getName')
            ->willReturn($name)
        ;

        $field
            ->expects($this->any())
            
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->entityTypeManager = $this->prophesize(EntityTypeManager::class);
    $this->entityFieldManager = $this->prophesize(EntityFieldManager::class);
    $this->entityLastInstalledSchemaRepository = $this->createMock(EntityLastInstalledSchemaRepositoryInterface::class);
    $this->storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage')
      ->disableOriginalConstructor()
      ->getMock();

    $this->storage->expects($this->any())
      ->method('getBaseTable')
      ->willReturn('entity_test');

    // Add an ID field. This also acts as a test for a simple, single-column     // field.     $this->setUpStorageDefinition('id', [
      'columns' => [
        'value' => [
          

  protected $cacheContextsManager;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->cacheContextsManager = $this->getMockBuilder('Drupal\Core\Cache\Context\CacheContextsManager')
      ->disableOriginalConstructor()
      ->getMock();

    $this->cacheContextsManager->method('assertValidTokens')->willReturn(TRUE);
    $container = new ContainerBuilder();
    $container->set('cache_contexts_manager', $this->cacheContextsManager);
    \Drupal::setContainer($container);
  }

  /** * @internal */
  
private const CUSTOM_FIELD_NAME = 'custom_test';

    private LineItemCustomFieldRule $rule;

    private SalesChannelContext $salesChannelContext;

    protected function setUp(): void
    {
        $this->rule = new LineItemCustomFieldRule();

        $this->salesChannelContext = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
        $this->salesChannelContext->method('getContext')->willReturn(Context::createDefaultContext());
    }

    public function testGetName(): void
    {
        static::assertSame('cartLineItemCustomField', $this->rule->getName());
    }

    public function testGetConstraints(): void
    {
        $ruleConstraints = $this->rule->getConstraints();

        
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->user = $this->createMock('Drupal\Core\Session\AccountInterface');
    $this->requestStack = new RequestStack();
    $this->view = $this->createMock('Drupal\views\ViewEntityInterface');
    $this->viewsData = $this->getMockBuilder('Drupal\views\ViewsData')
      ->disableOriginalConstructor()
      ->getMock();
    $this->routeProvider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
    $this->viewExecutableFactory = new ViewExecutableFactory($this->user, $this->requestStack, $this->viewsData, $this->routeProvider);
  }

  /** * Tests the get method. * * @covers ::get */
  public function testGet() {
    

    private SalesChannelContext $salesChannelContext;

    protected function setUp(): void
    {
        $this->promotion = new PromotionEntity();
        $this->promotion->setId('PR-1');
        $this->promotion->setUseCodes(false);
        $this->promotion->setUseIndividualCodes(false);
        $this->promotion->setUseSetGroups(false);

        $this->salesChannelContext = $this->getMockBuilder(SalesChannelContext::class)->disableOriginalConstructor()->getMock();
        $context = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();

        $this->salesChannelContext->method('getContext')->willReturn($context);
    }

    /** * This test verifies that we have the correct payload in our * discount line item. this is used to identify the promotion behind it. * It's also used as reference to individual codes that get marked as redeemed * in the event subscriber, when the order is created. * * @group promotions */
Home | Imprint | This part of the site doesn't use cookies.