Commit c1ecf4f6 authored by catch's avatar catch

Issue #1598618 by aspilicious, Rob Loach: Convert update.test to PSR-0.

parent d4a401a3
<?php
/**
* @file
* Definition of Drupal\system\Tests\Update\DependencyHookInvocationTest.
*/
namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the invocation of hook_update_dependencies().
*/
class DependencyHookInvocationTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Update dependency hook invocation',
'description' => 'Test that the hook invocation for determining update dependencies works correctly.',
'group' => 'Update API',
);
}
function setUp() {
parent::setUp('update_test_1', 'update_test_2');
require_once DRUPAL_ROOT . '/core/includes/update.inc';
}
/**
* Test the structure of the array returned by hook_update_dependencies().
*/
function testHookUpdateDependencies() {
$update_dependencies = update_retrieve_dependencies();
$this->assertTrue($update_dependencies['system'][8000]['update_test_1'] == 8000, t('An update function that has a dependency on two separate modules has the first dependency recorded correctly.'));
$this->assertTrue($update_dependencies['system'][8000]['update_test_2'] == 8001, t('An update function that has a dependency on two separate modules has the second dependency recorded correctly.'));
$this->assertTrue($update_dependencies['system'][8001]['update_test_1'] == 8002, t('An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.'));
}
}
<?php
/**
* @file
* Definition of Drupal\system\Tests\Update\DependencyMissingTest.
*/
namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for missing update dependencies.
*/
class DependencyMissingTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Missing update dependencies',
'description' => 'Test that missing update dependencies are correctly flagged.',
'group' => 'Update API',
);
}
function setUp() {
// Only install update_test_2.module, even though its updates have a
// dependency on update_test_3.module.
parent::setUp('update_test_2');
require_once DRUPAL_ROOT . '/core/includes/update.inc';
}
function testMissingUpdate() {
$starting_updates = array(
'update_test_2' => 8000,
);
$update_graph = update_resolve_dependencies($starting_updates);
$this->assertTrue($update_graph['update_test_2_update_8000']['allowed'], t("The module's first update function is allowed to run, since it does not have any missing dependencies."));
$this->assertFalse($update_graph['update_test_2_update_8001']['allowed'], t("The module's second update function is not allowed to run, since it has a direct dependency on a missing update."));
$this->assertFalse($update_graph['update_test_2_update_8002']['allowed'], t("The module's third update function is not allowed to run, since it has an indirect dependency on a missing update."));
}
}
......@@ -2,15 +2,17 @@
/**
* @file
* Tests for the update system.
* Definition of Drupal\system\Tests\Update\DependencyOrderingTest.
*/
namespace Drupal\system\Tests\Update;
use Drupal\simpletest\WebTestBase;
/**
* Tests for the update dependency ordering system.
*/
class UpdateDependencyOrderingTestCase extends WebTestBase {
class DependencyOrderingTest extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Update dependency ordering',
......@@ -56,62 +58,3 @@ function testUpdateOrderingModuleInterdependency() {
$this->assertTrue($second_dependency_satisfied, t('The dependency of the first module on the second module is respected by the update function order.'));
}
}
/**
* Tests for missing update dependencies.
*/
class UpdateDependencyMissingTestCase extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Missing update dependencies',
'description' => 'Test that missing update dependencies are correctly flagged.',
'group' => 'Update API',
);
}
function setUp() {
// Only install update_test_2.module, even though its updates have a
// dependency on update_test_3.module.
parent::setUp('update_test_2');
require_once DRUPAL_ROOT . '/core/includes/update.inc';
}
function testMissingUpdate() {
$starting_updates = array(
'update_test_2' => 8000,
);
$update_graph = update_resolve_dependencies($starting_updates);
$this->assertTrue($update_graph['update_test_2_update_8000']['allowed'], t("The module's first update function is allowed to run, since it does not have any missing dependencies."));
$this->assertFalse($update_graph['update_test_2_update_8001']['allowed'], t("The module's second update function is not allowed to run, since it has a direct dependency on a missing update."));
$this->assertFalse($update_graph['update_test_2_update_8002']['allowed'], t("The module's third update function is not allowed to run, since it has an indirect dependency on a missing update."));
}
}
/**
* Tests for the invocation of hook_update_dependencies().
*/
class UpdateDependencyHookInvocationTestCase extends WebTestBase {
public static function getInfo() {
return array(
'name' => 'Update dependency hook invocation',
'description' => 'Test that the hook invocation for determining update dependencies works correctly.',
'group' => 'Update API',
);
}
function setUp() {
parent::setUp('update_test_1', 'update_test_2');
require_once DRUPAL_ROOT . '/core/includes/update.inc';
}
/**
* Test the structure of the array returned by hook_update_dependencies().
*/
function testHookUpdateDependencies() {
$update_dependencies = update_retrieve_dependencies();
$this->assertTrue($update_dependencies['system'][8000]['update_test_1'] == 8000, t('An update function that has a dependency on two separate modules has the first dependency recorded correctly.'));
$this->assertTrue($update_dependencies['system'][8000]['update_test_2'] == 8001, t('An update function that has a dependency on two separate modules has the second dependency recorded correctly.'));
$this->assertTrue($update_dependencies['system'][8001]['update_test_1'] == 8002, t('An update function that depends on more than one update from the same module only has the dependency on the higher-numbered update function recorded.'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment