class ModifiedFilesTest in Automatic Updates 8
Same name in this branch
- 8 tests/src/Build/ModifiedFilesTest.php \Drupal\Tests\automatic_updates\Build\ModifiedFilesTest
- 8 tests/src/Kernel/ReadinessChecker/ModifiedFilesTest.php \Drupal\Tests\automatic_updates\Kernel\ReadinessChecker\ModifiedFilesTest
@coversDefaultClass \Drupal\automatic_updates\Services\ModifiedFiles
@group Update
@requires externalCommand composer @requires externalCommand curl @requires externalCommand git @requires externalCommand tar
Hierarchy
- class \Drupal\BuildTests\Framework\BuildTestBase extends \PHPUnit\Framework\TestCase uses ExternalCommandRequirementsTrait, PhpunitCompatibilityTrait
- class \Drupal\Tests\automatic_updates\Build\QuickStart\QuickStartTestBase
- class \Drupal\Tests\automatic_updates\Build\ModifiedFilesTest uses InstallTestTrait
- class \Drupal\Tests\automatic_updates\Build\QuickStart\QuickStartTestBase
Expanded class hierarchy of ModifiedFilesTest
File
- tests/
src/ Build/ ModifiedFilesTest.php, line 19
Namespace
Drupal\Tests\automatic_updates\BuildView source
class ModifiedFilesTest extends QuickStartTestBase {
use InstallTestTrait;
/**
* Symfony file system.
*
* @var \Symfony\Component\Filesystem\Filesystem
*/
protected $symfonyFileSystem;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->symfonyFileSystem = new SymfonyFilesystem();
}
/**
* @covers ::getModifiedFiles
* @dataProvider coreProjectProvider
*/
public function testCoreModified($version, array $modifications = []) {
$this
->installCore($version);
// Assert modifications.
$this
->assertModifications('core', 'drupal', $modifications);
}
/**
* @covers ::getModifiedFiles
* @dataProvider contribProjectsProvider
*/
public function testContribModified($project, $project_type, $version, array $modifications = []) {
$this
->markTestSkipped('Contrib updates are not currently supported');
$this
->copyCodebase();
// Download the project.
$this->symfonyFileSystem
->mkdir($this
->getWorkspaceDirectory() . "/{$project_type}s/contrib/{$project}");
$this
->executeCommand("curl -fsSL https://ftp.drupal.org/files/projects/{$project}-{$version}.tar.gz | tar xvz -C {$project_type}s/contrib/{$project} --strip 1");
$this
->assertCommandSuccessful();
// Assert modifications.
$this
->assertModifications($project_type, $project, $modifications);
}
/**
* Core project data provider.
*/
public function coreProjectProvider() {
$datum[] = [
'version' => '8.7.3',
'modifications' => [
'core/LICENSE.txt',
],
];
return $datum;
}
/**
* Contrib project data provider.
*/
public function contribProjectsProvider() {
$datum[] = [
'project' => 'bootstrap',
'project_type' => 'theme',
'version' => '8.x-3.20',
'modifications' => [
'themes/contrib/bootstrap/LICENSE.txt',
],
];
$datum[] = [
'project' => 'token',
'project_type' => 'module',
'version' => '8.x-1.5',
'modifications' => [
'modules/contrib/token/LICENSE.txt',
],
];
return $datum;
}
/**
* Assert modified files.
*
* @param string $project_type
* The project type.
* @param string $project
* The project to assert.
* @param array $modifications
* The modified files to assert.
*/
protected function assertModifications($project_type, $project, array $modifications) {
// Validate project is not modified.
$this
->visit("/automatic_updates/modified-files/{$project_type}/{$project}");
$assert = $this
->getMink()
->assertSession();
$assert
->statusCodeEquals(200);
$assert
->pageTextContains('No modified files!');
// Assert modifications.
$this
->assertNotEmpty($modifications);
foreach ($modifications as $modification) {
$file = $this
->getWorkspaceDirectory() . DIRECTORY_SEPARATOR . $modification;
$this
->fileExists($file);
$this->symfonyFileSystem
->appendToFile($file, PHP_EOL . '// file is modified' . PHP_EOL);
}
$this
->visit("/automatic_updates/modified-files/{$project_type}/{$project}");
$assert
->pageTextContains('Modified files include:');
foreach ($modifications as $modification) {
$assert
->pageTextContains($modification);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BuildTestBase:: |
private | property | The most recent command process. | |
BuildTestBase:: |
protected | property | Default to destroying build artifacts after a test finishes. | |
BuildTestBase:: |
private static | property | Our native host name, used by PHP when it starts up the server. | |
BuildTestBase:: |
private | property | Port that will be tested. | |
BuildTestBase:: |
private | property | The Mink session manager. | |
BuildTestBase:: |
private | property | A list of ports used by the test. | |
BuildTestBase:: |
private | property | The docroot for the server process. | |
BuildTestBase:: |
private | property | The process that's running the HTTP server. | |
BuildTestBase:: |
private | property | The working directory where this test will manipulate files. | |
BuildTestBase:: |
public | function | Asserts that the last command returned the specified exit code. | |
BuildTestBase:: |
public | function | Assert that text is present in the output of the most recent command. | |
BuildTestBase:: |
public | function | Asserts that the last command ran without error. | |
BuildTestBase:: |
public | function | Helper function to assert that the last visit was a Drupal site. | |
BuildTestBase:: |
public | function | Assert that text is present in the error output of the most recent command. | |
BuildTestBase:: |
protected | function | Checks whether a port is available. | |
BuildTestBase:: |
public | function | Copy the current working codebase into a workspace. | |
BuildTestBase:: |
public | function | Run a command. | |
BuildTestBase:: |
protected | function | Discover an available port number. | |
BuildTestBase:: |
public | function | Get a default Finder object for a Drupal codebase. | |
BuildTestBase:: |
protected | function | Get the root path of this Drupal codebase. | |
BuildTestBase:: |
public | function | Get the Mink instance. | |
BuildTestBase:: |
protected | function | Get the port number for requests. | |
BuildTestBase:: |
protected | function | Get the working directory within the workspace, creating if necessary. | |
BuildTestBase:: |
public | function | Full path to the workspace where this test can build. | |
BuildTestBase:: |
protected | function | Set up the Mink session manager. | |
BuildTestBase:: |
protected | function | Do the work of making a server process. | |
BuildTestBase:: |
public static | function | ||
BuildTestBase:: |
protected | function | Makes a local test server using PHP's internal HTTP server. | |
BuildTestBase:: |
protected | function | Stop the HTTP server, zero out all necessary variables. | |
BuildTestBase:: |
protected | function | ||
BuildTestBase:: |
public | function | Visit a URI on the HTTP server. | |
ExternalCommandRequirementsTrait:: |
private static | property | A list of existing external commands we've already discovered. | |
ExternalCommandRequirementsTrait:: |
private static | function | Checks whether required external commands are available per test class. | |
ExternalCommandRequirementsTrait:: |
private static | function | Checks missing external command requirements. | |
ExternalCommandRequirementsTrait:: |
private static | function | Checks whether required external commands are available per method. | |
ExternalCommandRequirementsTrait:: |
private static | function | Determine if an external command is available. | 3 |
InstallTestTrait:: |
protected | function | Helper method that uses Drupal's module page to install a module. | |
InstallTestTrait:: |
protected | function | Helper method that uses Drupal's theme page to install a theme. | |
ModifiedFilesTest:: |
protected | property | Symfony file system. | |
ModifiedFilesTest:: |
protected | function | Assert modified files. | |
ModifiedFilesTest:: |
public | function | Contrib project data provider. | |
ModifiedFilesTest:: |
public | function | Core project data provider. | |
ModifiedFilesTest:: |
protected | function |
Overrides BuildTestBase:: |
|
ModifiedFilesTest:: |
public | function | @covers ::getModifiedFiles @dataProvider contribProjectsProvider | |
ModifiedFilesTest:: |
public | function | @covers ::getModifiedFiles @dataProvider coreProjectProvider | |
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. | |
QuickStartTestBase:: |
protected | property | Password of the admin account generated during install. | |
QuickStartTestBase:: |
protected | property | User name of the admin account generated during install. | |
QuickStartTestBase:: |
public | function | Helper that uses Drupal's user/login form to log in. | |
QuickStartTestBase:: |
protected | function | Prepare core for testing. | |
QuickStartTestBase:: |
public | function | Install a Drupal site using the quick start feature. |