Commit 5a6eed43 authored by Roman Paska's avatar Roman Paska Committed by Roman Paska
Browse files

chore(tests) Fix failing tests on SQLite/PostgreSQL (issue #3143557 by Taran2L)

parent 5198a8cc
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -360,9 +360,17 @@ class MigrateRangeFieldTest extends MigrateDrupal6TestBase {
   *
   * @dataProvider fieldDataMigrationDataProvider
   */
  public function testFieldDataMigration($field_name, $expected) {
  public function testFieldDataMigration($field_name, $data) {

    $node = Node::load(1);
    $this->assertSame($expected, $node->{$field_name}->getValue());
    foreach ($data as $i => $expected) {
      // Normalize data presentation, as this test is about data value, and is
      // not about amount of zeros in the end (there is a difference between
      // database drivers).
      $format = $field_name === 'field_integer' ? '%d' : '%.1f';
      $this->assertSame($expected['from'], sprintf($format, $node->{$field_name}->get($i)->from));
      $this->assertSame($expected['to'], sprintf($format, $node->{$field_name}->get($i)->to));
    }
  }

  /**
+15 −8
Original line number Diff line number Diff line
@@ -296,9 +296,16 @@ class MigrateRangeFieldTest extends MigrateDrupal7TestBase {
   *
   * @dataProvider fieldDataMigrationDataProvider
   */
  public function testFieldDataMigration($field_name, $expected) {
  public function testFieldDataMigration($field_name, $data) {
    $node = Node::load(1);
    $this->assertSame($expected, $node->{$field_name}->getValue());
    foreach ($data as $i => $expected) {
      // Normalize data presentation, as this test is about data value, and is
      // not about amount of zeros in the end (there is a difference between
      // database drivers).
      $format = $field_name === 'field_integer' ? '%d' : '%.2f';
      $this->assertSame($expected['from'], sprintf($format, $node->{$field_name}->get($i)->from));
      $this->assertSame($expected['to'], sprintf($format, $node->{$field_name}->get($i)->to));
    }
  }

  /**
@@ -310,12 +317,12 @@ class MigrateRangeFieldTest extends MigrateDrupal7TestBase {
        'field_decimal',
        [
          [
            'from' => '12.0000',
            'to' => '18.0000',
            'from' => '12.00',
            'to' => '18.00',
          ],
          [
            'from' => '-44.3300',
            'to' => '66.7700',
            'from' => '-44.33',
            'to' => '66.77',
          ],
        ],
      ],
@@ -323,8 +330,8 @@ class MigrateRangeFieldTest extends MigrateDrupal7TestBase {
        'field_float',
        [
          [
            'from' => '2.5',
            'to' => '4.5',
            'from' => '2.50',
            'to' => '4.50',
          ],
        ],
      ],