Move into nested docroot
This commit is contained in:
parent
83a0d3a149
commit
c8b70abde9
13405 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\update\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to update.settings.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateUpdateConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('update');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('update_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of update variables to update.settings.yml.
|
||||
*/
|
||||
public function testUpdateSettings() {
|
||||
$config = $this->config('update.settings');
|
||||
$this->assertIdentical(2, $config->get('fetch.max_attempts'));
|
||||
$this->assertIdentical('http://updates.drupal.org/release-history', $config->get('fetch.url'));
|
||||
$this->assertIdentical('all', $config->get('notification.threshold'));
|
||||
$this->assertIdentical(array(), $config->get('notification.emails'));
|
||||
$this->assertIdentical(7, $config->get('check.interval_days'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'update.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\update\Unit\Menu;
|
||||
|
||||
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
|
||||
|
||||
/**
|
||||
* Tests existence of update local tasks.
|
||||
*
|
||||
* @group update
|
||||
*/
|
||||
class UpdateLocalTasksTest extends LocalTaskIntegrationTestBase {
|
||||
|
||||
protected function setUp() {
|
||||
$this->directoryList = array('update' => 'core/modules/update');
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks update report tasks.
|
||||
*
|
||||
* @dataProvider getUpdateReportRoutes
|
||||
*/
|
||||
public function testUpdateReportLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('update.status', 'update.settings', 'update.report_update'),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of report routes to test.
|
||||
*/
|
||||
public function getUpdateReportRoutes() {
|
||||
return array(
|
||||
array('update.status'),
|
||||
array('update.settings'),
|
||||
array('update.report_update'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks update module tasks.
|
||||
*
|
||||
* @dataProvider getUpdateModuleRoutes
|
||||
*/
|
||||
public function testUpdateModuleLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('update.module_update'),
|
||||
));
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of module routes to test.
|
||||
*/
|
||||
public function getUpdateModuleRoutes() {
|
||||
return array(
|
||||
array('update.module_update'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks update theme tasks.
|
||||
*
|
||||
* @dataProvider getUpdateThemeRoutes
|
||||
*/
|
||||
public function testUpdateThemeLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('update.theme_update'),
|
||||
));
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of theme routes to test.
|
||||
*/
|
||||
public function getUpdateThemeRoutes() {
|
||||
return array(
|
||||
array('update.theme_update'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
104
web/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
Normal file
104
web/core/modules/update/tests/src/Unit/UpdateFetcherTest.php
Normal file
|
@ -0,0 +1,104 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\update\Unit;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\update\UpdateFetcher;
|
||||
|
||||
if (!defined('DRUPAL_CORE_COMPATIBILITY')) {
|
||||
define('DRUPAL_CORE_COMPATIBILITY', '8.x');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests update functionality unrelated to the database.
|
||||
*
|
||||
* @group update
|
||||
*/
|
||||
class UpdateFetcherTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The update fetcher to use.
|
||||
*
|
||||
* @var \Drupal\update\UpdateFetcher
|
||||
*/
|
||||
protected $updateFetcher;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$config_factory = $this->getConfigFactoryStub(array('update.settings' => array('fetch_url' => 'http://www.example.com')));
|
||||
$http_client_mock = $this->getMock('\GuzzleHttp\ClientInterface');
|
||||
$this->updateFetcher = new UpdateFetcher($config_factory, $http_client_mock);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that buildFetchUrl() builds the URL correctly.
|
||||
*
|
||||
* @param array $project
|
||||
* A keyed array of project information matching results from
|
||||
* \Drupal\Update\UpdateManager::getProjects().
|
||||
* @param string $site_key
|
||||
* A string to mimic an anonymous site key hash.
|
||||
* @param string $expected
|
||||
* The expected url returned from UpdateFetcher::buildFetchUrl()
|
||||
*
|
||||
* @dataProvider providerTestUpdateBuildFetchUrl
|
||||
*
|
||||
* @see \Drupal\update\UpdateFetcher::buildFetchUrl()
|
||||
*/
|
||||
public function testUpdateBuildFetchUrl(array $project, $site_key, $expected) {
|
||||
$url = $this->updateFetcher->buildFetchUrl($project, $site_key);
|
||||
$this->assertEquals($url, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide test data for self::testUpdateBuildFetchUrl().
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays, each containing:
|
||||
* - 'project' - An array matching a project's .info file structure.
|
||||
* - 'site_key' - An arbitrary site key.
|
||||
* - 'expected' - The expected url from UpdateFetcher::buildFetchUrl().
|
||||
*/
|
||||
public function providerTestUpdateBuildFetchUrl() {
|
||||
$data = array();
|
||||
|
||||
// First test that we didn't break the trivial case.
|
||||
$project['name'] = 'update_test';
|
||||
$project['project_type'] = '';
|
||||
$project['info']['version'] = '';
|
||||
$project['info']['project status url'] = 'http://www.example.com';
|
||||
$project['includes'] = array('module1' => 'Module 1', 'module2' => 'Module 2');
|
||||
$site_key = '';
|
||||
$expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
|
||||
|
||||
$data[] = array($project, $site_key, $expected);
|
||||
|
||||
// For disabled projects it shouldn't add the site key either.
|
||||
$site_key = 'site_key';
|
||||
$project['project_type'] = 'disabled';
|
||||
$expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
|
||||
|
||||
$data[] = array($project, $site_key, $expected);
|
||||
|
||||
// For enabled projects, test adding the site key.
|
||||
$project['project_type'] = '';
|
||||
$expected = 'http://www.example.com/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
|
||||
$expected .= '?site_key=site_key';
|
||||
$expected .= '&list=' . rawurlencode('module1,module2');
|
||||
|
||||
$data[] = array($project, $site_key, $expected);
|
||||
|
||||
// Test when the URL contains a question mark.
|
||||
$project['info']['project status url'] = 'http://www.example.com/?project=';
|
||||
$expected = 'http://www.example.com/?project=/' . $project['name'] . '/' . DRUPAL_CORE_COMPATIBILITY;
|
||||
$expected .= '&site_key=site_key';
|
||||
$expected .= '&list=' . rawurlencode('module1,module2');
|
||||
|
||||
$data[] = array($project, $site_key, $expected);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue