class Drupal6SqlBaseTest in Drupal 8
Same name and namespace in other branches
- 9 core/modules/migrate_drupal/tests/src/Unit/source/d6/Drupal6SqlBaseTest.php \Drupal\Tests\migrate_drupal\Unit\source\d6\Drupal6SqlBaseTest
Tests the D6 SQL base class.
@group migrate_drupal
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
- class \Drupal\Tests\migrate_drupal\Unit\source\d6\Drupal6SqlBaseTest
- class \Drupal\Tests\migrate\Unit\MigrateTestCase
Expanded class hierarchy of Drupal6SqlBaseTest
File
- core/
modules/ migrate_drupal/ tests/ src/ Unit/ source/ d6/ Drupal6SqlBaseTest.php, line 17 - Contains \Drupal\Tests\migrate_drupal\Unit\source\d6\Drupal6SqlBaseTest.
Namespace
Drupal\Tests\migrate_drupal\Unit\source\d6View source
class Drupal6SqlBaseTest extends MigrateTestCase {
/**
* Define bare minimum migration configuration.
*/
protected $migrationConfiguration = [
'id' => 'Drupal6SqlBase',
];
/**
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
*/
protected $base;
/**
* Minimum database contents needed to test Drupal6SqlBase.
*/
protected $databaseContents = [
'system' => [
[
'filename' => 'sites/all/modules/module1',
'name' => 'module1',
'type' => 'module',
'status' => 1,
'schema_version' => -1,
],
[
'filename' => 'sites/all/modules/module2',
'name' => 'module2',
'type' => 'module',
'status' => 0,
'schema_version' => 7201,
],
[
'filename' => 'sites/all/modules/test2',
'name' => 'test2',
'type' => 'theme',
'status' => 1,
'schema_version' => -1,
],
],
'variable' => [
[
'name' => 'my_variable',
'value' => 'b:1;',
],
],
];
/**
* {@inheritdoc}
*/
protected function setUp() {
$plugin = 'placeholder_id';
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this
->createMock('Drupal\\Core\\State\\StateInterface');
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
$entity_type_manager = $this
->createMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
$this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, [], $this
->getMigration(), $state, $entity_type_manager);
$this->base
->setDatabase($this
->getDatabase($this->databaseContents));
}
/**
* Tests for Drupal6SqlBase::getSystemData().
*/
public function testGetSystemData() {
$system_data = $this->base
->getSystemData();
// Should be 1 theme and 2 modules.
$this
->assertCount(1, $system_data['theme']);
$this
->assertCount(2, $system_data['module']);
// Calling again should be identical.
$this
->assertSame($system_data, $this->base
->getSystemData());
}
/**
* Tests for Drupal6SqlBase::moduleExists().
*/
public function testDrupal6ModuleExists() {
// This module should exist.
$this
->assertTrue($this->base
->moduleExistsWrapper('module1'));
// These modules should not exist.
$this
->assertFalse($this->base
->moduleExistsWrapper('module2'));
$this
->assertFalse($this->base
->moduleExistsWrapper('module3'));
}
/**
* Tests for Drupal6SqlBase::getModuleSchemaVersion().
*/
public function testGetModuleSchemaVersion() {
// Non-existent module.
$this
->assertFalse($this->base
->getModuleSchemaVersionWrapper('module3'));
// Disabled module should still return schema version.
$this
->assertEquals(7201, $this->base
->getModuleSchemaVersionWrapper('module2'));
// Enabled module.
$this
->assertEquals(-1, $this->base
->getModuleSchemaVersionWrapper('module1'));
}
/**
* Tests for Drupal6SqlBase::variableGet().
*/
public function testVariableGet() {
// Test default value.
$this
->assertEquals('my_default', $this->base
->variableGetWrapper('non_existent_variable', 'my_default'));
// Test non-default.
$this
->assertSame(TRUE, $this->base
->variableGetWrapper('my_variable', FALSE));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Drupal6SqlBaseTest:: |
protected | property | ||
Drupal6SqlBaseTest:: |
protected | property | Minimum database contents needed to test Drupal6SqlBase. | |
Drupal6SqlBaseTest:: |
protected | property |
Define bare minimum migration configuration. Overrides MigrateTestCase:: |
|
Drupal6SqlBaseTest:: |
protected | function |
Overrides UnitTestCase:: |
|
Drupal6SqlBaseTest:: |
public | function | Tests for Drupal6SqlBase::moduleExists(). | |
Drupal6SqlBaseTest:: |
public | function | Tests for Drupal6SqlBase::getModuleSchemaVersion(). | |
Drupal6SqlBaseTest:: |
public | function | Tests for Drupal6SqlBase::getSystemData(). | |
Drupal6SqlBaseTest:: |
public | function | Tests for Drupal6SqlBase::variableGet(). | |
MigrateTestCase:: |
protected | property | The migration ID map. | |
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Gets an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieves a mocked migration. | 1 |
MigrateTestCase:: |
protected | function | Gets the value on a row for a given key. | 1 |
MigrateTestCase:: |
public | function | Tests a query. | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |