class Drupal6SqlBaseTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 \Drupal\Tests\PHPUnit_Framework_TestCase
- 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 = array(
'id' => 'Drupal6SqlBase',
);
/**
* @var \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
*/
protected $base;
/**
* Minimum database contents needed to test Drupal6SqlBase.
*/
protected $databaseContents = array(
'system' => array(
array(
'filename' => 'sites/all/modules/module1',
'name' => 'module1',
'type' => 'module',
'status' => 1,
'schema_version' => -1,
),
array(
'filename' => 'sites/all/modules/module2',
'name' => 'module2',
'type' => 'module',
'status' => 0,
'schema_version' => 7201,
),
array(
'filename' => 'sites/all/modules/test2',
'name' => 'test2',
'type' => 'theme',
'status' => 1,
'schema_version' => -1,
),
),
'variable' => array(
array(
'name' => 'my_variable',
'value' => 'b:1;',
),
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$plugin = 'placeholder_id';
/** @var \Drupal\Core\State\StateInterface $state */
$state = $this
->getMock('Drupal\\Core\\State\\StateInterface');
/** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */
$entity_manager = $this
->getMock('Drupal\\Core\\Entity\\EntityManagerInterface');
$this->base = new TestDrupal6SqlBase($this->migrationConfiguration, $plugin, array(), $this
->getMigration(), $state, $entity_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
->assertEquals(1, count($system_data['theme']));
$this
->assertEquals(2, count($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 | ||
MigrateTestCase:: |
protected | property | Local store for mocking setStatus()/getStatus(). | |
MigrateTestCase:: |
protected | function | Generates a table schema from a row. | |
MigrateTestCase:: |
protected | function | Get an SQLite database connection object for use in tests. | |
MigrateTestCase:: |
protected | function | Retrieve a mocked migration. | |
MigrateTestCase:: |
protected | function | 1 | |
MigrateTestCase:: |
public | function | Tests a query | |
MigrateTestCase:: |
protected | function | Asserts tested values during test retrieval. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in 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. |