Commit db7c533b authored by catch's avatar catch
Browse files

Issue #3417528 by longwave: Remove withConsecutive() in MigrateSqlIdMapEnsureTablesTest

(cherry picked from commit e0f7856a)
parent e874b962
Loading
Loading
Loading
Loading
Loading
+32 −62
Original line number Diff line number Diff line
@@ -117,75 +117,45 @@ public function testEnsureTablesNotExist() {
      ],
    ];

    $schema = $this->getMockBuilder('Drupal\Core\Database\Schema')
      ->disableOriginalConstructor()
      ->getMock();
    $schema->expects($this->exactly(2))
      ->method('tableExists')
      ->willReturnMap([
        ['migrate_map_sql_idmap_test', FALSE],
        ['migrate_message_sql_idmap_test', FALSE],
      ]);
    $schema->expects($this->exactly(2))
      ->method('createTable')
      ->withConsecutive(
        ['migrate_map_sql_idmap_test', $map_table_schema],
        ['migrate_message_sql_idmap_test', $table_schema],
      );

    $this->runEnsureTablesTest($schema);
    $schema = $this->prophesize('Drupal\Core\Database\Schema');
    $schema->tableExists('migrate_map_sql_idmap_test')->willReturn(FALSE);
    $schema->tableExists('migrate_message_sql_idmap_test')->willReturn(FALSE);
    $schema->createTable('migrate_map_sql_idmap_test', $map_table_schema)->shouldBeCalled();
    $schema->createTable('migrate_message_sql_idmap_test', $table_schema)->shouldBeCalled();
    $this->runEnsureTablesTest($schema->reveal());
  }

  /**
   * Tests the ensureTables method when the tables exist.
   */
  public function testEnsureTablesExist() {
    $schema = $this->getMockBuilder('Drupal\Core\Database\Schema')
      ->disableOriginalConstructor()
      ->getMock();
    $schema->expects($this->exactly(1))
      ->method('tableExists')
      ->with('migrate_map_sql_idmap_test')
      ->willReturn(TRUE);
    $schema->expects($this->exactly(3))
      ->method('fieldExists')
      ->willReturnMap([
        ['migrate_map_sql_idmap_test', 'rollback_action', FALSE],
        ['migrate_map_sql_idmap_test', 'hash', FALSE],
        ['migrate_map_sql_idmap_test', 'source_ids_hash', FALSE],
      ]);
    $schema->expects($this->exactly(3))
      ->method('addField')
      ->withConsecutive(
        [
          'migrate_map_sql_idmap_test', 'rollback_action', [
    $schema = $this->prophesize('Drupal\Core\Database\Schema');
    $schema->tableExists('migrate_map_sql_idmap_test')->willReturn(TRUE);
    $schema->fieldExists('migrate_map_sql_idmap_test', 'rollback_action')->willReturn(FALSE);
    $schema->fieldExists('migrate_map_sql_idmap_test', 'hash')->willReturn(FALSE);
    $schema->fieldExists('migrate_map_sql_idmap_test', 'source_ids_hash')->willReturn(FALSE);
    $schema->addField('migrate_map_sql_idmap_test', 'rollback_action', [
      'type' => 'int',
      'size' => 'tiny',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'default' => 0,
      'description' => 'Flag indicating what to do for this item on rollback',
          ],
        ],
        [
          'migrate_map_sql_idmap_test', 'hash', [
    ])->shouldBeCalled();
    $schema->addField('migrate_map_sql_idmap_test', 'hash', [
      'type' => 'varchar',
      'length' => '64',
      'not null' => FALSE,
      'description' => 'Hash of source row data, for detecting changes',
          ],
        ],
        [
          'migrate_map_sql_idmap_test', 'source_ids_hash', [
    ])->shouldBeCalled();
    $schema->addField('migrate_map_sql_idmap_test', 'source_ids_hash', [
      'type' => 'varchar',
      'length' => '64',
      'not null' => TRUE,
      'description' => 'Hash of source ids. Used as primary key',
          ],
        ],
      );
    ])->shouldBeCalled();

    $this->runEnsureTablesTest($schema);
    $this->runEnsureTablesTest($schema->reveal());
  }

  /**
+0 −5
Original line number Diff line number Diff line
@@ -1853,11 +1853,6 @@ parameters:
			count: 1
			path: modules/migrate/tests/src/Kernel/MigrateTestBase.php

		-
			message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#"
			count: 2
			path: modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php

		-
			message: "#^Variable \\$sub_process_plugins might not be defined\\.$#"
			count: 2