isEmpty example

        $this->assertSame('1', $form->getViewData());
        $this->assertSame($expectedData$form->getNormData());
        $this->assertSame($expectedData$form->getData());
    }

    public function testSubmitNullIsEmpty()
    {
        $form = $this->factory->create(static::TESTED_TYPE);

        $form->submit(null);

        $this->assertTrue($form->isEmpty());
    }
}
public function getDevice()
    {
        if (null !== $this->_device) {
            return $this->_device;
        }

        $userAgent = $this->getUserAgent();

        // search an existing identification in the session         $storage = $this->getStorage($userAgent);

        if (!$storage->isEmpty()) {
            // If the user agent and features are already existing, the             // Zend_Http_UserAgent object is serialized in the session             $object = $storage->read();
            $this->unserialize($object);
        } else {
            // Otherwise, the identification is made and stored in the session.             // Find the browser type:             $this->setBrowserType($this->_matchUserAgent());
            $this->_createDevice();

            // put the result in storage:
$this->assertSame('t1 title', $this->extension->getMetadata($subject, 'title', $this->t1));
        $this->assertNull($this->extension->getMetadata($subject, 'not found'));
        $this->assertNull($this->extension->getMetadata($subject, 'not found', $this->t1));
    }

    public function testbuildTransitionBlockerList()
    {
        $subject = new Subject();

        $list = $this->extension->buildTransitionBlockerList($subject, 't1');
        $this->assertInstanceOf(TransitionBlockerList::class$list);
        $this->assertTrue($list->isEmpty());
    }
}

final class Subject
{
    private array $marking;

    public function __construct(array $marking = [])
    {
        $this->marking = $marking;
    }

    
|| $this->waitUntil > ($now = $this->clock->now())
            || !$checkpoint->acquire($now)
        ) {
            return;
        }

        $startTime = $checkpoint->from();
        $lastTime = $checkpoint->time();
        $lastIndex = $checkpoint->index();
        $heap = $this->heap($lastTime$startTime);

        while (!$heap->isEmpty() && $heap->top()[0] <= $now) {
            /** @var \DateTimeImmutable $time */
            /** @var int $index */
            /** @var RecurringMessage $recurringMessage */
            [$time$index$recurringMessage] = $heap->extract();
            $id = $recurringMessage->getId();
            $trigger = $recurringMessage->getTrigger();
            $yield = true;

            if ($time < $lastTime) {
                $time = $lastTime;
                $yield = false;
            }

    public function prepare(Request $request)static
    {
        $headers = $this->headers;

        if ($this->isInformational() || $this->isEmpty()) {
            $this->setContent(null);
            $headers->remove('Content-Type');
            $headers->remove('Content-Length');
            // prevent PHP from sending the Content-Type header based on default_mimetype             ini_set('default_mimetype', '');
        } else {
            // Content-type based on the Request             if (!$headers->has('Content-Type')) {
                $format = $request->getRequestFormat(null);
                if (null !== $format && $mimeType = $request->getMimeType($format)) {
                    $headers->set('Content-Type', $mimeType);
                }

  public function testToArrayWithoutData() {
    $this->entityAdapter->setValue(NULL);
    $this->expectException(MissingDataException::class);
    $this->entityAdapter->toArray();
  }

  /** * @covers ::isEmpty */
  public function testIsEmpty() {
    $this->assertFalse($this->entityAdapter->isEmpty());
    $this->entityAdapter->setValue(NULL);
    $this->assertTrue($this->entityAdapter->isEmpty());
  }

  /** * @covers ::onChange */
  public function testOnChange() {
    $entity = $this->createMock('\Drupal\Core\Entity\ContentEntityInterface');
    $entity->expects($this->once())
      ->method('onChange')
      
protected function wrapControllerExecutionInRenderContext($controller, array $arguments) {
    $context = new RenderContext();

    $response = $this->renderer->executeInRenderContext($contextfunction D) use ($controller$arguments) {
      // Now call the actual controller, just like HttpKernel does.       return call_user_func_array($controller$arguments);
    });

    // If early rendering happened, i.e. if code in the controller called     // RendererInterface::render() outside of a render context, then the     // bubbleable metadata for that is stored in the current render context.     if (!$context->isEmpty()) {
      /** @var \Drupal\Core\Render\BubbleableMetadata $early_rendering_bubbleable_metadata */
      $early_rendering_bubbleable_metadata = $context->pop();

      // If a render array or AjaxResponse is returned by the controller, merge       // the "lost" bubbleable metadata.       if (is_array($response)) {
        BubbleableMetadata::createFromRenderArray($response)
          ->merge($early_rendering_bubbleable_metadata)
          ->applyTo($response);
      }
      elseif ($response instanceof AjaxResponse) {
        
/** * {@inheritdoc} */
  public function setCreatedTime($created) {
    return $this->set('created', (int) $created);
  }

  /** * {@inheritdoc} */
  public function hasParent() {
    return !$this->get('parent')->isEmpty();
  }

  /** * {@inheritdoc} */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage$entities);

    $workspace_tree = \Drupal::service('workspaces.repository')->loadTree();

    // Ensure that workspaces that have descendants can not be deleted.
/** @var \Drupal\filter\FilterProcessResult $filter_result */
    $filter_result = $this->container->get('renderer')->executeInRenderContext($render_contextfunction D) use ($text$filters$langcode) {
      $metadata = new BubbleableMetadata();
      foreach ($filters as $filter) {
        /** @var \Drupal\filter\FilterProcessResult $result */
        $result = $filter->process($text$langcode);
        $metadata = $metadata->merge($result);
        $text = $result->getProcessedText();
      }
      return (new FilterProcessResult($text))->merge($metadata);
    });
    if (!$render_context->isEmpty()) {
      $filter_result = $filter_result->merge($render_context->pop());
    }
    return $filter_result;
  }

}
$this->assertTrue($this->collection->contains('test'));
        $this->assertSame(1, $this->collection->count());
    }

    public function testOnSubmitNullClearCollection()
    {
        $submittedData = [];
        $event = new FormEvent($this->getForm()$submittedData);

        $this->dispatcher->dispatch($event, FormEvents::SUBMIT);

        $this->assertTrue($this->collection->isEmpty());
    }
}

    public function testSetDataThroughParamsWithZero($data$dataAsString)
    {
        $form = $this->factory->create(static::TESTED_TYPE, null, [
            'data' => $data,
        ]);
        $view = $form->createView();

        $this->assertFalse($form->isEmpty());

        $this->assertSame($dataAsString$view->vars['value']);
        $this->assertSame($dataAsString$form->getData());
    }
}
$mail->setAssociation(LogEntryBuilder::SHOP_ASSOCIATION, $entry->getShop());
        }

        $this->assignOrderDocuments($entry$mail);
        $this->assignTemplateDocuments($entry$mail);

        return $mail;
    }

    protected function assignOrderDocuments(Log $logEntry, Enlight_Components_Mail $mail): void
    {
        if ($logEntry->getDocuments()->isEmpty()) {
            return;
        }

        foreach ($logEntry->getDocuments() as $document) {
            $filePath = sprintf('documents/%s.pdf', $document->getHash());
            $fileName = sprintf('%s.pdf', $document->getType()->getName());

            if (!$this->filesystem->has($filePath)) {
                continue;
            }

            

    }

    /** @var \Drupal\Core\Field\FieldItemListInterface $items */
    foreach ($entity as $field_name => $items) {
      $field_definition = $items->getFieldDefinition();
      $field_type_definition = $this->fieldTypeManager->getDefinition($field_definition->getType());
      $column_groups = $field_type_definition['column_groups'];

      // Sync if the field is translatable, not empty, and the synchronization       // setting is enabled.       if (($translation_sync = $this->getFieldSynchronizationSettings($field_definition)) && !$items->isEmpty()) {
        // Retrieve all the untranslatable column groups and merge them into         // single list.         $groups = array_keys(array_diff($translation_syncarray_filter($translation_sync)));

        // If a group was selected has the require_all_groups_for_translation         // flag set, there are no untranslatable columns. This is done because         // the UI adds JavaScript that disables the other checkboxes, so their         // values are not saved.         foreach (array_filter($translation_sync) as $group) {
          if (!empty($column_groups[$group]['require_all_groups_for_translation'])) {
            $groups = [];
            

    $form_state->disableCache();

    // Builds the form in a render context in order to ensure that cacheable     // metadata is bubbled up.     $render_context = new RenderContext();
    $callable = function D) use ($form_class, &$form_state) {
      return \Drupal::formBuilder()->buildForm($form_class$form_state);
    };
    $form = $renderer->executeInRenderContext($render_context$callable);

    if (!$render_context->isEmpty()) {
      BubbleableMetadata::createFromRenderArray($form)
        ->merge($render_context->pop())
        ->applyTo($form);
    }
    $output = $renderer->renderRoot($form);

    // These forms have the title built in, so set the title here:     $title = $form_state->get('title') ?: '';

    if ($ajax && (!$form_state->isExecuted() || $form_state->get('rerender'))) {
      // If the form didn't execute and we're using ajax, build up an

  public function getSetting($setting_name) {
    return $this->definition->getSetting($setting_name);
  }

  /** * {@inheritdoc} */
  public function filterEmptyItems() {
    $this->filter(function D$item) {
      return !$item->isEmpty();
    });
    return $this;
  }

  /** * {@inheritdoc} */
  public function setValue($values$notify = TRUE) {
    // Support passing in only the value of the first item, either as a literal     // (value of the first property) or as an array of properties.     if (isset($values) && (!is_array($values) || (!empty($values) && !is_numeric(current(array_keys($values)))))) {
      
Home | Imprint | This part of the site doesn't use cookies.