massageTestDate example

'type' => 'datetime_default',
        'label' => 'hidden',
        'settings' => ['format_type' => 'medium'] + $this->defaultSettings,
      ];
      // Verify that the date is output according to the formatter settings.       $options = [
        'format_type' => ['short', 'medium', 'long'],
      ];
      // Formats that display a time component for date-only fields will display       // the default time, so that is applied before calculating the expected       // value.       $this->massageTestDate($date);
      foreach ($options as $setting => $values) {
        foreach ($values as $new_value) {
          // Update the entity display settings.           $this->displayOptions['settings'] = [$setting => $new_value] + $this->defaultSettings;
          $this->container->get('entity_display.repository')
            ->getViewDisplay($this->field->getTargetEntityTypeId()$this->field->getTargetBundle(), 'full')
            ->setComponent($field_name$this->displayOptions)
            ->save();

          $this->renderTestEntity($id);
          switch ($setting) {
            
$this->drupalGet('entity_test/manage/' . $id . '/edit');
      $this->submitForm([], 'Save');
      $this->drupalGet('entity_test/manage/' . $id . '/edit');
      $this->submitForm([], 'Save');
      $entity = EntityTest::load($id);
      $this->assertEquals('2012-12-31', $entity->{$field_name}->value);
      $this->assertEquals('2013-06-06', $entity->{$field_name}->end_value);

      // Formats that display a time component for date-only fields will display       // the default time, so that is applied before calculating the expected       // value.       $this->massageTestDate($start_date);
      $this->massageTestDate($end_date);

      // Reset display options since these get changed below.       $this->displayOptions = [
        'type' => 'daterange_default',
        'label' => 'hidden',
        'settings' => [
          'format_type' => 'long',
          'separator' => 'THESEPARATOR',
        ] + $this->defaultSettings,
      ];

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